Corrections for the following cases:

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.
This commit is contained in:
nds 2017-01-19 10:46:22 +03:00
parent b9162f3eab
commit 7deaf84d7e
8 changed files with 118 additions and 93 deletions

View File

@ -32,7 +32,11 @@
/*!
\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.
*/
/*!
@ -60,7 +64,7 @@ GEOMGUI_TextTreeSelector::~GEOMGUI_TextTreeSelector()
/*!
\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
{
@ -68,7 +72,7 @@ GEOMGUI_TextTreeWdg* GEOMGUI_TextTreeSelector::textTree() const
}
/*!
\brief Get selector type.
\brief Get selector unique type.
\return selector type
*/
QString GEOMGUI_TextTreeSelector::type() const
@ -77,20 +81,19 @@ 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
{
@ -118,35 +121,6 @@ void GEOMGUI_TextTreeSelector::getSelection( SUIT_DataOwnerPtrList& theList ) co
}
}
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;*/
}
/*!
@ -158,9 +132,6 @@ void GEOMGUI_TextTreeSelector::setSelection( const SUIT_DataOwnerPtrList& theLis
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();
@ -178,7 +149,7 @@ void GEOMGUI_TextTreeSelector::setSelection( const SUIT_DataOwnerPtrList& theLis
continue;
QString anEntry = anAnnotationInfo[0];
int anAnnotationId = anAnnotationInfo[1].toInt();//myAnnotationMgr->FindAnnotationIndex( anIO );
int anAnnotationId = anAnnotationInfo[1].toInt();
if ( anAnnotationId < 0)
continue;
@ -195,24 +166,3 @@ void GEOMGUI_TextTreeSelector::setSelection( const SUIT_DataOwnerPtrList& theLis
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();
}*/

View File

@ -32,7 +32,6 @@
class GEOMGUI_TextTreeWdg;
class GEOMGUI_AnnotationMgr;
//class LightApp_DataObject;
class GEOMGUI_EXPORT GEOMGUI_TextTreeSelector : public QObject, public SUIT_Selector
{
@ -46,17 +45,14 @@ public:
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;

View File

@ -113,8 +113,6 @@ namespace
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();
@ -125,9 +123,6 @@ namespace
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 */
@ -219,6 +214,9 @@ GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app )
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 ) ),
@ -251,7 +249,8 @@ void GEOMGUI_TextTreeWdg::createActions()
//=================================================================================
// function : updateTree
// purpose :
// purpose : Rebuild branches of objects and remove objects if there are no more annotations
// for it
//=================================================================================
void GEOMGUI_TextTreeWdg::updateTree()
{
@ -288,7 +287,7 @@ void GEOMGUI_TextTreeWdg::updateTree()
//=================================================================================
// function : updateBranches
// purpose :
// purpose : Rebuild branches for object of the given entry
//=================================================================================
void GEOMGUI_TextTreeWdg::updateBranches( const QString& theEntry )
{
@ -298,7 +297,7 @@ 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 )
{
@ -307,13 +306,43 @@ 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 :
@ -324,7 +353,6 @@ void GEOMGUI_TextTreeWdg::fillBranch( const BranchType& theBranchType, const QSt
if ( myStudy && !theEntry.isEmpty() ) {
QSharedPointer<VisualProperty> aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
const std::string anEntry = theEntry.toStdString();
if ( !aProp ) {
return;
}
@ -452,7 +480,7 @@ int GEOMGUI_TextTreeWdg::idFromItem( QTreeWidgetItem* theItem )
// function : entryFromItem
// purpose :
//=================================================================================
QString GEOMGUI_TextTreeWdg::entryFromItem( QTreeWidgetItem* theShapeItem )
QString GEOMGUI_TextTreeWdg::entryFromItem( QTreeWidgetItem* theShapeItem ) const
{
if ( !theShapeItem )
return "";
@ -549,8 +577,25 @@ void GEOMGUI_TextTreeWdg::showContextMenu( const QPoint& pos )
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] ||
@ -640,7 +685,7 @@ void GEOMGUI_TextTreeWdg::setShapeItemVisibility( const BranchType& theBranchTyp
// function : setShapeItemVisibility
// purpose :
//=================================================================================
void GEOMGUI_TextTreeWdg::updateVisibility( SALOME_View* theView )
void GEOMGUI_TextTreeWdg::updateVisibility()
{
//QList<QString> aDimensionObjEntries = getObjects( DimensionShape ).keys();
BranchType aBranchType = AnnotationShape;
@ -736,6 +781,28 @@ QList<QString> GEOMGUI_TextTreeWdg::getAllEntries( const BranchType& theBranchTy
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 :
@ -807,4 +874,3 @@ GEOMGUI_TextTreeWdg::BranchType GEOMGUI_TextTreeWdg::branchTypeFromItem( QTreeWi
return aBranchType;
}

View File

@ -59,7 +59,7 @@ public:
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,
@ -68,13 +68,15 @@ public:
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 );
@ -84,6 +86,7 @@ public slots:
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 );

View File

@ -3534,6 +3534,7 @@ bool GeometryGUI::renameObject( const QString& entry, const QString& name)
if (!CORBA::is_nil(anObj)) {
anObj->SetName( name.toLatin1().data() ); // Rename the corresponding GEOM_Object
emit SignalDependencyTreeRenameObject( anObj->GetEntry() );
emit SignalTextTreeRenameObject( entry );
}
result = true;
}

View File

@ -186,6 +186,7 @@ signals :
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& );

View File

@ -28,6 +28,7 @@
#include <GeometryGUI.h>
#include "GeometryGUI_Operations.h"
#include <GEOMGUI_TextTreeWdg.h>
#include <GEOMGUI_DimensionProperty.h>
#include <GEOMGUI_AnnotationAttrs.h>
@ -230,11 +231,17 @@ void MeasureGUI::ChangeAnnotationsVisibility( const bool theIsVisible )
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 );
@ -252,14 +259,14 @@ void MeasureGUI::ChangeAnnotationsVisibility( const bool theIsVisible )
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 {
@ -269,6 +276,7 @@ void MeasureGUI::ChangeAnnotationsVisibility( const bool theIsVisible )
else {
getGeometryGUI()->GetAnnotationMgr()->EraseAllAnnotations();
}
getGeometryGUI()->GetTextTreeWdg()->updateVisibility();
}
}

View File

@ -610,7 +610,6 @@ void MeasureGUI_AnnotationDlg::onTextChange()
myAnnotationProperties.Text = myTextEdit->text();
if ( !myShapeNameModified )
myShapeNameModified = true;
redisplayPreview();
}
@ -792,6 +791,7 @@ bool MeasureGUI_AnnotationDlg::execute()
else {
aShapeAnnotations->SetProperties( myEditAnnotationIndex, myAnnotationProperties );
myGeomGUI->emitAnnotationsUpdated( QString( myShape->GetStudyEntry() ) );
}
return true;
}