From: ouv Date: Tue, 28 Nov 2006 08:41:14 +0000 (+0000) Subject: VisuGUI_FieldFilter added - selection filter for fields X-Git-Tag: WP1_2_3_05-12-2006_cache_system~42 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=aedce583655654b36395cb7bd7553b5f4d32e61d;p=modules%2Fvisu.git VisuGUI_FieldFilter added - selection filter for fields --- diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index a6626b1a..08c5dced 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -78,7 +78,8 @@ LIB_SRC = VisuGUI.cxx \ VisuGUI_Timer.cxx \ VisuGUI_Slider.cxx \ VisuGUI_InputPane.cxx \ - VisuGUI_CacheDlg.cxx + VisuGUI_CacheDlg.cxx \ + VisuGUI_FieldFilter.cxx LIB_MOC = VisuGUI.h \ VisuGUI_Module.h \ diff --git a/src/VISUGUI/VisuGUI_CutLinesDlg.cxx b/src/VISUGUI/VisuGUI_CutLinesDlg.cxx index 172dd49a..c2cb198e 100644 --- a/src/VISUGUI/VisuGUI_CutLinesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutLinesDlg.cxx @@ -214,7 +214,7 @@ VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule) myScalarPane = new VisuGUI_ScalarBarPane(this, false); myScalarPane->setMargin( 5 ); - myInputPane = new VisuGUI_InputPane(theModule, this); + myInputPane = new VisuGUI_InputPane(VISU::TCUTLINES, theModule, this); myTabBox->addTab(myScalarPane, "Scalar Bar"); myTabBox->addTab(myInputPane, "Input"); diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx index b369535d..18de4229 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx @@ -485,7 +485,7 @@ VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg (SalomeApp_Module* theModule) myTabBox->addTab(myCutPane, "Cut Planes"); myScalarPane = new VisuGUI_ScalarBarPane(this, false); myScalarPane->setMargin(5); - myInputPane = new VisuGUI_InputPane(theModule, this); + myInputPane = new VisuGUI_InputPane(VISU::TCUTPLANES, theModule, this); myTabBox->addTab(myScalarPane, "Scalar Bar"); myTabBox->addTab(myInputPane, "Input"); diff --git a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx index 8149ef89..e45d8dad 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx @@ -93,7 +93,7 @@ VisuGUI_DeformedShapeDlg::VisuGUI_DeformedShapeDlg (SalomeApp_Module* theModule) // Scalar bar pane myScalarPane = new VisuGUI_ScalarBarPane (this, false); myScalarPane->setMargin(5); - myInputPane = new VisuGUI_InputPane(theModule, this); + myInputPane = new VisuGUI_InputPane(VISU::TDEFORMEDSHAPE, theModule, this); myTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB")); myTabBox->addTab(myInputPane, tr("INPUT_TAB")); diff --git a/src/VISUGUI/VisuGUI_FieldFilter.cxx b/src/VISUGUI/VisuGUI_FieldFilter.cxx new file mode 100644 index 00000000..d1f22c81 --- /dev/null +++ b/src/VISUGUI/VisuGUI_FieldFilter.cxx @@ -0,0 +1,105 @@ +// 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_FieldFilter.cxx +// Author : Oleg UVAROV +// Module : VISU + +#include "VisuGUI_FieldFilter.h" + +#include "VisuGUI_Tools.h" + +#include "VISUConfig.hh" +#include "VISU_ColoredPrs3dFactory.hh" + +#include + +#include +#include + +using namespace VISU; + +VisuGUI_FieldFilter::VisuGUI_FieldFilter( VISU::VISUType theType ) : + myType( theType ) +{ +} + +VisuGUI_FieldFilter::~VisuGUI_FieldFilter() +{ +} + +bool VisuGUI_FieldFilter::isOk( const SUIT_DataOwner* theDataOwner ) const +{ + const LightApp_DataOwner* anOwner = + dynamic_cast( theDataOwner ); + + SalomeApp_Study* anAppStudy = dynamic_cast + (SUIT_Session::session()->activeApplication()->activeStudy()); + + if( anOwner && anAppStudy ) + { + _PTR(Study) aStudy = anAppStudy->studyDS(); + _PTR(SObject) aSObject = aStudy->FindObjectID( anOwner->entry() ); + if (!aSObject) + return false; + + _PTR(SObject) aRefSO; + if( aSObject->ReferencedObject( aRefSO ) ) + aSObject = aRefSO; + + if( !aSObject ) + return false; + + _PTR(GenericAttribute) anAttr; + if( !aSObject->FindAttribute( anAttr, "AttributeComment" ) ) + return false; + + _PTR(AttributeComment) aComment( anAttr ); + string aComm = aComment->Value(); + QString strIn( aComm.c_str() ); + + bool isExist; + VISU::Storable::TRestoringMap aMap; + VISU::Storable::StrToMap( strIn, aMap ); + VISU::VISUType aType = ( VISU::VISUType )VISU::Storable::FindValue( aMap, "myType", &isExist ).toInt(); + + if( aType == VISU::TFIELD ) + { + VISU::Result_var aResult = FindResult( VISU::GetSObject( aSObject ).in() ); + QString aMeshName = VISU::getValue( aSObject, "myMeshName" ); + int anEntity = VISU::getValue( aSObject, "myEntityId" ).toInt(); + QString aFieldName = VISU::getValue( aSObject, "myName" ); + + VISU::ColoredPrs3dHolder::BasicInput anInput; + anInput.myResult = aResult; + anInput.myMeshName = CORBA::string_dup( aMeshName.latin1() ); + anInput.myEntity = (VISU::Entity)anEntity; + anInput.myFieldName = CORBA::string_dup( aFieldName.latin1() ); + anInput.myTimeStampNumber = 1; + + size_t isOk = VISU::CheckIsPossible( myType, anInput, true ); + return isOk > 0; + } + } + return false; +} diff --git a/src/VISUGUI/VisuGUI_FieldFilter.h b/src/VISUGUI/VisuGUI_FieldFilter.h new file mode 100644 index 00000000..b6816e4a --- /dev/null +++ b/src/VISUGUI/VisuGUI_FieldFilter.h @@ -0,0 +1,45 @@ +// Copyright (C) 2005 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_FieldFilter.hxx +// Author : Oleg UVAROV +// Module : VISU + +#ifndef VISUGUI_FIELDFILTER_H +#define VISUGUI_FIELDFILTER_H + +#include "VISUConfig.hh" + +#include "SUIT_SelectionFilter.h" + +class SUIT_DataOwner; + +class VisuGUI_FieldFilter : public SUIT_SelectionFilter +{ +public: + VisuGUI_FieldFilter( VISU::VISUType theType ); + ~VisuGUI_FieldFilter(); + + virtual bool isOk( const SUIT_DataOwner* ) const; + +private: + VISU::VISUType myType; +}; + +#endif diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx index 25ea6eb4..17f0d172 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx @@ -566,7 +566,7 @@ VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule, bool myScalarPane->setMargin(5); // Input pane - myInputPane = new VisuGUI_InputPane(theModule, this); + myInputPane = new VisuGUI_InputPane(VISU::TGAUSSPOINTS, theModule, this); connect( myResultsButton, SIGNAL( clicked() ), mySizeBox, SLOT( onToggleResults() ) ); connect( myResultsButton, SIGNAL( toggled( bool ) ), myScalarPane, SLOT( setEnabled( bool ) ) ); diff --git a/src/VISUGUI/VisuGUI_InputPane.cxx b/src/VISUGUI/VisuGUI_InputPane.cxx index 60612e89..abae4947 100644 --- a/src/VISUGUI/VisuGUI_InputPane.cxx +++ b/src/VISUGUI/VisuGUI_InputPane.cxx @@ -27,6 +27,7 @@ #include "VisuGUI_InputPane.h" +#include "VisuGUI_FieldFilter.h" #include "VisuGUI_Tools.h" #include "VISU_ColoredPrs3d_i.hh" @@ -51,16 +52,13 @@ using namespace VISU; -VisuGUI_InputPane::VisuGUI_InputPane( SalomeApp_Module* theModule, QWidget* parent ) : +VisuGUI_InputPane::VisuGUI_InputPane( VISU::VISUType theType, SalomeApp_Module* theModule, QWidget* parent ) : QGroupBox( 2, Qt::Horizontal, parent ), myModule( theModule ) { - //SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); - setFrameStyle( QFrame::Box | QFrame::Sunken ); - LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr( myModule ); - connect( aSelectionMgr, SIGNAL( selectionChanged() ), SLOT( onSelectionChanged() ) ); + connect( mySelectionMgr, SIGNAL( selectionChanged() ), SLOT( onSelectionChanged() ) ); new QLabel( "Med File : ", this ); myMedFile = new QLineEdit( this ); @@ -87,6 +85,9 @@ VisuGUI_InputPane::VisuGUI_InputPane( SalomeApp_Module* theModule, QWidget* pare new QLabel( "Time Stamp : ", this ); myTimeStamps = new QComboBox( this ); + myFieldFilter = new VisuGUI_FieldFilter( theType ); + GetSelectionMgr( theModule )->installFilter( myFieldFilter ); + onSelectionChanged(); hide(); @@ -94,6 +95,13 @@ VisuGUI_InputPane::VisuGUI_InputPane( SalomeApp_Module* theModule, QWidget* pare VisuGUI_InputPane::~VisuGUI_InputPane() { + GetSelectionMgr( myModule )->removeFilter( myFieldFilter ); + + if( myFieldFilter ) + { + delete myFieldFilter; + myFieldFilter = 0; + } } bool VisuGUI_InputPane::check() @@ -112,7 +120,7 @@ void VisuGUI_InputPane::clear() void VisuGUI_InputPane::onSelectionChanged() { - clear(); + //clear(); SALOME_ListIO aListIO; GetSelectionMgr( myModule )->selectedObjects(aListIO); @@ -144,6 +152,8 @@ void VisuGUI_InputPane::onSelectionChanged() if( !aMedObject ) return; + myTimeStamps->clear(); + QString anEntityName, aTimeStampName; _PTR(StudyBuilder) aBuilder = aCStudy->NewBuilder(); diff --git a/src/VISUGUI/VisuGUI_InputPane.h b/src/VISUGUI/VisuGUI_InputPane.h index 8adf941a..4a27aebd 100644 --- a/src/VISUGUI/VisuGUI_InputPane.h +++ b/src/VISUGUI/VisuGUI_InputPane.h @@ -36,6 +36,9 @@ class QComboBox; class QLineEdit; class SalomeApp_Module; +class LightApp_SelectionMgr; + +class VisuGUI_FieldFilter; namespace VISU { @@ -48,7 +51,7 @@ class VisuGUI_InputPane : public QGroupBox Q_OBJECT public: - VisuGUI_InputPane( SalomeApp_Module* theModule, QWidget* parent ); + VisuGUI_InputPane( VISU::VISUType theType, SalomeApp_Module* theModule, QWidget* parent ); virtual ~VisuGUI_InputPane(); public: @@ -72,6 +75,9 @@ private: VISU::Result_var myResult; int myEntity; + + LightApp_SelectionMgr* mySelectionMgr; + VisuGUI_FieldFilter* myFieldFilter; }; #endif diff --git a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx index 34156ba5..3df24940 100644 --- a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx +++ b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx @@ -182,7 +182,7 @@ VisuGUI_IsoSurfacesDlg::VisuGUI_IsoSurfacesDlg (SalomeApp_Module* theModule) myScalarPane = new VisuGUI_ScalarBarPane(this, false); myIsoPane->setScalarBarPane(myScalarPane); myScalarPane->setMargin( 5 ); - myInputPane = new VisuGUI_InputPane(theModule, this); + myInputPane = new VisuGUI_InputPane(VISU::TISOSURFACE, theModule, this); myTabBox->addTab(myScalarPane, "Scalar Bar"); myTabBox->addTab(myInputPane, "Input"); diff --git a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx index b5e3768c..bceb5b00 100644 --- a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx +++ b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx @@ -559,7 +559,7 @@ VisuGUI_Plot3DDlg::VisuGUI_Plot3DDlg (SalomeApp_Module* theModule) myTabBox->addTab(myIsoPane, tr("PLOT3D_TAB_TITLE")); myScalarPane = new VisuGUI_ScalarBarPane (this, false); myScalarPane->setMargin(5); - myInputPane = new VisuGUI_InputPane(theModule, this); + myInputPane = new VisuGUI_InputPane(VISU::TPLOT3D, theModule, this); myTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB_TITLE")); myTabBox->addTab(myInputPane, tr("INPUT_TAB_TITLE")); diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index a3a60f98..d3b90db7 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -1086,7 +1086,7 @@ VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool Se myTabBox = new QTabWidget(this); myScalarPane = new VisuGUI_ScalarBarPane(this, SetPref); myScalarPane->setMargin( 5 ); - myInputPane = new VisuGUI_InputPane(theModule, this); + myInputPane = new VisuGUI_InputPane(VISU::TSCALARMAP, theModule, this); myTabBox->addTab(myScalarPane, "Scalar Bar"); myTabBox->addTab(myInputPane, "Input"); diff --git a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx index 90b62a8d..1d4abdd6 100644 --- a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx @@ -118,7 +118,7 @@ VisuGUI_ScalarMapOnDeformedShapeDlg::VisuGUI_ScalarMapOnDeformedShapeDlg (Salome // Scalar bar pane myScalarPane = new VisuGUI_ScalarBarPane (this, false); myScalarPane->setMargin(5); - myInputPane = new VisuGUI_InputPane(theModule, this); + myInputPane = new VisuGUI_InputPane(VISU::TSCALARMAPONDEFORMEDSHAPE, theModule, this); myTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB")); myTabBox->addTab(myInputPane, tr("INPUT_TAB")); diff --git a/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx index 129e96a7..fd98bf6a 100644 --- a/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx +++ b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx @@ -270,7 +270,7 @@ VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg (SalomeApp_Module* theModule) myTabBox->addTab(aTopBox, "Stream Lines"); myScalarPane = new VisuGUI_ScalarBarPane(this, false); myScalarPane->setMargin( 5 ); - myInputPane = new VisuGUI_InputPane(theModule, this); + myInputPane = new VisuGUI_InputPane(VISU::TSTREAMLINES, theModule, this); myTabBox->addTab(myScalarPane, "Scalar Bar"); myTabBox->addTab(myInputPane, "Input"); diff --git a/src/VISUGUI/VisuGUI_VectorsDlg.cxx b/src/VISUGUI/VisuGUI_VectorsDlg.cxx index 8f1a4094..37614b16 100644 --- a/src/VISUGUI/VisuGUI_VectorsDlg.cxx +++ b/src/VISUGUI/VisuGUI_VectorsDlg.cxx @@ -175,7 +175,7 @@ VisuGUI_VectorsDlg::VisuGUI_VectorsDlg (SalomeApp_Module* theModule) myTabBox->addTab(aBox, "Vectors"); myScalarPane = new VisuGUI_ScalarBarPane(this, false); myScalarPane->setMargin( 5 ); - myInputPane = new VisuGUI_InputPane(theModule, this); + myInputPane = new VisuGUI_InputPane(VISU::TVECTORS, theModule, this); myTabBox->addTab(myScalarPane, "Scalar Bar"); myTabBox->addTab(myInputPane, "Input");