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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 // Author : Julia DOROVSKIKH
26 #include "LIGHTGUI_DataObject.h"
27 #include <SUIT_Session.h>
28 #include <SUIT_ResourceMgr.h>
31 * Class: LIGHTGUI_DataObject
32 * Description: LIGHT module's data object
35 //=================================================================================
36 // function : LIGHTGUI_DataObject()
37 // purpose : default constructor
38 //=================================================================================
39 LIGHTGUI_DataObject::LIGHTGUI_DataObject ( SUIT_DataObject* parent )
40 : CAM_DataObject( parent )
44 //=================================================================================
45 // function : LIGHTGUI_DataObject()
46 // purpose : constructor
47 //=================================================================================
48 LIGHTGUI_DataObject::LIGHTGUI_DataObject ( const QString& line_text, SUIT_DataObject* parent )
49 : CAM_DataObject( parent ),
50 myLineTxt( line_text )
54 //=================================================================================
55 // function : ~LIGHTGUI_DataObject()
56 // purpose : destructor
57 //=================================================================================
58 LIGHTGUI_DataObject::~LIGHTGUI_DataObject()
62 //=================================================================================
64 // purpose : gets an name of the object
65 //=================================================================================
66 QString LIGHTGUI_DataObject::name() const
68 return myLineTxt.stripWhiteSpace().isEmpty() ? QObject::tr( "LIGHT_PARAGRAPH" ) : myLineTxt ;
71 //=================================================================================
73 // purpose : gets an icon for the data object
74 //=================================================================================
75 QPixmap LIGHTGUI_DataObject::icon() const
77 static QPixmap pxp = SUIT_Session::session()->resourceMgr()->loadPixmap( "LIGHT", QObject::tr( "ICON_PARAGRAPH" ), false );
78 static QPixmap pxl = SUIT_Session::session()->resourceMgr()->loadPixmap( "LIGHT", QObject::tr( "ICON_LINE" ), false );
79 return myLineTxt.stripWhiteSpace().isEmpty() ? pxp : pxl;
82 //=================================================================================
83 // function : toolTip()
84 // purpose : gets a tooltip for the object (to be displayed in the Object Browser)
85 //=================================================================================
86 QString LIGHTGUI_DataObject::toolTip() const
88 return lineText().stripWhiteSpace().isEmpty() ?
89 QString( QObject::tr( "LIGHT_PARAGRAPH") + " %1" ).arg( parent()->childPos( this ) + 1 ) :
90 QString( QObject::tr( "LIGHT_LINE" ) + " %1: %2" ).arg( lineNb() ).arg( lineText() );
93 //=================================================================================
94 // function : lineText()
95 // purpose : gets line text
96 //=================================================================================
97 QString LIGHTGUI_DataObject::lineText() const
102 //=================================================================================
103 // function : setLineText()
104 // purpose : sets line text
105 //=================================================================================
106 void LIGHTGUI_DataObject::setLineText( const QString& text )
111 //=================================================================================
112 // function : lineNb()
113 // purpose : gets the line number
114 //=================================================================================
115 int LIGHTGUI_DataObject::lineNb() const
117 if ( level() == 1 ) // root object
121 SUIT_DataObject* o = (SUIT_DataObject*)this;
122 if ( level() == 3 ) {
123 pos += parent()->childPos( this ) + 1;
126 o = o->prevBrother();
128 pos += o->childCount() + 1;
129 o = o->prevBrother();
136 * Class: LIGHTGUI_ModuleObject
137 * Description: LIGHT module's root data object
140 //=================================================================================
141 // function : LIGHTGUI_ModuleObject()
142 // purpose : one more constructor
143 //=================================================================================
144 LIGHTGUI_ModuleObject::LIGHTGUI_ModuleObject ( CAM_DataModel* dm, SUIT_DataObject* parent )
145 : LIGHTGUI_DataObject( parent ),
146 CAM_RootObject( dm, parent ),
147 CAM_DataObject( parent )
151 //=================================================================================
153 // purpose : gets an name of the root object
154 //=================================================================================
155 QString LIGHTGUI_ModuleObject::name() const
157 return QObject::tr( "LIGHT_LIGHT" );
160 //=================================================================================
162 // purpose : gets an icon for the root object
163 //=================================================================================
164 QPixmap LIGHTGUI_ModuleObject::icon() const
166 static QPixmap px = SUIT_Session::session()->resourceMgr()->loadPixmap( "LIGHT", QObject::tr( "ICON_LIGHT" ), false );
170 //=================================================================================
171 // function : toolTip()
172 // purpose : gets a tootip for the root object
173 //=================================================================================
174 QString LIGHTGUI_ModuleObject::toolTip() const
176 return QObject::tr( "LIGHT_ROOT_TOOLTIP" );