1 // Copyright (C) 2007-2012 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.
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 // File : SalomePyQt.cxx
21 // Author : Roman NIKOLAEV, Open CASCADE S.A.S. (roman.nikolaev@opencascade.com)
23 #include <SUIT_Session.h>
24 #include <LightApp_Application.h>
25 #include <LightApp_Module.h>
26 #include <SALOME_Event.h>
29 #include "ATOMICGUI_Data.h"
30 #include "ATOMICGUI_DataModel.h"
32 class TCreateMoleculeEvent: public SALOME_Event
36 typedef QString TResult;
39 TCreateMoleculeEvent(const QString& name) : myResult(""), myName(name) {}
40 virtual void Execute()
42 if ( !SUIT_Session::session() )
44 LightApp_Application* app = dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() );
48 LightApp_Module* module = dynamic_cast<LightApp_Module*>( app->module("Atomic") );
52 ATOMICGUI_DataModel* model = dynamic_cast<ATOMICGUI_DataModel*>(module->dataModel());
56 myResult = model->createMolecule();
57 model->renameObj(myResult,myName);
61 class TAddAtomEvent: public SALOME_Event
68 TAddAtomEvent(const QString& id,
72 const double z) : myId(id), myName(name), myX(x), myY(y), myZ(z) {}
73 virtual void Execute()
75 if ( !SUIT_Session::session() )
77 LightApp_Application* app = dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() );
81 LightApp_Module* module = dynamic_cast<LightApp_Module*>( app->module("Atomic") );
85 ATOMICGUI_DataModel* model = dynamic_cast<ATOMICGUI_DataModel*>(module->dataModel());
89 model->addAtom(myId,myName,myX,myY,myZ);
94 AtomicMolecule::AtomicMolecule( const QString& name )
96 myId = ProcessEvent( new TCreateMoleculeEvent( name ) );
99 void AtomicMolecule::addAtom( const QString& atom, const double x, const double y, const double z ){
100 ProcessVoidEvent( new TAddAtomEvent( myId, atom, x, y, x ) );