1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HYDROGUI_DataObject.h"
25 #include <SUIT_DataObject.h>
27 HYDROGUI_DataObject::HYDROGUI_DataObject( SUIT_DataObject* theParent,
28 Handle(HYDROData_Object) theData )
29 : CAM_DataObject( theParent ),
30 LightApp_DataObject( theParent ),
33 // unique identifier generated from pointer to this object, like: "HD_0x123457"
34 // "H" means "HYDRO", "D" means "data" to avoid conflicts with named objects
35 std::ostringstream aStream;
36 aStream << "HD_" << this;
37 myEntry = QString( aStream.str().c_str() );
40 QString HYDROGUI_DataObject::entry() const
45 QString HYDROGUI_DataObject::name() const
47 if( !myData.IsNull() )
48 return myData->GetName();
52 HYDROGUI_DataObject* HYDROGUI_DataObject::objectByEntry( const QString& theEntry )
54 static const QString aPrefixD( "HD_" );
55 if ( theEntry.indexOf( aPrefixD ) != 0 )
56 return NULL; // not HYDRO entry
58 std::istringstream aStream( theEntry.toLatin1().constData() + 3 ); // start reading just after "HD_"
62 return ( HYDROGUI_DataObject* )aPtr;
65 HYDROGUI_NamedObject::HYDROGUI_NamedObject( SUIT_DataObject* theParent,
66 const QString& theName )
67 : CAM_DataObject( theParent ),
68 LightApp_DataObject( theParent ),
73 QString HYDROGUI_NamedObject::entry() const
75 // unique identifier generated from pointer to this object, like: "HD_0x123457"
76 // "H" means "HYDRO", "N" means "named" to avoid conflicts with data objects
77 return "HN_" + myName;
80 QString HYDROGUI_NamedObject::name() const
85 QString HYDROGUI_NamedObject::nameByEntry( const QString& theEntry )
87 static const QString aPrefixN( "HN_" );
88 if( theEntry.indexOf( aPrefixN ) != 0 )
89 return QString(); // not HYDRO entry
91 return theEntry.right( 3 );