1 // LIGHT : sample (no-corba-engine) SALOME module
3 // Copyright (C) 2003 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
22 // Author : Julia DOROVSKIKH
26 #include "LIGHTGUI_DataObject.h"
27 #include <SUIT_Session.h>
28 #include <SUIT_ResourceMgr.h>
30 #include <CAM_DataModel.h>
31 #include <CAM_Module.h>
34 * Class: LIGHTGUI_DataObject
35 * Description: LIGHT module's data object
38 //=================================================================================
39 // function : LIGHTGUI_DataObject()
40 // purpose : default constructor
41 //=================================================================================
42 LIGHTGUI_DataObject::LIGHTGUI_DataObject ( SUIT_DataObject* parent )
43 : LightApp_DataObject( parent ),
44 CAM_DataObject( parent )
48 //=================================================================================
49 // function : LIGHTGUI_DataObject()
50 // purpose : constructor
51 //=================================================================================
52 LIGHTGUI_DataObject::LIGHTGUI_DataObject ( const QString& line_text, SUIT_DataObject* parent )
53 : LightApp_DataObject( parent ),
54 myLineTxt( line_text ),
55 CAM_DataObject( parent)
59 //=================================================================================
60 // function : ~LIGHTGUI_DataObject()
61 // purpose : destructor
62 //=================================================================================
63 LIGHTGUI_DataObject::~LIGHTGUI_DataObject()
67 //=================================================================================
69 // purpose : Gets object ID. retval QString
70 //=================================================================================
71 QString LIGHTGUI_DataObject::entry() const
73 QString aStr = QString("LIGHTGUI_%1").arg(lineNb());
77 //=================================================================================
79 // purpose : gets an name of the object
80 //=================================================================================
81 QString LIGHTGUI_DataObject::name() const
83 return myLineTxt.stripWhiteSpace().isEmpty() ? QObject::tr( "LIGHT_PARAGRAPH" ) : myLineTxt ;
86 //=================================================================================
88 // purpose : gets an icon for the data object
89 //=================================================================================
90 QPixmap LIGHTGUI_DataObject::icon() const
92 static QPixmap pxp = SUIT_Session::session()->resourceMgr()->loadPixmap( "LIGHT", QObject::tr( "ICON_PARAGRAPH" ), false );
93 static QPixmap pxl = SUIT_Session::session()->resourceMgr()->loadPixmap( "LIGHT", QObject::tr( "ICON_LINE" ), false );
94 return myLineTxt.stripWhiteSpace().isEmpty() ? pxp : pxl;
97 //=================================================================================
98 // function : toolTip()
99 // purpose : gets a tooltip for the object (to be displayed in the Object Browser)
100 //=================================================================================
101 QString LIGHTGUI_DataObject::toolTip() const
103 return lineText().stripWhiteSpace().isEmpty() ?
104 QString( QObject::tr( "LIGHT_PARAGRAPH") + " %1" ).arg( parent()->childPos( this ) + 1 ) :
105 QString( QObject::tr( "LIGHT_LINE" ) + " %1: %2" ).arg( lineNb() ).arg( lineText() );
108 //=================================================================================
109 // function : lineText()
110 // purpose : gets line text
111 //=================================================================================
112 QString LIGHTGUI_DataObject::lineText() const
117 //=================================================================================
118 // function : setLineText()
119 // purpose : sets line text
120 //=================================================================================
121 void LIGHTGUI_DataObject::setLineText( const QString& text )
126 //=================================================================================
127 // function : lineNb()
128 // purpose : gets the line number
129 //=================================================================================
130 int LIGHTGUI_DataObject::lineNb() const
132 if ( level() == 1 ) // root object
136 SUIT_DataObject* o = (SUIT_DataObject*)this;
137 if ( level() == 3 ) {
138 pos += parent()->childPos( this ) + 1;
141 o = o->prevBrother();
143 pos += o->childCount() + 1;
144 o = o->prevBrother();
151 * Class: LIGHTGUI_ModuleObject
152 * Description: LIGHT module's root data object
155 //=================================================================================
156 // function : LIGHTGUI_ModuleObject()
157 // purpose : one more constructor
158 //=================================================================================
159 LIGHTGUI_ModuleObject::LIGHTGUI_ModuleObject ( CAM_DataModel* dm, SUIT_DataObject* parent )
160 : LIGHTGUI_DataObject( parent ),
161 LightApp_ModuleObject(dm, parent),
162 CAM_DataObject( parent )
166 //=================================================================================
168 // purpose : gets an name of the root object
169 //=================================================================================
170 QString LIGHTGUI_ModuleObject::name() const
172 return CAM_RootObject::name();
175 //=================================================================================
177 // purpose : gets an icon for the root object
178 //=================================================================================
179 QPixmap LIGHTGUI_ModuleObject::icon() const
183 QString anIconName = dataModel()->module()->iconName();
184 if (!anIconName.isEmpty())
185 px = SUIT_Session::session()->resourceMgr()->loadPixmap( "LIGHT", anIconName, false );
190 //=================================================================================
191 // function : toolTip()
192 // purpose : gets a tootip for the root object
193 //=================================================================================
194 QString LIGHTGUI_ModuleObject::toolTip() const
196 return QObject::tr( "LIGHT_ROOT_TOOLTIP" );