1) The names of the annotations and geometrical objects are not updated in the "Dimensions/Annotations" data tree:
- Create any primitive, box for example.
- Create annotation with text 'My initial annotation'
- Call edit annotation dialog box and set text of the annotation to 'My updated annotation'
= > As a result text is updated in the viewer, but not in the "Dimensions/Annotations" data tree.
- Rename box
= > As a result name is updated in the SALOME Object Browser, but not in the "Dimensions/Annotations" data tree.
2) Popup menu in the "Dimensions/Annotations" data tree: "Show all annotations" / "Hide all annotation" menu items appear / work incorrect:
- "Show all annotations" / "Hide all annotation" menu items should appear only for "Annotations" root object and for concrete geometrical object
- "Show all annotations" / "Hide all annotation" menu items should work in the following way:
If popup menu is called for "Annotations" root object, then show / hide operations should be applied to all annotations.
If popup menu is called for concrete geometrical object, then show / hide operations should be applied only to annotations which belong to this concrete geometrical object.
/*!
\class GEOMGUI_TextTreeSelector
- \brief Text tree selection handler class.
+ \brief Text tree selection handler class. It provides selection synchronization between
+ application and text tree widget. This selector listens item selection changed signal of
+ text tree widget to emit common selection changed signal of SUIT selector to start selection
+ synchronization. In get/setSelection selector processes annotation items. These items have
+ specific entry generated in annotation manager, having the "object entry:annotation_id" structure.
*/
/*!
/*!
\brief Get object browser.
- \return a pointer to the object browser
+ \return a pointer to the text tree widget
*/
GEOMGUI_TextTreeWdg* GEOMGUI_TextTreeSelector::textTree() const
{
}
/*!
- \brief Get selector type.
+ \brief Get selector unique type.
\return selector type
*/
QString GEOMGUI_TextTreeSelector::type() const
}
/*!
- \brief Called when the Object browser selection is changed.
+ \brief Called when the Object browser selection is changed. It emits signal to synchronize
+ selection in application.
*/
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.
+ \brief Get list of currently selected annotation objects.
\param theList list to be filled with the selected objects owners
+ The list contains owners for interactive objects of annotations
*/
void GEOMGUI_TextTreeSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const
{
}
}
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;*/
}
/*!
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();
continue;
QString anEntry = anAnnotationInfo[0];
- int anAnnotationId = anAnnotationInfo[1].toInt();//myAnnotationMgr->FindAnnotationIndex( anIO );
+ int anAnnotationId = anAnnotationInfo[1].toInt();
if ( anAnnotationId < 0)
continue;
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();
-}*/
-
class GEOMGUI_TextTreeWdg;
class GEOMGUI_AnnotationMgr;
-//class LightApp_DataObject;
class GEOMGUI_EXPORT GEOMGUI_TextTreeSelector : public QObject, public SUIT_Selector
{
GEOMGUI_TextTreeWdg* textTree() const;
- virtual QString type() const;
+ virtual QString type() const;
private slots:
- void onSelectionChanged();
+ void onSelectionChanged();
protected:
- virtual void getSelection( SUIT_DataOwnerPtrList& ) const;
- virtual void setSelection( const SUIT_DataOwnerPtrList& );
-
-//private:
- //void fillEntries( QMap<QString, LightApp_DataObject*>& );
+ virtual void getSelection( SUIT_DataOwnerPtrList& ) const;
+ virtual void setSelection( const SUIT_DataOwnerPtrList& );
private:
GEOMGUI_TextTreeWdg* myTextTree;
return false;
}
return aMgr->IsDisplayed( myEntry, theIndex );
- //return annotationMgr()->IsDisplayed(myEntry, theIndex);
- //return !myAttr.IsNull() ? myAttr->GetIsVisible( theIndex ) : false;
}
virtual void SetIsVisible( const int theIndex, const bool theIsVisible ) Standard_OVERRIDE {
GEOMGUI_AnnotationMgr* aMgr = annotationMgr();
annotationMgr()->Display(myEntry, theIndex);
else
annotationMgr()->Erase(myEntry, theIndex);
- /*if ( !myAttr.IsNull() ) {
- myAttr->SetIsVisible( theIndex, theIsVisible );
- }*/
}
virtual void Save() Standard_OVERRIDE {
/* every change is automatically saved */
this, SLOT( updateDimensionBranch( const QString& ) ) );
connect( aGeomGUI, SIGNAL( SignalAnnotationsUpdated( const QString& ) ),
this, SLOT( updateAnnotationBranch( const QString& ) ) );
+ connect( aGeomGUI, SIGNAL( SignalTextTreeRenameObject( const QString& ) ),
+ this, SLOT( updateObjectName( const QString& ) ) );
+
connect( this, SIGNAL( itemClicked( QTreeWidgetItem*, int) ),
this, SLOT( onItemClicked( QTreeWidgetItem*, int ) ) );
connect( myStudy, SIGNAL( objVisibilityChanged( QString, Qtx::VisibilityState ) ),
//=================================================================================
// function : updateTree
-// purpose :
+// purpose : Rebuild branches of objects and remove objects if there are no more annotations
+// for it
//=================================================================================
void GEOMGUI_TextTreeWdg::updateTree()
{
//=================================================================================
// function : updateBranches
-// purpose :
+// purpose : Rebuild branches for object of the given entry
//=================================================================================
void GEOMGUI_TextTreeWdg::updateBranches( const QString& theEntry )
{
//=================================================================================
// function : updateDimensionBranch
-// purpose :
+// purpose : Rebuild branch of dimension type for object of the given entry
//=================================================================================
void GEOMGUI_TextTreeWdg::updateDimensionBranch( const QString& theEntry )
{
//=================================================================================
// function : updateAnnotationBranch
-// purpose :
+// purpose : Rebuild branch of annotation type for object of the given entry
//=================================================================================
void GEOMGUI_TextTreeWdg::updateAnnotationBranch( const QString& theEntry )
{
fillBranch( AnnotationShape, theEntry );
}
+//=================================================================================
+// function : updateObjectName
+// purpose : Find name of the given object and set the name for corresponded tree item
+//=================================================================================
+void GEOMGUI_TextTreeWdg::updateObjectName( const QString& theEntry )
+{
+ QTreeWidgetItem* anObjectItem;
+
+ QHash<QString, QTreeWidgetItem*> anObjects = getObjects( DimensionShape );
+ if ( anObjects.contains( theEntry ) )
+ anObjectItem = anObjects.value( theEntry );
+ else {
+ anObjects = getObjects( AnnotationShape );
+ if ( anObjects.contains( theEntry ) )
+ anObjectItem = anObjects.value( theEntry );
+ }
+ if ( !anObjectItem )
+ return;
+
+ myStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+ if ( myStudy ) {
+ _PTR(Study) aStudyDS = myStudy->studyDS();
+ if ( aStudyDS ) {
+ _PTR(SObject) anObject( aStudyDS->FindObjectID( theEntry.toStdString() ) );
+ if ( anObject.get() )
+ anObjectItem->setText( 0, anObject->GetName().c_str() );
+ }
+ }
+}
+
//=================================================================================
// function : fillBranch
// purpose :
if ( myStudy && !theEntry.isEmpty() ) {
QSharedPointer<VisualProperty> aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
- const std::string anEntry = theEntry.toStdString();
if ( !aProp ) {
return;
}
// function : entryFromItem
// purpose :
//=================================================================================
-QString GEOMGUI_TextTreeWdg::entryFromItem( QTreeWidgetItem* theShapeItem )
+QString GEOMGUI_TextTreeWdg::entryFromItem( QTreeWidgetItem* theShapeItem ) const
{
if ( !theShapeItem )
return "";
aMenu.addAction( myActions[GEOMOp::OpShow] );
}
}
- aMenu.addAction( aModule->action(GEOMOp::OpShowAllAnnotations) );
- aMenu.addAction( aModule->action(GEOMOp::OpHideAllAnnotations) );
+
+ if (selectedItems().isEmpty() && currentItem()) {
+ QTreeWidgetItem* anItem = currentItem();
+ bool aShowAll = false;
+ if (anItem == getPropertyRootItem(AnnotationShape))
+ aShowAll = true;
+ else {
+ QHash<QString, QTreeWidgetItem*> anObjects = getObjects( AnnotationShape );
+ QHash<QString, QTreeWidgetItem*>::const_iterator anIt = anObjects.begin(),
+ aLast = anObjects.end();
+ for (; anIt != aLast && !aShowAll; anIt++) {
+ aShowAll = anIt.value() == anItem;
+ }
+ }
+ if (aShowAll) {
+ aMenu.addAction( aModule->action(GEOMOp::OpShowAllAnnotations) );
+ aMenu.addAction( aModule->action(GEOMOp::OpHideAllAnnotations) );
+ }
+ }
QAction* selPopupItem = aMenu.exec( viewport()->mapToGlobal(pos) );
if ( selPopupItem == myActions[GEOMOp::OpShow] ||
// function : setShapeItemVisibility
// purpose :
//=================================================================================
-void GEOMGUI_TextTreeWdg::updateVisibility( SALOME_View* theView )
+void GEOMGUI_TextTreeWdg::updateVisibility()
{
//QList<QString> aDimensionObjEntries = getObjects( DimensionShape ).keys();
BranchType aBranchType = AnnotationShape;
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 :
return aBranchType;
}
-
void removeBranch( const BranchType& theBranchType, const QString& theEntry,
bool force = true );
int idFromItem( QTreeWidgetItem* theItem );
- QString entryFromItem( QTreeWidgetItem* theShapeItem );
+ QString entryFromItem( QTreeWidgetItem* theShapeItem ) const;
QTreeWidgetItem* itemFromEntry( const BranchType& theBranchType, QString theEntry );
void setAllShapeItemsVisibility( const BranchType& theBranchType,
const QString& theEntry,
const QString& theEntry,
QTreeWidgetItem* theWidgetItem,
const bool theVisibility );
- void updateVisibility( SALOME_View* theView );
+ void updateVisibility();
void getSelected( QMap<QString, QList<int> >& theAnnotations );
void setSelected( const QMap<QString, QList<int> >& theAnnotations );
QList<QString> getAllEntries( const BranchType& theBranchType );
+ QString getSingleSelectedObject();
+
protected:
void createActions();
void redisplay( QString theEntry );
void updateBranches( const QString& theEntry );
void updateDimensionBranch( const QString& theEntry );
void updateAnnotationBranch( const QString& theEntry );
+ void updateObjectName( const QString& theEntry );
private slots:
void onUpdateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState );
if (!CORBA::is_nil(anObj)) {
anObj->SetName( name.toLatin1().data() ); // Rename the corresponding GEOM_Object
emit SignalDependencyTreeRenameObject( anObj->GetEntry() );
+ emit SignalTextTreeRenameObject( entry );
}
result = true;
}
void SignalDefaultStepValueChanged( double newVal );
void SignalDependencyTreeParamChanged( const QString&, const QString& );
void SignalDependencyTreeRenameObject( const QString& );
+ void SignalTextTreeRenameObject( const QString& );
void SignalAnnotationsUpdated( const QString& );
void DimensionsUpdated( const QString& );
#include <GeometryGUI.h>
#include "GeometryGUI_Operations.h"
+#include <GEOMGUI_TextTreeWdg.h>
#include <GEOMGUI_DimensionProperty.h>
#include <GEOMGUI_AnnotationAttrs.h>
if ( !anActiveStudy )
return;
+ QString anEntry;
Handle(SALOME_InteractiveObject) anIObject = getSingleSelectedIO();
if ( !anIObject.IsNull() && anIObject->hasEntry() ) {
- const QString aEntry = anIObject->getEntry();
+ anEntry = anIObject->getEntry();
+ }
+ if ( anEntry.isEmpty() ) {
+ anEntry = getGeometryGUI()->GetTextTreeWdg()->getSingleSelectedObject();
+ }
- _PTR(SObject) aSObj = anActiveStudy->studyDS()->FindObjectID( aEntry.toStdString() );
+ if ( !anEntry.isEmpty() ) {
+ _PTR(SObject) aSObj = anActiveStudy->studyDS()->FindObjectID( anEntry.toStdString() );
const Handle(GEOMGUI_AnnotationAttrs)
aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
for ( int anI = 0; anI < aCount; ++anI ) {
if ( !theIsVisible ) {
- getGeometryGUI()->GetAnnotationMgr()->Erase( aEntry, anI );
+ getGeometryGUI()->GetAnnotationMgr()->Erase( anEntry, anI );
}
else {
- getGeometryGUI()->GetAnnotationMgr()->Display( aEntry , anI );
+ getGeometryGUI()->GetAnnotationMgr()->Display( anEntry , anI );
}
}
- getGeometryGUI()->emitAnnotationsUpdated( aEntry );
+ getGeometryGUI()->emitAnnotationsUpdated( anEntry );
}
}
else {
else {
getGeometryGUI()->GetAnnotationMgr()->EraseAllAnnotations();
}
+ getGeometryGUI()->GetTextTreeWdg()->updateVisibility();
}
}
myAnnotationProperties.Text = myTextEdit->text();
if ( !myShapeNameModified )
myShapeNameModified = true;
-
redisplayPreview();
}
else {
aShapeAnnotations->SetProperties( myEditAnnotationIndex, myAnnotationProperties );
+ myGeomGUI->emitAnnotationsUpdated( QString( myShape->GetStudyEntry() ) );
}
return true;
}