1 // Copyright (C) 2007-2016 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 "ATOMSOLVGUI_DataModel.h"
21 #include "ATOMSOLVGUI_DataObject.h"
22 #include "ATOMSOLVGUI.h"
24 #include <LightApp_Study.h>
26 #include <CAM_Module.h>
27 #include <CAM_Application.h>
30 ATOMSOLVGUI_DataModel::ATOMSOLVGUI_DataModel( CAM_Module* module )
31 : LightApp_DataModel( module )
36 ATOMSOLVGUI_DataModel::~ATOMSOLVGUI_DataModel()
40 /*! Called on update of the structure of Data Objects */
41 void ATOMSOLVGUI_DataModel::build()
43 ATOMSOLVGUI_ModuleObject* modelRoot = dynamic_cast<ATOMSOLVGUI_ModuleObject*>( root() );
44 if( !modelRoot ) { // root is not set yet
45 modelRoot = new ATOMSOLVGUI_ModuleObject( this, 0 );
49 // create 'molecule' objects under model root object and 'atom' objects under 'molecule'-s
50 ATOMSOLV_ORB::ATOMSOLV_Gen_var engine = ATOMSOLVGUI::GetATOMSOLVGen();
51 if ( !CORBA::is_nil( engine ) ) {
52 ATOMSOLV_ORB::TMoleculeList_var molecules;
53 if ( !engine->getData( molecules ) ) {
54 // printf( " -- DataModel: getData() returned false! \n" );
57 for ( int i = 0, n = molecules->length(); i < n; i++ ) {
58 ATOMSOLVGUI_DataObject* molDO = new ATOMSOLVGUI_DataObject ( modelRoot, i );
59 const ATOMSOLV_ORB::TMolecule& mol = molecules[i];
60 const int atoms = mol.molecule->getNbAtoms();
61 for ( int j = 0; j < atoms; j++ )
62 new ATOMSOLVGUI_DataObject ( molDO, i, j );