1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // Author : Roman NIKOLAEV, Open CASCADE S.A.S. (roman.nikolaev@opencascade.com)
23 #include "SALOME_PYQT_DataObjectLight.h"
24 #include <LightApp_Application.h>
25 #include <SUIT_Session.h>
26 #include <utilities.h>
27 #include <SUIT_ResourceMgr.h>
30 #include <CAM_DataModel.h>
31 #include <CAM_Module.h>
35 * Class: SALOME_PYQT_DataObjectLight
36 * Description: LIGHT PYTHON module's data object
41 //=================================================================================
42 // function : SALOME_PYQT_DataObjectLight()
43 // purpose : constructor
44 //=================================================================================
45 SALOME_PYQT_DataObjectLight::SALOME_PYQT_DataObjectLight ( SUIT_DataObject* parent )
46 : CAM_DataObject(parent),
47 LightApp_DataObject( parent )
51 myEntry = QString("PYLIGHT_OBJ_%1").arg(_ID);
54 //=================================================================================
55 // function : SALOME_PYQT_DataObjectLight()
56 // purpose : destructor
57 //=================================================================================
58 SALOME_PYQT_DataObjectLight::~SALOME_PYQT_DataObjectLight()
63 //=================================================================================
64 // function : SALOME_PYQT_DataObjectLight::entry()
65 // purpose : return entry of object
66 //=================================================================================
67 QString SALOME_PYQT_DataObjectLight::entry() const
72 //=================================================================================
73 // function : SALOME_PYQT_DataObjectLight::refEntry()
74 // purpose : return entry of the data object referenced by this one (if any)
75 //=================================================================================
76 QString SALOME_PYQT_DataObjectLight::refEntry() const
81 //=================================================================================
82 // function : SALOME_PYQT_DataObjectLight::setRefEntry()
83 // purpose : sets entry of the data object referenced by this one
84 //=================================================================================
85 void SALOME_PYQT_DataObjectLight::setRefEntry( const QString& refEntry )
87 myRefEntry = refEntry;
90 //=================================================================================
91 // function : SALOME_PYQT_DataObjectLight::name()
92 // purpose : return name of object
93 //=================================================================================
94 QString SALOME_PYQT_DataObjectLight::name() const
99 //=================================================================================
100 // function : SALOME_PYQT_DataObjectLight::icon()
101 // purpose : return icon of object
102 //=================================================================================
103 QPixmap SALOME_PYQT_DataObjectLight::icon(const int index) const
108 return LightApp_DataObject::icon( index );
112 //=================================================================================
113 // function : SALOME_PYQT_DataObjectLight::toolTip()
114 // purpose : return toolTip of object
115 //=================================================================================
116 QString SALOME_PYQT_DataObjectLight::toolTip(const int index) const
121 //=================================================================================
122 // function : SALOME_PYQT_DataObjectLight::toolTip()
123 // purpose : return toolTip of object
124 //=================================================================================
125 QColor SALOME_PYQT_DataObjectLight::color( const ColorRole role, const int id ) const
133 if ( !isReference() )
141 // Issue 21379: LightApp_DataObject::color() defines colors for valid references
143 c = LightApp_DataObject::color( role, id );
148 bool SALOME_PYQT_DataObjectLight::setName(const QString& name)
154 void SALOME_PYQT_DataObjectLight::setIcon(const QString& iconname)
156 if(!iconname.isEmpty()) {
157 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() );
159 QString modulename = anApp->activeModule()->name();
160 if(!modulename.isEmpty())
162 myIcon = SUIT_Session::session()->resourceMgr()->loadPixmap(modulename,
163 QObject::tr(iconname.toLatin1()));
169 void SALOME_PYQT_DataObjectLight::setToolTip(const QString& tooltip)
174 void SALOME_PYQT_DataObjectLight::setColor(const QColor& color)