1 // Copyright (C) 2006-2013 CEA/DEN, EDF R&D
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 #include "YACSGUI_Swig.hxx"
23 #include "SUIT_Desktop.h"
24 #include "SUIT_Session.h"
26 #include "SalomeApp_Application.h"
27 #include "SalomeApp_Study.h"
29 #include "SALOME_Event.h"
30 #include "Yacsgui.hxx"
33 * \brief Interface to YACS GUI
35 * The YACS_Swig serves as an interface to the YACS GUI to activate it
36 * or to load a schema.
37 * It is wrapped with SWIG so it can be used from python to drive YACS GUI.
40 YACS_Swig::YACS_Swig()
44 YACS_Swig::~YACS_Swig()
50 * \param module the module name (default "YACS")
52 void YACS_Swig::activate(const std::string& module)
54 class TEvent: public SALOME_Event
59 TEvent(YACS_Swig* obj,const std::string& module) {_obj=obj;_module=module;};
60 virtual void Execute() {
61 _obj->real_activate(_module);
64 ProcessVoidEvent(new TEvent(this,module));
67 void YACS_Swig::real_activate(const std::string& module)
69 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
71 SalomeApp_Study* ActiveStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
72 if (!ActiveStudy) return;
73 app->activateModule(QString::fromStdString(module));
76 //! Load a schema in edit mode or in run mode
78 * \param filename the schema file to load
79 * \param edit the loading mode. true for edition (default), false for run
81 void YACS_Swig::loadSchema(const std::string& filename,bool edit, bool arrangeLocalNodes)
83 class TEvent: public SALOME_Event
90 TEvent(YACS_Swig* obj,const std::string& filename,bool edit,bool arrangeLocalNodes) {
96 virtual void Execute() {
97 _obj->real_loadSchema(fn,ed,ar);
100 ProcessVoidEvent(new TEvent(this,filename,edit,arrangeLocalNodes));
103 void YACS_Swig::real_loadSchema(const std::string& filename,bool edit, bool arrangeLocalNodes)
105 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
107 app->activateModule( "YACS" );
108 CAM_Module* module = app->module("YACS");
109 Yacsgui* appMod = dynamic_cast<Yacsgui*>(module);
111 appMod->loadSchema(filename,edit,arrangeLocalNodes);