From: epa Date: Thu, 12 Oct 2006 14:29:24 +0000 (+0000) Subject: Add internal class that updates object browser item properties X-Git-Tag: V3_2_3pre1~25 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=993110bd51eec3fa12d30c64fda03354a193fc51;p=modules%2Fgui.git Add internal class that updates object browser item properties --- diff --git a/src/ObjBrowser/OB_Browser.cxx b/src/ObjBrowser/OB_Browser.cxx index c0343a2ca..178a67a93 100755 --- a/src/ObjBrowser/OB_Browser.cxx +++ b/src/ObjBrowser/OB_Browser.cxx @@ -113,7 +113,7 @@ public: ObjPtr nullSrc() const; ItemPtr nullTrg() const; ItemPtr createItem( const ObjPtr&, const ItemPtr&, const ItemPtr&, const bool ) const; - void updateItem( const ItemPtr& ) const; + void updateItem( const ObjPtr& , const ItemPtr& ) const; void deleteItemWithChildren( const ItemPtr& ) const; void children( const ObjPtr&, QValueList& ) const; void children( const ItemPtr&, QValueList& ) const; @@ -171,13 +171,17 @@ bool OB_BrowserSync::needUpdate( const ItemPtr& item ) const Updates item \param p - item */ -void OB_BrowserSync::updateItem( const ItemPtr& p ) const +void OB_BrowserSync::updateItem( const ObjPtr& o, const ItemPtr& p ) const { if ( p && needUpdate( p ) ) { // printf( "--- needUpdate for %s = true ---\n", p->text( 0 ).latin1() ); myBrowser->updateText( p ); p->update(); } + if( o && myBrowser->getUpdater() ) + { + myBrowser->getUpdater()->update( o, p ); + } } /*! @@ -288,6 +292,7 @@ OB_Browser::OB_Browser( QWidget* parent, SUIT_DataObject* root ) myRoot( 0 ), myTooltip( 0 ), +myUpdater( 0 ), myAutoOpenLevel( 0 ), myAutoUpdate( false ), myAutoDelObjs( false ), @@ -325,6 +330,7 @@ OB_Browser::~OB_Browser() { myItems.clear(); delete myTooltip; + setUpdater( 0 ); } /*! @@ -421,6 +427,24 @@ void OB_Browser::setAutoDeleteObjects( const bool on ) myAutoDelObjs = on; } +/*! + \return updater of browser +*/ +OB_Updater* OB_Browser::getUpdater() const +{ + return myUpdater; +} + +/*! + \sets new updater of browser +*/ +void OB_Browser::setUpdater( OB_Updater* theUpdate ) +{ + if( myUpdater ) + delete myUpdater; + myUpdater = theUpdate; +} + /*! \return root SUIT object of browser */ diff --git a/src/ObjBrowser/OB_Browser.h b/src/ObjBrowser/OB_Browser.h index 6299afd2d..5bf4573ca 100755 --- a/src/ObjBrowser/OB_Browser.h +++ b/src/ObjBrowser/OB_Browser.h @@ -39,6 +39,14 @@ class OB_Filter; class OB_ListView; class OB_ListItem; +class OB_Updater +{ +public: + OB_Updater(){}; + virtual ~OB_Updater(){}; + virtual void update( SUIT_DataObject* theObj, OB_ListItem* theLI ) = 0; +}; + /*! \class OB_Browser Represents object browser. Allows to get/set selection, @@ -126,6 +134,9 @@ public: void setModified(); unsigned long getModifiedTime() { return myModifiedTime; } + + OB_Updater* getUpdater() const; + virtual void setUpdater( OB_Updater* theUpdate = 0 ); signals: void selectionChanged(); @@ -188,6 +199,7 @@ private: SUIT_DataObject* myRoot; ItemMap myItems; QToolTip* myTooltip; + OB_Updater* myUpdater; QMap myColumnIds; bool myAutoUpdate; bool myAutoDelObjs; diff --git a/src/SUIT/SUIT_TreeSync.h b/src/SUIT/SUIT_TreeSync.h index 602a8913b..61d8fde06 100644 --- a/src/SUIT/SUIT_TreeSync.h +++ b/src/SUIT/SUIT_TreeSync.h @@ -106,7 +106,7 @@ TrgItem synchronize( const SrcItem& r1, const TrgItem& r2, const TreeData& td ) if( td.isEqual( r1, r2 ) ) { // update items themselves - td.updateItem( r2 ); + td.updateItem( r1, r2 ); // iterate 'siblings' (direct children) QValueList< DiffItem< SrcItem, TrgItem > > d; @@ -135,7 +135,7 @@ TrgItem synchronize( const SrcItem& r1, const TrgItem& r2, const TreeData& td ) else { //to update - td.updateItem( item.myTrg ); + td.updateItem( item.mySrc, item.myTrg ); synchronize( item.mySrc, item.myTrg, td ); lastItem = item.myTrg; } diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index b2c5cfe89..d8b2ffc7c 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -81,6 +81,49 @@ #include #include +/*!Internal class that updates object browser item properties */ +class SalomeApp_Updater : public OB_Updater +{ +public: + SalomeApp_Updater() : OB_Updater(){}; + virtual ~SalomeApp_Updater(){}; + virtual void update( SUIT_DataObject* theObj, OB_ListItem* theItem ); +}; + +void SalomeApp_Updater::update( SUIT_DataObject* theObj, OB_ListItem* theItem ) +{ + if( !theObj || !theItem ) + return; + + SalomeApp_DataObject* SAObj = dynamic_cast( theObj ); + if( !SAObj ) + return; + + _PTR(SObject) SObj = SAObj->object(); + if( !SObj ) + return; + _PTR( GenericAttribute ) anAttr; + + // Selectable + if ( SObj->FindAttribute( anAttr, "AttributeSelectable" ) ) + { + _PTR(AttributeSelectable) aAttrSel = anAttr; + theItem->setSelectable( aAttrSel->IsSelectable() ); + } + // Expandable + if ( SObj->FindAttribute(anAttr, "AttributeExpandable") ) + { + _PTR(AttributeExpandable) aAttrExpand = anAttr; + theItem->setExpandable( aAttrExpand->IsExpandable() ); + } + // Opened + //this attribute is not supported in the version of SALOME 3.x + //if ( SObj->FindAttribute(anAttr, "AttributeOpened") ) + //{ + // _PTR(AttributeOpened) aAttrOpen = anAttr; + // theItem->setOpen( aAttrOpen->IsOpened() ); + //} +} /*!Create new instance of SalomeApp_Application.*/ extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication() @@ -662,6 +705,7 @@ QWidget* SalomeApp_Application::createWindow( const int flag ) if ( flag == WT_ObjectBrowser ) { OB_Browser* ob = (OB_Browser*)wid; + ob->setUpdater( new SalomeApp_Updater() ); connect( ob->listView(), SIGNAL( doubleClicked( QListViewItem* ) ), this, SLOT( onDblClick( QListViewItem* ) ) ); bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ), autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true ); diff --git a/src/SalomeApp/SalomeApp_DataModel.cxx b/src/SalomeApp/SalomeApp_DataModel.cxx index d899ad63d..97e7ce9e6 100644 --- a/src/SalomeApp/SalomeApp_DataModel.cxx +++ b/src/SalomeApp/SalomeApp_DataModel.cxx @@ -64,7 +64,7 @@ public: void children( const suitPtr&, QValueList& ) const; suitPtr parent( const suitPtr& ) const; bool isCorrect( const kerPtr& ) const; - void updateItem( const suitPtr& ) const; + void updateItem( const kerPtr&, const suitPtr& ) const; private: _PTR( Study ) myStudy; @@ -87,7 +87,14 @@ bool SalomeApp_DataModelSync::isCorrect( const kerPtr& so ) const { kerPtr refObj; QString name = so->GetName().c_str(); - bool res = so && ( so->GetName().size() || so->ReferencedObject( refObj ) ); + _PTR( GenericAttribute ) anAttr; + bool isDraw = true; + if ( so->FindAttribute(anAttr, "AttributeDrawable") ) + { + _PTR(AttributeDrawable) aAttrDraw = anAttr; + isDraw = aAttrDraw->IsDrawable(); + } + bool res = so && ( so->GetName().size() || so->ReferencedObject( refObj ) ) && isDraw; return res; } @@ -221,7 +228,7 @@ suitPtr SalomeApp_DataModelSync::parent( const suitPtr& p ) const Updates SUIT object \param p - SUIT object */ -void SalomeApp_DataModelSync::updateItem( const suitPtr& ) const +void SalomeApp_DataModelSync::updateItem( const kerPtr& obj, const suitPtr& ) const { } @@ -333,7 +340,7 @@ SUIT_DataObject* SalomeApp_DataModel::synchronize( const _PTR( SComponent )& sob { if( !study || !study->root() || !sobj ) return 0; - + DataObjectList ch; study->root()->children( ch ); DataObjectList::const_iterator anIt = ch.begin(), aLast = ch.end(); SUIT_DataObject* suitObj = 0; diff --git a/src/SalomeApp/SalomeApp_DataObject.cxx b/src/SalomeApp/SalomeApp_DataObject.cxx index d3a4b5c9d..5eb3c97a9 100644 --- a/src/SalomeApp/SalomeApp_DataObject.cxx +++ b/src/SalomeApp/SalomeApp_DataObject.cxx @@ -186,6 +186,17 @@ QColor SalomeApp_DataObject::color( const ColorRole cr ) const else clr = QColor( 200, 200, 200 ); } + else if ( myObject ) + { + _PTR(GenericAttribute) anAttr; + if( myObject->FindAttribute ( anAttr, "AttributeTextHighlightColor") ) + { + _PTR(AttributeTextHighlightColor) aHighColAttr = anAttr; + clr = QColor( (int)(aHighColAttr->TextHighlightColor().R), + (int)(aHighColAttr->TextHighlightColor().G), + (int)(aHighColAttr->TextHighlightColor().B)); + } + } break; case HighlightedText: if ( isReference() ) diff --git a/src/SalomeApp/SalomeApp_ExceptionHandler.cxx b/src/SalomeApp/SalomeApp_ExceptionHandler.cxx index d030d3c37..81cd56b04 100644 --- a/src/SalomeApp/SalomeApp_ExceptionHandler.cxx +++ b/src/SalomeApp/SalomeApp_ExceptionHandler.cxx @@ -36,14 +36,7 @@ SalomeApp_ExceptionHandler::SalomeApp_ExceptionHandler( const bool floatSignal ) : SUIT_ExceptionHandler() { - // JFA 2006-09-28: PAL10867: suppress signal catching, - // if environment variable DISABLE_SIGNALS_CATCHING is set to 1. - // Commonly this is used with "noexcepthandler" option. - char* envNoCatchSignals = getenv("NOT_INTERCEPT_SIGNALS"); - if (!envNoCatchSignals || !atoi(envNoCatchSignals)) - { - OSD::SetSignal( floatSignal ); - } + OSD::SetSignal( floatSignal ); } /*!Try to call SUIT_ExceptionHandler::internalHandle(o, e), catch if failure.*/ @@ -111,6 +104,5 @@ extern "C" SALOMEAPP_EXPORT SUIT_ExceptionHandler* getExceptionHandler() #else raiseFPE = false; #endif - return new SalomeApp_ExceptionHandler( raiseFPE ); }