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 <HYDROData_Image.h>
26 #include <HYDROData_Zone.h>
27 #include <HYDROData_Object.h>
28 #include <HYDROData_Bathymetry.h>
30 #include <SUIT_DataObject.h>
32 #include <TDF_Tool.hxx>
34 HYDROGUI_DataObject::HYDROGUI_DataObject( SUIT_DataObject* theParent,
35 Handle(HYDROData_Entity) theData,
36 const QString& theParentEntry )
37 : CAM_DataObject( theParent ),
38 LightApp_DataObject( theParent ),
40 myParentEntry( theParentEntry )
44 QString HYDROGUI_DataObject::entry() const
46 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( modelObject() );
48 anEntry.prepend( myParentEntry + "_" );
52 QString HYDROGUI_DataObject::refEntry() const
54 if( !myParentEntry.isEmpty() )
55 return HYDROGUI_DataObject::dataObjectEntry( modelObject() );
59 QString HYDROGUI_DataObject::name() const
61 if( !myData.IsNull() )
62 return myData->GetName();
66 QFont HYDROGUI_DataObject::font( const int theId ) const
68 QFont aFont = LightApp_DataObject::font( theId );
71 Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( modelObject() );
72 if( !anImage.IsNull() && anImage->MustBeUpdated() )
73 aFont.setItalic( true );
78 QString HYDROGUI_DataObject::text( const int theColumnId ) const
81 if( !myData.IsNull() )
83 if ( theColumnId == RefObjectId || theColumnId == BathymetryId )
85 Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( myData );
86 if ( !aZone.IsNull() )
88 HYDROData_SequenceOfObjects aSeq = aZone->GetGeometryObjects();
89 HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
90 for ( ; anIter.More(); anIter.Next() )
92 Handle(HYDROData_Object) aRefGeomObj =
93 Handle(HYDROData_Object)::DownCast( anIter.Value() );
94 if ( !aRefGeomObj.IsNull() )
96 switch ( theColumnId )
99 // Get Ref.Object name
100 aRes += aRefGeomObj->GetName() + ", ";
103 // Get bathymetry name
104 aRes += aRefGeomObj->GetBathymetry()->GetName() + ", ";
109 if ( aRes.length() > 1 )
111 aRes.remove( aRes.length() - 2, 2 );
116 aRes = LightApp_DataObject::text( theColumnId );
122 QColor HYDROGUI_DataObject::color( const ColorRole theColorRole, const int theColumnId ) const
124 //TODO: Implement red color for bathymetry conflicts in case creation dialog
125 return LightApp_DataObject::color( theColorRole, theColumnId );
129 QString HYDROGUI_DataObject::dataObjectEntry( const Handle(HYDROData_Entity)& theObject,
130 const bool theWithPrefix )
132 QString aEntryStr = QString::null;
133 if( !theObject.IsNull() )
135 TCollection_AsciiString aLabEntr;
136 TDF_Tool::Entry( theObject->Label(), aLabEntr );
137 aEntryStr = aLabEntr.ToCString();
139 aEntryStr.prepend( HYDROGUI_DataObject::entryPrefix() );
144 HYDROGUI_NamedObject::HYDROGUI_NamedObject( SUIT_DataObject* theParent,
145 const QString& theName,
146 const QString& theParentEntry )
147 : CAM_DataObject( theParent ),
148 LightApp_DataObject( theParent ),
150 myParentEntry( theParentEntry )
154 QString HYDROGUI_NamedObject::entry() const
156 QString anEntry = HYDROGUI_DataObject::entryPrefix() + name();
157 if( !myParentEntry.isEmpty() )
158 anEntry.prepend( myParentEntry + "_" );
162 QString HYDROGUI_NamedObject::name() const