1 // Copyright (C) 2007-2023 CEA/DEN, EDF R&D, 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 #include "ATOMICGUI_DataObject.h"
21 #include "ATOMICGUI_Data.h"
23 #include <SUIT_Session.h>
24 #include <SUIT_ResourceMgr.h>
25 #include <CAM_DataModel.h>
26 #include <CAM_Module.h>
29 ATOMICGUI_DataObject::ATOMICGUI_DataObject( SUIT_DataObject* parent,
30 ATOMICGUI_AtomicMolecule* mol,
32 : LightApp_DataObject( parent ),
33 CAM_DataObject( parent),
40 ATOMICGUI_DataObject::~ATOMICGUI_DataObject()
44 /*! Returns unique object ID */
45 QString ATOMICGUI_DataObject::entry() const
49 id = QString::number( myMolecule->id() );
51 id += QString( "_%1" ).arg( QString::number( myMolecule->atomId( myIndex ) ) );
52 return QString( "ATOMICGUI_%1" ).arg( id );
55 /*! Returns a name of the Data Object. */
56 QString ATOMICGUI_DataObject::name() const
60 n = myIndex < 0 ? myMolecule->name()
61 : myMolecule->atomName( myIndex );
65 /*! Returns an icon of the Data Object. */
66 QPixmap ATOMICGUI_DataObject::icon(const int column) const
68 static QPixmap pxmole = SUIT_Session::session()->resourceMgr()->loadPixmap( "ATOMIC", QObject::tr( "ICON_MOLECULE" ), false );
69 static QPixmap pxatom = SUIT_Session::session()->resourceMgr()->loadPixmap( "ATOMIC", QObject::tr( "ICON_ATOM" ), false );
70 static QPixmap nullpx;
71 return column == NameId ? ( myIndex < 0 ? pxmole : pxatom ) : nullpx;
74 /*! Returns a tooltip for the object (to be displayed in the Object Browser). */
75 QString ATOMICGUI_DataObject::toolTip(const int) const
79 tt = myIndex < 0 ? QString( QObject::tr( "ATOMIC_MOLECULE" ) + ": %1" ).arg( myMolecule->name() )
80 : QString( QObject::tr( "ATOMIC_ATOM" ) + ": %1: %2,%3,%4" ).
81 arg( myMolecule->atomName( myIndex ) ).
82 arg( myMolecule->atomX( myIndex ) ).
83 arg( myMolecule->atomY( myIndex ) ).
84 arg( myMolecule->atomZ( myIndex ) );
88 /*! Returns true if the Data Object corresponds to a Molecule. */
89 bool ATOMICGUI_DataObject::isMolecule() const
91 return myMolecule && myIndex < 0;
94 /*! Returns true if the Data Object corresponds to an Atom. */
95 bool ATOMICGUI_DataObject::isAtom() const
97 return myMolecule && myIndex >= 0;
101 ATOMICGUI_ModuleObject::ATOMICGUI_ModuleObject( CAM_DataModel* dm, SUIT_DataObject* parent )
102 : ATOMICGUI_DataObject( parent ),
103 LightApp_ModuleObject( dm, parent ),
104 CAM_DataObject( parent )
108 /*! Returns a name of the root object. */
109 QString ATOMICGUI_ModuleObject::name() const
111 return CAM_ModuleObject::name();
114 /*! Returns an icon of the root object. */
115 QPixmap ATOMICGUI_ModuleObject::icon(const int column) const
118 if ( column == NameId && dataModel() ) {
119 QString anIconName = dataModel()->module()->iconName();
120 if ( !anIconName.isEmpty() )
121 px = SUIT_Session::session()->resourceMgr()->loadPixmap( "ATOMIC", anIconName, false );
126 /*! Returns a tooltip of the root object. */
127 QString ATOMICGUI_ModuleObject::toolTip(const int) const
129 return QObject::tr( "ATOMIC_ROOT_TOOLTIP" );