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 : LightApp_DataObject( parent ),
41 CAM_DataObject( parent )
45 //=================================================================================
46 // function : LIGHTGUI_DataObject()
47 // purpose : constructor
48 //=================================================================================
49 LIGHTGUI_DataObject::LIGHTGUI_DataObject ( const QString& line_text, SUIT_DataObject* parent )
50 : LightApp_DataObject( parent ),
51 myLineTxt( line_text ),
52 CAM_DataObject( parent)
56 //=================================================================================
57 // function : ~LIGHTGUI_DataObject()
58 // purpose : destructor
59 //=================================================================================
60 LIGHTGUI_DataObject::~LIGHTGUI_DataObject()
67 QString LIGHTGUI_DataObject::entry() const
69 QString aStr = QString("LIGHTGUI_%1").arg(lineNb());
73 //=================================================================================
75 // purpose : gets an name of the object
76 //=================================================================================
77 QString LIGHTGUI_DataObject::name() const
79 return myLineTxt.stripWhiteSpace().isEmpty() ? QObject::tr( "LIGHT_PARAGRAPH" ) : myLineTxt ;
82 //=================================================================================
84 // purpose : gets an icon for the data object
85 //=================================================================================
86 QPixmap LIGHTGUI_DataObject::icon() const
88 static QPixmap pxp = SUIT_Session::session()->resourceMgr()->loadPixmap( "LIGHT", QObject::tr( "ICON_PARAGRAPH" ), false );
89 static QPixmap pxl = SUIT_Session::session()->resourceMgr()->loadPixmap( "LIGHT", QObject::tr( "ICON_LINE" ), false );
90 return myLineTxt.stripWhiteSpace().isEmpty() ? pxp : pxl;
93 //=================================================================================
94 // function : toolTip()
95 // purpose : gets a tooltip for the object (to be displayed in the Object Browser)
96 //=================================================================================
97 QString LIGHTGUI_DataObject::toolTip() const
99 return lineText().stripWhiteSpace().isEmpty() ?
100 QString( QObject::tr( "LIGHT_PARAGRAPH") + " %1" ).arg( parent()->childPos( this ) + 1 ) :
101 QString( QObject::tr( "LIGHT_LINE" ) + " %1: %2" ).arg( lineNb() ).arg( lineText() );
104 //=================================================================================
105 // function : lineText()
106 // purpose : gets line text
107 //=================================================================================
108 QString LIGHTGUI_DataObject::lineText() const
113 //=================================================================================
114 // function : setLineText()
115 // purpose : sets line text
116 //=================================================================================
117 void LIGHTGUI_DataObject::setLineText( const QString& text )
122 //=================================================================================
123 // function : lineNb()
124 // purpose : gets the line number
125 //=================================================================================
126 int LIGHTGUI_DataObject::lineNb() const
128 if ( level() == 1 ) // root object
132 SUIT_DataObject* o = (SUIT_DataObject*)this;
133 if ( level() == 3 ) {
134 pos += parent()->childPos( this ) + 1;
137 o = o->prevBrother();
139 pos += o->childCount() + 1;
140 o = o->prevBrother();
147 * Class: LIGHTGUI_ModuleObject
148 * Description: LIGHT module's root data object
151 //=================================================================================
152 // function : LIGHTGUI_ModuleObject()
153 // purpose : one more constructor
154 //=================================================================================
155 LIGHTGUI_ModuleObject::LIGHTGUI_ModuleObject ( CAM_DataModel* dm, SUIT_DataObject* parent )
156 : LIGHTGUI_DataObject( parent ),
157 CAM_RootObject( dm, parent ),
158 CAM_DataObject( parent )
162 //=================================================================================
164 // purpose : gets an name of the root object
165 //=================================================================================
166 QString LIGHTGUI_ModuleObject::name() const
168 return QObject::tr( "LIGHT_LIGHT" );
171 //=================================================================================
173 // purpose : gets an icon for the root object
174 //=================================================================================
175 QPixmap LIGHTGUI_ModuleObject::icon() const
177 static QPixmap px = SUIT_Session::session()->resourceMgr()->loadPixmap( "LIGHT", QObject::tr( "ICON_LIGHT" ), false );
181 //=================================================================================
182 // function : toolTip()
183 // purpose : gets a tootip for the root object
184 //=================================================================================
185 QString LIGHTGUI_ModuleObject::toolTip() const
187 return QObject::tr( "LIGHT_ROOT_TOOLTIP" );