Back to index

salome-smesh  6.5.0
StdMeshersGUI_SubShapeSelectorWdg.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 // File   : StdMeshersGUI_SubShapeSelectorWdg.cxx
00021 // Author : Open CASCADE S.A.S. (dmv)
00022 // SMESH includes
00023 //
00024 #include "StdMeshersGUI_SubShapeSelectorWdg.h"
00025 
00026 // SMESH Includes
00027 #include "SMESH_Type.h"
00028 #include "SMESHGUI_MeshUtils.h"
00029 #include "SMESH_Actor.h"
00030 #include "SMESH_PreviewActorsCollection.h"
00031 #include "SMESH_ActorUtils.h"
00032 #include "SMESHGUI_GroupUtils.h"
00033 #include "SMESH_Gen_i.hxx"
00034 #include "SMESHGUI_GEOMGenUtils.h"
00035 #include "SMESH_LogicalFilter.hxx"
00036 
00037 // SVTK Includes
00038 #include <SVTK_ViewWindow.h>
00039 #include <SVTK_ViewModel.h>
00040 #include <SVTK_ViewWindow.h>
00041 #include <SVTK_Selector.h>
00042 
00043 // SALOME GUI includes
00044 #include <SALOME_ListIO.hxx>
00045 #include <LightApp_SelectionMgr.h>
00046 #include <SALOME_ListIteratorOfListIO.hxx>
00047 
00048 // SUIT Includes
00049 #include <SUIT_ResourceMgr.h>
00050 
00051 // GEOM Includes
00052 #include <GEOMBase.h>
00053 #include <GEOM_TypeFilter.h>
00054 #include <GEOM_CompoundFilter.h>
00055 
00056 // Qt includes
00057 #include <QPushButton>
00058 #include <QGridLayout>
00059 #include <QListWidget>
00060 #include <QCheckBox>
00061 #include <QLineEdit>
00062 
00063 // OCCT includes
00064 #include <TColStd_MapOfInteger.hxx>
00065 #include <TColStd_IndexedMapOfInteger.hxx>
00066 #include <TopoDS_Shape.hxx>
00067 #include <TopExp.hxx>
00068 #include <TopExp_Explorer.hxx>
00069 #include <StdSelect_TypeOfEdge.hxx>
00070 
00071 // SALOME KERNEL includes
00072 #include <SALOMEDS_SObject.hxx>
00073 
00074 
00075 #define SPACING 6
00076 #define MARGIN 0
00077 
00078 //================================================================================
00082 //================================================================================
00083 
00084 StdMeshersGUI_SubShapeSelectorWdg
00085 ::StdMeshersGUI_SubShapeSelectorWdg( QWidget * parent, TopAbs_ShapeEnum aSubShType ): 
00086   QWidget( parent ),
00087   myPreviewActor( 0 ),
00088   myMaxSize( -1 )
00089 {
00090   QPixmap image0( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) );
00091 
00092   QGridLayout* edgesLayout = new QGridLayout( this );
00093   edgesLayout->setMargin( MARGIN );
00094   edgesLayout->setSpacing( SPACING );
00095   
00096   myListWidget   = new QListWidget( this );
00097   myAddButton    = new QPushButton( tr( "SMESH_BUT_ADD" ),    this );
00098   myRemoveButton = new QPushButton( tr( "SMESH_BUT_REMOVE" ), this );      
00099   myInfoLabel    = new QLabel( this );
00100   myPrevButton   = new QPushButton( "<<", this );
00101   myNextButton   = new QPushButton( ">>", this );
00102   myListWidget->setSelectionMode( QListWidget::ExtendedSelection );
00103 
00104   edgesLayout->addWidget(myListWidget,   0, 0, 3, 3);
00105   edgesLayout->addWidget(myAddButton,    0, 3);
00106   edgesLayout->addWidget(myRemoveButton, 1, 3);
00107   edgesLayout->addWidget(myInfoLabel,    3, 0, 1, 3);
00108   edgesLayout->addWidget(myPrevButton,   4, 0);
00109   edgesLayout->addWidget(myNextButton,   4, 2);
00110 
00111   edgesLayout->setRowStretch(2, 5);
00112   edgesLayout->setColumnStretch(1, 5);
00113 
00114   myListWidget->setMinimumWidth(300);
00115   myInfoLabel->setMinimumWidth(300);
00116   myInfoLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
00117   myInfoLabel->setAlignment(Qt::AlignCenter);
00118 
00119   mySubShType = aSubShType;
00120 
00121   init();
00122 }
00123 
00124 //================================================================================
00128 //================================================================================
00129 
00130 StdMeshersGUI_SubShapeSelectorWdg::~StdMeshersGUI_SubShapeSelectorWdg()
00131 {
00132   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) {
00133     if ( myPreviewActor ) {
00134       myPreviewActor->RemoveFromRender( myRenderer );
00135       aViewWindow->Repaint();
00136 
00137       delete myPreviewActor;
00138       myPreviewActor = 0;
00139     }
00140   }
00141   myEntry = "";
00142   myParamValue = "";
00143   myMainShape.Nullify();
00144 
00145   if ( mySelectionMgr && myFilter )
00146     mySelectionMgr->removeFilter( myFilter );
00147   delete myFilter; myFilter=0;
00148 
00149   SUIT_SelectionFilter* filter;
00150   foreach( filter, myGeomFilters )
00151     delete filter;
00152 }
00153 
00154 //================================================================================
00158 //================================================================================
00159 
00160 void StdMeshersGUI_SubShapeSelectorWdg::init()
00161 {
00162   myParamValue = "";
00163   myIsNotCorrected = true; // to dont call the GetCorrectedValue method twice
00164   myListOfIDs.clear();
00165   mySelectedIDs.clear();
00166 
00167   myAddButton->setEnabled( false );
00168   myRemoveButton->setEnabled( false );
00169 
00170   mySMESHGUI     = SMESHGUI::GetSMESHGUI();
00171   mySelectionMgr = SMESH::GetSelectionMgr( mySMESHGUI );
00172   mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
00173 
00174   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00175     aViewWindow->SetSelectionMode( ActorSelection );
00176 
00177   myFilter=0;
00178   //setFilter();
00179 
00180   connect( myAddButton,    SIGNAL(clicked()), SLOT(onAdd()));
00181   connect( myRemoveButton, SIGNAL(clicked()), SLOT(onRemove()));
00182   connect( myPrevButton,   SIGNAL(clicked()), SLOT(onPrevious()));
00183   connect( myNextButton,   SIGNAL(clicked()), SLOT(onNext()));
00184   
00185   connect( mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
00186   connect( myListWidget,   SIGNAL(itemSelectionChanged()),    this, SLOT(onListSelectionChanged()));
00187 
00188   updateState();
00189 }
00190 
00191 //================================================================================
00195 //================================================================================
00196 
00197 void StdMeshersGUI_SubShapeSelectorWdg::setFilter()
00198 {
00199   SalomeApp_Study* study = mySMESHGUI->activeStudy();
00200   GEOM_TypeFilter* typeFilter = new GEOM_TypeFilter(study, mySubShType, /*isShapeType=*/true );
00201   GEOM_CompoundFilter* gpoupFilter = new GEOM_CompoundFilter(study);
00202   gpoupFilter->addSubType( mySubShType );
00203   myGeomFilters.append( typeFilter );
00204   myGeomFilters.append( gpoupFilter );
00205   myFilter = new SMESH_LogicalFilter( myGeomFilters, SMESH_LogicalFilter::LO_OR );
00206   mySelectionMgr->installFilter( myFilter );
00207 }
00208 
00209 //================================================================================
00213 //================================================================================
00214 
00215 void StdMeshersGUI_SubShapeSelectorWdg::showPreview( bool visible)
00216 {
00217   if ( !myPreviewActor )
00218     return;
00219 
00220   if ( myIsShown != visible ) {
00221     myPreviewActor->SetShown( visible );
00222     
00223     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00224       aViewWindow->Repaint();
00225 
00226     myIsShown = visible;
00227   }
00228 }
00229 
00230 //=================================================================================
00231 // function : SelectionIntoArgument()
00232 // purpose  : Called when selection as changed or other case
00233 //=================================================================================
00234 void StdMeshersGUI_SubShapeSelectorWdg::SelectionIntoArgument()
00235 {
00236   if ( !myPreviewActor )
00237     return;
00238 
00239   mySelectedIDs.clear();
00240 
00241   // get selected mesh
00242   SALOME_ListIO aList;
00243   mySelectionMgr->selectedObjects( aList );
00244   int nbSel = aList.Extent();
00245 
00246   if (nbSel > 0) {
00247     SALOME_ListIteratorOfListIO anIt (aList);
00248     
00249     for ( ; anIt.More(); anIt.Next()) { // Loop on selected objects
00250       Handle(SALOME_InteractiveObject) IO = anIt.Value();
00251       
00252       GEOM::GEOM_Object_var aGeomObj = GetGeomObjectByEntry( IO->getEntry() );  
00253       if ( !CORBA::is_nil( aGeomObj ) ) { // Selected Object From Study
00254         GEOM::GEOM_Object_ptr aGeomFatherObj = aGeomObj->GetMainShape();
00255         QString aFatherEntry = "";
00256         QString aMainFatherEntry = "";
00257         TopoDS_Shape shape;
00258         if ( !CORBA::is_nil( aGeomFatherObj ) ) {
00259           // Get Main Shape
00260           GEOM::GEOM_Object_var aGeomMain = GetGeomObjectByEntry( myEntry );
00261           if ( !CORBA::is_nil( aGeomMain ) && aGeomMain->GetType() == 37 ) {  // Main Shape is a Group
00262             GEOM::GEOM_Object_ptr aMainFatherObj = aGeomMain->GetMainShape();
00263             if ( !CORBA::is_nil( aMainFatherObj ) )
00264               aMainFatherEntry = aMainFatherObj->GetStudyEntry();
00265           }
00266           aFatherEntry = aGeomFatherObj->GetStudyEntry();
00267         }
00268         
00269         if ( aFatherEntry != "" && ( aFatherEntry == myEntry || aFatherEntry == aMainFatherEntry ) )
00270         {
00271           if ( aGeomObj->GetType() == 37 /*GEOM_GROUP*/ ) { // Selected Group that belongs the main object
00272             GEOMBase::GetShape(aGeomObj, shape); 
00273             if ( !shape.IsNull() ) {
00274               TopExp_Explorer exp( shape, mySubShType );
00275               for ( ; exp.More(); exp.Next() ) {
00276                 int index = myPreviewActor->GetIndexByShape( exp.Current() );
00277                 if ( index ) {
00278                   mySelectedIDs.append( index );
00279                   myPreviewActor->HighlightID( index );
00280                 }
00281               }
00282             }
00283           } else if ( aGeomObj->GetType() == 28 /*GEOM_SUBSHAPE*/  ) {
00284             GEOMBase::GetShape(aGeomObj, shape); 
00285             if ( !shape.IsNull() && shape.ShapeType() == mySubShType ) {
00286               int index = myPreviewActor->GetIndexByShape( shape );
00287               if ( index ) {
00288                 mySelectedIDs.append( index );
00289                 myPreviewActor->HighlightID( index );
00290               }
00291             }
00292           }
00293         }
00294       } else { // Selected Actor from Actor Collection
00295         QString anEntry = IO->getEntry();
00296         QString str = "_";
00297         int index = anEntry.lastIndexOf( str );
00298         anEntry.remove(0, index+1);
00299         int ind = anEntry.toInt();
00300         if ( ind )
00301           mySelectedIDs.append( ind );
00302       }
00303     }
00304   }
00305   // update add button
00306   myAddButton->setEnabled( ( myListWidget->count() < myMaxSize || myMaxSize == -1 ) && mySelectedIDs.size() > 0 && ( mySelectedIDs.size() <= myMaxSize || myMaxSize == -1 ) );
00307 
00308   //Connect Selected Ids in viewer and dialog's Ids list
00309   bool signalsBlocked = myListWidget->blockSignals( true );
00310   myListWidget->clearSelection();
00311   if ( mySelectedIDs.size() > 0 ) {
00312     for (int i = 0; i < mySelectedIDs.size(); i++) {
00313       QString anID = QString(" %1").arg( mySelectedIDs.at(i) );
00314       QList<QListWidgetItem*> anItems = myListWidget->findItems ( anID, Qt::MatchExactly );
00315       QListWidgetItem* item;
00316       foreach(item, anItems)
00317         item->setSelected(true);
00318     }
00319   }
00320   myListWidget->blockSignals( signalsBlocked );
00321 }
00322 
00323 //=================================================================================
00324 // function : onAdd()
00325 // purpose  : Called when Add Button Clicked
00326 //=================================================================================
00327 void StdMeshersGUI_SubShapeSelectorWdg::onAdd()
00328 {
00329   if ( mySelectedIDs.size() < 1 )
00330     return;
00331 
00332   myListWidget->blockSignals( true );
00333   for (int i = 0; i < mySelectedIDs.size() && (myMaxSize == -1 || myListOfIDs.size() < myMaxSize); i++) {
00334     if ( myListOfIDs.indexOf( mySelectedIDs.at(i) ) == -1 ) {
00335       QString anID = QString(" %1").arg( mySelectedIDs.at(i) );
00336 
00337       QListWidgetItem* anItem = new QListWidgetItem( anID, myListWidget );
00338       anItem->setSelected(true);
00339       
00340       myListOfIDs.append( mySelectedIDs.at(i) );
00341     }
00342   }
00343   onListSelectionChanged();
00344   myListWidget->blockSignals( false );
00345   myAddButton->setEnabled( myMaxSize == -1 || myListOfIDs.size() < myMaxSize );
00346 }
00347          
00348 //=================================================================================
00349 // function : onRemove()
00350 // purpose  : Called when Remove Button Clicked
00351 //=================================================================================
00352 void StdMeshersGUI_SubShapeSelectorWdg::onRemove()
00353 {
00354   if ( myListWidget->count() < 1 )
00355     return;
00356 
00357   myListWidget->blockSignals( true );
00358   QList<QListWidgetItem*> selItems = myListWidget->selectedItems();
00359   QListWidgetItem* item;
00360   foreach(item, selItems) {
00361     QString idStr = item->text();
00362     int id = idStr.toInt();
00363 
00364     int index = myListOfIDs.indexOf( id );
00365     myListOfIDs.removeAt( index );
00366     delete item;
00367   }
00368 
00369   onListSelectionChanged();
00370   myListWidget->blockSignals( false );
00371   
00372   myAddButton->setEnabled( true );
00373 }
00374 
00375 void StdMeshersGUI_SubShapeSelectorWdg::onPrevious()
00376 {
00377   if ( myPreviewActor ) {
00378     myPreviewActor->previous();
00379     myListWidget->clearSelection();
00380     updateButtons();
00381     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00382       aViewWindow->Repaint();
00383   }
00384 }
00385 
00386 void StdMeshersGUI_SubShapeSelectorWdg::onNext()
00387 {
00388   if ( myPreviewActor ) {
00389     myPreviewActor->next();
00390     myListWidget->clearSelection();
00391     updateButtons();
00392     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00393       aViewWindow->Repaint();
00394   }
00395 }
00396 
00397 //=================================================================================
00398 // function : onListSelectionChanged()
00399 // purpose  : Called when selection in element list is changed
00400 //=================================================================================
00401 void StdMeshersGUI_SubShapeSelectorWdg::onListSelectionChanged()
00402 {
00403   if ( !myPreviewActor )
00404     return;
00405 
00406   mySelectionMgr->clearSelected();
00407   TColStd_MapOfInteger aIndexes;
00408   QList<QListWidgetItem*> selItems = myListWidget->selectedItems();
00409   QListWidgetItem* anItem;
00410   foreach(anItem, selItems)
00411     myPreviewActor->HighlightID( anItem->text().toInt() );
00412 
00413   // update remove button
00414   myRemoveButton->setEnabled( selItems.size() > 0 );
00415 }
00416 
00417 //=================================================================================
00418 // function : setGeomShape
00419 // purpose  : Called to set geometry whose sub-shapes are selected
00420 //================================================================================
00421 void StdMeshersGUI_SubShapeSelectorWdg::SetGeomShapeEntry( const QString& theEntry )
00422 {
00423   if ( theEntry != "") {
00424     myParamValue = theEntry;
00425     myEntry = theEntry;
00426     myGeomShape = GetTopoDSByEntry( theEntry );
00427     updateState();
00428     myIsNotCorrected = true;
00429   }
00430 }
00431 
00432 //=================================================================================
00433 // function : updateState
00434 // purpose  : update Widget state
00435 //=================================================================================
00436 void StdMeshersGUI_SubShapeSelectorWdg::updateState()
00437 {
00438   bool state = false;
00439   if ( !myGeomShape.IsNull() )
00440     state = true;
00441   myInfoLabel->setVisible( false );
00442   myPrevButton->setVisible( false );
00443   myNextButton->setVisible( false );
00444   
00445   myListWidget->setEnabled( state );
00446   myAddButton->setEnabled( mySelectedIDs.size() > 0 );
00447   
00448   if (state) {
00449     myPreviewActor = new SMESH_PreviewActorsCollection();
00450     myPreviewActor->SetSelector( mySelector );
00451     myPreviewActor->Init( myGeomShape, mySubShType, myEntry );
00452     myPreviewActor->SetShown( false );
00453     myIsShown = false;
00454     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) {
00455       myRenderer = aViewWindow->getRenderer();
00456       myPreviewActor->AddToRender( myRenderer );
00457       aViewWindow->Repaint();
00458     }
00459     updateButtons();
00460   }
00461 }
00462 
00463 //=================================================================================
00464 // function : GetGeomObjectByEntry
00465 // purpose  : Called to get GeomObject
00466 //=================================================================================
00467 GEOM::GEOM_Object_var StdMeshersGUI_SubShapeSelectorWdg::GetGeomObjectByEntry( const QString& theEntry )
00468 {
00469   GEOM::GEOM_Object_var aGeomObj;
00470   SALOMEDS::Study_var aStudy = SMESHGUI::GetSMESHGen()->GetCurrentStudy();
00471   if (aStudy != 0) {
00472     SALOMEDS::SObject_var aSObj = aStudy->FindObjectID( theEntry.toLatin1().data() );
00473     SALOMEDS::GenericAttribute_var anAttr;
00474 
00475     if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
00476       SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
00477       CORBA::String_var aVal = anIOR->Value();
00478       CORBA::Object_var obj = aStudy->ConvertIORToObject(aVal);
00479       aGeomObj = GEOM::GEOM_Object::_narrow(obj);
00480     }
00481   }
00482   return aGeomObj;
00483 }
00484 
00485 //=================================================================================
00486 // function : setObjectByEntry
00487 // purpose  : Called to get GeomObject
00488 //=================================================================================
00489 TopoDS_Shape StdMeshersGUI_SubShapeSelectorWdg::GetTopoDSByEntry( const QString& theEntry )
00490 {
00491   TopoDS_Shape shape;
00492   GEOM::GEOM_Object_var aGeomObj = GetGeomObjectByEntry( theEntry );
00493   GEOMBase::GetShape(aGeomObj, shape);
00494   return shape;
00495 }
00496 
00497 //=================================================================================
00498 // function : GetListOfIds
00499 // purpose  : Called to get the list of SubShapes IDs
00500 //=================================================================================
00501 SMESH::long_array_var StdMeshersGUI_SubShapeSelectorWdg::GetListOfIDs()
00502 {
00503   SMESH::long_array_var anArray = new SMESH::long_array;
00504 
00505   if ( myMainEntry != "" && myIsNotCorrected )
00506     myListOfIDs = GetCorrectedListOfIDs( true );
00507 
00508   int size = myListOfIDs.size();
00509   anArray->length( size );
00510   if ( size ) {
00511     for (int i = 0; i < size; i++) {
00512         anArray[i] = myListOfIDs.at(i);
00513     }
00514   }
00515   return anArray;
00516 }
00517 
00518 //=================================================================================
00519 // function : SetListOfIds
00520 // purpose  : Called to set the list of SubShapes IDs
00521 //=================================================================================
00522 void StdMeshersGUI_SubShapeSelectorWdg::SetListOfIDs( SMESH::long_array_var theIds)
00523 {
00524   mySelectedIDs.clear();
00525   myListOfIDs.clear();
00526   int size = theIds->length();
00527   for ( int i = 0; i < size; i++ )
00528     mySelectedIDs.append( theIds[ i ] );
00529 
00530   mySelectedIDs = GetCorrectedListOfIDs( false );
00531   onAdd();
00532 }
00533 
00534 //=================================================================================
00535 // function : SetMainShapeEntry
00536 // purpose  : Called to set the Entry of main shape of the mesh
00537 //=================================================================================
00538 void StdMeshersGUI_SubShapeSelectorWdg::SetMainShapeEntry( const QString& theEntry )
00539 {
00540   myMainEntry = theEntry;
00541   myMainShape = GetTopoDSByEntry( theEntry );
00542   myIsNotCorrected = true;
00543 }
00544 
00545 //=================================================================================
00546 // function : GetMainShapeEntry
00547 // purpose  : Called to get the Main Object Entry
00548 //=================================================================================
00549 const char* StdMeshersGUI_SubShapeSelectorWdg::GetMainShapeEntry()
00550 {
00551   if ( myMainEntry == "")
00552     return myEntry.toLatin1().data();
00553 
00554   return myMainEntry.toLatin1().data();
00555 }
00556 
00557 //=================================================================================
00558 // function : GetCorrectedListOfIds
00559 // purpose  : Called to convert the list of IDs from sub-shape IDs to main shape IDs
00560 //=================================================================================
00561 QList<int> StdMeshersGUI_SubShapeSelectorWdg::GetCorrectedListOfIDs( bool fromSubshapeToMainshape )
00562 {
00563   if ( ( myMainShape.IsNull() || myGeomShape.IsNull() ) &&  fromSubshapeToMainshape )
00564     return myListOfIDs;
00565   else   if ( ( myMainShape.IsNull() || myGeomShape.IsNull() ) &&  !fromSubshapeToMainshape )
00566     return mySelectedIDs;
00567 
00568   QList<int> aList;
00569   TopTools_IndexedMapOfShape   aGeomMap;
00570   TopTools_IndexedMapOfShape   aMainMap;
00571   TopExp::MapShapes(myGeomShape, aGeomMap);
00572   TopExp::MapShapes(myMainShape, aMainMap);
00573 
00574   if ( fromSubshapeToMainshape ) { // convert indexes from sub-shape to mainshape
00575     int size = myListOfIDs.size();
00576     for (int i = 0; i < size; i++) {
00577       TopoDS_Shape aSubShape = aGeomMap.FindKey( myListOfIDs.at(i) );
00578       int index = aMainMap.FindIndex( aSubShape );
00579       aList.append( index );
00580     }
00581     myIsNotCorrected = false;
00582   } else { // convert indexes from main shape to sub-shape
00583     int size = mySelectedIDs.size();
00584     for (int i = 0; i < size; i++) {
00585       TopoDS_Shape aSubShape = aMainMap.FindKey( mySelectedIDs.at(i) );
00586       int index = aGeomMap.FindIndex( aSubShape );
00587       aList.append( index );
00588     }
00589   }
00590 
00591   return aList;
00592 }
00593 
00594 void StdMeshersGUI_SubShapeSelectorWdg::updateButtons()
00595 {
00596   if ( myPreviewActor ) {
00597     int total = myPreviewActor->count();
00598     int chunk = myPreviewActor->currentChunk();
00599     int chunkSize = myPreviewActor->chunkSize();
00600     int imin = chunk*chunkSize+1;
00601     int imax = std::min((chunk+1)*chunkSize, total);
00602     bool vis = imax > 0 && total > chunkSize;
00603     myInfoLabel->setVisible( vis );
00604     myPrevButton->setVisible( vis );
00605     myNextButton->setVisible( vis );
00606     myInfoLabel->setText( tr( "X_FROM_Y_ITEMS_SHOWN" ).arg(imin).arg(imax).arg(total) );
00607     myPrevButton->setEnabled( myPreviewActor->hasPrevious() );
00608     myNextButton->setEnabled( myPreviewActor->hasNext() );
00609   }
00610 }