]> SALOME platform Git repositories - modules/paravis.git/blob - src/PVGUI/create_class.py
Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/paravis.git] / src / PVGUI / create_class.py
1 #!/bin/bash
2 # Copyright (C) 2010-2012  CEA/DEN, EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 import sys
22 import os
23
24 ffile = "PARAVIS_CreateClass.cxx"
25 wfile = os.path.join(sys.argv[1], "wrapfiles.txt")
26
27 ffile_stream = open(ffile, "w")
28
29 ffile_stream.write('#include <iostream>' + '\n')
30 ffile_stream.write('#include <QString>' + '\n')
31 ffile_stream.write('#include "PARAVIS_Gen_i.hh"' + '\n')
32 wfile_stream = open(wfile)
33 for line in wfile_stream:
34     ffile_stream.write('#include "PARAVIS_Gen_%s_i.hh"'%(line.split()[0]) + '\n')
35     pass
36 wfile_stream.close()
37 ffile_stream.write('' + '\n')
38 ffile_stream.write('PARAVIS::PARAVIS_Base_i* CreateInstance(::vtkObjectBase* Inst, const QString& theClassName)' + '\n')
39 ffile_stream.write('{' + '\n')
40 wfile_stream = open(wfile)
41 lst = []
42 for line in wfile_stream:
43     lst.append(line.split()[0])
44     pass
45 wfile_stream.close()
46 lst.reverse()
47 for item in lst:
48     ffile_stream.write('    if(theClassName == "%s" || (Inst != NULL && Inst->IsA("%s")))'%(item, item) + '\n')
49     ffile_stream.write('      return new PARAVIS::%s_i();'%(item) + '\n')
50     pass
51 ffile_stream.write('' + '\n')
52 ffile_stream.write('    cerr << "The class " << theClassName.toStdString() << " is not created!" << endl;' + '\n')
53 ffile_stream.write('    return new PARAVIS::PARAVIS_Base_i();' + '\n')
54 ffile_stream.write('}' + '\n')
55 ffile_stream.close()