+ if ( setShapeItemVisibility( aProp, theWidgetItem, theVisibility ) ) {
+ aProp->Save();
+ redisplay( theEntry );
+ }
+}
+
+//=================================================================================
+// function : setShapeItemVisibility
+// purpose :
+//=================================================================================
+void GEOMGUI_TextTreeWdg::updateVisibility()
+{
+ //QList<QString> aDimensionObjEntries = getObjects( DimensionShape ).keys();
+ BranchType aBranchType = AnnotationShape;
+
+ QList<QString> anAnnotationObjEntries = getObjects( aBranchType ).keys();
+
+ QTreeWidgetItem* anEntryItem;
+ foreach ( QString anEntry, getObjects( aBranchType ).keys() )
+ {
+ anEntryItem = itemFromEntry( aBranchType, anEntry );
+
+ QTreeWidgetItem* anItem;
+ for ( int i = 0; i < anEntryItem->childCount(); i++ ) {
+ anItem = anEntryItem->child( i );
+ int aDimIndex = idFromItem( anItem );
+ QSharedPointer<VisualProperty> aProp = getVisualProperty( aBranchType, myStudy,
+ anEntry.toStdString() );
+ bool isItemVisible = aProp->GetIsVisible( aDimIndex );
+ anItem->setIcon( 1, isItemVisible ? myVisibleIcon : myInvisibleIcon );
+ }
+
+ redisplay( anEntry );
+ }
+}
+
+//=================================================================================
+// function : getSelected
+// purpose :
+//=================================================================================
+void GEOMGUI_TextTreeWdg::getSelected( QMap<QString, QList<int> >& theAnnotations )
+{
+ theAnnotations.clear();
+
+ QItemSelectionModel* aSelectionModel = selectionModel();
+ QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
+
+ for (int i = 0, aNbItems = aSelectedIndices.size(); i < aNbItems; i++) {
+ QTreeWidgetItem* anItem = itemFromIndex( aSelectedIndices[i] );
+ if ( !anItem )
+ continue;
+ QString anEntry = entryFromItem( anItem->parent() );
+ int aDimIndex = idFromItem( anItem );
+ if ( aDimIndex < 0 )
+ continue;
+
+ if ( theAnnotations.contains( anEntry ) )
+ theAnnotations[anEntry].append( aDimIndex );
+ else {
+ QList<int> anIndices;
+ anIndices.append( aDimIndex );
+ theAnnotations[anEntry] = anIndices;
+ }
+ }
+}
+
+//=================================================================================
+// function : setSelected
+// purpose :
+//=================================================================================
+void GEOMGUI_TextTreeWdg::setSelected( const QMap<QString, QList<int> >& theAnnotations )
+{
+ QItemSelectionModel* aSelectionModel = selectionModel();
+ aSelectionModel->clearSelection();
+
+ QMap<QString, QList<int> >::const_iterator anIt = theAnnotations.begin(),
+ aLast = theAnnotations.end();
+ BranchType aBranchType = AnnotationShape;
+ for ( ; anIt != aLast; anIt++ ) {
+ QString anEntry = anIt.key();
+ QTreeWidgetItem* anEntryItem = itemFromEntry( aBranchType, anEntry );
+ if ( !anEntryItem )
+ continue;
+
+ QList<int> anAnnotationIds = anIt.value();
+ QTreeWidgetItem* anItem;
+ for ( int i = 0; i < anEntryItem->childCount(); i++ ) {
+ anItem = anEntryItem->child( i );
+ int aDimIndex = idFromItem( anItem );
+ if ( anAnnotationIds.contains( aDimIndex ) ) {
+ QModelIndex anIndex = indexFromItem( anItem );
+ aSelectionModel->select( anIndex, QItemSelectionModel::Select );
+ }
+ }
+ }
+}
+
+//=================================================================================
+// function : getAllEntries
+// purpose :
+//=================================================================================
+QList<QString> GEOMGUI_TextTreeWdg::getAllEntries( const BranchType& theBranchType )
+{
+ return getObjects( theBranchType ).keys();
+}
+
+//=================================================================================
+// function : getSingleSelectedObject
+// purpose :
+//=================================================================================
+QString GEOMGUI_TextTreeWdg::getSingleSelectedObject()
+{
+ QString anEntry;
+ QTreeWidgetItem* anItem = currentItem();
+ if (anItem) {
+ QHash<QString, QTreeWidgetItem*> anObjects = getObjects( AnnotationShape );
+ QHash<QString, QTreeWidgetItem*>::const_iterator anIt = anObjects.begin(),
+ aLast = anObjects.end();
+ for (; anIt != aLast; anIt++) {
+ if ( anIt.value() == anItem ) {
+ anEntry = anIt.key();
+ break;
+ }
+ }
+ }
+ return anEntry;
+}
+
+//=================================================================================
+// function : setShapeItemVisibility
+// purpose :
+//=================================================================================
+bool GEOMGUI_TextTreeWdg::setShapeItemVisibility( QSharedPointer<VisualProperty>& theProps,
+ QTreeWidgetItem* theWidgetItem,
+ const bool theVisibility )
+{
+ int aDimIndex = idFromItem( theWidgetItem );
+ if ( theProps->GetNumber() == 0
+ || theProps->GetIsVisible( aDimIndex ) == theVisibility ) {
+ return false;
+ }
+ theProps->SetIsVisible( aDimIndex, theVisibility );
+
+ theWidgetItem->setIcon( 1, theVisibility ? myVisibleIcon : myInvisibleIcon );
+
+ return true;