+//=================================================================================
+// function : SetMainShapeEntry
+// purpose : Called to set the Entry of main shape of the mesh
+//=================================================================================
+void StdMeshersGUI_SubShapeSelectorWdg::SetMainShapeEntry( const QString& theEntry )
+{
+ myMainEntry = theEntry;
+ myMainShape = GetTopoDSByEntry( theEntry );
+ myIsNotCorrected = true;
+}
+
+//=================================================================================
+// function : GetMainShapeEntry
+// purpose : Called to get the Main Object Entry
+//=================================================================================
+const char* StdMeshersGUI_SubShapeSelectorWdg::GetMainShapeEntry()
+{
+ if ( myMainEntry == "")
+ return myEntry.toLatin1().data();
+
+ return myMainEntry.toLatin1().data();
+}
+
+//=================================================================================
+// function : GetCorrectedListOfIds
+// purpose : Called to convert the list of IDs from sub-shape IDs to main shape IDs
+//=================================================================================
+QList<int> StdMeshersGUI_SubShapeSelectorWdg::GetCorrectedListOfIDs( bool fromSubshapeToMainshape )
+{
+ if ( ( myMainShape.IsNull() || myGeomShape.IsNull() ) && fromSubshapeToMainshape )
+ return myListOfIDs;
+ else if ( ( myMainShape.IsNull() || myGeomShape.IsNull() ) && !fromSubshapeToMainshape )
+ return mySelectedIDs;
+
+ QList<int> aList;
+ TopTools_IndexedMapOfShape aGeomMap;
+ TopTools_IndexedMapOfShape aMainMap;
+ TopExp::MapShapes(myGeomShape, aGeomMap);
+ TopExp::MapShapes(myMainShape, aMainMap);
+
+ if ( fromSubshapeToMainshape ) { // convert indexes from sub-shape to mainshape
+ int size = myListOfIDs.size();
+ for (int i = 0; i < size; i++) {
+ TopoDS_Shape aSubShape = aGeomMap.FindKey( myListOfIDs.at(i) );
+ int index = aMainMap.FindIndex( aSubShape );
+ aList.append( index );
+ }
+ myIsNotCorrected = false;
+ } else { // convert indexes from main shape to sub-shape
+ int size = mySelectedIDs.size();
+ for (int i = 0; i < size; i++) {
+ TopoDS_Shape aSubShape = aMainMap.FindKey( mySelectedIDs.at(i) );
+ int index = aGeomMap.FindIndex( aSubShape );
+ aList.append( index );
+ }
+ }
+
+ return aList;
+}
+
+void StdMeshersGUI_SubShapeSelectorWdg::updateButtons()
+{
+ if ( myPreviewActor ) {
+ int total = myPreviewActor->count();
+ int chunk = myPreviewActor->currentChunk();
+ int chunkSize = myPreviewActor->chunkSize();
+ int imin = chunk*chunkSize+1;
+ int imax = std::min((chunk+1)*chunkSize, total);
+ bool vis = imax > 0 && total > chunkSize;
+ myInfoLabel->setVisible( vis );
+ myPrevButton->setVisible( vis );
+ myNextButton->setVisible( vis );
+ myInfoLabel->setText( tr( "X_FROM_Y_ITEMS_SHOWN" ).arg(imin).arg(imax).arg(total) );
+ myPrevButton->setEnabled( myPreviewActor->hasPrevious() );
+ myNextButton->setEnabled( myPreviewActor->hasNext() );
+ }
+}