// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : VisuGUI_Selection.cxx
-// Author : Laurent CORNABE & Hubert ROLLAND
+// Author : Laurent CORNABE & Hubert ROLLAND
// Module : VISU
// $Header$
-using namespace std;
-#include "utilities.h"
-#include "SALOME_ListIteratorOfListIO.hxx"
-#include "SALOME_Selection.h"
+#include "VisuGUI_Selection.h"
+
+#include "VisuGUI.h"
+#include "VisuGUI_Tools.h"
+
#include "VISU_Actor.h"
#include "VISU_PrsObject_i.hh"
+#include "VISU_Prs3d_i.hh"
+#include "VISU_PipeLine.hxx"
+
+#include "SalomeApp_Study.h"
+#include "SalomeApp_Application.h"
+#include "LightApp_SelectionMgr.h"
+#include "LightApp_VTKSelector.h"
+
+#include "SUIT_MessageBox.h"
+#include "SUIT_ViewWindow.h"
+#include "SUIT_Session.h"
+#include "SALOME_ListIO.hxx"
+#include "SALOME_ListIteratorOfListIO.hxx"
+
+#include "SVTK_ViewWindow.h"
+#include "SVTK_ViewModel.h"
+#include "SVTK_Selector.h"
+
+#include "utilities.h"
+
+// OCCT Includes
+#include <TColStd_IndexedMapOfInteger.hxx>
#include <TColStd_MapOfInteger.hxx>
-#include <TColStd_MapIteratorOfMapOfInteger.hxx>
+// QT Includes
#include <qstring.h>
#include <qlabel.h>
#include <qspinbox.h>
#include <qlistbox.h>
+#include <qlayout.h>
+#include <qhbuttongroup.h>
+#include <qradiobutton.h>
+#include <qvalidator.h>
+#include <qpushbutton.h>
+#include <qwidgetstack.h>
+#include <qvbox.h>
+#include <qgroupbox.h>
+#include <qlineedit.h>
+#include <qvalidator.h>
+#include <qtable.h>
+// VTK Includes
+#include <vtkDataSetMapper.h>
#include <vtkDataSet.h>
+#include <vtkPointData.h>
+#include <vtkCellData.h>
#include <vtkCell.h>
-#include "VisuGUI_CellsResultsDlg.h"
-#include "VisuGUI_PointsResultsDlg.h"
-#include "VisuGUI_Selection.h"
+// STL Includes
+#include <map>
+
+using namespace std;
+
+static VisuGUI_SelectionDlg* mySelectionDlg = NULL;
+
+VisuGUI_SelectionDlg::VisuGUI_SelectionDlg (QWidget* parent)
+ : QDialog(parent, 0, false, WStyle_Customize | WStyle_NormalBorder |
+ WStyle_Title | WStyle_SysMenu | WDestructiveClose),
+ mySelectionMgr(NULL)
+{
+ if (mySelectionDlg)
+ mySelectionDlg->close(true);
+
+ setCaption( "Data on elements" );
+ setSizeGripEnabled(TRUE);
+
+ QGridLayout* TopLayout = new QGridLayout (this);
+ TopLayout->setSpacing(6);
+ TopLayout->setMargin(11);
+ TopLayout->setRowStretch(0, 0);
+ TopLayout->setRowStretch(1, 0);
+ TopLayout->setRowStretch(2, 1);
+ TopLayout->setRowStretch(3, 0);
+
+ QHButtonGroup* aTypeBox = new QHButtonGroup ("Selection", this);
+
+ QRadioButton* aPointBtn =
+ new QRadioButton ("Point", aTypeBox);
+ new QRadioButton ("Cell" , aTypeBox);
+ new QRadioButton ("Actor", aTypeBox);
+ aPointBtn->setChecked(true);
+
+ connect(aTypeBox, SIGNAL(clicked(int)), this, SLOT(onSelectionChange(int)));
+
+ TopLayout->addWidget(aTypeBox, 0, 0);
+
+ QWidget* aNamePane = new QWidget (this);
+ QGridLayout* aNameLay = new QGridLayout (aNamePane);
+
+ QLabel* aMeshLbl = new QLabel ("Mesh name: ", aNamePane);
+ myMeshName = new QLabel (aNamePane);
+
+ QLabel* aFieldLbl = new QLabel ("Field name: ", aNamePane);
+ myFieldName = new QLabel (aNamePane);
+
+ aNameLay->addWidget(aMeshLbl, 0, 0);
+ aNameLay->addWidget(myMeshName, 0, 1);
+ aNameLay->addWidget(aFieldLbl, 1, 0);
+ aNameLay->addWidget(myFieldName, 1, 1);
+
+ TopLayout->addWidget(aNamePane, 1, 0);
+
+ myWidgetStack = new QWidgetStack (this);
+
+ // Create Points pane
+ myPointsPane = new QVBox (myWidgetStack);
+ myPointsPane->layout()->setSpacing(6);
+
+ QGroupBox* aDataGrp = new QGroupBox (2, Qt::Horizontal, "Data of Point", myPointsPane);
+ aDataGrp->layout()->setSpacing(6);
+
+ new QLabel ("ID:", aDataGrp);
+ myIDValLbl = new QLineEdit ("", aDataGrp);
+ QIntValidator* aIntValidator = new QIntValidator (myIDValLbl);
+ aIntValidator->setBottom(0);
+ myIDValLbl->setValidator(aIntValidator);
+ connect(myIDValLbl, SIGNAL(textChanged(const QString&)), this, SLOT(onPointIdEdit(const QString&)));
+
+ new QLabel ("Scalar Value:", aDataGrp);
+ myScalarValLbl = new QLabel ("", aDataGrp);
+ new QLabel ("Vector Value:", aDataGrp);
+ myVectorValLbl = new QLabel ("", aDataGrp);
+ myVectorValLbl->setMinimumWidth(150);
+
+ QGroupBox* aCoordGrp = new QGroupBox (2, Qt::Horizontal, "Coordinates", myPointsPane);
+ aCoordGrp->layout()->setSpacing(6);
+ new QLabel ("X:", aCoordGrp);
+ myXValLbl = new QLabel ("", aCoordGrp);
+ new QLabel ("Y:", aCoordGrp);
+ myYValLbl = new QLabel ("", aCoordGrp);
+ new QLabel ("Z:",aCoordGrp );
+ myZValLbl = new QLabel ("", aCoordGrp);
+
+
+ myWidgetStack->addWidget(myPointsPane, 0);
+
+ // Create Cells pane
+ myCellsPane = new QWidget (myWidgetStack);
+ QGridLayout* aCellLayout = new QGridLayout (myCellsPane);
+ aCellLayout->setSpacing(6);
+ aCellLayout->setRowStretch(0, 0);
+ aCellLayout->setRowStretch(1, 1);
+
+ QGroupBox* aCellGrp = new QGroupBox(2, Qt::Horizontal, "Data of Cell", myCellsPane);
+
+ new QLabel ("ID:", aCellGrp);
+ myCellIDValLbl = new QLineEdit ("", aCellGrp);
+ myCellIDValLbl->setValidator(aIntValidator);
+ connect(myCellIDValLbl, SIGNAL(textChanged(const QString&)), this, SLOT(onCellIdEdit(const QString&)));
+
+ new QLabel ("Scalar Value:", aCellGrp);
+ myCellScalarValLbl = new QLabel ("", aCellGrp);
+ new QLabel ("Vector Value:", aCellGrp);
+ myCellVectorValLbl = new QLabel ("", aCellGrp);
+
+ aCellLayout->addWidget(aCellGrp, 0, 0);
+
+ myListPoints = new QTable (myCellsPane);
+ myListPoints->setReadOnly(true);
+ myListPoints->setNumCols(6);
+ myListPoints->setNumRows(0);
+ myListPoints->setColumnWidth(0, 40);
+ myListPoints->setColumnWidth(1, 40);
+ myListPoints->setColumnWidth(2, 40);
+ myListPoints->setColumnWidth(3, 40);
+ myListPoints->setSelectionMode(QTable::NoSelection);
+ QHeader* aHeader = myListPoints->horizontalHeader();
+ aHeader->setLabel( 0, "ID" );
+ aHeader->setLabel( 1, "X" );
+ aHeader->setLabel( 2, "Y" );
+ aHeader->setLabel( 3, "Z" );
+ aHeader->setLabel( 4, "Scalar" );
+ aHeader->setLabel( 5, "Vector" );
+
+ aCellLayout->addWidget(myListPoints, 1, 0);
+
+ myWidgetStack->addWidget(myCellsPane, 1);
+
+ // Actor Pane
+ myActorsPane = new QVBox (myWidgetStack);
+ myActorsPane->layout()->setSpacing(6);
+
+ QGroupBox* aPosGrp = new QGroupBox (2, Qt::Horizontal, "Position", myActorsPane);
+ aPosGrp->layout()->setSpacing(6);
+ new QLabel ("X:", aPosGrp);
+ myXPosLbl = new QLabel ("0", aPosGrp);
+ new QLabel ("Y:", aPosGrp);
+ myYPosLbl = new QLabel ("0", aPosGrp);
+ new QLabel ("Z:", aPosGrp);
+ myZPosLbl = new QLabel ("0", aPosGrp);
+
+ QGroupBox* aSizeGrp = new QGroupBox (2, Qt::Horizontal, "Size", myActorsPane);
+ aSizeGrp->layout()->setSpacing(6);
+ new QLabel ("dX:", aSizeGrp);
+ myDXLbl = new QLabel ("0", aSizeGrp);
+ new QLabel ("dY:", aSizeGrp);
+ myDYLbl = new QLabel ("0", aSizeGrp);
+ new QLabel ("dZ:",aSizeGrp );
+ myDZLbl = new QLabel ("0", aSizeGrp);
+
+ myWidgetStack->addWidget(myActorsPane, 2);
+
+
+ TopLayout->addWidget(myWidgetStack, 2, 0);
+
+ // Create buttons group
+ QHBox* aBtnBox = new QHBox (this);
+ QHBoxLayout* aBtnLayout = (QHBoxLayout*)aBtnBox->layout();
+ aBtnLayout->addStretch();
+
+ QPushButton* aCloseBtn = new QPushButton (tr("BUT_CLOSE"), aBtnBox);
+ connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(close()));
+
+ TopLayout->addWidget(aBtnBox, 3, 0);
+
+ SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
+ (SUIT_Session::session()->activeApplication());
+ mySelectionMgr = anApp->selectionMgr();
+ connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionEvent()));
+
+ //connect(visuGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(close()));
+
+ myFl = false;
-template<class TData, class TDialog> void SetMessage(TData* theData, int theId, TDialog* theDialog){
- // Scalar result
- QString Msg_1;
- if (vtkDataArray *Scalar = theData->GetScalars()){
- float aVal = Scalar->GetTuple1(theId);
- Msg_1.sprintf("%6.3g",aVal);
- }else
- Msg_1.sprintf("NO DATA");
- theDialog->ScalValue->setText( Msg_1.latin1() );
-
- // Vector result
- QString Msg_2;
- if (vtkDataArray *Vector = theData->GetVectors()){
- float *aVal = Vector->GetTuple3(theId);
- Msg_2.sprintf("%6.3g; %6.3g; %6.3g",aVal[0],aVal[1],aVal[2]);
- }else
- Msg_2.sprintf("NO DATA");
- theDialog->VectTxt->setText( Msg_2.latin1() );
+ // Activate Points pane
+ SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow();
+ myWidgetStack->raiseWidget(myPointsPane);
+ if (aSVTKVW)
+ aSVTKVW->SetSelectionMode(NodeSelection);
+ onSelectionEvent();
+
+ mySelectionDlg = this;
+}
+
+VisuGUI_SelectionDlg::~VisuGUI_SelectionDlg()
+{
+}
+
+void VisuGUI_SelectionDlg::onSelectionChange (int theId)
+{
+ SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow();
+ if (!aSVTKVW) return;
+
+ switch (theId) {
+ case 0: // Points
+ myWidgetStack->raiseWidget(myPointsPane);
+ aSVTKVW->SetSelectionMode(NodeSelection);
+ onPointIdEdit(myIDValLbl->text());
+ break;
+ case 1: // Cells
+ myWidgetStack->raiseWidget(myCellsPane);
+ aSVTKVW->SetSelectionMode(CellSelection);
+ onCellIdEdit(myCellIDValLbl->text());
+ break;
+ case 2: // Actor
+ myWidgetStack->raiseWidget(myActorsPane);
+ aSVTKVW->SetSelectionMode(ActorSelection);
+ onSelectionEvent();
+ }
+}
+
+
+void VisuGUI_SelectionDlg::closeEvent (QCloseEvent* theEvent)
+{
+ SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow();
+
+ mySelectionDlg = NULL;
+ if (aSVTKVW)
+ aSVTKVW->SetSelectionMode(ActorSelection);
+ disconnect(mySelectionMgr,0,0,0);
+ QDialog::closeEvent(theEvent);
+}
+
+template<class TData> QString getValue(TData* theData, int theId){
+ if (vtkDataArray *aScalar = theData->GetScalars()){
+ float aVal = aScalar->GetTuple1(theId);
+ return QString::number(aVal);
+ } else {
+ return QString("No data");
+ }
}
-// ============================================================================================ //
-// PICKING CELL //
-// ============================================================================================ //
-
-void VisuGUI_Selection::PickingCell(QAD_Study *theActiveStudy, vtkDataSet *theDataSet, int theId){
- if(theId >= 0){
- VisuGUI_CellsResultsDlg *aResultsDlg = new VisuGUI_CellsResultsDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
- vtkCellData *aData = theDataSet->GetCellData();
- vtkCell *aCell = theDataSet->GetCell(theId);
-
- float aPntCoord[12][3];
- int aNbOfPoints = aCell->GetNumberOfPoints();
- vtkIdList *aPointList = aCell->GetPointIds();
- QListViewItem* anItem = NULL;
- for(int i = 0; i < aNbOfPoints; i++){
- float aCoord[3];
- int idCurrent = aPointList->GetId(i);
- theDataSet->GetPoint(idCurrent,aCoord);
- for (int j=0; j<3; j++)
- aPntCoord[i][j]=aCoord[j];
- anItem = new QListViewItem(aResultsDlg->ListPoints,
- anItem,
- QString::number( idCurrent ),
- QString::number( aPntCoord[i][0] ),
- QString::number( aPntCoord[i][1] ),
- QString::number( aPntCoord[i][2] ));
+template<class TData> QString getVector(TData* theData, int theId){
+ if (vtkDataArray *aVector = theData->GetVectors()) {
+ float *aVal = aVector->GetTuple3(theId);
+ return QString("%1; %2; %3").arg(aVal[0]).arg(aVal[1]).arg(aVal[2]);
+ } else {
+ return QString("No data");
+ }
+}
+
+#define ABS(a) (a>=0)?a:-a
+
+void VisuGUI_SelectionDlg::onSelectionEvent() {
+ SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow();
+ if (!aSVTKVW) return;
+
+ if (myFl) return;
+ myFl = true;
+
+ int aType = myWidgetStack->id(myWidgetStack->visibleWidget());
+
+ SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
+ (SUIT_Session::session()->activeApplication());
+
+ SVTK_Selector* aSelector = aSVTKVW->GetSelector();
+
+ VISU::Prs3d_i* aPrs3d = NULL;
+ _PTR(SObject) aSObject;
+ Handle(SALOME_InteractiveObject) anIO;
+
+ SALOME_ListIO aListIO;
+ mySelectionMgr->selectedObjects(aListIO, SVTK_Viewer::Type());
+
+ if (aListIO.Extent() == 1) {
+ anIO = aListIO.First();
+
+ if (anIO->hasEntry()) {
+ SalomeApp_Study* theStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy());
+ _PTR(Study) aStudy = theStudy->studyDS();
+ aSObject = aStudy->FindObjectID(anIO->getEntry());
+
+ if (aSObject) {
+ CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject);
+
+ if (!CORBA::is_nil(anObject)) {
+ PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+
+ if (aServant.in()) {
+ aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+ }
+ }
+ }
}
+ }
- SetMessage(aData,theId,aResultsDlg);
+ if (aPrs3d) {
+ VISU::Storable::TRestoringMap aMap;
+ if (aSObject) {
+ _PTR(GenericAttribute) anAttr;
+ if (aSObject->FindAttribute(anAttr, "AttributeComment")) {
+ _PTR(AttributeComment) aComment (anAttr);
+ std::string aString = aComment->Value();
+ QString strIn( aString.c_str() );
+ VISU::Storable::StrToMap(strIn, aMap);
+ }
+ }
- aResultsDlg->IdCell->setText( QString::number( theId ) );
- aResultsDlg->NbPoint->setText( QString::number( aNbOfPoints ) );
- aResultsDlg->exec();
- delete aResultsDlg;
+ QString aMeshName("NULL"), aFieldName("NULL");
+ if (!aMap.empty()) {
+ aMeshName = VISU::Storable::FindValue(aMap, "myMeshName");
+ aFieldName = VISU::Storable::FindValue(aMap, "myFieldName");
+ }
+
+ myMeshName ->setText((aMeshName == "NULL") ? QString("No name") : aMeshName);
+ myFieldName->setText((aFieldName == "NULL") ? QString("No name") : aFieldName);
+
+ VISU_Actor* anVISUActor =
+ VISU::FindActor(aSVTKVW, aSObject->GetID().c_str());
+ if (anVISUActor) {
+ float aCoord[6];
+ anVISUActor->GetBounds(aCoord);
+ myXPosLbl->setText(QString::number( aCoord[0] ));
+ myYPosLbl->setText(QString::number( aCoord[2] ));
+ myZPosLbl->setText(QString::number( aCoord[4] ));
+
+ myDXLbl->setText(QString::number( ABS(aCoord[1]-aCoord[0]) ));
+ myDYLbl->setText(QString::number( ABS(aCoord[3]-aCoord[2]) ));
+ myDZLbl->setText(QString::number( ABS(aCoord[5]-aCoord[4]) ));
+
+ TColStd_IndexedMapOfInteger aMapIndex;
+ typedef map<int,float*> PointsMap;
+ PointsMap aPointsMap;
+
+ aSelector->GetIndex(anIO, aMapIndex);
+
+ vtkDataSet* aDataSet = anVISUActor->GetInput();
+ vtkPointData* aPntData = aDataSet->GetPointData();
+
+ for (int ind = 1; ind <= aMapIndex.Extent(); ind++) {
+ int aID = aMapIndex(ind);
+
+ switch (aType) {
+ case 0:
+ {
+ float aCoord[3];
+ aDataSet->GetPoint(aID, aCoord);
+ myXValLbl->setText( QString::number( aCoord[0] ) );
+ myYValLbl->setText( QString::number( aCoord[1] ) );
+ myZValLbl->setText( QString::number( aCoord[2] ) );
+ myIDValLbl->setText( QString::number(aID) );
+ myScalarValLbl->setText(getValue(aPntData, aID));
+ myVectorValLbl->setText(getVector(aPntData, aID));
+ }
+ break;
+ case 1:
+ {
+ vtkCellData* aData = aDataSet->GetCellData();
+ vtkCell* aCell = aDataSet->GetCell(aID);
+ if (aCell != NULL) {
+ int aNbOfPoints = aCell->GetNumberOfPoints();
+ if (aNbOfPoints <=1 ) { // Cell is point
+ clearFields();
+ } else {
+ myCellIDValLbl->setText( QString::number(aID) );
+ myCellScalarValLbl->setText(getValue(aData, aID));
+ myCellVectorValLbl->setText(getVector(aData, aID));
+
+ float* aCoord;
+ vtkIdList *aPointList = aCell->GetPointIds();
+
+ for (int i = 0; i < aNbOfPoints; i++) {
+ int idCurrent = aPointList->GetId(i);
+ aCoord = aDataSet->GetPoint(idCurrent);
+ aPointsMap.insert(PointsMap::value_type(idCurrent,aCoord));
+ }
+ }
+ }
+ }
+ break;
+ }
+ }
+
+ myListPoints->setNumRows(aPointsMap.size());
+ PointsMap::const_iterator It = aPointsMap.begin();
+ for (int i = 0; It != aPointsMap.end() && i < myListPoints->numRows(); It++, i++) {
+ myListPoints->verticalHeader()->setLabel(i, QString::number( i ));
+ int id = It->first;
+ myListPoints->setText(i, 0, QString::number( id ));
+ float* aCoord = It->second;
+ myListPoints->setText(i, 1, QString::number( aCoord[0] ));
+ myListPoints->setText(i, 2, QString::number( aCoord[1] ));
+ myListPoints->setText(i, 3, QString::number( aCoord[2] ));
+ myListPoints->setText(i, 4, getValue(aPntData, id));
+ myListPoints->setText(i, 5, getVector(aPntData, id));
+ }
+ }
+ } else {
+ clearFields();
+ }
+ myFl = false;
+}
+#undef ABS
+
+
+void VisuGUI_SelectionDlg::clearFields() {
+ int aType = myWidgetStack->id(myWidgetStack->visibleWidget());
+ switch (aType) {
+ case 0:
+ myXValLbl->setText( "" );
+ myYValLbl->setText( "" );
+ myZValLbl->setText( "" );
+ myIDValLbl->setText( "" );
+ myScalarValLbl->setText("");
+ myVectorValLbl->setText("");
+ break;
+ case 1:
+ myCellIDValLbl->setText( "" );
+ myCellScalarValLbl->setText("");
+ myCellVectorValLbl->setText("");
+ myListPoints->setNumRows(0);
+ break;
+ case 2:
+ myXPosLbl->setText("");
+ myYPosLbl->setText("");
+ myZPosLbl->setText("");
+ myDXLbl->setText("");
+ myDYLbl->setText("");
+ myDZLbl->setText("");
}
}
+typedef vtkIdType (vtkDataSet::* TDataSetMethod)();
+
+bool onIdEdit (const QString& theText,
+ TDataSetMethod theMethod,
+ bool theIsCell,
+ LightApp_SelectionMgr* theSelectionMgr,
+ QLabel* theMeshName,
+ QString theValue,
+ QLabel* theFieldName)
+{
+ SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
+ (SUIT_Session::session()->activeApplication());
+ SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow();
+ if (!aSVTKVW) return false;
+ SVTK_Selector* aSelector = aSVTKVW->GetSelector();
+
+ VISU::Prs3d_i* aPrs3d = NULL;
+ Handle(SALOME_InteractiveObject) anIO;
-// ============================================================================================ //
-// PICKING POINT //
-// ============================================================================================ //
+ SALOME_ListIO aListIO;
+ theSelectionMgr->selectedObjects(aListIO, SVTK_Viewer::Type());
-void VisuGUI_Selection::PickingPoint(QAD_Study *theActiveStudy, vtkDataSet *theDataSet, int theId){
- if(theId >= 0){
- VisuGUI_PointsResultsDlg *aResultsDlg = new VisuGUI_PointsResultsDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
- vtkPointData *aData = theDataSet->GetPointData();
+ if (aListIO.Extent() == 1) {
+ anIO = aListIO.First();
- float Coord[3];
- theDataSet->GetPoint(theId,Coord);
- aResultsDlg->CoordX->setText( QString::number( Coord[0] ) );
- aResultsDlg->CoordY->setText( QString::number( Coord[1] ) );
- aResultsDlg->CoordZ->setText( QString::number( Coord[2] ) );
- aResultsDlg->IdPoint->setText( QString::number(theId) );
-
- SetMessage(aData,theId,aResultsDlg);
+ if (anIO->hasEntry()) {
+ SalomeApp_Study* theStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy());
+ _PTR(Study) aStudy = theStudy->studyDS();
+ _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
- aResultsDlg->exec();
- delete aResultsDlg;
+ if (aSObject) {
+ CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject);
+
+ if (!CORBA::is_nil(anObject)) {
+ PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+
+ if (aServant.in()) {
+ aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+ }
+ }
+ }
+ }
}
+
+ if (aPrs3d) {
+ int anId = theText.toInt();
+ vtkDataSet* aDataSet = aPrs3d->GetPL()->GetMapper()->GetInput();
+ int aMaxId = (aDataSet->*theMethod)();
+ if (anId < 0) anId = 0;
+ if (anId >= aMaxId) anId = aMaxId - 1;
+
+ TColStd_MapOfInteger newIndices;
+ newIndices.Add(anId);
+ aSelector->AddOrRemoveIndex(anIO, newIndices, false);
+ aSVTKVW->highlight(anIO, true, true);
+
+ return true;
+
+ } else {
+ theMeshName->setText(theValue);
+ theFieldName->setText("");
+ }
+ return false;
}
-void VisuGUI_Selection::Highlight(QAD_Study *theActiveStudy, const Handle(SALOME_InteractiveObject)& theIO, int theId){
- MESSAGE("HighlightCell");
- SALOME_Selection *aSel = SALOME_Selection::Selection(theActiveStudy->getSelection());
- aSel->AddIObject(theIO);
- aSel->AddOrRemoveIndex(theIO, theId, false);
-}
+void VisuGUI_SelectionDlg::onPointIdEdit (const QString& theText)
+{
+ if (myFl) return;
+ TDataSetMethod aMethod = &vtkDataSet::GetNumberOfPoints;
+ bool anIsSelected = onIdEdit(theText,aMethod,false,mySelectionMgr,
+ myMeshName,tr("WRN_NO_AVAILABLE_DATA"),
+ myFieldName);
+ if (anIsSelected)
+ // as selection manager doesn't send signal currentSelectionChanged()
+ onSelectionEvent();
+ else
+ clearFields();
+}
+
+void VisuGUI_SelectionDlg::onCellIdEdit (const QString& theText)
+{
+ if (myFl) return;
+ TDataSetMethod aMethod = &vtkDataSet::GetNumberOfCells;
+ bool anIsSelected = onIdEdit(theText,aMethod,true,mySelectionMgr,
+ myMeshName,tr("WRN_NO_AVAILABLE_DATA"),
+ myFieldName);
+ if (anIsSelected)
+ // as selection manager doesn't send signal currentSelectionChanged()
+ onSelectionEvent();
+ else
+ clearFields();
+}