X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_Measurements.cxx;h=4e94217ed96c33d046b0feb3c723858f019c40c4;hb=43db13f33a1d75fae36db8f06fa378ed7906a332;hp=b07c08dc4032f35eae4a02265080af5641e2afbc;hpb=d8f644ca3d4ce62f2ef41d4aacb52f5bb1221df3;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_Measurements.cxx b/src/SMESHGUI/SMESHGUI_Measurements.cxx index b07c08dc4..4e94217ed 100644 --- a/src/SMESHGUI/SMESHGUI_Measurements.cxx +++ b/src/SMESHGUI/SMESHGUI_Measurements.cxx @@ -1,23 +1,23 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 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 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. +// 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 +// 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // File : SMESHGUI_Measurements.cxx // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) @@ -392,50 +392,50 @@ void SMESHGUI_MinDistance::selectionChanged() SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface( IO ); if ( !CORBA::is_nil( obj ) ) { if ( myCurrentTgt == FirstTgt ) { - myFirstSrc = obj; - myFirstActor = SMESH::FindActorByEntry( IO->getEntry() ); - if ( myFirst->checkedId() == ObjectTgt ) { - QString aName; - SMESH::GetNameOfSelectedIObjects( SMESHGUI::selectionMgr(), aName ); - myFirstTgt->setText( aName ); - } - else { - SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector(); - QString ID; - int nb = 0; - if ( myFirstActor && selector ) { - nb = myFirst->checkedId() == NodeTgt ? - SMESH::GetNameOfSelectedElements( selector, IO, ID ) : - SMESH::GetNameOfSelectedNodes( selector, IO, ID ); - } - if ( nb == 1 ) - myFirstTgt->setText( ID.trimmed() ); - else - myFirstTgt->clear(); - } + myFirstSrc = obj; + myFirstActor = SMESH::FindActorByEntry( IO->getEntry() ); + if ( myFirst->checkedId() == ObjectTgt ) { + QString aName; + SMESH::GetNameOfSelectedIObjects( SMESHGUI::selectionMgr(), aName ); + myFirstTgt->setText( aName ); + } + else { + SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector(); + QString ID; + int nb = 0; + if ( myFirstActor && selector ) { + nb = myFirst->checkedId() == NodeTgt ? + SMESH::GetNameOfSelectedElements( selector, IO, ID ) : + SMESH::GetNameOfSelectedNodes( selector, IO, ID ); + } + if ( nb == 1 ) + myFirstTgt->setText( ID.trimmed() ); + else + myFirstTgt->clear(); + } } else if ( myCurrentTgt == SecondTgt ) { - mySecondSrc = obj; - mySecondActor = SMESH::FindActorByEntry( IO->getEntry() ); - if ( mySecond->checkedId() == ObjectTgt ) { - QString aName; - SMESH::GetNameOfSelectedIObjects( SMESHGUI::selectionMgr(), aName ); - mySecondTgt->setText( aName ); - } - else { - SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector(); - QString ID; - int nb = 0; - if ( mySecondActor && selector ) { - nb = mySecond->checkedId() == NodeTgt ? - SMESH::GetNameOfSelectedElements( selector, IO, ID ) : - SMESH::GetNameOfSelectedNodes( selector, IO, ID ); - } - if ( nb == 1 ) - mySecondTgt->setText( ID.trimmed() ); - else - mySecondTgt->clear(); - } + mySecondSrc = obj; + mySecondActor = SMESH::FindActorByEntry( IO->getEntry() ); + if ( mySecond->checkedId() == ObjectTgt ) { + QString aName; + SMESH::GetNameOfSelectedIObjects( SMESHGUI::selectionMgr(), aName ); + mySecondTgt->setText( aName ); + } + else { + SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector(); + QString ID; + int nb = 0; + if ( mySecondActor && selector ) { + nb = mySecond->checkedId() == NodeTgt ? + SMESH::GetNameOfSelectedElements( selector, IO, ID ) : + SMESH::GetNameOfSelectedNodes( selector, IO, ID ); + } + if ( nb == 1 ) + mySecondTgt->setText( ID.trimmed() ); + else + mySecondTgt->clear(); + } } } } @@ -529,11 +529,11 @@ void SMESHGUI_MinDistance::compute() SMESH::SMESH_Mesh_var m = myFirstSrc->GetMesh(); long id = myFirstTgt->text().toLong(); if ( !CORBA::is_nil( m ) && id ) { - SMESH::long_array_var ids = new SMESH::long_array(); - ids->length( 1 ); - ids[0] = id; - SMESH::SMESH_MeshEditor_var me = m->GetMeshEditor(); - s1 = me->MakeIDSource( ids.in(), myFirst->checkedId() == NodeTgt ? SMESH::NODE : SMESH::FACE ); + SMESH::long_array_var ids = new SMESH::long_array(); + ids->length( 1 ); + ids[0] = id; + SMESH::SMESH_MeshEditor_var me = m->GetMeshEditor(); + s1 = me->MakeIDSource( ids.in(), myFirst->checkedId() == NodeTgt ? SMESH::NODE : SMESH::FACE ); } } else { @@ -547,11 +547,11 @@ void SMESHGUI_MinDistance::compute() SMESH::SMESH_Mesh_var m = mySecondSrc->GetMesh(); long id = mySecondTgt->text().toLong(); if ( !CORBA::is_nil( m ) && id ) { - SMESH::long_array_var ids = new SMESH::long_array(); - ids->length( 1 ); - ids[0] = id; - SMESH::SMESH_MeshEditor_var me = m->GetMeshEditor(); - s2 = me->MakeIDSource( ids.in(), mySecond->checkedId() == NodeTgt ? SMESH::NODE : SMESH::FACE ); + SMESH::long_array_var ids = new SMESH::long_array(); + ids->length( 1 ); + ids[0] = id; + SMESH::SMESH_MeshEditor_var me = m->GetMeshEditor(); + s2 = me->MakeIDSource( ids.in(), mySecond->checkedId() == NodeTgt ? SMESH::NODE : SMESH::FACE ); } } else { @@ -564,7 +564,7 @@ void SMESHGUI_MinDistance::compute() int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 ); SMESH::Measurements_var measure = SMESHGUI::GetSMESHGen()->CreateMeasurements(); SMESH::Measure result = measure->MinDistance( s1.in(), s2.in() ); - measure->Destroy(); + measure->UnRegister(); myDX->setText( QString::number( result.minX, precision > 0 ? 'f' : 'g', qAbs( precision ) ) ); myDY->setText( QString::number( result.minY, precision > 0 ? 'f' : 'g', qAbs( precision ) ) ); myDZ->setText( QString::number( result.minZ, precision > 0 ? 'f' : 'g', qAbs( precision ) ) ); @@ -912,40 +912,40 @@ void SMESHGUI_BoundingBox::selectionChanged() mySrc.append( obj ); myActor = SMESH::FindActorByEntry( IO->getEntry() ); if ( mySourceMode->checkedId() == ObjectsSrc ) { - QString aName; - SMESH::GetNameOfSelectedIObjects( SMESHGUI::selectionMgr(), aName ); - mySource->setText( aName ); + QString aName; + SMESH::GetNameOfSelectedIObjects( SMESHGUI::selectionMgr(), aName ); + mySource->setText( aName ); } else { - SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector(); - QString ID; - int nb = 0; - if ( myActor && selector ) { - nb = mySourceMode->checkedId() == NodesSrc ? - SMESH::GetNameOfSelectedElements( selector, IO, ID ) : - SMESH::GetNameOfSelectedNodes( selector, IO, ID ); - } - if ( nb > 0 ) { - myIDs = ID.trimmed(); - if ( nb < MAX_NB_FOR_EDITOR ) { - mySource->setReadOnly( false ); - if ( mySource->validator() != myValidator ) - mySource->setValidator( myValidator ); - mySource->setText( ID.trimmed() ); - } - else { - mySource->setReadOnly( true ); - mySource->setValidator( 0 ); - mySource->setText( tr( "SELECTED_NB_OBJ" ).arg( nb ) - .arg( mySourceMode->checkedId() == NodesSrc ? tr( "NB_NODES" ) : tr( "NB_ELEMENTS") ) ); - } - } - else { - myIDs = ""; - mySource->clear(); - mySource->setReadOnly( false ); - mySource->setValidator( myValidator ); - } + SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector(); + QString ID; + int nb = 0; + if ( myActor && selector ) { + nb = mySourceMode->checkedId() == NodesSrc ? + SMESH::GetNameOfSelectedElements( selector, IO, ID ) : + SMESH::GetNameOfSelectedNodes( selector, IO, ID ); + } + if ( nb > 0 ) { + myIDs = ID.trimmed(); + if ( nb < MAX_NB_FOR_EDITOR ) { + mySource->setReadOnly( false ); + if ( mySource->validator() != myValidator ) + mySource->setValidator( myValidator ); + mySource->setText( ID.trimmed() ); + } + else { + mySource->setReadOnly( true ); + mySource->setValidator( 0 ); + mySource->setText( tr( "SELECTED_NB_OBJ" ).arg( nb ) + .arg( mySourceMode->checkedId() == NodesSrc ? tr( "NB_NODES" ) : tr( "NB_ELEMENTS") ) ); + } + } + else { + myIDs = ""; + mySource->clear(); + mySource->setReadOnly( false ); + mySource->setValidator( myValidator ); + } } } } @@ -956,11 +956,11 @@ void SMESHGUI_BoundingBox::selectionChanged() myActor = 0; if ( mySourceMode->checkedId() == ObjectsSrc ) { for( ; It.More(); It.Next()){ - Handle(SALOME_InteractiveObject) IO = It.Value(); - SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface( IO ); - if ( !CORBA::is_nil( obj ) ) { - mySrc.append( obj ); - } + Handle(SALOME_InteractiveObject) IO = It.Value(); + SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface( IO ); + if ( !CORBA::is_nil( obj ) ) { + mySrc.append( obj ); + } } QString aName; SMESH::GetNameOfSelectedIObjects( SMESHGUI::selectionMgr(), aName ); @@ -999,10 +999,10 @@ void SMESHGUI_BoundingBox::sourceEdited() if ( mySourceMode->checkedId() == NodesSrc || mySourceMode->checkedId() == ElementsSrc ) { TColStd_MapOfInteger ID; if ( !mySource->isReadOnly() ) - myIDs = mySource->text(); + myIDs = mySource->text(); QStringList ids = myIDs.split( " ", QString::SkipEmptyParts ); foreach ( QString id, ids ) - ID.Add( id.trimmed().toLong() ); + ID.Add( id.trimmed().toLong() ); selector->AddOrRemoveIndex( IO, ID, false ); } if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() ) @@ -1022,14 +1022,14 @@ void SMESHGUI_BoundingBox::compute() SMESH::SMESH_Mesh_var m = mySrc[0]->GetMesh(); QStringList ids = myIDs.split( " ", QString::SkipEmptyParts ); if ( !CORBA::is_nil( m ) && ids.count() > 0 ) { - SMESH::long_array_var ids_in = new SMESH::long_array(); - ids_in->length( ids.count() ); - for( int i = 0; i < ids.count(); i++ ) - ids_in[i] = ids[i].trimmed().toLong(); - SMESH::SMESH_MeshEditor_var me = m->GetMeshEditor(); - SMESH::SMESH_IDSource_var s = me->MakeIDSource( ids_in.in(), mySourceMode->checkedId() == NodesSrc ? SMESH::NODE : SMESH::FACE ); - srcList->length( 1 ); - srcList[0] = s; + SMESH::long_array_var ids_in = new SMESH::long_array(); + ids_in->length( ids.count() ); + for( int i = 0; i < ids.count(); i++ ) + ids_in[i] = ids[i].trimmed().toLong(); + SMESH::SMESH_MeshEditor_var me = m->GetMeshEditor(); + SMESH::SMESH_IDSource_var s = me->MakeIDSource( ids_in.in(), mySourceMode->checkedId() == NodesSrc ? SMESH::NODE : SMESH::FACE ); + srcList->length( 1 ); + srcList[0] = s; } } } @@ -1043,7 +1043,7 @@ void SMESHGUI_BoundingBox::compute() int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 ); SMESH::Measurements_var measure = SMESHGUI::GetSMESHGen()->CreateMeasurements(); SMESH::Measure result = measure->BoundingBox( srcList.in() ); - measure->Destroy(); + measure->UnRegister(); myXmin->setText( QString::number( result.minX, precision > 0 ? 'f' : 'g', qAbs( precision ) ) ); myXmax->setText( QString::number( result.maxX, precision > 0 ? 'f' : 'g', qAbs( precision ) ) ); myDX->setText( QString::number( result.maxX-result.minX, precision > 0 ? 'f' : 'g', qAbs( precision ) ) ); @@ -1204,8 +1204,8 @@ void SMESHGUI_MeasureDlg::updateSelection() void SMESHGUI_MeasureDlg::help() { SMESH::ShowHelpFile( myTabWidget->currentIndex() == MinDistance ? - "measurements_page.html#min_distance_anchor" : - "measurements_page.html#bounding_box_anchor" ); + "measurements_page.html#min_distance_anchor" : + "measurements_page.html#bounding_box_anchor" ); } /*!