X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FCAM%2FCAM_DataObject.cxx;h=d36833034c3087cd3b136845c29a51141d60df4a;hb=257308ab92a2ecccb38294bf15b690580d6cbebc;hp=c2069fdffee78e4f9bde409caa5c4ec4d40dd84e;hpb=077ca08b7937cca4b459b8a3b7edd51bafc770d2;p=modules%2Fgui.git diff --git a/src/CAM/CAM_DataObject.cxx b/src/CAM/CAM_DataObject.cxx index c2069fdff..d36833034 100755 --- a/src/CAM/CAM_DataObject.cxx +++ b/src/CAM/CAM_DataObject.cxx @@ -1,43 +1,184 @@ +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + #include "CAM_DataObject.h" #include "CAM_Module.h" #include "CAM_DataModel.h" -/*!Constructor. Sets parent object.*/ +#include + +/*! + \class CAM_DataObject + \brief CAM-based implementation of the data object. + + In addition to base implementation provides integration + with CAM_DataModel. +*/ + +/*! + \brief Constructor. + \param parent parent data object +*/ CAM_DataObject::CAM_DataObject( SUIT_DataObject* parent ) : SUIT_DataObject( parent ) { } -/*!Destructor.Do nothing*/ +/*! + \brief Destructor. + + Does nothing. +*/ CAM_DataObject::~CAM_DataObject() { } -/*!Get module. - *\retval const CAM_Module pointer - module - */ +/*! + \brief Get CAM module. + \return parent module object pointer +*/ CAM_Module* CAM_DataObject::module() const { - CAM_Module* mod = 0; - - CAM_DataModel* data = dataModel(); - if ( data ) - mod = data->module(); - - return mod; + CAM_DataModel* dm = dataModel(); + return dm ? dm->module() : 0; } -/*!Get data model. - *Return 0 - if no parent obbject. - *\retval const CAM_DataModel pointer - data model - */ +/*! + \brief Get CAM data model. + \return data model or 0 if it is not set + \sa CAM_ModuleObject class +*/ CAM_DataModel* CAM_DataObject::dataModel() const { CAM_DataObject* parentObj = dynamic_cast( parent() ); + return parentObj ? parentObj->dataModel() : 0; +} + +/*! + \class CAM_ModuleObject + \brief CAM data model root object. + + This class is intended for optimized access to CAM_DataModel instance + from CAM_DataObject instances. + + To take advantage of this class in a specific application, + custom data model root object class should be derived from both CAM_ModuleObject + and application-specific DataObject implementation using virtual inheritance. +*/ + +/*! + \brief Constructor. + \param parent parent data object +*/ +CAM_ModuleObject::CAM_ModuleObject( SUIT_DataObject* parent ) +: CAM_DataObject( parent ), + myDataModel( 0 ) +{ +} + +/*! + \brief Constructor. + \param data data model + \param parent parent data object +*/ +CAM_ModuleObject::CAM_ModuleObject( CAM_DataModel* data, SUIT_DataObject* parent ) +: CAM_DataObject( parent ), + myDataModel( data ) +{ +} + +/*! + \brief Destructor. + + Does nothing. +*/ +CAM_ModuleObject::~CAM_ModuleObject() +{ +} - if ( !parentObj ) - return 0; +/*! + \brief Get root object name. - return parentObj->dataModel(); + If the data model is set, this method returns module name. + Otherwise returns empty string. + + \return root object name +*/ +QString CAM_ModuleObject::name() const +{ + return myDataModel ? myDataModel->module()->moduleName() : QString(); +} + +/*! + \brief Get data object icon for the specified column. + + The parameter \a id specifies the column identificator + + \param id column id + \return object icon for the specified column +*/ +QPixmap CAM_ModuleObject::icon( const int id ) const +{ + QPixmap p; + // show icon only for the "Name" column + if ( id == NameId && dataModel() && dataModel()->module() ) + p = dataModel()->module()->moduleIcon(); + if ( !p.isNull() ) + p = Qtx::scaleIcon( p, 16 ); + return p; +} + +/*! + \brief Get data object tooltip for the specified column. + + The parameter \a id specifies the column identificator + + \param id column id + \return object tooltip for the specified column +*/ +QString CAM_ModuleObject::toolTip( const int /*id*/ ) const +{ + // show the same tooltip for all columns + QString tip; + if ( dataModel() && dataModel()->module() ) + tip = QObject::tr( "MODULE_ROOT_OBJECT_TOOLTIP" ).arg( dataModel()->module()->moduleName() ); + return tip; +} + +/*! + \brief Get data model. + \return data model pointer or 0 if it is not set +*/ +CAM_DataModel* CAM_ModuleObject::dataModel() const +{ + return myDataModel; +} + +/*! + \brief Set data model. + \param dm data model +*/ +void CAM_ModuleObject::setDataModel( CAM_DataModel* dm ) +{ + myDataModel = dm; }