From Manuel Gutierrez Algaba Mon Nov 9 21:03:29 1998 From: Manuel Gutierrez Algaba (Manuel Gutierrez Algaba) Date: Mon, 9 Nov 1998 21:03:29 +0000 (GMT) Subject: [Doc-SIG] Tex OO Rumbaugh classes drawer. Message-ID: Hello, This is my 'saying hello to this list' email. I have the problem that I have to do lots and lots of drawing of classes for the documentation of my thesis. Although I could use any drawing utility, I think it could be easier to produce Texdraw code... So this is what I've done: ''' 1998 Manuel Gutierrez Algaba You are free to use , modify, distribute and copy this piece of python code, if you keep this free copyright notice in it. By the way , I dont mind change this copyright notice to GPL, pythonish or whatever, if you like constructor of diagrams: Given a frame of classes and relationships among clases, it generates latex code ,that represents those classes in the Rumbaugh OO notation. ''' ''' The first idea is this : If we have a box representing the class we stablish *contact_points* in its borders, so we can connect them , the positions inside a box are absolute to a relative point, the self.x , self.y in the a_simple_class. a_simple_class just draw a box , with the name of the class the next steps are to do: - union_derivation - union_atribution and create complex drawings. The position of the boxes are determined by the position of a base a_simple_class, whose contact_points will be supplied to the boxes conected (by unions) to it , so that the other boxes can obtain an absolute positioning. Currently it generates only tex code, but it will be interesting ,perhaps, to generate tcl/tk code, and do a small drawing utility in canvas. But now, my only target is to generate tex code, my inmediate target. ''' ''' scale: it is just a factor for adjusting the length of the lines. ''' class scale: def __init__(self,l): self.l = l def what_scale(self): return self.l class line: def __init__(self,length,dx,dy): self.l = length self.dx = dx self.dy = dy def what_length(self): return self.l def what_x(self): return self.dx def what_y(self): return self.dy class horizontal_line(line): def __init__(self,dx): line.__init__(self,dx,dx,0) class vertical_line(line): def __init__(self,dy): line.__init__(self,dy,0,dy) class contact_point: def __init__(self,name): self.name = name def what_name(self): return self.name def what_x(self): return self.x def what_y(self): return self.y def do_x(self,x): self.x = x def do_y(self,y): self.y = y ''' a_simple_class: This one should generate code for a class, that is , if we say : class frutas, attributes: perecedera , dulce, seca, carnosa, del tiempo, tropical, then it generates code that represents: __________ | frutas | |--------| |pereced | |dulce | |seca | |.... | |________| Besides contact_points should be stablished to insert another classes ''' class a_simple_class(scale): def __init__(self): scale.__init__(self,2) self.list_of_lines = [] self.x = 0 self.y = 0 def do_origin_x(self, x): self.originx = x def do_origin_y(self, y): self.originy = y def do_name_clase(self,name_clase): self.name_clase = name_clase def do_attributes(self, list_of_atributes): self.list_of_atributes = list_of_atributes def do_lines(self): self.do_line_upwards() self.do_lines_of_the_right() self.do_downwards_line() self.do_lines_of_the_left() def do_line_upwards(self): j = len(self.name_clase) parte_uno = j * self.what_scale() / 2 self.virtually_drawing([horizontal_line(parte_uno), contact_point('superior'), horizontal_line(parte_uno)]) def virtually_drawing(self,l): for i in l: if isinstance(i,vertical_line): self.y = self.y + i.what_y() elif isinstance(i, horizontal_line): self.x = self.x + i.what_x() else: # es un punto de contacto i.do_x(self.x) i.do_y(self.y) self.list_of_lines.append(i) def do_lines_of_the_left(self): j = len(self.list_of_atributes) + 2 self.virtually_drawing([vertical_line(j), contact_point('leftsided'), vertical_line(j)]) def do_lines_of_the_right(self): j = len(self.list_of_atributes) + 2 self.virtually_drawing([vertical_line(-j), contact_point('rightsided'), vertical_line(-j)]) def do_downwards_line(self): j = len(self.name_clase) parte_uno = j * self.what_scale() / 2 self.virtually_drawing([horizontal_line(-parte_uno), contact_point('inferior'), horizontal_line(-parte_uno)]) def imprime_list_of_lines(self): self.x = 0 self.y = 0 print self.list_of_lines for i in self.list_of_lines: if isinstance(i,vertical_line): self.y = self.y + i.what_y() print "vertical_line", self.y elif isinstance(i, horizontal_line): self.x = self.x + i.what_x() print "horizontal_line", self.x else: # it is a contact point print "contact point", i.what_name(), i.what_x(), i.what_y() def generate_latex_code(self,f): fi = open(f,'w') print "\\begin{center}" print "\\begin{texdraw}" print " \\drawdim {cm}" print " \\linewd 0.02" fi.write( "\\begin{center}\n"+ "\\begin{texdraw}\n"+ " \\drawdim {cm}\n \setunitscale 0.3"+ " \\linewd 0.02\n" ) self.genera_labels(fi) for i in self.list_of_lines: if isinstance(i,vertical_line): print "\\rlvec(0 ",i.what_y()," )" fi.write("\\rlvec(0 "+`i.what_y()`+" )\n") elif isinstance(i, horizontal_line): self.x = self.x + i.what_x() fi.write( "\\rlvec( "+`i.what_x()`+" 0)\n") fi.write( "\\end{texdraw}\n"+ "\\end{center}\n") fi.close() def genera_labels(self,f): f.write(" \\move(0 0)\\lvec(0 0) \\textref h:L v:C \\htext(1.5 -1){"+self.name_clase+"}\n ") counter = -1.8 for i in self.list_of_atributes: counter = counter - 1.5 f.write(" \\htext(1.5 "+`counter`+"){"+i+"}\n ") j = len(self.name_clase) j = j * self.what_scale() f.write("\\move(0 -2.4)\\rlvec("+`j` +" 0 )\\move(0 0)\n") def test(): c = a_simple_class() c.do_name_clase('fruta') c.do_attributes(['perecedera' , 'dulce', 'seca', 'carnosa', 'del tiempo', 'tropical']) c.do_lines() c.imprime_list_of_lines() c.generate_latex_code('result') d = a_simple_class() d.do_name_clase('empleado') d.do_attributes(['paga por horas' , 'sueldo']) d.do_lines() d.imprime_list_of_lines() d.generate_latex_code('result2') if __name__=='__main__': test() And that's what you can find in the 'result' file: \begin{center} \begin{texdraw} \drawdim {cm} \setunitscale 0.3 \linewd 0.02 \move(0 0)\lvec(0 0) \textref h:L v:C \htext(1.5 -1){fruta} \htext(1.5 -3.3){perecedera} \htext(1.5 -4.8){dulce} \htext(1.5 -6.3){seca} \htext(1.5 -7.8){carnosa} \htext(1.5 -9.3){del tiempo} \htext(1.5 -10.8){tropical} \move(0 -2.4)\rlvec(10 0 )\move(0 0) \rlvec( 5 0) \rlvec( 5 0) \rlvec(0 -8 ) \rlvec(0 -8 ) \rlvec( -5 0) \rlvec( -5 0) \rlvec(0 8 ) \rlvec(0 8 ) \end{texdraw} \end{center} It's not too much. I'll improve the code until it does all what I need. Do you want to join ? If so, email irmina@ctv.es I've created a web page for such a project in : www.ctv.es/USERS/irmina/texpython.htm I think it's a very easy and interesting project,... provide with Tex documentation python sources!!! At last for those who use python and tex in their theses. ideas? Regards Manolo From skaller@maxtal.com.au Fri Nov 13 07:03:51 1998 From: skaller@maxtal.com.au (John Skaller) Date: Fri, 13 Nov 1998 17:03:51 +1000 Subject: [Doc-SIG] Tex OO Rumbaugh classes drawer. Message-ID: <1.5.4.32.19981113070351.00f5d238@triode.net.au> > >It's not too much. >I'll improve the code until it does all what I need. > >Do you want to join? > >I've created a web page for such a project in : >www.ctv.es/USERS/irmina/texpython.htm > >I think it's a very easy and >interesting project,... provide with Tex documentation python sources!!! >At last for those who use python and tex in their theses. >ideas? I'd be interested to incorporate something like this into Interscript. [See http://www.triode.net.au/~skaller/interscript] Hmm. How to draw in HTML?? ------------------------------------------------------- John Skaller email: skaller@maxtal.com.au http://www.maxtal.com.au/~skaller phone: 61-2-96600850 snail: 10/1 Toxteth Rd, Glebe NSW 2037, Australia From Manuel Gutierrez Algaba Tue Nov 17 10:07:49 1998 From: Manuel Gutierrez Algaba (Manuel Gutierrez Algaba) Date: Tue, 17 Nov 1998 10:07:49 +0000 (GMT) Subject: [Doc-SIG] Tex OO Rumbaugh classes drawer. In-Reply-To: <1.5.4.32.19981113070351.00f5d238@triode.net.au> Message-ID: On Fri, 13 Nov 1998, John Skaller wrote: > > I'd be interested to incorporate something like this > into Interscript. [See http://www.triode.net.au/~skaller/interscript] > > Hmm. How to draw in HTML?? > As far as I know, you can't draw lines in HTML, maybe I'm wrong. Anyway you can easily translate from tex code to postcript or to a kind of ASCII- text draw . You just create an array and you follow the tex commands to write ASCII chars in that matrix. You can incorporate this program. But anyway tex-dvi are a very common way of documentation, why not incorporate as is? I've uploaded some improvements, by next week I'll think it could be fully operative. Regards Manolo From skaller@maxtal.com.au Tue Nov 17 21:39:02 1998 From: skaller@maxtal.com.au (John Skaller) Date: Wed, 18 Nov 1998 07:39:02 +1000 Subject: [Doc-SIG] Tex OO Rumbaugh classes drawer. Message-ID: <1.5.4.32.19981117213902.00f4f984@triode.net.au> At 10:07 17/11/98 +0000, Manuel Gutierrez Algaba wrote: >> Hmm. How to draw in HTML?? >As far as I know, you can't draw lines in HTML, maybe I'm wrong. you can refer to images such as a gif or jpg file. >Anyway you can easily translate from tex code to postcript or to >a kind of ASCII- text draw . You just create an array and you >follow the tex commands to write ASCII chars in that matrix. >You can incorporate this program. But anyway tex-dvi are a very >common way of documentation, why not incorporate as is? interscript is 'typesetter independent': the documents must be renderable in plain text, html, and latex2e, and any other typesetter language such as postscript. So, if a client document contains information I pass to your package to draw a diagram, I have to be able to 'paste' it into both Latex and HTML ... although plain text is probably pushing it. I need to do this automatically: I can always run Xdvi and a screen grabber to make a jpg file for HTML, but I don't know how to do it automatically without user intervention. Another way to do it in HTML .. is to use a Java applet. ------------------------------------------------------- John Skaller email: skaller@maxtal.com.au http://www.maxtal.com.au/~skaller phone: 61-2-96600850 snail: 10/1 Toxteth Rd, Glebe NSW 2037, Australia From doughellmann@mindspring.com Wed Nov 18 01:43:47 1998 From: doughellmann@mindspring.com (Doug Hellmann) Date: Tue, 17 Nov 1998 20:43:47 -0500 Subject: [Doc-SIG] Tex OO Rumbaugh classes drawer. References: <1.5.4.32.19981117213902.00f4f984@triode.net.au> Message-ID: <36522653.B8E6D69E@mindspring.com> John Skaller wrote: > > I need to do this automatically: I can always > run Xdvi and a screen grabber to make a jpg file for HTML, > but I don't know how to do it automatically without user > intervention. If you're assuming UNIX (questionable assumption), you can just run Xdvi with a specific window name (or if that app doesn't allow you to change the window name, you can find out what the fixed window name is). Then you call xwd with the name of the window, and it dumps it without any user input. Kill of Xdvi and you're done. > Another way to do it in HTML .. is to use a Java applet. That would be more portable. Doug From skaller@maxtal.com.au Wed Nov 18 10:03:42 1998 From: skaller@maxtal.com.au (John Skaller) Date: Wed, 18 Nov 1998 20:03:42 +1000 Subject: [Doc-SIG] Tex OO Rumbaugh classes drawer. Message-ID: <1.5.4.32.19981118100342.00f561f4@triode.net.au> >If you're assuming UNIX (questionable assumption), you can just run Xdvi >with a specific window name Thanks!! >> Another way to do it in HTML .. is to use a Java applet. > >That would be more portable. Yeah, but it only works for 'html' files, not latex. I.e. the integration architecture seems non-trivial. :-( ------------------------------------------------------- John Skaller email: skaller@maxtal.com.au http://www.maxtal.com.au/~skaller phone: 61-2-96600850 snail: 10/1 Toxteth Rd, Glebe NSW 2037, Australia From Manuel Gutierrez Algaba Thu Nov 19 15:12:52 1998 From: Manuel Gutierrez Algaba (Manuel Gutierrez Algaba) Date: Thu, 19 Nov 1998 15:12:52 +0000 (GMT) Subject: [Doc-SIG] Tex OO Rumbaugh classes drawer. In-Reply-To: <1.5.4.32.19981118100342.00f561f4@triode.net.au> Message-ID: On Wed, 18 Nov 1998, John Skaller wrote: > > Yeah, but it only works for 'html' files, not latex. > I.e. the integration architecture seems non-trivial. :-( If you like, I can generate Java code instead of Latex, depending on a switch. Just say me the headings and footnotes needed and the primitives. Regards Manolo From Manuel Gutierrez Algaba Sat Nov 21 10:03:30 1998 From: Manuel Gutierrez Algaba (Manuel Gutierrez Algaba) Date: Sat, 21 Nov 1998 10:03:30 +0000 (GMT) Subject: [Doc-SIG] New version of Tex 00 Rumbaugh boxes drawer Message-ID: This version allows several levels of inheritance, an several sons of a class . But I have a problem, how could I get inheritance from several classes, using this very same model of 'contact points' ? Any feedback ? Regards, Manolo From Manuel Gutierrez Algaba Sun Nov 29 16:07:19 1998 From: Manuel Gutierrez Algaba (Manuel Gutierrez Algaba) Date: Sun, 29 Nov 1998 16:07:19 +0000 (GMT) Subject: [Doc-SIG] An 'apropos' utility for documentations Message-ID: Dear folks, I'm a Linux user that always has a bad time when installing a new package or reading the mastodontic documentation that most programs include. This morning I have a simply idea that I'd like you to consider and to comment. Do you know Unix command 'apropos' ? Well, the idea is to do an apropos command ( written in python of course) containing all the 'concepts' and tips related with the documentation of a program. Exactly, imagine that your program can be installed in AIX, Linux, and MS-dos,and for every platform it needs certain procedures. Well, apart from a description in a README file with the differences. It'd be easy to build a database as: core_of_it.py : AIX, Linux, MS-DOS, config.py, ../bin/files, setup, structures, socket This information could be introduced on line by the author, or it could be generated automatically ( at least part of it ). The fields of the database could be grouped so more complex searchs could be done ... Or the fields themselves could be entries in the database. Is it already done ? Can any of the maintainers of documentation of programs consider this feature ? Do you think is useful ? Do you think is easy to do ? Regards/Saludos Manolo ------------- My addresses / mis direcciones: www.ctv.es/USERS/irmina ---> lritaunas peki project/proyecto in python www.ctv.es/USERS/irmina/pyttex.htm ---> page of spanish users of latex / pagina de usuarios en espanyol de latex www.ctv.es/USERS/irmina/texpython.htm --> page of drawing utility for tex / pagina de utilidad de dibujo para Latex