1 // Copyright (C) 2007-2010 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 #include "ATOMICGUI_DataObject.h"
23 #include "ATOMICGUI_Data.h"
25 #include <SUIT_Session.h>
26 #include <SUIT_ResourceMgr.h>
27 #include <CAM_DataModel.h>
28 #include <CAM_Module.h>
31 ATOMICGUI_DataObject::ATOMICGUI_DataObject( SUIT_DataObject* parent,
32 ATOMICGUI_AtomicMolecule* mol,
34 : LightApp_DataObject( parent ),
35 CAM_DataObject( parent),
42 ATOMICGUI_DataObject::~ATOMICGUI_DataObject()
46 /*! Returns unique object ID */
47 QString ATOMICGUI_DataObject::entry() const
51 id = QString::number( myMolecule->id() );
53 id += QString( "_%1" ).arg( QString::number( myMolecule->atomId( myIndex ) ) );
54 return QString( "ATOMICGUI_%1" ).arg( id );
57 /*! Returns a name of the Data Object. */
58 QString ATOMICGUI_DataObject::name() const
62 n = myIndex < 0 ? myMolecule->name()
63 : myMolecule->atomName( myIndex );
67 /*! Returns an icon of the Data Object. */
68 QPixmap ATOMICGUI_DataObject::icon(const int column) const
70 static QPixmap pxmole = SUIT_Session::session()->resourceMgr()->loadPixmap( "ATOMIC", QObject::tr( "ICON_MOLECULE" ), false );
71 static QPixmap pxatom = SUIT_Session::session()->resourceMgr()->loadPixmap( "ATOMIC", QObject::tr( "ICON_ATOM" ), false );
72 static QPixmap nullpx;
73 return column == NameId ? ( myIndex < 0 ? pxmole : pxatom ) : nullpx;
76 /*! Returns a tooltip for the object (to be displayed in the Object Browser). */
77 QString ATOMICGUI_DataObject::toolTip(const int) const
81 tt = myIndex < 0 ? QString( QObject::tr( "ATOMIC_MOLECULE" ) + ": %1" ).arg( myMolecule->name() )
82 : QString( QObject::tr( "ATOMIC_ATOM" ) + ": %1: %2,%3,%4" ).
83 arg( myMolecule->atomName( myIndex ) ).
84 arg( myMolecule->atomX( myIndex ) ).
85 arg( myMolecule->atomY( myIndex ) ).
86 arg( myMolecule->atomZ( myIndex ) );
90 /*! Returns true if the Data Object corresponds to a Molecule. */
91 bool ATOMICGUI_DataObject::isMolecule() const
93 return myMolecule && myIndex < 0;
96 /*! Returns true if the Data Object corresponds to an Atom. */
97 bool ATOMICGUI_DataObject::isAtom() const
99 return myMolecule && myIndex >= 0;
103 ATOMICGUI_ModuleObject::ATOMICGUI_ModuleObject( CAM_DataModel* dm, SUIT_DataObject* parent )
104 : ATOMICGUI_DataObject( parent ),
105 LightApp_ModuleObject( dm, parent ),
106 CAM_DataObject( parent )
110 /*! Returns a name of the root object. */
111 QString ATOMICGUI_ModuleObject::name() const
113 return CAM_ModuleObject::name();
116 /*! Returns an icon of the root object. */
117 QPixmap ATOMICGUI_ModuleObject::icon(const int column) const
120 if ( column == NameId && dataModel() ) {
121 QString anIconName = dataModel()->module()->iconName();
122 if ( !anIconName.isEmpty() )
123 px = SUIT_Session::session()->resourceMgr()->loadPixmap( "ATOMIC", anIconName, false );
128 /*! Returns a tooltip of the root object. */
129 QString ATOMICGUI_ModuleObject::toolTip(const int) const
131 return QObject::tr( "ATOMIC_ROOT_TOOLTIP" );