1 // Copyright (C) 2007-2013 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
23 #include "CAM_DataObject.h"
25 #include "CAM_Module.h"
26 #include "CAM_DataModel.h"
32 \brief CAM-based implementation of the data object.
34 In addition to base implementation provides integration
40 \param parent parent data object
42 CAM_DataObject::CAM_DataObject( SUIT_DataObject* parent )
43 : SUIT_DataObject( parent )
52 CAM_DataObject::~CAM_DataObject()
57 \brief Get CAM module.
58 \return parent module object pointer
60 CAM_Module* CAM_DataObject::module() const
62 CAM_DataModel* dm = dataModel();
63 return dm ? dm->module() : 0;
67 \brief Get CAM data model.
68 \return data model or 0 if it is not set
69 \sa CAM_ModuleObject class
71 CAM_DataModel* CAM_DataObject::dataModel() const
73 CAM_DataObject* parentObj = dynamic_cast<CAM_DataObject*>( parent() );
74 return parentObj ? parentObj->dataModel() : 0;
78 \class CAM_ModuleObject
79 \brief CAM data model root object.
81 This class is intended for optimized access to CAM_DataModel instance
82 from CAM_DataObject instances.
84 To take advantage of this class in a specific application,
85 custom data model root object class should be derived from both CAM_ModuleObject
86 and application-specific DataObject implementation using virtual inheritance.
91 \param parent parent data object
93 CAM_ModuleObject::CAM_ModuleObject( SUIT_DataObject* parent )
94 : CAM_DataObject( parent ),
101 \param data data model
102 \param parent parent data object
104 CAM_ModuleObject::CAM_ModuleObject( CAM_DataModel* data, SUIT_DataObject* parent )
105 : CAM_DataObject( parent ),
115 CAM_ModuleObject::~CAM_ModuleObject()
120 \brief Get root object name.
122 If the data model is set, this method returns module name.
123 Otherwise returns empty string.
125 \return root object name
127 QString CAM_ModuleObject::name() const
129 return myDataModel ? myDataModel->module()->moduleName() : QString();
133 \brief Get data object icon for the specified column.
135 The parameter \a id specifies the column identificator
138 \return object icon for the specified column
140 QPixmap CAM_ModuleObject::icon( const int id ) const
143 // show icon only for the "Name" column
144 if ( id == NameId && dataModel() && dataModel()->module() )
145 p = dataModel()->module()->moduleIcon();
147 p = Qtx::scaleIcon( p, 16 );
152 \brief Get data object tooltip for the specified column.
154 The parameter \a id specifies the column identificator
157 \return object tooltip for the specified column
159 QString CAM_ModuleObject::toolTip( const int /*id*/ ) const
161 // show the same tooltip for all columns
163 if ( dataModel() && dataModel()->module() )
164 tip = QObject::tr( "MODULE_ROOT_OBJECT_TOOLTIP" ).arg( dataModel()->module()->moduleName() );
169 \brief Get data model.
170 \return data model pointer or 0 if it is not set
172 CAM_DataModel* CAM_ModuleObject::dataModel() const
178 \brief Set data model.
181 void CAM_ModuleObject::setDataModel( CAM_DataModel* dm )