1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : VisuGUI_Selection.cxx
25 // Author : Laurent CORNABE & Hubert ROLLAND
30 #include "utilities.h"
31 #include "SALOME_ListIteratorOfListIO.hxx"
32 #include "SALOME_Selection.h"
33 #include "VISU_Actor.h"
34 #include "VISU_PrsObject_i.hh"
36 #include <TColStd_MapOfInteger.hxx>
37 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
44 #include <vtkDataSet.h>
47 #include "VisuGUI_CellsResultsDlg.h"
48 #include "VisuGUI_PointsResultsDlg.h"
49 #include "VisuGUI_Selection.h"
51 template<class TData, class TDialog> void SetMessage(TData* theData, int theId, TDialog* theDialog){
54 if (vtkDataArray *Scalar = theData->GetScalars()){
55 float aVal = Scalar->GetTuple1(theId);
56 Msg_1.sprintf("%6.3g",aVal);
58 Msg_1.sprintf("NO DATA");
59 theDialog->ScalValue->setText( Msg_1.latin1() );
63 if (vtkDataArray *Vector = theData->GetVectors()){
64 float *aVal = Vector->GetTuple3(theId);
65 Msg_2.sprintf("%6.3g; %6.3g; %6.3g",aVal[0],aVal[1],aVal[2]);
67 Msg_2.sprintf("NO DATA");
68 theDialog->VectTxt->setText( Msg_2.latin1() );
71 // ============================================================================================ //
73 // ============================================================================================ //
75 void VisuGUI_Selection::PickingCell(QAD_Study *theActiveStudy, vtkDataSet *theDataSet, int theId){
77 VisuGUI_CellsResultsDlg *aResultsDlg = new VisuGUI_CellsResultsDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
78 vtkCellData *aData = theDataSet->GetCellData();
79 vtkCell *aCell = theDataSet->GetCell(theId);
81 float aPntCoord[12][3];
82 int aNbOfPoints = aCell->GetNumberOfPoints();
83 vtkIdList *aPointList = aCell->GetPointIds();
84 QListViewItem* anItem = NULL;
85 for(int i = 0; i < aNbOfPoints; i++){
87 int idCurrent = aPointList->GetId(i);
88 theDataSet->GetPoint(idCurrent,aCoord);
89 for (int j=0; j<3; j++)
90 aPntCoord[i][j]=aCoord[j];
91 anItem = new QListViewItem(aResultsDlg->ListPoints,
93 QString::number( idCurrent ),
94 QString::number( aPntCoord[i][0] ),
95 QString::number( aPntCoord[i][1] ),
96 QString::number( aPntCoord[i][2] ));
99 SetMessage(aData,theId,aResultsDlg);
101 aResultsDlg->IdCell->setText( QString::number( theId ) );
102 aResultsDlg->NbPoint->setText( QString::number( aNbOfPoints ) );
109 // ============================================================================================ //
111 // ============================================================================================ //
113 void VisuGUI_Selection::PickingPoint(QAD_Study *theActiveStudy, vtkDataSet *theDataSet, int theId){
115 VisuGUI_PointsResultsDlg *aResultsDlg = new VisuGUI_PointsResultsDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
116 vtkPointData *aData = theDataSet->GetPointData();
119 theDataSet->GetPoint(theId,Coord);
120 aResultsDlg->CoordX->setText( QString::number( Coord[0] ) );
121 aResultsDlg->CoordY->setText( QString::number( Coord[1] ) );
122 aResultsDlg->CoordZ->setText( QString::number( Coord[2] ) );
123 aResultsDlg->IdPoint->setText( QString::number(theId) );
125 SetMessage(aData,theId,aResultsDlg);
132 void VisuGUI_Selection::Highlight(QAD_Study *theActiveStudy, const Handle(SALOME_InteractiveObject)& theIO, int theId){
133 MESSAGE("HighlightCell");
134 SALOME_Selection *aSel = SALOME_Selection::Selection(theActiveStudy->getSelection());
135 aSel->AddIObject(theIO);
136 aSel->AddOrRemoveIndex(theIO, theId, false);