Home
Creating Flowcharts in LATEX Using the pic Language
Contents
1. 1 1 sf Process 2 at P2 c move to P2 e arrow move to R3 e right arrow P3 process 1 1 sf Process 3 at P3 c move to P3 e arrow move to PiA end line gt down PiA end y Li end y then left P1iA end x Lil end x down arrow box invis Large sf Case Of move to CS1 ne 40 35 Do Until DU1 L1 line arrow P1 process 1 1 sf Process at Pl c move to Pi s arrow R1 decision 1 1 sf Decision at R1 c move to R1 s arrow box invis Large sf Do Until move to Ri e line gt right 20 then up Li end y Ri e y then left Ri e x 20 Li1 end x 3 3 A real example To illustrate the application of the flowchart macros on a real example consider the pseudocode of a color based image segmentation process presented as algo rithm 1 For every pixel p in an image the algorithm computes a color feature f p and checks if the feature is within some threshold A with respect to all the 10 Process 1 Process 2 Process 3 Process Default Process Do Until Case Of Figure 3 Derived program flow structures 11 different classes reference feature vector fe The two outer for from to do loops correspond to the pixel position while the inner loop corresponds to the testing with respect to each class c This algorithm can be describe in terms of the flowchart shown in fig 4 In this flowchart example the two outer for from to do loops have been represented by a single for f
2. e g Xdvi Yap On the other hand dpic requires the PSTricks ATEX package to be installed and included in your TEX file while the output produced by gpic does not require the use of any additional package As stated in section 2 converting from pic to tex can be done using one of the following alternatives 16 a Using dpic 4 dpic p fig pic gt fig tex b Using gpic 5 gpic t fig pic gt fig tex or with pic t fig pic gt fig tex if a newer version of groff is installed in your system IMPORTANT When processing the pic files provided with this document the variable pstricks in the pic files must be set to 0 if gpic is used or to 1 when dpic is used Once the tex files are produced with any of the two previous methods the last step is to include them into your T X document according to the corresponding approach as explained in the third point of section 2 see also the source code of the examples provided with this document References 1 B W Kernighan PIC A Graphics Language for Type setting Revised User Manual Bell Labs Computing Sci ence Technical Report 116 December 1991 Available at http www cs bell labs com 10thEdMan pic pdf E S Raymond Making pictures with GNU PIC 1995 In GNUgroff source distribution J D Aplevich M4 Macros for Electric Circuit Dia grams in FATpX Documents version 6 4 2008 Available at http texcatalogue sarovar org
3. entries circuit macros html or the CTAN http www ctan org mirrors J D Aplevich Dpic package version 29 Oct 2008 Available at http www ece uwaterloo ca aplevich dpic Groff for Windows version 1 19 2 Available at http gnuwin32 sourceforge net packages groff htm The package homepage is http www gnu org software groff groff html 17 6 International Business Machines Corporation IBM Flowchart ing Techniques IBM Technical Publications Dept Doc ument No 20 8152 1 New York 1069 Available at http www fh jena de kleine history software IBM FlowchartingTechniques GC20 8152 1 pdf ISO 5807 1985 Standard Information processing Documentation symbols and conventions for data program and system flowcharts program network charts and system resources charts Available at http www iso org iso iso_catalogue catalogue tc catalogue_detail htm csnumber 11955 Wikipedia Flowchart Visited on December 17t 2008 http en wikipedia org wiki Flowchart 18 Appendix A pic Flowchart Macros The macros implemented to produce the flowcharts in this document were de fined as pic language blocks These blocks provide flowchart primitives by group ing into a single object or entity the lower level primitives of the pic language such as lines boxes and arcs Not surprisingly the pic language primitives grouped to form an object are called blocks in the terminology of the pic lan g
4. of clarity as far as the data flow or algorithmic description are concerned Additional examples on the use of the macros are presented in the next subsections For further information and references about flowcharts please check also 8 and references therein 3 1 Basic Program Flow Structures Figure 2 shows the basic program flow structures a simple sequential execution of three process a conditional branching If Then Else and a program loop While Do loop These simple flowcharts were generated by the following code see file flowbs pic Sequence down S1 move down 30 arrow PA process 1 1 sf Process A at PA c move to PA B s arrow PB process 1 1 sf Process B at PB c move to PB B s arrow PC process 1 1 sf Process C at PC c move to PC B s arrow box invis Large sf Sequence move to Si ne 60 0 If Then Else Ii arrow R1 decision 1 1 sf Decision at R1 c move to Ri s arrow Preparation Process Keyboard Terminator Figure 1 Basic flowchart symbols Pi process 1 1 sf Process 1 at Pl c move to P1i B s Li line move to R1 e line gt right 20 then down Ri e y Pi n y P2 process 1 1 sf Process 2 at P2 c move to P2 B s line gt down P2 s y Li end y then left P2 s x Li end x down arrow box invis Large sf If Then Else move to I1 s 0 5 While Do W1 L1 line arrow R1 decision 1 1 sf Decision at R1 c move
5. 2 First version July 16 2001 dpic p fig pic gt fig tex b Code containing tpic special commands by executing the GNU pic interpreter as follows gpic t fig pic gt fig tex or pic t fig pic gt fig tex if a newer version of groff is installed in your system IMPORTANT When processing the pic files provided with this document the variable pstricks in the pic files must be set to 0 if gpic is used or to 1 when dpic is used 3 Depending on whether gpic or dpic were used in the previous step include fig tex in your document respectively as follows a begin document begin figure htbp input fig tex centerline box graph caption Figure title label fig_label1 end figure end document b begin document usepackage pstricks begin figure htbp centering input fig tex caption Figure title label fig_label1 end figure end document The next sections briefly explain where to find the information and tools to accomplish steps 1 and 2 Step 3 should be pretty straight forward as may be seen from the source code for the inclusion of this document s figures see file flowchart tex 3 Drawing Flowcharts with pic Making figures with pic is well described in the following documents that are available on Internet 1 B W Kernighan PIC A Graphics Language for Typesetting Revised User Manual Bell Labs Computing Sc
6. 2 csize h 2 8 csize B box wid w ht h invis sshade line from B n to B e to B s to B w to B n eshade 3 at B c 1 define preparation w 1 12 csize h 2 8 csize dx h 2 2 B box wid w ht h invis sshade line from B w to B nw dx 0 to B ne dx 0 to B e to B se dx 0 to B swt dx 0 to B w eshade 3 at B c define terminator 20 w 1 12 csize h 2 4 csize r h 2 B box wid w ht h invis sshade line from B swt r 0 to B se r 0 right arc rad r from Here to B ne r 0 line from Here to B nw r 0 left arc rad r from Here to B swt r 0 eshade 3 at B c define keying tE w 1 14 csize h 2 8 csize dx h 4 2 r dx 2 h 2 2 2 dx B box wid w ht h invis sshade line from B swt dx 0 to B se dx 0 left arc rad r from Here to B ne dx 0 line from Here to B nw dx 0 right arc rad r from Here to B swt dx 0 eshade 3 at B c define keyboard w 1 12 csize h 2 5 csize dy w 6 2 B box wid w ht h invis sshade line from B nw 0 dy to B sw to B se to B ne 0 dy to B nw 0 dy eshade 3 at B c define document tI w 1 12 csize h 2 7 csize dy w 6 2 r sqrt w 2 2 dy 2 B box wid w ht h invis sshade line from B se 0 dy to B ne to B nw to B sw up arc rad w 2 from B sw to B s 21 arc cw rad r from B s to B se 0 dy eshade 3 at B c define display w 1 12 csize h 2 8 csize dx 1 5 h 4 2 r dx 2
7. Creating Flowcharts in XTRX Using the pic Language Miguel Torres Torriti December 21 2008 1 Introduction This tutorial document explains how to create flowcharts in ATEX using the pic language developed by Brian W Kernighan for typesetting graphics 1 The pic language provides an easy and flexible way to create procedural box and arrow diagrams state flow charts circuit layouts and other drawings involving repetitive uses of simple geometric forms and splines The illustrations produced with pic can be easily included in troff and TeX documents An important advantage of using pic is that the figures are in vector form rather than bitmaps thus can be scaled and stored in compact files without altering the quality of the graphs The purpose of this to quickly get you on the right track to producing flowcharts that can be included in TEX documents using This document is not intended to serve as a pic tutorial but it provides references to the docu mentation where you may find elementary examples sample pictures and other details that your are encouraged to check if you are unfamiliar with the pic language 2 Steps to Create Flowcharts and Other Graphs with pic The steps can be summarized in 1 Write a description of your figure or flowchart using the pic language 2 Convert your pic diagram into either of a Code containing PSTricks commands by executing the dpic inter preter as follows Document revision
8. d by these macros are shown in the figure 1 which was created with the following lines of code see file flow0 pic down CO connector 1 arrow HO preparation 1 1 sf Preparation at H0O c move to HO B s arrow DO data 1 1 sf Data at DO c move to DO B s arrow PO process 1 1 sf Process at PO c move to PO B s arrow RO decision 1 1 sf Decision at RO c move to RO B s arrow TO terminator 1 1 sf Terminator at TO c move to RO B w left arrow KO keying 1 1 sf Keying at KO c move to KO B w arrow invis K1 keyboard 1 1 sf Keyboard at Ki c move to Ki B e right arrow move to KO B n line gt dashed up CO w y KO n y then right CO w x KO n x move to PO B e right arrow WO document 1 1 sf Document at WO c move to DO B e right arrow SO display 1 1 sf Display at S0 c It is to be noted that the sizing of the symbols was made according to the IBM flowcharting template 6 in which most symbols are 12 x 8 units long and should also match those of the ISO standard 7 Practically any flowchart can be prepared with these symbols As a matter of fact the basic blocks process data connector together with the processing and sequencing symbols decision preparation terminator should be sufficient for most flowcharting needs The input output and processing hardware related symbols can be replaced for data blocks without losx
9. groff htm The package homepage is http www gnu org software groff groff html Read the MAN file manual of gpic also known as pic for more information on gpic the GNU pic interpreter There is no point in repeating the good explanations found in these references If you are unfamiliar with pic and cannot figure out the meaning of the drawing commands in the pic files provided as examples with this document you should read the references in the order in which they have been listed to get a good basis of pic s capabilities and functionality Creating flowcharts with pic is not much different to the process of making a figure with pic To facilitate the task of making flowcharts a set of macros for the standard flowchart symbols was created see Appendix A or the pic files for details on the macro definitions In order to make your own flowcharts you must copy the macros from any of the pic files to a new file and write your code right after the macros Do not forget to end your code with the PE pic command The structure of your pic file should look like PS 20 25 4 Scale drawing to 20 25 4 in x 20 25 4 in 25 4 mm in 20 mm FLOWCHART Basic flow chart blocks lt lt lt HERE ARE THE MACRO DEFINITONS gt gt gt END OF MACROS YOUR FLOWHART CODE STARTS HERE lt lt lt PLACE YOUR FLOWCHART CODE HERE gt gt gt PE The macros receive as arguments the scaling factors for the horiz
10. h 2 2 2 dx B box wid w ht h invis sshade line from B sw 4 dx 1 5 0 to B se dx 0 left arc rad r from Here to B ne dx 0 line from Here to B nw 4 dx 1 5 0 arc rad r from Here to B w right arc rad r from Here to B sw 4 dx 1 5 0 eshade 3 at B c END OF MACROS 22
11. ience Technical Report 116 De cember 1991 Available at http www cs bell labs com 10thEdMan pic pdf This is the classic pic manual and a must read E S Raymond Making pictures with GNU PIC 1995 In GNUgroff source distribution This is a more complete pic manual See reference 5 at the end of this document for information on where to get the groff package J D Aplevich M4 Macros for Electric Circuit Diagrams in BTRX Docu ments version 6 4 2008 Available at http texcatalogue sarovar org entries circuit macros html or the Comprehensive TeX Archive Network CTAN http www ctan org mirrors This document is about the BTRXpackage circutit macros which is based on M4 macros and pic This package contains an excellent collec tion of PIC macros for many circuit components and other schematic diagrams blocks It is a must read because it provides a good set of ref erences and a concise explanation about the methodology to create pic drawings using the gpic or dpic interpreters The circuit macros documentation played a key role in the preparation of this tutorial and the flowchart macros and examples J D Aplevich Dpic package version 29 Oct 2008 Available at http www ece uwaterloo ca aplevich dpic Read the README and the MAN file manual for more information on the dpic interpreter Groff for Windows version 1 19 2 Available at http gnuwin32 sourceforge net packages
12. ontal sx and vertical sy dimension of the symbol Only the connector symbol receives one scaling factor s because it is a circle The scaling factors multiply the basic unit length defined for the macros as parameter csize cell size For example a symbol which is 12 x 8 units or cells and that has been declared with sx set to 2 sy set to 4 will be 24 x 32 units big By default the cell size value is set to 2 mm therefore the scaled symbol will actually measure 48 x 64 mm The available macros are e process sx sy makes a process block rectangle e data sx sy makes a data input or output block parallelogram e connector s makes a connector symbol circle e decision sx sy makes a decision block rhombus e preparation sx sy makes a routine initialization or program preparation block hexagon like block e sf terminator sx sy makes a terminating block flat slim sausage block e keying sx sy makes a block to represent a process or operation that in volves typing or is driven by some manual input device flat fat sausage block e keyboard sx sy makes a block to represent a keyboard switches or push buttons quadrilateral block e document sx sy makes a document symbol rectangle with wavy line at the bottom e display sx sy makes a display symbol to represent a computer screen or monitor video devices console printers or other visual indicators The symbols produce
13. rom to do loop over the pixel position p Algorithm 1 ProcessImage Low level Pseudocode input amp img input image amp ProcessParam process parameters output amp img segmented image amp imgaux amp img ComputeSegmentation for row 0 to amp img height do for col 0 to amp img width do for class 1 to amp ProcessParam Nclasses do if ConvertToYCrCb amp imgaux row col amp ProcessParam FeatureVector class lt Threshold then amp img lt class end end end end 12 amp imgaux amp img p 0 0 Compute feature vector Increment class c c 1 Update position pe p Ap 13 Figure 4 Flowchart for a color based image segmentation process The code that generates de flowchart in fig 4 is see file flowcs pic alen 25 4 4 0 8 arrow length 1 csize 2 connector radius in csize 2 units crad initialize the for loop on p p is the pixel position down HO preparation 1 5 0 5 parbox 6em centering sf amp imgaux leftarrow kimg p leftarrow 0 0 at HO c move to HO B s arrow alen CO connector crad arrow alen check if the for loop on p is done RO decision 1 1 parbox 6em centering sf p in mathcal D _I at RO c move to RO B w sf no above rjust move to RO B s sf yes below ljust move to RO B s arrow alen POa process 1 0 8 parbox 6em centering sf small Compute feat
14. to R1 s arrow box invis Large sf While Do move to Ri e right arrow Pi process 1 1 sf Process X at Pl c move to Pi n line gt up Li end y Pi n y then left Pi n x Li end x 3 2 Derived Program Flow Structures There exist two common program flow structures that can be derived from the previous ones These are the Case Of which corresponds to a series of If Then Else statements and the Do Until loop which is derived from the While Do loop The Do Until loop is equivalent to always executing the code within the While Do loop at least once before exiting the loop if the condition is not met Other names for the Do Until loop are Repeat Until or the similar Do While These derived program flow structures are represented by the flowcharts shown in fig 3 which was created with the following code see file fileds pic Case Of down CS1 arrow R1 decision 1 1 sf Decision 1 at Ri c move to Ri s arrow R2 decision 1 1 sf Decision 2 at R2 c move to R2 s arrow R3 decision 1 1 sf Decision 3 at R3 c Process A Process 1 Process 2 Process B If T hen Else Process C Seq uence Process X While Do Figure 2 Basic program flow structures move to R3 s arrow PD process 1 1 sf Default sf Process at PD c move to PD s Li line move to Ri e right arrow Pi process 1 1 sf Process 1 at Pl c move to Pi e P1A arrow move to R2 e right arrow P2 process
15. uage The following code shows the implementation of the macros developed to plot the flowchart symbols of the examples presented in this document The code of these macros should be included at the beginning of your own flowcharts as explained in section 3 PS 20 25 4 Scale drawing to 20 25 4 in 20 25 4 in 25 4 mm in 20 mm FLOWCHART Basic flow chart blocks scale 25 4 Scale units from inches to mm csize 2 0 Cell size in mm pstricks 1 dx 0 dy 2 sshade Starts shading of an arbitrary closed curve define sshade if pstricks 0 then sprintf special sh g 0 1 command special sh 0 1 else sprintf newgray xcolor s 0 9 command newgray xcolor 0 9 command pscustom fillstyle solid fillcolor xcolor eshade Ends shading of an arbitrary close curve define eshade if pstricks 1 then command define process w 1 12 csize h 2 8 csize B box wid w ht h invis sshade 19 line from B ne to B nw to B sw to B se to B ne eshade 3 at B c data parallelogram gt data input output block define data w 1 12 csize h 2 8 csize dx h 4 2 B box wid w ht h invis sshade line from B sw dx 0 to B se dx 0 to B ne dx 0 to B nw dx 0 to B sw dx 0 eshade 3 at B c define connector r 1 2 csize sshade B circle rad r eshade 3 at B c 1 decision rhomboid gt if block define decision w 1 1
16. ure vector f p at POa c move to POa B s arrow alen initialize the for loop on c c is the class label H1 preparation 1 5 0 5 parbox 6em centering sf c 0 at H1 c move to H1i B s arrow alen C1 connector crad arrow alen check if the for loop on c is done R1 decision 1 1 parbox 6em centering sf c lt N_ classes at R1 c move to R1 B w sf no above rjust move to R1 B s sf yes below ljust move to R1i B s arrow alen 14 check if the feature at pixel p f p can be classified as the class c due to the proximity with respect to the class feature vector f_c Ria decision 1 1 parbox 7em centering sf footnotesize f p f_c lt lambda at Ria c move to Ria B w sf no above rjust move to Ria B s sf yes below ljust move to Ria B s arrow alen Pia process 1 0 5 parbox 6em centering sf amp img p c at Pla c move to Pia B s down arrow alen Cle connector 0 1 move to Ria B w left line line alen line gt down Rlia c y Pia n y Pib process 1 0 5 parbox 6em centering sf amp img p 0 at Pib c move to Pib B s line gt down Pib s y Cle c y then right to Cle w move to Cle s down arrow alen P1 process 1 0 8 parbox 6em centering sf Increment class c leftarrow ct1 at Pi c move to P1i B s Lia line alen close for loop on c move to Lia end right line line up line Ci c
17. y Here y left line gt to Cl e end for loop on c move to R1i B w left line line line line down R1i B w y P1 B s y 2 alen line right P1 B c x Here x 15 Lib arrow down alen move to Lib end down PO process 1 0 8 parbox 6em centering sf Update position p leftarrow p Delta p at PO c close for loop on p move to PO B s line down alen right line line line line up CO c y Here y line gt left to CO0 e end for loop on p move to RO B w left line line line line line down RO B w y PO B s y 2 alen line right PO B c x Here x LOb arrow down alen TO terminator 1 0 5 parbox 6em centering sf End at TO c 4 Compiling pic drawings to BTEX Processing pic code can be done using dpic or the GNU pic interpreter gpic The output formats produced by dpic and gpic are completely different see Ch 12 of the circuit macros documentation 3 or the dpic manual 4 for a com plete description of the multiple formats The differences can be summarized in e dpic produces PSTricks commands e gpic produces tpic TEX pic special commands that have to be later processed with a printer driver that understands tpic special commands such as dvips Depending on the approach chosen and the version of your dvi or Postscript viewer the output produced with gpic may be correctly displayed only under the Postscript viewer e g gv Ghostview but not under the dvi viewer
Download Pdf Manuals
Related Search
Related Contents
vSphere-Administratorhandbuch für virtuelle Maschinen Gigabyte GA-7VA Computer Accessories User Manual Samsung ST88 מדריך למשתמש ,4L, c o4,/b IntelliJacks RV Leveling System Users Manual pompe rf GEM-2 User`s Manual Origin Storage 500GB 7200RPM Enigma FIPS Notebook Drive Owners Manual2 Gravity inversion (C11) Copyright © All rights reserved.
Failed to retrieve file