[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz metacode/pegboard.py metacode/uml.py metaco...
From: |
Asko Soukka |
Subject: |
[Gzz-commits] gzz metacode/pegboard.py metacode/uml.py metaco... |
Date: |
Tue, 17 Dec 2002 09:11:38 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Asko Soukka <address@hidden> 02/12/17 09:11:38
Modified files:
metacode : pegboard.py uml.py umldoc.py umlrst.py
umltool.py
doc/pegboard/1018: PEG_1018.rst
Log message:
umltool
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/metacode/pegboard.py.diff?tr1=1.23&tr2=1.24&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/metacode/uml.py.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/metacode/umldoc.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/metacode/umlrst.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/metacode/umltool.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/doc/pegboard/1018/PEG_1018.rst.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
Patches:
Index: gzz/doc/pegboard/1018/PEG_1018.rst
diff -u gzz/doc/pegboard/1018/PEG_1018.rst:1.4
gzz/doc/pegboard/1018/PEG_1018.rst:1.5
--- gzz/doc/pegboard/1018/PEG_1018.rst:1.4 Tue Dec 10 11:06:39 2002
+++ gzz/doc/pegboard/1018/PEG_1018.rst Tue Dec 17 09:11:38 2002
@@ -4,17 +4,14 @@
:Author: Asko Soukka, Benja Fallenstein
:Date-created: 2002-12-10
-:Last-Modified: $Date: 2002/12/10 16:06:39 $
-:Revision: $Revision: 1.4 $
+:Last-Modified: $Date: 2002/12/17 14:11:38 $
+:Revision: $Revision: 1.5 $
:Status: Incomplete
This PEG is about creating a ViewTool. The ViewTool would offer easy-to-use
interface for prototyping new views - and lowering the treshold of starting
view development.
-PS. UML-diagrams are not currently compiled with this PEG, but
-by "make uml", sorry for that.
-
Motivation
----------
@@ -59,7 +56,50 @@
void connect(Cell c1, Cell c2, int dx, int dy);
}
-.. image:: ../../uml/vanishingview.png
+.. UML:: vanishingview
+
+ jlinkpackage gzz.view
+
+ class View "interface"
+ jlink
+ methods
+ void render(VobScene vs, int box, ViewContext context)
+
+ class BFRaster
+ jlink
+ methods
+ void read(Cell center, Dim[] dims)
+
+ class PlainVanishing
+ jlink
+ use BFRaster
+ use VanishingClient
+ methods
+ void paint(int index, int x, int y, int d, int rdepth,
float fract, float xalign, float yalign, int pdx, int pdy, float rot)
+ void connect(int index, int rdepth)
+ void render(VanishingClient client, ViewContext
context, int px, int py)
+
+ class VobVanishingClient
+ jlink
+ realize View
+ realize VanishingClient
+ use PlainVanishing
+
+ class VanishingClient "interface"
+ jlink
+ methods
+ void connect(Cell c1, Cell c2, int dx, int dy)
+ java.lang.Object getVobSize(Cell c, float fract, int
flags, java.awt.Dimension into)
+ void place(Cell c, java.lang.Object o, float fract, int
x0, int y0, int x1, int y1, int depth, float rot)
+ ------------------------------------------------------------------
+ PlainVanishing.c = (350, 200);
+ horizontally(50, plain_h, PlainVanishing);
+
+ View.c = (0, 100);
+ horizontally(50, view_h, View, VobVanishingClient, BFRaster);
+
+ VanishingClient.c = (350,0);
+ horizontally(50, client_h, VanishingClient);
Describing shortly (this will be replaced with sequence diagram):
VobVanishingClient
implements both the View and VanishingClient interface. When its render() is
called,
@@ -102,6 +142,41 @@
This is currently in very beginning.
-.. image:: ../../uml/viewtool.png
+.. UML:: umltool
+
+ jlinkpackage gzz.view
+
+ class View "interface"
+ jlink
+ methods
+ void render(VobScene vs, int box, ViewContext context)
+
+ class XXXView
+ realize View
+ use XXXViewTool
+
+ class XXXViewTool
+ inherit AbstractViewTool
+ use XXXRaster
+ methods
+ void connectionCS(int box, Cell c1, Cell c2, float cs[])
+ int placeCS(int box, Cell c, int x, int y, int depth,
float fract)
+ methods for raster?
+
+ class XXXRaster
+ inherit AbstractRaster
+
+ class AbstractViewTool "??????????"
+
+ class AbstractRaster "??????????"
+ -------------------------------------------------------------------
+ XXXView.c = (0, 200);
+ horizontally(50, view_h, XXXView, View);
+
+ XXXViewTool.c = (0,100);
+ horizontally(50, tool_h, XXXViewTool, XXXRaster);
+
+ AbstractViewTool.c = (0,0);
+ horizontally(50, raster_h, AbstractViewTool, AbstractRaster);
Finally basic views should rewrite using ViewTool.
Index: gzz/metacode/pegboard.py
diff -u gzz/metacode/pegboard.py:1.23 gzz/metacode/pegboard.py:1.24
--- gzz/metacode/pegboard.py:1.23 Fri Dec 13 06:27:41 2002
+++ gzz/metacode/pegboard.py Tue Dec 17 09:11:38 2002
@@ -20,6 +20,7 @@
# because of hardcoded pegroot and css.
import sys, os, os.path, string
+import umlrst
import docutils
from docutils import Component
from docutils import frontend, io, readers, parsers, writers, nodes
Index: gzz/metacode/uml.py
diff -u gzz/metacode/uml.py:1.20 gzz/metacode/uml.py:1.21
--- gzz/metacode/uml.py:1.20 Sun Dec 15 20:08:49 2002
+++ gzz/metacode/uml.py Tue Dec 17 09:11:38 2002
@@ -15,8 +15,9 @@
# file for more details.
#
-import sys
-from umltool import *
+import sys, umltool
+
+umltool.settings['to_root']= '../../'
for prefix in sys.argv[1:]:
- run(prefix)
+ umltool.run(prefix)
Index: gzz/metacode/umldoc.py
diff -u gzz/metacode/umldoc.py:1.1 gzz/metacode/umldoc.py:1.2
--- gzz/metacode/umldoc.py:1.1 Sun Dec 15 22:53:26 2002
+++ gzz/metacode/umldoc.py Tue Dec 17 09:11:38 2002
@@ -16,52 +16,71 @@
#
import sys, os
-from umltool import *
-from umlrst import *
+import docutils.core
+import umltool, umlrst
# must be run in the main directory of gzz module
-settings['tmpdir'] = 'doc/uml'
-settings['to_root'] = ''
-settings['css'] = 'doc/gzz.css'
+umltool.settings['css'] = 'doc/gzz.css'
-os.putenv("MPINPUTS", "metacode")
-os.putenv("TEXMFOUTPUT", settings['tmpdir'])
-
-def run_documl(path):
- depth = path.count("/")
- settings['to_root'] = "".join(["../" for i in range(depth)])
+#Environmental variable MPINPUTS should be relative to tmpdir, or absolute
path.
+os.putenv("MPINPUTS", "../../metacode")
+#TEXFMOUTPUT should change the output directory of metapost, but it didn't
+#seem to do that. Instead of this, metapost is currently run in tmpdir.
+#os.putenv("TEXMFOUTPUT", umltool.settings['tmpdir'])
+
+def run(path):
+ set_to_root(path)
+
if os.path.isdir(path):
- if not path.endswith("/"): settings['to_root'] += "../"
+ if not path.endswith("/"): umltool.settings['to_root'] += "../"
elif os.path.isfile(path) or os.path.isfile(path+'.rst'):
- #the first pass - converts rst into html
- if path.endswith(".rst"): path = path[0:len(path)-4]
- args = '-stg --stylesheet '+settings['to_root']+settings['css'] \
- +' '+path+'.rst '+path+'.html'
- docutils.core.publish_cmdline(writer_name='html', argv=args.split())
-
- #the second pass - adds uml into html
- if os.path.isfile(path+".html"):
- html = open(path+".html").read()
- out = open(path+".html", "w")
+ rst2html(path)
+ embed_diagram(path)
+
+def set_to_root(path):
+ depth = path.count("/")
+ umltool.settings['to_root'] = "".join(["../" for i in range(depth)])
+
+def rst2html(path):
+ #the first pass - converts rst into html
+ if path.endswith(".rst"): path = path[0:len(path)-4]
+ args = '-stg --stylesheet '+umltool.settings['to_root']\
+ +umltool.settings['css']+' '+path+'.rst '+path+'.html'
+ docutils.core.publish_cmdline(writer_name='html', argv=args.split())
+
+def create_diagram(diagram):
+ umltool.run(diagram)
+
+def embed_diagram(path):
+ if not umltool.settings.has_key('to_root'):
+ set_to_root(path)
+
+ #the second pass - adds uml into html
+ if path.endswith(".rst"): path = path[0:len(path)-4]
+ print path
+ if os.path.isfile(path+".html"):
+ html = open(path+".html").read()
+ out = open(path+".html", "w")
+ insert = html.find("<!-- UML:")
+ while insert > -1:
+ out.write(html[0:insert]);
+ name = html[insert+9:html.find(" ", insert+9)]
+ create_diagram(name)
+ imgmap = open(umltool.settings['tmpdir']+"/"+name+".html").read()
+ out.write("<map name=\""+name+"\">\n")
+ out.write(imgmap[imgmap.find('>',imgmap.find('<map'))+1:\
+ imgmap.find('</map>')])
+ out.write("</map>\n")
+ out.write("<img src=\""+umltool.settings['to_root']\
+ +umltool.settings['tmpdir']+"/"+name+".png"\
+ +"\" usemap=\""+name+"\"/>")
+ html = html[html.find("-->", insert)+3:len(html)]
insert = html.find("<!-- UML:")
- while insert > -1:
- out.write(html[0:insert]);
- name = html[insert+9:html.find(" ", insert+9)]
- imgmap = open(settings['tmpdir']+"/"+name+".html").read()
- out.write("<map name=\""+name+"\">\n")
- out.write(imgmap[imgmap.find('>',imgmap.find('<map'))+1:\
- imgmap.find('</map>')])
- out.write("</map>\n")
- out.write("<img src=\""+settings['to_root']\
- +settings['tmpdir']+"/"+name+".png"\
- +"\" usemap=\""+name+"\"/>")
- html = html[html.find("-->", insert)+3:len(html)]
- insert = html.find("<!-- UML:")
- out.write(html)
- out.close()
+ out.write(html)
+ out.close()
for path in sys.argv[1:]:
- run_documl(path)
+ run(path)
Index: gzz/metacode/umlrst.py
diff -u gzz/metacode/umlrst.py:1.1 gzz/metacode/umlrst.py:1.2
--- gzz/metacode/umlrst.py:1.1 Sun Dec 15 22:53:26 2002
+++ gzz/metacode/umlrst.py Tue Dec 17 09:11:38 2002
@@ -16,17 +16,10 @@
#
import sys, os
-import docutils, docutils.parsers.rst.directives, docutils.core
-from umltool import *
+import docutils.parsers.rst.directives, docutils.nodes, docutils.core
+import umltool
-# must be run in the main directory of gzz module
-
-settings['tmpdir'] = 'doc/uml'
-settings['to_root'] = ''
-settings['css'] = 'doc/gzz.css'
-
-os.putenv("MPINPUTS", "metacode")
-os.putenv("TEXMFOUTPUT", settings['tmpdir'])
+umltool.settings['tmpdir'] = 'doc/uml'
def uml_directive(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
@@ -52,15 +45,16 @@
files[current] = temp
# XXX fatal error if
- if os.path.isfile(settings['tmpdir']+"/"+attributes['name']+".uml"):
+ if
os.path.isfile(umltool.settings['tmpdir']+"/"+attributes['name']+".uml"):
pass
#writes uml and mp sourcefiles and converts them into png and html
- open(settings['tmpdir']+"/"+attributes['name']\
- +".uml", "w").write(files[0])
- open(settings['tmpdir']+"/"+attributes['name']\
- +".mp", "w").write(files[1])
- run(settings['tmpdir']+"/"+attributes['name'])
+ uml = open(umltool.settings['tmpdir']+"/"+attributes['name']+".uml",
"w")
+ mp = open(umltool.settings['tmpdir']+"/"+attributes['name']+".mp", "w")
+ uml.write(files[0])
+ mp.write(files[1])
+ uml.close()
+ mp.close()
return [uml_node]
Index: gzz/metacode/umltool.py
diff -u gzz/metacode/umltool.py:1.2 gzz/metacode/umltool.py:1.3
--- gzz/metacode/umltool.py:1.2 Sun Dec 15 22:53:26 2002
+++ gzz/metacode/umltool.py Tue Dec 17 09:11:38 2002
@@ -23,7 +23,6 @@
import string
settings = {
- 'to_root': '../../',
'javadoc': 'doc/javadoc',
}
@@ -680,8 +679,12 @@
"-xborder", 0, "-yborder", 0]]
def run(prefix):
- s = open(prefix+".uml").read()
+ #Runs metapost in the tmpdir (to store all output data there)
+ current_path = os.path.abspath("")
+ if settings.has_key('tmpdir'):
+ os.chdir(os.path.abspath(settings['tmpdir']))
+ s = open(prefix+".uml").read()
l = parseIndented(s)
m = mplist(l)
@@ -701,7 +704,6 @@
end
""" % locals())
-
assert not os.spawnlp(os.P_WAIT,
"/usr/bin/mpost", "/usr/bin/mpost", prefix+".gen3")
@@ -738,7 +740,7 @@
<BODY>
<P>
%(prefix)s<BR>
- <OBJECT data="%(filename)s" type="image/png" usemap="#map1">
+ <OBJECT data="%(filename)s" type="image/png" usemap="map1">
<map name="map1">
%(links)s
</map>
@@ -749,3 +751,6 @@
"filename": prefix+".png",
"links": " ".join([l.imgmapanchor() for l in links]) }
open(prefix+".html", "w").write(htmlcode)
+
+ #Returning back to the current directory
+ os.chdir(current_path)
- [Gzz-commits] gzz metacode/pegboard.py metacode/uml.py metaco...,
Asko Soukka <=