X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSalomeApp%2FSalomeApp_DataObject.cxx;h=0e9866fa9dd4069f66d13f3fa72e3541d2b99e8b;hb=5d1bd8e870f818cea5e77c5efe2717e76ea8dbe2;hp=0a1bbe819675ac3bd0c54f70f630288417af17bd;hpb=26c42324c345edd513f45434137aac7a48acfa08;p=modules%2Fgui.git diff --git a/src/SalomeApp/SalomeApp_DataObject.cxx b/src/SalomeApp/SalomeApp_DataObject.cxx index 0a1bbe819..0e9866fa9 100644 --- a/src/SalomeApp/SalomeApp_DataObject.cxx +++ b/src/SalomeApp/SalomeApp_DataObject.cxx @@ -19,7 +19,6 @@ Class: SalomeApp_DataObject::Key Level: Internal */ - class SalomeApp_DataObject::Key : public SUIT_DataObjectKey { public: @@ -33,48 +32,57 @@ private: QString myEntry; }; +/*!Constructor. Initialize by \a entry.*/ SalomeApp_DataObject::Key::Key( const QString& entry ) : SUIT_DataObjectKey(), myEntry( entry ) { } +/*!Destructor. Do nothing.*/ SalomeApp_DataObject::Key::~Key() { } +/*!Checks: Is current key less than \a other.*/ bool SalomeApp_DataObject::Key::isLess( const SUIT_DataObjectKey* other ) const { Key* that = (Key*)other; return myEntry < that->myEntry; } +/*!Checks: Is current key equal with \a other.*/ bool SalomeApp_DataObject::Key::isEqual( const SUIT_DataObjectKey* other ) const { Key* that = (Key*)other; return myEntry == that->myEntry; } -/*! +/* Class: SalomeApp_DataObject Level: Public */ - +/*!Constructor. Initialize by \a parent*/ SalomeApp_DataObject::SalomeApp_DataObject( SUIT_DataObject* parent ) : CAM_DataObject( parent ) { } +/*!Constructor. Initialize by \a parent and SObject*/ SalomeApp_DataObject::SalomeApp_DataObject( const _PTR(SObject)& sobj, SUIT_DataObject* parent ) : CAM_DataObject( parent ) { myObject = sobj; } +/*!Destructor. Do nothing.*/ SalomeApp_DataObject::~SalomeApp_DataObject() { } +/*!Gets object ID. + *\retval QString + */ QString SalomeApp_DataObject::entry() const { if ( myObject ) @@ -82,12 +90,14 @@ QString SalomeApp_DataObject::entry() const return QString::null; } +/*!Create and return new key object.*/ SUIT_DataObjectKey* SalomeApp_DataObject::key() const { QString str = entry(); return new Key( str ); } +/*!Gets name of object.*/ QString SalomeApp_DataObject::name() const { QString str; @@ -95,12 +105,25 @@ QString SalomeApp_DataObject::name() const if ( myObject ) str = myObject->GetName().c_str(); + if ( str.isEmpty() ) + { + _PTR(SObject) refObj = referencedObject(); + if ( refObj ) + str = refObj->GetName().c_str(); + } + if ( isReference() ) - str = QString( "* " ) + str; + { + if ( !(QString(referencedObject()->GetName().c_str()).isEmpty()) ) + str = QString( "* " ) + str; + else + str = QString( "" ); + } return str; } +/*!Gets icon picture of object.*/ QPixmap SalomeApp_DataObject::icon() const { _PTR(GenericAttribute) anAttr; @@ -110,7 +133,7 @@ QPixmap SalomeApp_DataObject::icon() const QString pixmapName = QObject::tr( aPixAttr->GetPixMap().c_str() ); SalomeApp_RootObject* aRoot = dynamic_cast( root() ); if ( aRoot && aRoot->study() ) { - QPixmap pixmap = aRoot->study()->application()->resourceMgr()->loadPixmap( componentDataType(), pixmapName ); + QPixmap pixmap = aRoot->study()->application()->resourceMgr()->loadPixmap( componentDataType(), pixmapName, false ); return pixmap; } } @@ -118,25 +141,23 @@ QPixmap SalomeApp_DataObject::icon() const return QPixmap(); } -QColor SalomeApp_DataObject::color() const -{ - _PTR(GenericAttribute) anAttr; - if ( myObject && myObject->FindAttribute( anAttr, "AttributeTextColor" ) ) - { - _PTR(AttributeTextColor) aColAttr( anAttr ); - QColor color( (int)aColAttr->TextColor().R, (int)aColAttr->TextColor().G, (int)aColAttr->TextColor().B ); - return color; - } - return QColor(); -} - +/*!Gets text value for one of entity: + *\li Value (id = SalomeApp_DataObject::CT_Value) + *\li Entry (id = SalomeApp_DataObject::CT_Entry) + *\li IOR (id = SalomeApp_DataObject::CT_IOR) + *\li Reference entry (id = SalomeApp_DataObject::CT_RefEntry) + */ QString SalomeApp_DataObject::text( const int id ) const { QString txt; switch ( id ) { case CT_Value: +#ifndef WNT if ( componentObject() != this ) +#else + if ( componentObject() != (SUIT_DataObject*)this ) +#endif txt = value( referencedObject() ); break; case CT_Entry: @@ -153,24 +174,42 @@ QString SalomeApp_DataObject::text( const int id ) const return txt; } +/*!Get color value for one of entity: + *\li Text color + *\li Highlight color + *\li Higlighted text color + */ QColor SalomeApp_DataObject::color( const ColorRole cr ) const { QColor clr; switch ( cr ) { - case Foreground: + case Text: + if ( isReference() ) + { + if ( !(QString(referencedObject()->GetName().c_str()).isEmpty()) ) + clr = QColor( 255, 0, 0 ); + else + clr = QColor( 200, 200, 200 ); + } + else if ( myObject ) { _PTR(GenericAttribute) anAttr; - if ( myObject && myObject->FindAttribute( anAttr, "AttributeTextColor" ) ) + if ( myObject->FindAttribute( anAttr, "AttributeTextColor" ) ) { - _PTR(AttributeTextColor) aColAttr( anAttr ); + _PTR(AttributeTextColor) aColAttr = anAttr; clr = QColor( (int)aColAttr->TextColor().R, (int)aColAttr->TextColor().G, (int)aColAttr->TextColor().B ); } } break; case Highlight: if ( isReference() ) - clr = QColor( 255, 0, 0 ); + { + if ( !(QString(referencedObject()->GetName().c_str()).isEmpty()) ) + clr = QColor( 255, 0, 0 ); + else + clr = QColor( 200, 200, 200 ); + } break; case HighlightedText: if ( isReference() ) @@ -180,12 +219,16 @@ QColor SalomeApp_DataObject::color( const ColorRole cr ) const return clr; } +/*!Gets tooltip.*/ QString SalomeApp_DataObject::toolTip() const { //return object()->Name(); return QString( "Object \'%1\', module \'%2\', ID=%3" ).arg( name() ).arg( componentDataType() ).arg( entry() ); } +/*!Gets component object. + *\retval SUIT_DataObject. + */ SUIT_DataObject* SalomeApp_DataObject::componentObject() const { SUIT_DataObject* compObj = 0; // for root object (invisible SALOME_ROOT_OBJECT) @@ -202,6 +245,7 @@ SUIT_DataObject* SalomeApp_DataObject::componentObject() const return compObj; } +/*!Get component type.*/ QString SalomeApp_DataObject::componentDataType() const { const SalomeApp_DataObject* compObj = dynamic_cast( componentObject() ); @@ -215,11 +259,13 @@ QString SalomeApp_DataObject::componentDataType() const return ""; } +/*!Gets object.*/ _PTR(SObject) SalomeApp_DataObject::object() const { return myObject; } +/*!Checks: Is object reference.*/ bool SalomeApp_DataObject::isReference() const { bool isRef = false; @@ -231,6 +277,7 @@ bool SalomeApp_DataObject::isReference() const return isRef; } +/*!Gets reference object.*/ _PTR(SObject) SalomeApp_DataObject::referencedObject() const { _PTR(SObject) refObj; @@ -241,6 +288,7 @@ _PTR(SObject) SalomeApp_DataObject::referencedObject() const return obj; } +/*!Gets IOR*/ QString SalomeApp_DataObject::ior( const _PTR(SObject)& obj ) const { QString txt; @@ -260,6 +308,7 @@ QString SalomeApp_DataObject::ior( const _PTR(SObject)& obj ) const return txt; } +/*!Gets Entry*/ QString SalomeApp_DataObject::entry( const _PTR(SObject)& obj ) const { QString txt; @@ -271,6 +320,7 @@ QString SalomeApp_DataObject::entry( const _PTR(SObject)& obj ) const return txt; } +/*!Value*/ QString SalomeApp_DataObject::value( const _PTR(SObject)& obj ) const { if ( !obj ) @@ -319,11 +369,12 @@ QString SalomeApp_DataObject::value( const _PTR(SObject)& obj ) const return val; } -/*! +/* Class: SalomeApp_ModuleObject Level: Public */ +/*!Constructor.Initialize by \a parent.*/ SalomeApp_ModuleObject::SalomeApp_ModuleObject( SUIT_DataObject* parent ) : SalomeApp_DataObject( parent ), CAM_RootObject( parent ), @@ -331,6 +382,7 @@ SalomeApp_ModuleObject::SalomeApp_ModuleObject( SUIT_DataObject* parent ) { } +/*!Constructor.Initialize by \a parent and SObject.*/ SalomeApp_ModuleObject::SalomeApp_ModuleObject( const _PTR(SObject)& sobj, SUIT_DataObject* parent ) : SalomeApp_DataObject( sobj, parent ), CAM_RootObject( 0, parent ), @@ -338,6 +390,7 @@ SalomeApp_ModuleObject::SalomeApp_ModuleObject( const _PTR(SObject)& sobj, SUIT_ { } +/*!Constructor.Initialize by \a parent and CAM_DataModel.*/ SalomeApp_ModuleObject::SalomeApp_ModuleObject( CAM_DataModel* dm, const _PTR(SObject)& sobj, SUIT_DataObject* parent ) : SalomeApp_DataObject( sobj, parent ), CAM_RootObject( dm, parent ), @@ -345,6 +398,7 @@ SalomeApp_ModuleObject::SalomeApp_ModuleObject( CAM_DataModel* dm, const _PTR(SO { } +/*!Destructor. Do nothing.*/ SalomeApp_ModuleObject::~SalomeApp_ModuleObject() { }