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>
29 #include <SUIT_DataObject.h>
31 #include <TDF_Tool.hxx>
33 HYDROGUI_DataObject::HYDROGUI_DataObject( SUIT_DataObject* theParent,
34 Handle(HYDROData_Entity) theData,
35 const QString& theParentEntry )
36 : CAM_DataObject( theParent ),
37 LightApp_DataObject( theParent ),
39 myParentEntry( theParentEntry )
43 QString HYDROGUI_DataObject::entry() const
45 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( modelObject() );
47 anEntry.prepend( myParentEntry + "_" );
51 QString HYDROGUI_DataObject::refEntry() const
53 if( !myParentEntry.isEmpty() )
54 return HYDROGUI_DataObject::dataObjectEntry( modelObject() );
58 QString HYDROGUI_DataObject::name() const
60 if( !myData.IsNull() )
61 return myData->GetName();
65 QFont HYDROGUI_DataObject::font( const int theId ) const
67 QFont aFont = LightApp_DataObject::font( theId );
70 Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( modelObject() );
71 if( !anImage.IsNull() && anImage->MustBeUpdated() )
72 aFont.setItalic( true );
77 QString HYDROGUI_DataObject::text( const int theColumnId ) const
80 if( !myData.IsNull() )
82 if ( theColumnId == RefObjectId || theColumnId == BathymetryId )
84 Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( myData );
85 if ( !aZone.IsNull() )
87 HYDROData_SequenceOfObjects::Iterator anIter( aZone->GetGeometryObjects() );
88 for ( ; anIter.More(); anIter.Next() )
90 Handle(HYDROData_Object) aRefGeomObj =
91 Handle(HYDROData_Object)::DownCast( anIter.Value() );
92 if ( !aRefGeomObj.IsNull() )
94 switch ( theColumnId )
97 aRes += aRefGeomObj->GetName() + ", ";
100 //TODO: Get bathymetry name
101 //aRes += aRefGeomObj->
107 if ( aRes.length() > 1 )
109 aRes.remove( aRes.length() - 2, 2 );
114 aRes = LightApp_DataObject::text( theColumnId );
120 QColor HYDROGUI_DataObject::color( const ColorRole theColorRole, const int theColumnId ) const
122 //TODO: Implement red color for bathymetry conflicts in case creation dialog
123 return LightApp_DataObject::color( theColorRole, theColumnId );
127 QString HYDROGUI_DataObject::dataObjectEntry( const Handle(HYDROData_Entity)& theObject,
128 const bool theWithPrefix )
130 QString aEntryStr = QString::null;
131 if( !theObject.IsNull() )
133 TCollection_AsciiString aLabEntr;
134 TDF_Tool::Entry( theObject->Label(), aLabEntr );
135 aEntryStr = aLabEntr.ToCString();
137 aEntryStr.prepend( HYDROGUI_DataObject::entryPrefix() );
142 HYDROGUI_NamedObject::HYDROGUI_NamedObject( SUIT_DataObject* theParent,
143 const QString& theName,
144 const QString& theParentEntry )
145 : CAM_DataObject( theParent ),
146 LightApp_DataObject( theParent ),
148 myParentEntry( theParentEntry )
152 QString HYDROGUI_NamedObject::entry() const
154 QString anEntry = HYDROGUI_DataObject::entryPrefix() + name();
155 if( !myParentEntry.isEmpty() )
156 anEntry.prepend( myParentEntry + "_" );
160 QString HYDROGUI_NamedObject::name() const