Back to index

salome-paravis  6.5.0
create_class.py
Go to the documentation of this file.
00001 #!/bin/bash
00002 # Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00003 #
00004 # This library is free software; you can redistribute it and/or
00005 # modify it under the terms of the GNU Lesser General Public
00006 # License as published by the Free Software Foundation; either
00007 # version 2.1 of the License.
00008 #
00009 # This library is distributed in the hope that it will be useful,
00010 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 # Lesser General Public License for more details.
00013 #
00014 # You should have received a copy of the GNU Lesser General Public
00015 # License along with this library; if not, write to the Free Software
00016 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00017 #
00018 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00019 #
00020 
00021 import sys
00022 import os
00023 
00024 ffile = "PARAVIS_CreateClass.cxx"
00025 wfile = os.path.join(sys.argv[1], "wrapfiles.txt")
00026 
00027 ffile_stream = open(ffile, "w")
00028 
00029 ffile_stream.write('#include <iostream>' + '\n')
00030 ffile_stream.write('#include <QString>' + '\n')
00031 ffile_stream.write('#include "PARAVIS_Gen_i.hh"' + '\n')
00032 wfile_stream = open(wfile)
00033 for line in wfile_stream:
00034     ffile_stream.write('#include "PARAVIS_Gen_%s_i.hh"'%(line.split()[0]) + '\n')
00035     pass
00036 wfile_stream.close()
00037 ffile_stream.write('' + '\n')
00038 ffile_stream.write('PARAVIS::PARAVIS_Base_i* CreateInstance(::vtkObjectBase* Inst, const QString& theClassName)' + '\n')
00039 ffile_stream.write('{' + '\n')
00040 wfile_stream = open(wfile)
00041 lst = []
00042 for line in wfile_stream:
00043     lst.append(line.split()[0])
00044     pass
00045 wfile_stream.close()
00046 lst.reverse()
00047 for item in lst:
00048     ffile_stream.write('    if(theClassName == "%s" || (Inst != NULL && Inst->IsA("%s")))'%(item, item) + '\n')
00049     ffile_stream.write('      return new PARAVIS::%s_i();'%(item) + '\n')
00050     pass
00051 ffile_stream.write('' + '\n')
00052 ffile_stream.write('    cerr << "The class " << theClassName.toStdString() << " is not created!" << endl;' + '\n')
00053 ffile_stream.write('    return new PARAVIS::PARAVIS_Base_i();' + '\n')
00054 ffile_stream.write('}' + '\n')
00055 ffile_stream.close()