+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// 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.
+//
+// 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/
+//
#include "SalomeApp_DataObject.h"
#include "SalomeApp_Study.h"
-#include "SalomeApp_RootObject.h"
+#include "LightApp_RootObject.h"
#include <SUIT_Application.h>
#include <SUIT_ResourceMgr.h>
#include <SALOMEDSClient_AttributeTableOfReal.hxx>
#include <SALOMEDSClient_AttributeTableOfInteger.hxx>
-/*!
- Class: SalomeApp_DataObject::Key
- Level: Internal
-*/
-
-class SalomeApp_DataObject::Key : public SUIT_DataObjectKey
-{
-public:
- Key( const QString& );
- virtual ~Key();
-
- virtual bool isLess( const SUIT_DataObjectKey* ) const;
- virtual bool isEqual( const SUIT_DataObjectKey* ) const;
-
-private:
- QString myEntry;
-};
-
-SalomeApp_DataObject::Key::Key( const QString& entry )
-: SUIT_DataObjectKey(),
- myEntry( entry )
-{
-}
-
-SalomeApp_DataObject::Key::~Key()
-{
-}
-
-bool SalomeApp_DataObject::Key::isLess( const SUIT_DataObjectKey* other ) const
-{
- Key* that = (Key*)other;
- return myEntry < that->myEntry;
-}
-
-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 )
+: LightApp_DataObject( parent ),
+ CAM_DataObject( parent ),
+ myEntry( "" ),
+ myName( "" )
{
}
+/*!Constructor. Initialize by \a parent and SObject*/
SalomeApp_DataObject::SalomeApp_DataObject( const _PTR(SObject)& sobj, SUIT_DataObject* parent )
-: CAM_DataObject( parent )
+: LightApp_DataObject( parent ),
+ CAM_DataObject( parent ),
+ myName( "" )
{
myObject = sobj;
+ myEntry = myObject->GetID().c_str();
}
+/*!Destructor. Do nothing.*/
SalomeApp_DataObject::~SalomeApp_DataObject()
{
}
+/*!Gets object ID.
+ *\retval QString
+ */
QString SalomeApp_DataObject::entry() const
{
- if ( myObject )
+ if ( myObject )
return myObject->GetID().c_str();
return QString::null;
+ //return myEntry;
}
-SUIT_DataObjectKey* SalomeApp_DataObject::key() const
-{
- QString str = entry();
- return new Key( str );
-}
-
+/*!Gets name of object.*/
QString SalomeApp_DataObject::name() const
{
- QString str;
-
- if ( myObject )
- str = myObject->GetName().c_str();
-
- if ( str.isEmpty() )
+ //if ( myName.isEmpty() )
{
- _PTR(SObject) refObj = referencedObject();
- if ( refObj )
- str = refObj->GetName().c_str();
- }
+ QString str;
+ if ( myObject )
+ str = myObject->GetName().c_str();
- if ( isReference() )
- str = QString( "* " ) + str;
+ if ( str.isEmpty() )
+ {
+ _PTR(SObject) refObj = referencedObject();
+ if ( refObj )
+ str = refObj->GetName().c_str();
+ }
- return str;
+ if ( isReference() )
+ {
+ if ( !(QString(referencedObject()->GetName().c_str()).isEmpty()) )
+ str = QString( "* " ) + str;
+ else
+ str = QString( "<Invalid Reference>" );
+ }
+ SalomeApp_DataObject* that = (SalomeApp_DataObject*)this;
+ that->myName = str;
+ }
+ return myName;
}
+/*!Gets icon picture of object.*/
QPixmap SalomeApp_DataObject::icon() const
{
_PTR(GenericAttribute) anAttr;
_PTR(AttributePixMap) aPixAttr ( anAttr );
if ( aPixAttr->HasPixMap() ){
QString pixmapName = QObject::tr( aPixAttr->GetPixMap().c_str() );
- SalomeApp_RootObject* aRoot = dynamic_cast<SalomeApp_RootObject*>( root() );
+ LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>( root() );
if ( aRoot && aRoot->study() ) {
- QPixmap pixmap = aRoot->study()->application()->resourceMgr()->loadPixmap( componentDataType(), pixmapName, false );
- return pixmap;
+ SUIT_ResourceMgr* mgr = aRoot->study()->application()->resourceMgr();
+ return mgr->loadPixmap( componentDataType(), pixmapName, false );
}
}
}
return QPixmap();
}
+/*!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:
- txt = entry( referencedObject() );
+ txt = entry( object() );
break;
case CT_IOR:
txt = ior( referencedObject() );
break;
case CT_RefEntry:
if ( isReference() )
- txt = entry( object() );
+ txt = entry( referencedObject() );
break;
}
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;
{
case Text:
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 );
+ }
else if ( myObject )
{
_PTR(GenericAttribute) anAttr;
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() )
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() );
}
-SUIT_DataObject* SalomeApp_DataObject::componentObject() const
-{
- SUIT_DataObject* compObj = 0; // for root object (invisible SALOME_ROOT_OBJECT)
-
- if ( parent() && parent() == root() )
- compObj = (SUIT_DataObject*)this; // for component-level objects
- else
- {
- compObj = parent(); // for lower level objects
- while ( compObj && compObj->parent() != root() )
- compObj = compObj->parent();
- }
-
- return compObj;
-}
-
+/*!Get component type.*/
QString SalomeApp_DataObject::componentDataType() const
{
- const SalomeApp_DataObject* compObj = dynamic_cast<SalomeApp_DataObject*>( componentObject() );
- if ( compObj && compObj->object() )
- {
- _PTR(SComponent) aComp( compObj->object() );
- if ( aComp )
- return aComp->ComponentDataType().c_str();
- }
-
- return "";
+ // if ( myCompDataType.isEmpty() ) {
+ const SalomeApp_DataObject* compObj = dynamic_cast<SalomeApp_DataObject*>( componentObject() );
+ if ( compObj && compObj->object() )
+ {
+ _PTR(SComponent) aComp( compObj->object() );
+ if ( aComp ) {
+ SalomeApp_DataObject* that = (SalomeApp_DataObject*)this;
+ that->myCompDataType = aComp->ComponentDataType().c_str();
+ }
+ }
+ // }
+ return myCompDataType;
}
+/*!Gets object.*/
_PTR(SObject) SalomeApp_DataObject::object() const
{
return myObject;
}
+/*!Checks: Is object reference.*/
bool SalomeApp_DataObject::isReference() const
{
bool isRef = false;
return isRef;
}
+/*!Gets reference object.*/
_PTR(SObject) SalomeApp_DataObject::referencedObject() const
{
_PTR(SObject) refObj;
return obj;
}
+/*!Gets IOR*/
QString SalomeApp_DataObject::ior( const _PTR(SObject)& obj ) const
{
QString txt;
return txt;
}
+/*!Gets Entry*/
QString SalomeApp_DataObject::entry( const _PTR(SObject)& obj ) const
{
QString txt;
return txt;
}
+/*!Value*/
QString SalomeApp_DataObject::value( const _PTR(SObject)& obj ) const
{
if ( !obj )
return val;
}
-/*!
+/*
Class: SalomeApp_ModuleObject
Level: Public
*/
+/*!Constructor.Initialize by \a parent.*/
SalomeApp_ModuleObject::SalomeApp_ModuleObject( SUIT_DataObject* parent )
-: SalomeApp_DataObject( parent ),
+: SalomeApp_DataObject( parent ),
CAM_RootObject( parent ),
CAM_DataObject( parent )
{
}
+/*!Constructor.Initialize by \a parent and SObject.*/
SalomeApp_ModuleObject::SalomeApp_ModuleObject( const _PTR(SObject)& sobj, SUIT_DataObject* parent )
-: SalomeApp_DataObject( sobj, parent ),
+: SalomeApp_DataObject( sobj, parent ),
CAM_RootObject( 0, parent ),
CAM_DataObject( parent )
{
}
+/*!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 ),
+: SalomeApp_DataObject( sobj, parent ),
CAM_RootObject( dm, parent ),
- CAM_DataObject( parent )
+ CAM_DataObject( parent )
{
}
+/*!Destructor. Do nothing.*/
SalomeApp_ModuleObject::~SalomeApp_ModuleObject()
{
}
+
+/*!Returns module name */
+QString SalomeApp_ModuleObject::name() const
+{
+ return SalomeApp_DataObject::name();
+}
+