svghmi/svghmi.py
branchsvghmi
changeset 2756 f94bc35a023e
parent 2753 9a7e12e96399
child 2757 c901baa36bb3
equal deleted inserted replaced
2755:4efc509e9a1a 2756:f94bc35a023e
    12 
    12 
    13 import wx
    13 import wx
    14 
    14 
    15 import util.paths as paths
    15 import util.paths as paths
    16 from POULibrary import POULibrary
    16 from POULibrary import POULibrary
    17 from docutil import open_svg
    17 from docutil import open_svg, get_inkscape_path
    18 from lxml import etree
    18 from lxml import etree
       
    19 
       
    20 from util.ProcessLogger import ProcessLogger
    19 
    21 
    20 HMI_TYPES_DESC = {
    22 HMI_TYPES_DESC = {
    21     "HMI_CLASS":{},
    23     "HMI_CLASS":{},
    22     "HMI_LABEL":{},
    24     "HMI_LABEL":{},
    23     "HMI_STRING":{},
    25     "HMI_STRING":{},
    96             shutil.copyfile(self._getSVGpath(from_project_path),
    98             shutil.copyfile(self._getSVGpath(from_project_path),
    97                             self._getSVGpath())
    99                             self._getSVGpath())
    98         return True
   100         return True
    99 
   101 
   100     def GetSVGGeometry(self):
   102     def GetSVGGeometry(self):
   101         # TODO : invoke inskscape -S, csv-parse output, produce elements
   103         # invoke inskscape -S, csv-parse output, produce elements
   102         return [etree.Element("bbox", id="blah0", x="1", y="2", w="3", h="4"),
   104         InkscapeGeomColumns = ["Id", "x", "y", "w", "h"]
   103                 etree.Element("bbox", id="blah1", x="5", y="6", w="7", h="8")]
   105 
       
   106         # TODO : move following line to __init__
       
   107         inkpath = get_inkscape_path()
       
   108         svgpath = self._getSVGpath()
       
   109         _status, result, _err_result = ProcessLogger(None,
       
   110                                                      inkpath + " -S " + svgpath,
       
   111                                                      no_stdout=True,
       
   112                                                      no_stderr=True).spin()
       
   113         res = []
       
   114         for line in result.split():
       
   115             strippedline = line.strip()
       
   116             attrs = dict(
       
   117                 zip(InkscapeGeomColumns, line.strip().split(',')))
       
   118 
       
   119             res.append(etree.Element("bbox", **attrs))
       
   120 
       
   121         return res
   104 
   122 
   105     def CTNGenerate_C(self, buildpath, locations):
   123     def CTNGenerate_C(self, buildpath, locations):
   106         """
   124         """
   107         Return C code generated by iec2c compiler
   125         Return C code generated by iec2c compiler
   108         when _generate_softPLC have been called
   126         when _generate_softPLC have been called