// 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$
#include "VisuGUI_Selection.h"
-#include "SALOME_ListIteratorOfListIO.hxx"
-#include "SALOME_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 "VisuGUI.h"
-#include "QAD_MessageBox.h"
-#include "QAD_RightFrame.h"
-#include "VTKViewer_ViewFrame.h"
-#include <TColStd_MapOfInteger.hxx>
-#include <TColStd_MapIteratorOfMapOfInteger.hxx>
+#include "SalomeApp_Study.h"
+#include "SalomeApp_Application.h"
+#include "LightApp_SelectionMgr.h"
+#include "LightApp_VTKSelector.h"
-#include <map>
+#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>
+// QT Includes
#include <qstring.h>
#include <qlabel.h>
#include <qspinbox.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 <qvalidator.h>
-#include "utilities.h"
+// STL Includes
+#include <map>
using namespace std;
-extern VisuGUI *visuGUI;
-static QAD_Study* myStudy = NULL;
static VisuGUI_SelectionDlg* mySelectionDlg = NULL;
-VisuGUI_SelectionDlg::VisuGUI_SelectionDlg()
- : QDialog( QAD_Application::getDesktop(), 0, false,
- WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose)
+VisuGUI_SelectionDlg::VisuGUI_SelectionDlg (QWidget* parent)
+ : QDialog(parent, 0, false, WStyle_Customize | WStyle_NormalBorder |
+ WStyle_Title | WStyle_SysMenu | WDestructiveClose),
+ mySelectionMgr(NULL)
{
- if(mySelectionDlg)
+ if (mySelectionDlg)
mySelectionDlg->close(true);
setCaption( "Data on elements" );
- setSizeGripEnabled( TRUE );
-
- QGridLayout* TopLayout = new QGridLayout(this);
+ setSizeGripEnabled(TRUE);
+
+ QGridLayout* TopLayout = new QGridLayout (this);
TopLayout->setSpacing(6);
TopLayout->setMargin(11);
TopLayout->setRowStretch(0, 0);
TopLayout->setRowStretch(2, 1);
TopLayout->setRowStretch(3, 0);
- QHButtonGroup* aTypeBox = new QHButtonGroup("Selection", this);
-
- QRadioButton* aPointBtn = new QRadioButton("Point", aTypeBox);
- QRadioButton* aCellBtn = new QRadioButton("Cell", aTypeBox);
- QRadioButton* aActorBtn = new QRadioButton("Actor", aTypeBox);
+ 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);
+ QWidget* aNamePane = new QWidget (this);
+ QGridLayout* aNameLay = new QGridLayout (aNamePane);
- QLabel* aMeshLbl = new QLabel("Mesh name: ", aNamePane);
- myMeshName = new QLabel(aNamePane);
+ QLabel* aMeshLbl = new QLabel ("Mesh name: ", aNamePane);
+ myMeshName = new QLabel (aNamePane);
- QLabel* aFieldLbl = new QLabel("Field name: ", aNamePane);
- myFieldName = new QLabel(aNamePane);
+ QLabel* aFieldLbl = new QLabel ("Field name: ", aNamePane);
+ myFieldName = new QLabel (aNamePane);
aNameLay->addWidget(aMeshLbl, 0, 0);
aNameLay->addWidget(myMeshName, 0, 1);
TopLayout->addWidget(aNamePane, 1, 0);
- myWidgetStack = new QWidgetStack(this);
-
+ myWidgetStack = new QWidgetStack (this);
+
// Create Points pane
- myPointsPane = new QVBox(myWidgetStack);
+ myPointsPane = new QVBox (myWidgetStack);
myPointsPane->layout()->setSpacing(6);
-
- QGroupBox* aDataGrp = new QGroupBox(2, Qt::Horizontal, "Data of Point", myPointsPane);
+
+ QGroupBox* aDataGrp = new QGroupBox (2, Qt::Horizontal, "Data of Point", myPointsPane);
aDataGrp->layout()->setSpacing(6);
- QLabel* aIDLbl = new QLabel("ID:", aDataGrp);
- myIDValLbl = new QLineEdit("", aDataGrp);
- QIntValidator* aIntValidator = new QIntValidator(myIDValLbl);
+ 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&)));
- QLabel* aValueLbl = new QLabel("Scalar Value:", aDataGrp);
- myScalarValLbl = new QLabel("", aDataGrp);
- QLabel* aVectorLbl = new QLabel("Vector Value:", aDataGrp);
- myVectorValLbl = new QLabel("", aDataGrp);
+ 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);
+ QGroupBox* aCoordGrp = new QGroupBox (2, Qt::Horizontal, "Coordinates", myPointsPane);
aCoordGrp->layout()->setSpacing(6);
- QLabel* aXLbl = new QLabel("X:", aCoordGrp);
- myXValLbl = new QLabel("", aCoordGrp);
- QLabel* aYLbl = new QLabel("Y:", aCoordGrp);
- myYValLbl = new QLabel("", aCoordGrp);
- QLabel* aZLbl = new QLabel("Z:",aCoordGrp );
- myZValLbl = new QLabel("", aCoordGrp);
+ 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);
+ 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);
-
- QLabel* aCellIDLbl = new QLabel("ID:", aCellGrp);
- myCellIDValLbl = new QLineEdit("", aCellGrp);
+
+ new QLabel ("ID:", aCellGrp);
+ myCellIDValLbl = new QLineEdit ("", aCellGrp);
myCellIDValLbl->setValidator(aIntValidator);
connect(myCellIDValLbl, SIGNAL(textChanged(const QString&)), this, SLOT(onCellIdEdit(const QString&)));
- QLabel* aCellValueLbl = new QLabel("Scalar Value:", aCellGrp);
- myCellScalarValLbl = new QLabel("", aCellGrp);
- QLabel* aCellVectorLbl = new QLabel("Vector Value:", aCellGrp);
- myCellVectorValLbl = new QLabel("", aCellGrp);
+ 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 = new QTable (myCellsPane);
myListPoints->setReadOnly(true);
myListPoints->setNumCols(6);
myListPoints->setNumRows(0);
aCellLayout->addWidget(myListPoints, 1, 0);
myWidgetStack->addWidget(myCellsPane, 1);
-
+
// Actor Pane
- myActorsPane = new QVBox(myWidgetStack);
+ myActorsPane = new QVBox (myWidgetStack);
myActorsPane->layout()->setSpacing(6);
- QGroupBox* aPosGrp = new QGroupBox(2, Qt::Horizontal, "Position", myActorsPane);
+ QGroupBox* aPosGrp = new QGroupBox (2, Qt::Horizontal, "Position", myActorsPane);
aPosGrp->layout()->setSpacing(6);
- QLabel* aXPosLbl = new QLabel("X:", aPosGrp);
- myXPosLbl = new QLabel("0", aPosGrp);
- QLabel* aYPosLbl = new QLabel("Y:", aPosGrp);
- myYPosLbl = new QLabel("0", aPosGrp);
- QLabel* aZPosLbl = new QLabel("Z:", aPosGrp);
- myZPosLbl = new QLabel("0", aPosGrp);
-
- QGroupBox* aSizeGrp = new QGroupBox(2, Qt::Horizontal, "Size", myActorsPane);
+ 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);
- QLabel* aXSizeLbl = new QLabel("dX:", aSizeGrp);
- myDXLbl = new QLabel("0", aSizeGrp);
- QLabel* aYSizeLbl = new QLabel("dY:", aSizeGrp);
- myDYLbl = new QLabel("0", aSizeGrp);
- QLabel* aZSizeLbl = new QLabel("dZ:",aSizeGrp );
- myDZLbl = new QLabel("0", aSizeGrp);
+ 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();
+ QHBox* aBtnBox = new QHBox (this);
+ QHBoxLayout* aBtnLayout = (QHBoxLayout*)aBtnBox->layout();
aBtnLayout->addStretch();
- QPushButton* aCloseBtn = new QPushButton(tr("BUT_CLOSE"), aBtnBox);
+ QPushButton* aCloseBtn = new QPushButton (tr("BUT_CLOSE"), aBtnBox);
connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(close()));
-
+
TopLayout->addWidget(aBtnBox, 3, 0);
- myStudy = visuGUI->GetActiveStudy();
- mySelection = SALOME_Selection::Selection(myStudy->getSelection());
- connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionEvent()));
+ 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()));
+ //connect(visuGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(close()));
myFl = false;
- onSelectionChange(0);
+
+ // 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;
-void VisuGUI_SelectionDlg::onSelectionChange(int theId) {
- // clearFields();
switch (theId) {
case 0: // Points
- myWidgetStack->raiseWidget(myPointsPane);
- QAD_Application::getDesktop()->SetSelectionMode(NodeSelection, true);
+ myWidgetStack->raiseWidget(myPointsPane);
+ aSVTKVW->SetSelectionMode(NodeSelection);
onPointIdEdit(myIDValLbl->text());
break;
case 1: // Cells
myWidgetStack->raiseWidget(myCellsPane);
- QAD_Application::getDesktop()->SetSelectionMode(CellSelection, true);
+ aSVTKVW->SetSelectionMode(CellSelection);
onCellIdEdit(myCellIDValLbl->text());
break;
case 2: // Actor
myWidgetStack->raiseWidget(myActorsPane);
- QAD_Application::getDesktop()->SetSelectionMode(ActorSelection, true);
+ aSVTKVW->SetSelectionMode(ActorSelection);
+ onSelectionEvent();
}
- onSelectionEvent();
-// if (VTKViewer_ViewFrame* vf = visuGUI->GetVtkViewFrame())
-// vf->Repaint();
}
-void VisuGUI_SelectionDlg::closeEvent(QCloseEvent* theEvent) {
+void VisuGUI_SelectionDlg::closeEvent (QCloseEvent* theEvent)
+{
+ SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow();
+
mySelectionDlg = NULL;
- myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->SetSelectionMode( ActorSelection );
- QAD_Application::getDesktop()->SetSelectionMode(ActorSelection, true);
- disconnect(mySelection,0,0,0);
+ if (aSVTKVW)
+ aSVTKVW->SetSelectionMode(ActorSelection);
+ disconnect(mySelectionMgr,0,0,0);
QDialog::closeEvent(theEvent);
}
float aVal = aScalar->GetTuple1(theId);
return QString::number(aVal);
} else {
- return QString("No data");
+ return QString("No data");
}
}
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]);
+ 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;
- Handle(SALOME_InteractiveObject) anIO;
+ myFl = true;
+
int aType = myWidgetStack->id(myWidgetStack->visibleWidget());
- if(VISU::Prs3d_i* aPrs3d = visuGUI->GetSelectedPrs3d(&anIO)){
- SALOMEDS::SObject_var aSObject = visuGUI->GetStudyDocument()->FindObjectID(anIO->getEntry());
- QString aMeshName = VisuGUI::getValue(aSObject, "myMeshName");
- QString aFieldName = VisuGUI::getValue(aSObject, "myFieldName");
- myMeshName->setText((aMeshName == "NULL")? QString("No name") : aMeshName);
- myFieldName->setText((aFieldName == "NULL")? QString("No name") : aFieldName);
-
- VISU_Actor* anVISUActor = visuGUI->GetActor(aPrs3d);
+
+ 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());
+ }
+ }
+ }
+ }
+ }
+
+ 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);
+ }
+ }
+
+ 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_MapOfInteger aMapIndex;
- typedef map<int,float*> PointsMap;
- PointsMap aPointsMap;
- mySelection->GetIndex(anIO, aMapIndex);
- TColStd_MapIteratorOfMapOfInteger anIter(aMapIndex);
-
- VISU_Actor* anActor = visuGUI->GetActor(aPrs3d);
- if(!anActor)
- return;
- vtkDataSet* aDataSet = anActor->GetMapper()->GetInput();
- vtkPointData* aPntData = aDataSet->GetPointData();
-
- for (;anIter.More();anIter.Next()){
- int aID = anIter.Key();
-
- 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));
- // adjustSize();
- //qApp->processEvents();
- }
- break;
- case 1:
- {
- //int aMaxId = aDataSet->GetNumberOfCells();
- //cout<<"### MaxId="<<aMaxId<<endl;
- //cout<<"### SelectedId="<<aID<<endl;
- vtkCellData* aData = aDataSet->GetCellData();
- vtkCell* aCell = aDataSet->GetCell(aID);
- if (aCell != NULL) {
- int aNbOfPoints = aCell->GetNumberOfPoints();
- if (aNbOfPoints <=1 ) { // Cell is point
- clearFields();
- }
- else {
- int aDSId = anActor->GetObjId(aID);
- if (aDSId==-1) aDSId = aID;
- myCellIDValLbl->setText( QString::number(aDSId) );
- myCellScalarValLbl->setText(getValue(aData, aID));
- myCellVectorValLbl->setText(getVector(aData, aID));
-
- float* aCoord;
- vtkIdList *aPointList = aCell->GetPointIds();
- QListViewItem* anItem = NULL;
-
- for(int i = 0; i < aNbOfPoints; i++){
- int idCurrent = aPointList->GetId(i);
- aCoord = aDataSet->GetPoint(idCurrent);
- aPointsMap.insert(PointsMap::value_type(idCurrent,aCoord));
- }
- }
- }
- }
- break;
+ 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));
+ 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();
}
case 2:
myXPosLbl->setText("");
myYPosLbl->setText("");
- myZPosLbl->setText("");
+ myZPosLbl->setText("");
myDXLbl->setText("");
myDYLbl->setText("");
myDZLbl->setText("");
typedef vtkIdType (vtkDataSet::* TDataSetMethod)();
-bool onIdEdit(const QString& theText,
- TDataSetMethod theMethod,
- bool theIsCell,
- SALOME_Selection* theSelection,
- QLabel* theMeshName,
- QString theValue,
- QLabel* theFieldName)
+bool onIdEdit (const QString& theText,
+ TDataSetMethod theMethod,
+ bool theIsCell,
+ LightApp_SelectionMgr* theSelectionMgr,
+ QLabel* theMeshName,
+ QString theValue,
+ QLabel* theFieldName)
{
- int anId = theText.toInt();
+ 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;
- if(VISU::Prs3d_i* aPrs3d = visuGUI->GetSelectedPrs3d(&anIO)){
- vtkDataSet* aDataSet = aPrs3d->GetPL()->GetMapper()->GetInput();
- int aMaxId = (aDataSet->*theMethod)();
- if(anId < 0) anId = 0;
- if(aMaxId <= anId) anId = aMaxId-1;
- theSelection->ClearIObjects();
- theSelection->AddIObject(anIO);
- VISU_Actor* anVISUActor = visuGUI->GetActor(aPrs3d);
- if(theIsCell){
- VISU_Actor::TVectorId aVec = anVISUActor->GetVtkId(anId);
- if(!aVec.empty()){
- theSelection->AddOrRemoveIndex( anIO, aVec, false );
- return true;
+
+ SALOME_ListIO aListIO;
+ theSelectionMgr->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();
+ _PTR(SObject) 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());
+ }
+ }
}
- }else{
- theSelection->AddOrRemoveIndex(anIO, anId, false);
- return true;
}
- }else{
+ }
+
+ 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_SelectionDlg::onPointIdEdit(const QString& theText){
+void VisuGUI_SelectionDlg::onPointIdEdit (const QString& theText)
+{
if (myFl) return;
TDataSetMethod aMethod = &vtkDataSet::GetNumberOfPoints;
- bool anIsSelected = onIdEdit(theText,aMethod,false,mySelection,
+ bool anIsSelected = onIdEdit(theText,aMethod,false,mySelectionMgr,
myMeshName,tr("WRN_NO_AVAILABLE_DATA"),
myFieldName);
- if(!anIsSelected)
+ if (anIsSelected)
+ // as selection manager doesn't send signal currentSelectionChanged()
+ onSelectionEvent();
+ else
clearFields();
}
-void VisuGUI_SelectionDlg::onCellIdEdit(const QString& theText){
+void VisuGUI_SelectionDlg::onCellIdEdit (const QString& theText)
+{
if (myFl) return;
TDataSetMethod aMethod = &vtkDataSet::GetNumberOfCells;
- bool anIsSelected = onIdEdit(theText,aMethod,true,mySelection,
+ bool anIsSelected = onIdEdit(theText,aMethod,true,mySelectionMgr,
myMeshName,tr("WRN_NO_AVAILABLE_DATA"),
myFieldName);
- if(!anIsSelected)
+ if (anIsSelected)
+ // as selection manager doesn't send signal currentSelectionChanged()
+ onSelectionEvent();
+ else
clearFields();
}