3 |
3 |
4 from pyjs import translate |
4 from pyjs import translate |
5 |
5 |
6 from POULibrary import POULibrary |
6 from POULibrary import POULibrary |
7 from docutil import open_svg |
7 from docutil import open_svg |
|
8 from py_ext import PythonFileCTNMixin |
8 |
9 |
9 class SVGUILibrary(POULibrary): |
10 class SVGUILibrary(POULibrary): |
10 def GetLibraryPath(self): |
11 def GetLibraryPath(self): |
11 return os.path.join(os.path.split(__file__)[0], "pous.xml") |
12 return os.path.join(os.path.split(__file__)[0], "pous.xml") |
12 |
13 |
13 class SVGUI: |
14 class SVGUI(PythonFileCTNMixin): |
14 |
15 |
15 ConfNodeMethods = [ |
16 ConfNodeMethods = [ |
16 {"bitmap" : "ImportSVG", |
17 {"bitmap" : "ImportSVG", |
17 "name" : _("Import SVG"), |
18 "name" : _("Import SVG"), |
18 "tooltip" : _("Import SVG"), |
19 "tooltip" : _("Import SVG"), |
24 ] |
25 ] |
25 |
26 |
26 def ConfNodePath(self): |
27 def ConfNodePath(self): |
27 return os.path.join(os.path.dirname(__file__)) |
28 return os.path.join(os.path.dirname(__file__)) |
28 |
29 |
29 def _getSVGpath(self): |
30 def _getSVGpath(self, project_path=None): |
30 # define name for IEC raw code file |
31 if project_path is None: |
31 return os.path.join(self.CTNPath(), "gui.svg") |
32 project_path = self.CTNPath() |
|
33 # define name for SVG file containing gui layout |
|
34 return os.path.join(project_path, "gui.svg") |
32 |
35 |
33 def _getSVGUIserverpath(self): |
36 def _getSVGUIserverpath(self): |
34 return os.path.join(os.path.dirname(__file__), "svgui_server.py") |
37 return os.path.join(os.path.dirname(__file__), "svgui_server.py") |
|
38 |
|
39 def OnCTNSave(self, from_project_path=None): |
|
40 if from_project_path is not None: |
|
41 shutil.copyfile(self._getSVGpath(from_project_path), |
|
42 self._getSVGpath()) |
|
43 return PythonFileCTNMixin.OnCTNSave(self, from_project_path) |
35 |
44 |
36 def CTNGenerate_C(self, buildpath, locations): |
45 def CTNGenerate_C(self, buildpath, locations): |
37 """ |
46 """ |
38 Return C code generated by iec2c compiler |
47 Return C code generated by iec2c compiler |
39 when _generate_softPLC have been called |
48 when _generate_softPLC have been called |