1 // Copyright (C) 2007-2024 CEA, EDF, 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_BorrowedDataObjectLight.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_BorrowedDataObjectLight
36 * Description: LIGHT PYTHON module's Borrowed data object: reference objects from other modules.
37 * Used to propagate selection in a light module client of other modules publishing objects in study.
38 * (copied from SALOME_PYQT_DataObjectLight)
41 //=================================================================================
42 // function : SALOME_PYQT_BorrowedDataObjectLight()
43 // purpose : constructor
44 //=================================================================================
45 SALOME_PYQT_BorrowedDataObjectLight::SALOME_PYQT_BorrowedDataObjectLight ( QString entry )
47 LightApp_DataObject( 0 )
53 //=================================================================================
54 // function : SALOME_PYQT_BorrowedDataObjectLight()
55 // purpose : destructor
56 //=================================================================================
57 SALOME_PYQT_BorrowedDataObjectLight::~SALOME_PYQT_BorrowedDataObjectLight()
62 //=================================================================================
63 // function : SALOME_PYQT_BorrowedDataObjectLight::entry()
64 // purpose : return entry of object
65 //=================================================================================
66 QString SALOME_PYQT_BorrowedDataObjectLight::entry() const
71 //=================================================================================
72 // function : SALOME_PYQT_BorrowedDataObjectLight::refEntry()
73 // purpose : return entry of the data object referenced by this one (if any)
74 //=================================================================================
75 QString SALOME_PYQT_BorrowedDataObjectLight::refEntry() const
80 //=================================================================================
81 // function : SALOME_PYQT_BorrowedDataObjectLight::setRefEntry()
82 // purpose : sets entry of the data object referenced by this one
83 //=================================================================================
84 void SALOME_PYQT_BorrowedDataObjectLight::setRefEntry( const QString& refEntry )
86 myRefEntry = refEntry;
89 //=================================================================================
90 // function : SALOME_PYQT_BorrowedDataObjectLight::name()
91 // purpose : return name of object
92 //=================================================================================
93 QString SALOME_PYQT_BorrowedDataObjectLight::name() const
98 //=================================================================================
99 // function : SALOME_PYQT_BorrowedDataObjectLight::icon()
100 // purpose : return icon of object
101 //=================================================================================
102 QPixmap SALOME_PYQT_BorrowedDataObjectLight::icon(const int index) const
107 return LightApp_DataObject::icon( index );
111 //=================================================================================
112 // function : SALOME_PYQT_BorrowedDataObjectLight::toolTip()
113 // purpose : return toolTip of object
114 //=================================================================================
115 QString SALOME_PYQT_BorrowedDataObjectLight::toolTip(const int /*index*/) const
120 //=================================================================================
121 // function : SALOME_PYQT_BorrowedDataObjectLight::toolTip()
122 // purpose : return toolTip of object
123 //=================================================================================
124 QColor SALOME_PYQT_BorrowedDataObjectLight::color( const ColorRole role, const int id ) const
132 if ( !isReference() )
140 // Issue 21379: LightApp_DataObject::color() defines colors for valid references
142 c = LightApp_DataObject::color( role, id );
147 bool SALOME_PYQT_BorrowedDataObjectLight::setName(const QString& name)
153 void SALOME_PYQT_BorrowedDataObjectLight::setIcon(const QString& iconname)
155 if(!iconname.isEmpty()) {
156 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() );
158 QString modulename = anApp->activeModule()->name();
159 if(!modulename.isEmpty())
161 myIcon = SUIT_Session::session()->resourceMgr()->loadPixmap(modulename,
162 QObject::tr(iconname.toLatin1()));
168 void SALOME_PYQT_BorrowedDataObjectLight::setToolTip(const QString& tooltip)
173 void SALOME_PYQT_BorrowedDataObjectLight::setColor(const QColor& color)