Salome HOME
Fix for the bug #42: point C is not activated, but point C is shown in preview in...
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_DataObject.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "HYDROGUI_DataObject.h"
24
25 #include <HYDROData_Image.h>
26 #include <SUIT_DataObject.h>
27 #include <TDF_Tool.hxx>
28
29 HYDROGUI_DataObject::HYDROGUI_DataObject( SUIT_DataObject* theParent, 
30                                           Handle(HYDROData_Entity) theData,
31                                           const QString& theParentEntry )
32 : CAM_DataObject( theParent ),
33   LightApp_DataObject( theParent ),
34   myData( theData ),
35   myParentEntry( theParentEntry )
36 {
37 }
38
39 QString HYDROGUI_DataObject::entry() const
40 {
41   QString anEntry = HYDROGUI_DataObject::dataObjectEntry( modelObject() );
42   if( isReference() )
43     anEntry.prepend( myParentEntry + "_" );
44   return anEntry;
45 }
46
47 QString HYDROGUI_DataObject::refEntry() const
48 {
49   if( !myParentEntry.isEmpty() )
50     return HYDROGUI_DataObject::dataObjectEntry( modelObject() );
51   return QString();
52 }
53
54 QString HYDROGUI_DataObject::name() const
55 {
56   if( !myData.IsNull() )
57     return myData->GetName();
58   return QString();
59 }
60
61 QFont HYDROGUI_DataObject::font( const int theId ) const
62 {
63   QFont aFont = LightApp_DataObject::font( theId );
64   if( theId == NameId )
65   {
66     Handle(HYDROData_Entity) aDataObject = modelObject();
67     if( !aDataObject.IsNull() && aDataObject->IsMustBeUpdated() )
68       aFont.setItalic( true );
69   }
70   return aFont;
71 }
72
73 QString HYDROGUI_DataObject::dataObjectEntry( const Handle(HYDROData_Entity)& theObject,
74                                               const bool theWithPrefix )
75 {
76   QString aEntryStr = QString::null;
77   if( !theObject.IsNull() )
78   {
79     TCollection_AsciiString aLabEntr;
80     TDF_Tool::Entry( theObject->Label(), aLabEntr );
81     aEntryStr = aLabEntr.ToCString();
82     if( theWithPrefix )
83       aEntryStr.prepend( HYDROGUI_DataObject::entryPrefix() );
84   }
85   return aEntryStr;
86 }
87
88 HYDROGUI_NamedObject::HYDROGUI_NamedObject( SUIT_DataObject* theParent,
89                                             const QString&   theName,
90                                             const QString&   theParentEntry  )
91 : CAM_DataObject( theParent ),
92   LightApp_DataObject( theParent ),
93   myName( theName ),
94   myParentEntry( theParentEntry )
95 {
96 }
97
98 QString HYDROGUI_NamedObject::entry() const
99 {
100   QString anEntry = HYDROGUI_DataObject::entryPrefix() + name();
101   if( !myParentEntry.isEmpty() )
102     anEntry.prepend( myParentEntry + "_" );
103   return anEntry;
104 }
105
106 QString HYDROGUI_NamedObject::name() const
107 {
108   return myName;
109 }
110
111 HYDROGUI_DropTargetObject::HYDROGUI_DropTargetObject( SUIT_DataObject* theParent,
112                                             const QString&   theName,
113                                             const QString&   theParentEntry  )
114 : HYDROGUI_NamedObject( theParent, theName, theParentEntry ), CAM_DataObject( theParent )
115 {
116 }
117