mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-28 05:50:34 +05:00
Selection synchronization between OCC viewer and TreeWidget.
This commit is contained in:
parent
8fca8ce02e
commit
765d34906e
@ -76,6 +76,7 @@ SET(GEOMGUI_HEADERS
|
||||
GEOM_GEOMGUI.hxx
|
||||
GEOMGUI_CreationInfoWdg.h
|
||||
GEOMGUI_TextTreeWdg.h
|
||||
GEOMGUI_TextTreeSelector.h
|
||||
GEOMGUI_DimensionProperty.h
|
||||
GEOMGUI_AnnotationAttrs.h
|
||||
)
|
||||
@ -85,6 +86,7 @@ SET(_moc_HEADERS
|
||||
GEOMGUI_AnnotationMgr.h
|
||||
GEOMGUI_CreationInfoWdg.h
|
||||
GEOMGUI_TextTreeWdg.h
|
||||
GEOMGUI_TextTreeSelector.h
|
||||
GeometryGUI.h
|
||||
)
|
||||
|
||||
@ -119,6 +121,7 @@ SET(GEOMGUI_SOURCES
|
||||
GEOMGUI_Selection.cxx
|
||||
GEOMGUI_CreationInfoWdg.cxx
|
||||
GEOMGUI_TextTreeWdg.cxx
|
||||
GEOMGUI_TextTreeSelector.cxx
|
||||
GEOMGUI_DimensionProperty.cxx
|
||||
GEOMGUI_AnnotationAttrs.cxx
|
||||
${_moc_SOURCES}
|
||||
|
@ -43,6 +43,7 @@
|
||||
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
||||
|
||||
#include <QFont>
|
||||
#include <QColor>
|
||||
@ -53,10 +54,22 @@ GEOMGUI_AnnotationMgr::GEOMGUI_AnnotationMgr( SalomeApp_Application* theApplicat
|
||||
{
|
||||
}
|
||||
|
||||
QString GEOMGUI_AnnotationMgr::GetEntrySeparator()
|
||||
{
|
||||
return "_annotation:";
|
||||
}
|
||||
|
||||
SALOME_Prs* GEOMGUI_AnnotationMgr::CreatePresentation( const GEOMGUI_AnnotationAttrs::Properties& theProperty,
|
||||
GEOM::GEOM_Object_ptr theObject )
|
||||
GEOM::GEOM_Object_ptr theObject,
|
||||
const QString& theEntry )
|
||||
{
|
||||
Handle ( GEOM_Annotation ) aPresentation = new GEOM_Annotation();
|
||||
if ( !theEntry.isEmpty() ) {
|
||||
// owner should be set to provide selection mechanizm
|
||||
Handle( SALOME_InteractiveObject ) anIO = new SALOME_InteractiveObject();
|
||||
anIO->setEntry( theEntry.toLatin1().constData() );
|
||||
aPresentation->SetOwner( anIO );
|
||||
}
|
||||
|
||||
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
|
||||
const QFont aFont = aResMgr->fontValue( "Geometry", "shape_annotation_font", QFont( "Y14.5M-2009", 24 ) );
|
||||
@ -133,7 +146,8 @@ void GEOMGUI_AnnotationMgr::Display( const QString& theEntry, const int theIndex
|
||||
getObject( theEntry, theIndex, anObject, aProperty );
|
||||
|
||||
// display presentation in the viewer
|
||||
SALOME_Prs* aPrs = CreatePresentation( aProperty, anObject );
|
||||
QString anEntry = QString("%1%2%3").arg(theEntry).arg(GetEntrySeparator()).arg(theIndex);
|
||||
SALOME_Prs* aPrs = CreatePresentation( aProperty, anObject, anEntry );
|
||||
aView->Display( getDisplayer(), aPrs );
|
||||
getDisplayer()->UpdateViewer();
|
||||
|
||||
@ -236,6 +250,81 @@ void GEOMGUI_AnnotationMgr::EraseVisibleAnnotations( const QString& theEntry, SA
|
||||
myVisualized[aView] = anEntryToAnnotation;
|
||||
}
|
||||
|
||||
Handle(SALOME_InteractiveObject) GEOMGUI_AnnotationMgr::FindInteractiveObject( const QString& theEntry,
|
||||
const int theIndex,
|
||||
SALOME_View* theView ) const
|
||||
{
|
||||
Handle(SALOME_InteractiveObject) anIO;
|
||||
|
||||
SALOME_View* aView = viewOrActiveView( theView );
|
||||
if ( !myVisualized.contains( aView ) )
|
||||
return anIO;
|
||||
|
||||
EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
|
||||
if ( !anEntryToAnnotation.contains( theEntry ) )
|
||||
return anIO;
|
||||
|
||||
AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[theEntry];
|
||||
if ( !anAnnotationToPrs.contains(theIndex) )
|
||||
return anIO;
|
||||
|
||||
SALOME_Prs* aPrs = anAnnotationToPrs[theIndex];
|
||||
SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
|
||||
if ( !anOCCPrs )
|
||||
return anIO;
|
||||
|
||||
AIS_ListOfInteractive anIOs;
|
||||
anOCCPrs->GetObjects( anIOs );
|
||||
AIS_ListIteratorOfListOfInteractive anIter( anIOs );
|
||||
for ( ; anIter.More() && anIO.IsNull(); anIter.Next() ) {
|
||||
Handle(AIS_InteractiveObject) aPrs = anIter.Value();
|
||||
if ( aPrs->GetOwner() )
|
||||
anIO = Handle(SALOME_InteractiveObject)::DownCast(aPrs->GetOwner());
|
||||
}
|
||||
return anIO;
|
||||
}
|
||||
|
||||
int GEOMGUI_AnnotationMgr::FindAnnotationIndex( Handle(SALOME_InteractiveObject) theIO,
|
||||
SALOME_View* theView )
|
||||
{
|
||||
int anIndex = -1;
|
||||
|
||||
SALOME_View* aView = viewOrActiveView( theView );
|
||||
if ( !myVisualized.contains( aView ) )
|
||||
return anIndex;
|
||||
|
||||
QString anEntry = theIO->getEntry();
|
||||
|
||||
EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
|
||||
if ( !anEntryToAnnotation.contains( anEntry ) )
|
||||
return anIndex;
|
||||
|
||||
AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[anEntry];
|
||||
//typedef QMap<int, SALOME_Prs*> AnnotationToPrs;
|
||||
AnnotationToPrs::const_iterator anIt = anAnnotationToPrs.begin(),
|
||||
aLast = anAnnotationToPrs.end();
|
||||
for (; anIt != aLast && anIndex < 0; anIt++) {
|
||||
SALOME_Prs* aPrs = anIt.value();
|
||||
SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
|
||||
if ( !anOCCPrs )
|
||||
continue;
|
||||
|
||||
AIS_ListOfInteractive anIOs;
|
||||
anOCCPrs->GetObjects( anIOs );
|
||||
AIS_ListIteratorOfListOfInteractive anIter( anIOs );
|
||||
for ( ; anIter.More() && anIndex < 0; anIter.Next() ) {
|
||||
Handle(AIS_InteractiveObject) aPrs = anIter.Value();
|
||||
if ( aPrs->GetOwner() ) {
|
||||
Handle(SALOME_InteractiveObject) aPrsOwner = Handle(SALOME_InteractiveObject)::DownCast(aPrs->GetOwner());
|
||||
if ( aPrsOwner == theIO )
|
||||
anIndex = anIt.key();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return anIndex;
|
||||
}
|
||||
|
||||
void GEOMGUI_AnnotationMgr::RemoveView( SALOME_View* theView )
|
||||
{
|
||||
if ( !theView && myVisualized.contains( theView ) )
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <GEOMGUI_AnnotationAttrs.h>
|
||||
|
||||
#include <SALOME_Prs.h>
|
||||
#include <SALOME_InteractiveObject.hxx>
|
||||
|
||||
class SalomeApp_Application;
|
||||
class GEOM_Displayer;
|
||||
@ -47,8 +48,10 @@ public:
|
||||
GEOMGUI_AnnotationMgr( SalomeApp_Application* theApplication );
|
||||
~GEOMGUI_AnnotationMgr() {}
|
||||
|
||||
static QString GetEntrySeparator();
|
||||
|
||||
SALOME_Prs* CreatePresentation( const GEOMGUI_AnnotationAttrs::Properties& theProperty,
|
||||
GEOM::GEOM_Object_ptr theObject );
|
||||
GEOM::GEOM_Object_ptr theObject, const QString& theEntry = QString() );
|
||||
|
||||
bool IsDisplayed( const QString& theEntry, const int theIndex, SALOME_View* theView = 0 ) const;
|
||||
void Display( const QString& theEntry, const int theIndex, SALOME_View* theView = 0 );
|
||||
@ -59,6 +62,12 @@ public:
|
||||
|
||||
void RemoveView( SALOME_View* theView);
|
||||
|
||||
int FindAnnotationIndex( Handle(SALOME_InteractiveObject) theIO,
|
||||
SALOME_View* theView = 0 );
|
||||
|
||||
Handle(SALOME_InteractiveObject) FindInteractiveObject( const QString& theEntry, const int theIndex,
|
||||
SALOME_View* theView = 0 ) const;
|
||||
|
||||
QString getDisplayedIndicesInfo( const QString& theEntry, SALOME_View* theView ) const;
|
||||
|
||||
void setDisplayedIndicesInfo( const QString& theEntry, SALOME_View* theView, const QString theIndicesInfo );
|
||||
|
218
src/GEOMGUI/GEOMGUI_TextTreeSelector.cxx
Normal file
218
src/GEOMGUI/GEOMGUI_TextTreeSelector.cxx
Normal file
@ -0,0 +1,218 @@
|
||||
// Copyright (C) 2015-2016 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// 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, or (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// File : GEOMGUI_TextTreeSelector.cxx
|
||||
// Author :
|
||||
//
|
||||
#include "GEOMGUI_TextTreeSelector.h"
|
||||
#include "GEOMGUI_TextTreeWdg.h"
|
||||
#include "GEOMGUI_AnnotationMgr.h"
|
||||
|
||||
#include "LightApp_DataOwner.h"
|
||||
#include "LightApp_DataObject.h"
|
||||
#include "LightApp_Application.h"
|
||||
#include <SUIT_Session.h>
|
||||
#include <SUIT_DataObjectIterator.h>
|
||||
|
||||
/*!
|
||||
\class GEOMGUI_TextTreeSelector
|
||||
\brief Text tree selection handler class.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\brief Constructor.
|
||||
\param widget text tree widget
|
||||
\param theManager selection manager
|
||||
*/
|
||||
GEOMGUI_TextTreeSelector::GEOMGUI_TextTreeSelector( GEOMGUI_TextTreeWdg* theWidget,
|
||||
GEOMGUI_AnnotationMgr* theAnnotationMgr,
|
||||
SUIT_SelectionMgr* theManager )
|
||||
: SUIT_Selector( theManager, theWidget ),
|
||||
myTextTree( theWidget ), myAnnotationMgr( theAnnotationMgr )
|
||||
{
|
||||
if ( myTextTree ) {
|
||||
connect( myTextTree, SIGNAL( itemSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Destructor.
|
||||
*/
|
||||
GEOMGUI_TextTreeSelector::~GEOMGUI_TextTreeSelector()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Get object browser.
|
||||
\return a pointer to the object browser
|
||||
*/
|
||||
GEOMGUI_TextTreeWdg* GEOMGUI_TextTreeSelector::textTree() const
|
||||
{
|
||||
return myTextTree;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Get selector type.
|
||||
\return selector type
|
||||
*/
|
||||
QString GEOMGUI_TextTreeSelector::type() const
|
||||
{
|
||||
return "TextTree";
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Called when the Object browser selection is changed.
|
||||
*/
|
||||
void GEOMGUI_TextTreeSelector::onSelectionChanged()
|
||||
{
|
||||
//QTime t1 = QTime::currentTime();
|
||||
mySelectedList.clear();
|
||||
selectionChanged();
|
||||
//QTime t2 = QTime::currentTime();
|
||||
//qDebug( QString( "selection time = %1 msecs" ).arg( t1.msecsTo( t2 ) ).toLatin1().constData() );
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Get list of currently selected objects.
|
||||
\param theList list to be filled with the selected objects owners
|
||||
*/
|
||||
void GEOMGUI_TextTreeSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const
|
||||
{
|
||||
if ( mySelectedList.count() == 0 ) {
|
||||
|
||||
GEOMGUI_TextTreeSelector* aThisSelector = (GEOMGUI_TextTreeSelector*)this;
|
||||
QMap<QString, QList<int> > aSelectedAnnotations;
|
||||
myTextTree->getSelected(aSelectedAnnotations);
|
||||
|
||||
QMap<QString, QList<int> >::const_iterator anIt = aSelectedAnnotations.begin(),
|
||||
aLast = aSelectedAnnotations.end();
|
||||
for ( ; anIt != aLast; anIt++ ) {
|
||||
QString anEntry = anIt.key();
|
||||
QList<int> anIndices = anIt.value();
|
||||
QList<int>::const_iterator anIdIt = anIndices.begin(), anIdLast = anIndices.end();
|
||||
for ( ; anIdIt != anIdLast; anIdIt++ ) {
|
||||
int anIndex = *anIdIt;
|
||||
Handle(SALOME_InteractiveObject) anIO = myAnnotationMgr->FindInteractiveObject( anEntry, anIndex );
|
||||
if ( anIO.IsNull() )
|
||||
continue;
|
||||
|
||||
LightApp_DataOwner* owner = new LightApp_DataOwner( anIO );
|
||||
aThisSelector->mySelectedList.append( SUIT_DataOwnerPtr( owner ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
theList = mySelectedList;
|
||||
|
||||
/*if ( aSelectedAnnotations.count() == 0 ) {
|
||||
SUIT_Session* session = SUIT_Session::session();
|
||||
SUIT_Application* sapp = session ? session->activeApplication() : 0;
|
||||
LightApp_Application* app = dynamic_cast<LightApp_Application*>( sapp );
|
||||
if( !app || !myBrowser )
|
||||
return;
|
||||
|
||||
DataObjectList objlist;
|
||||
myBrowser->getSelected( objlist );
|
||||
GEOMGUI_TextTreeSelector* that = (GEOMGUI_TextTreeSelector*)this;
|
||||
QListIterator<SUIT_DataObject*> it( objlist );
|
||||
while ( it.hasNext() ) {
|
||||
LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>( it.next() );
|
||||
if ( obj && app->checkDataObject( obj) ) {
|
||||
#ifndef DISABLE_SALOMEOBJECT
|
||||
Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
|
||||
( obj->entry().toLatin1().constData(),
|
||||
obj->componentDataType().toLatin1().constData(),
|
||||
obj->name().toLatin1().constData() );
|
||||
LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
|
||||
#else
|
||||
LightApp_DataOwner* owner = new LightApp_DataOwner( obj->entry() );
|
||||
#endif
|
||||
that->mySelectedList.append( SUIT_DataOwnerPtr( owner ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
theList = mySelectedList;*/
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Set selection.
|
||||
\param theList list of the object owners to be set selected
|
||||
*/
|
||||
void GEOMGUI_TextTreeSelector::setSelection( const SUIT_DataOwnerPtrList& theList )
|
||||
{
|
||||
if ( !myTextTree )
|
||||
return;
|
||||
|
||||
//if( myEntries.count() == 0 || myModifiedTime < myBrowser->getModifiedTime() )
|
||||
// fillEntries( myEntries );
|
||||
|
||||
QMap<QString, QList<int> > aSelectedAnnotations;
|
||||
DataObjectList objList;
|
||||
for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin();
|
||||
it != theList.end(); ++it ) {
|
||||
const LightApp_DataOwner* anOwner = dynamic_cast<const LightApp_DataOwner*>( (*it).operator->() );
|
||||
if ( !anOwner )
|
||||
continue;
|
||||
Handle(SALOME_InteractiveObject) anIO = anOwner->IO();
|
||||
if ( anIO.IsNull() )
|
||||
continue;
|
||||
|
||||
QString anIOEntry = anIO->getEntry();
|
||||
QStringList anAnnotationInfo = anIOEntry.split(GEOMGUI_AnnotationMgr::GetEntrySeparator());
|
||||
if (anAnnotationInfo.size() != 2 )
|
||||
continue;
|
||||
|
||||
QString anEntry = anAnnotationInfo[0];
|
||||
int anAnnotationId = anAnnotationInfo[1].toInt();//myAnnotationMgr->FindAnnotationIndex( anIO );
|
||||
if ( anAnnotationId < 0)
|
||||
continue;
|
||||
|
||||
QList<int> anIndices;
|
||||
if ( aSelectedAnnotations.contains( anEntry ) )
|
||||
anIndices = aSelectedAnnotations[anEntry];
|
||||
|
||||
if ( !anIndices.contains( anAnnotationId ) )
|
||||
anIndices.append( anAnnotationId );
|
||||
|
||||
aSelectedAnnotations[anEntry] = anIndices;
|
||||
}
|
||||
myTextTree->setSelected(aSelectedAnnotations);
|
||||
mySelectedList.clear();
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Fill map of the data objects currently shown in the Object Browser.
|
||||
\param entries map to be filled
|
||||
*/
|
||||
/*void GEOMGUI_TextTreeSelector::fillEntries( QMap<QString, LightApp_DataObject*>& entries )
|
||||
{
|
||||
entries.clear();
|
||||
|
||||
if ( !myBrowser )
|
||||
return;
|
||||
|
||||
for ( SUIT_DataObjectIterator it( myBrowser->root(),
|
||||
SUIT_DataObjectIterator::DepthLeft ); it.current(); ++it ) {
|
||||
LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>( it.current() );
|
||||
if ( obj )
|
||||
entries.insert( obj->entry(), obj );
|
||||
}
|
||||
|
||||
setModified();
|
||||
}*/
|
||||
|
67
src/GEOMGUI/GEOMGUI_TextTreeSelector.h
Normal file
67
src/GEOMGUI/GEOMGUI_TextTreeSelector.h
Normal file
@ -0,0 +1,67 @@
|
||||
// Copyright (C) 2015-2016 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// 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, or (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// File : GEOMGUI_TextTreeSelector.h
|
||||
// Author :
|
||||
//
|
||||
#ifndef GEOMGUI_TEXTTREESELECTOR_H
|
||||
#define GEOMGUI_TEXTTREESELECTOR_H
|
||||
|
||||
#include "GEOM_GEOMGUI.hxx"
|
||||
|
||||
#include <SUIT_Selector.h>
|
||||
#include <SUIT_DataOwner.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class GEOMGUI_TextTreeWdg;
|
||||
class GEOMGUI_AnnotationMgr;
|
||||
//class LightApp_DataObject;
|
||||
|
||||
class GEOMGUI_EXPORT GEOMGUI_TextTreeSelector : public QObject, public SUIT_Selector
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GEOMGUI_TextTreeSelector( GEOMGUI_TextTreeWdg* theWidget,
|
||||
GEOMGUI_AnnotationMgr* theAnnotationMgr,
|
||||
SUIT_SelectionMgr* theManager );
|
||||
virtual ~GEOMGUI_TextTreeSelector();
|
||||
|
||||
GEOMGUI_TextTreeWdg* textTree() const;
|
||||
|
||||
virtual QString type() const;
|
||||
|
||||
private slots:
|
||||
void onSelectionChanged();
|
||||
|
||||
protected:
|
||||
virtual void getSelection( SUIT_DataOwnerPtrList& ) const;
|
||||
virtual void setSelection( const SUIT_DataOwnerPtrList& );
|
||||
|
||||
//private:
|
||||
//void fillEntries( QMap<QString, LightApp_DataObject*>& );
|
||||
|
||||
private:
|
||||
GEOMGUI_TextTreeWdg* myTextTree;
|
||||
GEOMGUI_AnnotationMgr* myAnnotationMgr;
|
||||
SUIT_DataOwnerPtrList mySelectedList;
|
||||
};
|
||||
|
||||
#endif
|
@ -626,21 +626,86 @@ void GEOMGUI_TextTreeWdg::updateVisibility( SALOME_View* theView )
|
||||
|
||||
QList<QString> anAnnotationObjEntries = getObjects( aBranchType ).keys();
|
||||
|
||||
QTreeWidgetItem* anItem;
|
||||
QTreeWidgetItem* anEntryItem;
|
||||
foreach ( QString anEntry, getObjects( aBranchType ).keys() )
|
||||
{
|
||||
anItem = itemFromEntry( aBranchType, anEntry );
|
||||
anEntryItem = itemFromEntry( aBranchType, anEntry );
|
||||
|
||||
int aDimIndex = idFromItem( anItem );
|
||||
QSharedPointer<VisualProperty> aProp = getVisualProperty( aBranchType, myStudy,
|
||||
anEntry.toStdString() );
|
||||
bool isItemVisible = aProp->GetIsVisible( aDimIndex );
|
||||
anItem->setIcon( 1, isItemVisible ? myVisibleIcon : myInvisibleIcon );
|
||||
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 : setShapeItemVisibility
|
||||
// purpose :
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include "GEOM_Displayer.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QMap>
|
||||
#include <QList>
|
||||
#include <QSharedPointer>
|
||||
#include <QTreeWidget>
|
||||
|
||||
@ -68,6 +70,9 @@ public:
|
||||
const bool theVisibility );
|
||||
void updateVisibility( SALOME_View* theView );
|
||||
|
||||
void getSelected( QMap<QString, QList<int> >& theAnnotations );
|
||||
void setSelected( const QMap<QString, QList<int> >& theAnnotations );
|
||||
|
||||
protected:
|
||||
void createActions();
|
||||
void redisplay( QString theEntry );
|
||||
|
@ -697,13 +697,15 @@ void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO,
|
||||
Erase( theIO, true, false, theViewFrame );
|
||||
Display( theIO, theUpdateViewer, theViewFrame );
|
||||
myIsRedisplayed = aRedisplayed;
|
||||
if ( !theViewFrame->isVisible( theIO ) ) {
|
||||
// hide annotations for erased presentation
|
||||
SUIT_Session* session = SUIT_Session::session();
|
||||
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
|
||||
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( anApp->activeModule() );
|
||||
if ( aModule )
|
||||
// hide annotations for erased presentation
|
||||
SUIT_Session* session = SUIT_Session::session();
|
||||
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
|
||||
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( anApp->activeModule() );
|
||||
if ( aModule ) {
|
||||
if ( !theViewFrame->isVisible( theIO ) )
|
||||
aModule->GetAnnotationMgr()->EraseVisibleAnnotations(QString(theIO->getEntry()), theViewFrame);
|
||||
else
|
||||
aModule->GetAnnotationMgr()->DisplayVisibleAnnotations(QString(theIO->getEntry()), theViewFrame);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "GEOM_AISShape.hxx"
|
||||
#include "GEOMUtils_XmlHandler.hxx"
|
||||
#include "GEOMGUI_AnnotationMgr.h"
|
||||
#include "GEOMGUI_TextTreeSelector.h"
|
||||
|
||||
#include "GEOM_Actor.h"
|
||||
|
||||
@ -1847,8 +1848,10 @@ bool GeometryGUI::activateModule( SUIT_Study* study )
|
||||
getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg );
|
||||
getApp()->placeDockWindow( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
|
||||
|
||||
if ( !myTextTreeWdg )
|
||||
if ( !myTextTreeWdg ) {
|
||||
myTextTreeWdg = new GEOMGUI_TextTreeWdg( getApp() );
|
||||
new GEOMGUI_TextTreeSelector( myTextTreeWdg, GetAnnotationMgr(), getApp()->selectionMgr() );
|
||||
}
|
||||
|
||||
getApp()->insertDockWindow( myTextTreeWdg->getWinID(), myTextTreeWdg );
|
||||
getApp()->placeDockWindow( myTextTreeWdg->getWinID(), Qt::LeftDockWidgetArea );
|
||||
|
Loading…
Reference in New Issue
Block a user