Salome HOME
Copyrights update 2015.
[modules/paravis.git] / src / VTKWrapping / create_class.py
1 #!/bin/bash
2 # Copyright (C) 2010-2015  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, or (at your option) any later version.
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     if line.split()[0] == "vtkWebGLExporter" :
35        ffile_stream.write('#ifdef WIN32\n')
36        ffile_stream.write('  #ifdef GetObject\n')
37        ffile_stream.write('    #undef GetObject\n')
38        ffile_stream.write('  #endif\n')
39        ffile_stream.write('#endif\n')
40        pass
41     ffile_stream.write('#include "PARAVIS_Gen_%s_i.hh"'%(line.split()[0]) + '\n')
42     pass
43 wfile_stream.close()
44 ffile_stream.write('' + '\n')
45 ffile_stream.write('PARAVIS::PARAVIS_Base_i* CreateInstance(::vtkObjectBase* Inst, const QString& theClassName)' + '\n')
46 ffile_stream.write('{' + '\n')
47 wfile_stream = open(wfile)
48 lst = []
49 for line in wfile_stream:
50     lst.append(line.split()[0])
51     pass
52 wfile_stream.close()
53 lst.reverse()
54 for item in lst:
55     ffile_stream.write('    if(theClassName == "%s" || (Inst != NULL && Inst->IsA("%s")))'%(item, item) + '\n')
56     ffile_stream.write('      return new PARAVIS::%s_i();'%(item) + '\n')
57     pass
58 ffile_stream.write('' + '\n')
59 ffile_stream.write('    cerr << "The class " << theClassName.toStdString() << " is not created!" << endl;' + '\n')
60 ffile_stream.write('    return new PARAVIS::PARAVIS_Base_i();' + '\n')
61 ffile_stream.write('}' + '\n')
62 ffile_stream.close()