1 // Copyright (C) 2007-2011 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SalomePyQt.cxx
24 // Author : Roman NIKOLAEV, Open CASCADE S.A.S. (roman.nikolaev@opencascade.com)
26 #include <SUIT_Session.h>
27 #include <LightApp_Application.h>
28 #include <LightApp_Module.h>
29 #include <SALOME_Event.h>
32 #include "ATOMICGUI_Data.h"
33 #include "ATOMICGUI_DataModel.h"
35 class TCreateMoleculeEvent: public SALOME_Event
39 typedef QString TResult;
42 TCreateMoleculeEvent(const QString& name) : myResult(""), myName(name) {}
43 virtual void Execute()
45 if ( !SUIT_Session::session() )
47 LightApp_Application* app = dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() );
51 LightApp_Module* module = dynamic_cast<LightApp_Module*>( app->module("Atomic") );
55 ATOMICGUI_DataModel* model = dynamic_cast<ATOMICGUI_DataModel*>(module->dataModel());
59 myResult = model->createMolecule();
60 model->renameObj(myResult,myName);
64 class TAddAtomEvent: public SALOME_Event
71 TAddAtomEvent(const QString& id,
75 const double z) : myId(id), myName(name), myX(x), myY(y), myZ(z) {}
76 virtual void Execute()
78 if ( !SUIT_Session::session() )
80 LightApp_Application* app = dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() );
84 LightApp_Module* module = dynamic_cast<LightApp_Module*>( app->module("Atomic") );
88 ATOMICGUI_DataModel* model = dynamic_cast<ATOMICGUI_DataModel*>(module->dataModel());
92 model->addAtom(myId,myName,myX,myY,myZ);
97 AtomicMolecule::AtomicMolecule( const QString& name )
99 myId = ProcessEvent( new TCreateMoleculeEvent( name ) );
102 void AtomicMolecule::addAtom( const QString& atom, const double x, const double y, const double z ){
103 ProcessVoidEvent( new TAddAtomEvent( myId, atom, x, y, x ) );