1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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 #include "CAM_DataObject.h"
24 #include "CAM_Module.h"
25 #include "CAM_DataModel.h"
31 \brief CAM-based implementation of the data object.
33 In addition to base implementation provides integration
39 \param parent parent data object
41 CAM_DataObject::CAM_DataObject( SUIT_DataObject* parent )
42 : SUIT_DataObject( parent )
51 CAM_DataObject::~CAM_DataObject()
56 \brief Get CAM module.
57 \return parent module object pointer
59 CAM_Module* CAM_DataObject::module() const
61 CAM_DataModel* dm = dataModel();
62 return dm ? dm->module() : 0;
66 \brief Get CAM data model.
67 \return data model or 0 if it is not set
68 \sa CAM_ModuleObject class
70 CAM_DataModel* CAM_DataObject::dataModel() const
72 CAM_DataObject* parentObj = dynamic_cast<CAM_DataObject*>( parent() );
73 return parentObj ? parentObj->dataModel() : 0;
77 \class CAM_ModuleObject
78 \brief CAM data model root object.
80 This class is intended for optimized access to CAM_DataModel instance
81 from CAM_DataObject instances.
83 To take advantage of this class in a specific application,
84 custom data model root object class should be derived from both CAM_ModuleObject
85 and application-specific DataObject implementation using virtual inheritance.
90 \param parent parent data object
92 CAM_ModuleObject::CAM_ModuleObject( SUIT_DataObject* parent )
93 : CAM_DataObject( parent ),
100 \param data data model
101 \param parent parent data object
103 CAM_ModuleObject::CAM_ModuleObject( CAM_DataModel* data, SUIT_DataObject* parent )
104 : CAM_DataObject( parent ),
114 CAM_ModuleObject::~CAM_ModuleObject()
119 \brief Get root object name.
121 If the data model is set, this method returns module name.
122 Otherwise returns empty string.
124 \return root object name
126 QString CAM_ModuleObject::name() const
128 return myDataModel ? myDataModel->module()->moduleName() : QString();
132 \brief Get data object icon for the specified column.
134 The parameter \a id specifies the column identificator
137 \return object icon for the specified column
139 QPixmap CAM_ModuleObject::icon( const int id ) const
142 // show icon only for the "Name" column
143 if ( id == NameId && dataModel() && dataModel()->module() )
144 p = dataModel()->module()->moduleIcon();
146 p = Qtx::scaleIcon( p, 16 );
151 \brief Get data object tooltip for the specified column.
153 The parameter \a id specifies the column identificator
156 \return object tooltip for the specified column
158 QString CAM_ModuleObject::toolTip( const int /*id*/ ) const
160 // show the same tooltip for all columns
162 if ( dataModel() && dataModel()->module() )
163 tip = QObject::tr( "MODULE_ROOT_OBJECT_TOOLTIP" ).arg( dataModel()->module()->moduleName() );
168 \brief Get data model.
169 \return data model pointer or 0 if it is not set
171 CAM_DataModel* CAM_ModuleObject::dataModel() const
177 \brief Set data model.
180 void CAM_ModuleObject::setDataModel( CAM_DataModel* dm )