UsingXFig
PeterHiscocks
Departmentof ElectricalandComputerEngineeringRyersonPolytechnicUniversity
December26,2001
1
Contents
1 ProducingDocuments 41.1 DocumentProcessingTools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.2 BitmapandVectorDrawing Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 Applying XFig 4
3 Drawing Tools 4
4 Editing Tools 64.1 Grouping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84.2 Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94.3 Align . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94.4 Move,Add andRemoveVertex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94.5 Delete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94.6 UpdateParameter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104.7 Edit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104.8 HorizontalandVerticalFlips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114.9 Rotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114.10 Splineto/from StraightLine Segment/ Box to/from Arc-Box . . . . . . . . . . . . . . . . . . . . 114.11 Add / RemoveArrowhead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5 Importing and Tracing: the PictureObject Tool 11
6 CreatingSchematicDrawings 12
7 Incorporating Figuresin Text 167.1 Latex PictureFormat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167.2 Pictex Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177.3 PostscriptFormat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177.4 EncapsulatedPostscript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177.5 GIF Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
8 Printed Cir cuit Board Design:Filled Ar eas 19
9 Perf Board Layout 21
10 ScreenCapture to Xfig 22
11 Making OverheadsusingXfig 2211.1 LargeFonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
12 Automatically Changing Exported Sizeand Format 24
2
13 Configuring Xfig 2513.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2513.2 ScreenSize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2613.3 Colour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2613.4 HELP Doesn’t Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2713.5 References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3
1 ProducingDocuments
We areblessedto live in a time whendocumentproductiontools,word processorsanddrawing programs,havebecomeaccessibleto everyoneandrelatively easyto use. Thesedocumentprocessorsallow us to producedoc-umentsrangingfrom shorttechnicalpapersto extensive textbooks,documentsthatarethatarepleasantto view,easyto read,andentirelyelectronic.
As recentlyasthemid-80’s, we werestill usingrubbercementto pastefiguresinto documents.If they stillexist at all, thedocumentsthemselvesarenow falling apart:thehand-drawn diagramsareyellow, andfall off thepagethatthey weremountedon.
In contrast,anelectronicdocumentdoesnot ageandcanberevisedwith ease.Sectionsof it canbecut andpastedfor usein otherdocuments.Copiesareclean:they arenotmarkedup with correctionsandrevisions.Theycanbetransmittedelectronically. Bestof all, in my opinion,thefiguresareincludedautomatically.
1.1 DocumentProcessingTools
In theUNIX world, XFig is oneof themostpopularandusedprogramsto producediagrams.(Unfortunately, it isnotavailableto rununderDOSor Windows). OthertoolsincludetheLATEX text processingprogram,GNUPLOTfor generatinggraphs,xdvi andghostviewfor viewing documents,andxv for manipulatingimages.Thissuiteofprogramsmakesit possibleto producehighqualitydocumentsthatcanbeprinted(treeware) or viewedon-screen.
1.2 Bitmap and Vector Drawing Programs
Therearebasicallytwo typesof drawing programsin this world: bitmapandvectorprograms.Paint programs,suchasXPaint, work with bitmaps, which aregroupsof pixels. Thedrawing programlays
down andmanipulatesindividual pixels in variousways. Paint programshave their uses,but it is difficult tocreateandmanipulatesymbols,andthey aregenerallynot suitablefor technicaldrawings. On the otherhand,paint programsaregoodat generatingdifferentfill patterns,creatingshapes(suchascurves),andcomplicatedshading.
Vectordrawing programswork with drawing elementssuchaslines, circlesandpolygons. Theseelementsmaybegroupedandmanipulatedin variousways,suchasbeingmovedor sized. Vectordrawing programsarewell suitedfor technicalwork suchaselectronicschematicsandmechanicaldiagrams.XFig is a vectordrawingprogram,andit hassomepaint-programfeatures.For example,it is possibleto fill areas.Unlike paintprogramshowever, XFig hasaproblemwith complex curves.
2 Applying XFig
Thedrawing programXFig canbeusedto createa wide varietyof technicaldrawings. It’s not difficult to learnto useXFig, but it cantakeawhile to learnto useit in aneffectiveandefficientmanner. This reportassumesthatyou have learnedthebasicsof operatingtheprogram.It provideshintson varioustechniquesthatmaybeusefulwith the program. It is not intendedto be a comprehensive manualfor the program: that is the purposeof theHTML pages,whichmaybeviewedby any browser, andtheMAN entry.
3 Drawing Tools
Thedrawing toolsof XFig areshown in figure1.
4
Regular Polygon
Straight LineIrregular Polygon
Rectangle Arc-Box
ArcRegular Polygon
Text
Spline Curves
Circles and Ellipses
Library Tool
Figure1: XFig Drawing Tools
(XFig wasusedto createfigure1. Theprocedureis describedin section10.)Most of thedrawing tool operationsarestraightforward,but herearesomemiscellaneoushintson theuseof
thevarioustools:
� TheSpline Curvesaretheonly availablemethodfor constructingsmoothcurves.Theuppersplinepassesthroughthetwo endpointsandapproximatestheotherenteredpoints.Thelower splinepassesthroughallthedrawn points.
� TheLine is drawn by specifyingthestartingpoint andsubsequentpointswith mousebutton1 andtheendpointwith mousebutton2. A freehandline (andspline)maybedrawn by startingwith mousebutton2.
� WhentheRegular Polygon tool is selected,a parameterbox appearsat thebottomof thescreen,allowingoneto specifythenumberof verticesin thepolygon.By creatingapolygonwith n verticesandthendrawing
5
constructionlinesfrom thecentreof thepolygonto thevertices,onecansubdivide a circle into n-1 equalsegments.This is usefulwhendrawing somethinglikea CompassRose,for example.
� The Ar c is specifiedby markingthreepointswith mousebutton 1. Whena precisearc is required,it isoftenusefulto first draw a circle with thedesiredradiusandcentrepoint. Thenplacethearcpointson thecircumferenceof thecircleasrequired,anderasethecircle.
� Many parametersbecomeavailablewhentheText tool is selected.A widevarietyof text fontsareavailable,and the text can be printed at varioussizesand justifications. To edit text, you can usethe Edit tool(describedbelow). Alternatively, choosetheText drawing tool, click thecursorat thepointof thetext to bemodified,andtypein thedesiredtext.
� Theuseof thePictureObject tool is describedin section5 below.
� SelectingtheLibrary tool popsupapanelfrom whichoneof severallibrariesof Fig objectsmaybeloaded.After selectingoneof theobjectsandpoppingdown thepanel,youmayplacetheobjecton thecanvasoneor moretimesby pressingmousebutton 1 at eachlocation. The imageof the object follows the mousefor placementease.Pressingmousebutton2 while in this modepopsup thelibrary panelwhereyou mayselectanotherobjector library. Anotherusefulfeatureis thatbeforeplacinganobjecton thecanvasit maybe rotatedclockwise90 degreesby pressing’r’, counter-clockwiseby pressing’ l’, flipped vertically bypressing’v’, or flippedhorizontallyby pressing’h’.
4 Editing Tools
Theeditingtoolsof XFig areshown in figure2.
6
and to/from box/arc-box
Edit
Rotate clockwise
Scale
Flip horizontallyFlip vertically
Rotate counterclockwise
Group Ungroup
Ungroup temporarily
Move vertex Move
CopyAdd vertex
Remove vertex Delete
Transform to/from spline
Align
Add/remove arrow tofrom line
Update parameter(s)
Figure2: XFig EditingTools
7
Thesetoolsaredescribedin thefollowing sections:
4.1 Grouping
Oneof themostusefulfunctionsin any drawing programis theability to specifya groupof symbolsinto whatis calleda compoundobject. This effectively allows you to createany objectandthenmove it asa unit in thedrawing.
For example,an electronicsymbol consistsof an arrangementof circles and lines. Oncegroupedinto acompound,thesymbolbecomesa transistorandmaybepositioned,rotated,or becomepartof a largersymbol.
Ondigital schematics,groupingmayapplyto abunchof gatesthatperformsomefunction,suchasbuffersona digital bus.They maybegroupedandmovedasan8-bit buffer unit.
In XFig, symbolsaregroupedasfollows:
1. Selectthecompoundtool by clicking on it with mousebutton1. Thetool darkensto indicateit is selected.At thesametime,handles(squares)will appearon eachsymbolof thedrawing.
2. Selectthe itemsoneat a time to be grouped,by clicking on eachitem handlewith mousebutton1. Thehandleof eachitem will darkenwhenit is selected.If you changeyour mind, click on thesamehandletounselectthatitem.
3. Whenreadyto makethecompound,click mousebutton3. Handlesof theselecteditemsdisappearandnewhandlesappearat thecornersof thenew compoundobject.
Often,it is fasterto groupa wholebunchof thingsat once.This is doneasfollows:
1. Selectthecompound tool by clicking on it with mousebutton1.
2. Selecta groupof itemsby pressingmousebutton2 anddragginga rectanglearoundthegroups.Whentherectangleis positionedcorrectly, click mousebutton2 again,andeverythingwithin thegroupis selectedatonce.
3. Click mousebutton3. Handleswill thenappearat thecornersof thenew compoundobject.
Ungrouping(breaking)is mucheasier:
1. Selectthebreakcompound tool (mousebutton1).
2. Selectthecompoundto be’broken’ (mousebutton1). Thehandlesof theindividualobjectsappear.
3. Click onthehandleof thecompoundobjectto bebroken.It becomesindividualobjects,andtheir individualhandlesareshown.
If you only want to modify an object in a compoundobjectbut don’t want to hasslewith ungroupingandre-groupingit, theopencompoundtool is useful.
1. Selecttheopencompoundtool (mousebutton1).
2. Selectthecompoundto be’broken’ (mousebutton1). All theotherobjectsonthecanvasdissappearexceptthe compoundand the handlesof the individual objectsin that compoundappear. Also, a popuppanelappearswith two buttons:‘CloseThisCompound’and‘CloseAll Compounds’.
8
3. After editing the objects(including addingnew objectsanddeletingobjects)click on ‘Close This Com-pound’ to automaticallyre-groupthe objectsinto the compoundandmake the otherpartsof the drawingre-appear. You mayrepeatedlyopencompoundobjectswithin othercompoundobjects.If you areinsideacompoundthatis severallevelsdeepinsideothercompounds,the‘CloseAll Compounds’buttonwill closethemall up in onestep.
4.2 Scaling
In general,I don’t usethis tool very often. Whenyou areworking to a rectangulargrid (snap-to-griddrawing),you expectvarioussymbolsto line up in a particularway. For example,thebaseof a transistorshouldalwaysbeon agrid point. However, scalingsymbolsdestroys thatsimplerelationship.
Thatsaid,thescalingcontrolis quiteversatile:anobjectmaybescaledhorizontally, vertically or diagonally.Thelastmethodchangesthesizeof theobjectwithoutchangingits proportions.
4.3 Align
This tool is usefulwhenyouwanta precisealignment,verticalor horizontal,andsnap-to-gridis not anoption.
1. Grouptheobjectsto bealignedasdescribedin section4.1above.
2. SelecttheAlign tool.
3. Fromthe Alignment Parametersat thebottomof the drawing area,selectthe typeof alignmentdesired(oneof six possiblities).
4. Click on thegroupandtheobjectsin it will bealignedasrequired.
Nifty.
4.4 Move,Add and RemoveVertex
Thesetoolsarevery useful.They canbeusedon many of thedrawing objectsto modify theshapeof theobject.For example,a line vertex maybemoved,a line maybebrokeninto additionalsections(kinked),or a line maybereducedto fewersegments(straightened)with thesetools.
Onecaution:whenaddinga vertex to a spline,theaddpoint mustbeon animaginarystraightline betweentwo existing vertices,not on thesplinetraceitself. This cantake a while to figureout if you don’t know what’sgoingon . . . .
4.5 Delete
SelectDeleteandthenclick on anobjectto eraseit. If you makea mistake,Undo will bring theobjectback,butkeepin mind thatthereis only onelevel of undo.Youcanonly Undo thelatestaction.
To erasea groupof objects,selectDeleteandthenusethemiddlemousebuttonto draga selectionrectanglearoundtheobjects.Click themiddlebuttonagainandtheobjectsareerased.
9
4.6 UpdateParameter
This tool is not a must-usewhenyou arefirst learningXFig, but it canbe a real time-saver later. The Updatetool allows you to changean object’s propertiesby clicking on the object. As a consequence,it is especiallyusefulwhena largenumberof objectsmustbechanged.For example,you might decidethatevery text stringona drawing shouldbelarger. Onepossibletechniqueis to Edit every text string.However, Update is muchfaster.
Here’show it works: WhenyouselecttheUpdate function,theUpdateParametersareshown at thebottomof the screen.Unfortunately, there’s not enoughroom to show themall, but the importantonesarethere. (Youmayhave to scroll it usingthescrollbarbelow it to seeall theparameters).Now, whenyouclick on anobject,itspropertieswill bechangedto thepropertiesshown in theUpdateParameters list.
There’sanotherway to do this,which is quiteuseful:
1. SelecttheUpdate tool
2. ChoosesomeobjectA thathastheparametersthatyou would like to copy to anotherobject.Click on thatobjectwith mousebutton2 insteadof button1.
3. Theparametersof this objectarenow transferredto theUpdateParametersdisplay.
4. Now click ontheobjectB to beupdated,usingmousebutton1, andobjectB will acquirethesettingsof theobjectA.
Furthermore,andthis canbea life-saver, if youupdatea compoundobjectsuchasanobjectwith severaltextstringsincludedin it, everysubobjectin that container(in this case,every text stringin thatobject)will acquirethenew properties.
If you only wantto affect certainparametersof anobject,therearelittle redboxesin theupper-right cornersof theUpdate Parametersbuttons.You canselectanddeselectthosesettingsthatyou want to usefor updatingobjectsor thepanelitself. In addition,you mayturn all theboxeson by pressingthesolid redbutton in theboxlabelledUpdate Control which appearson the left sideof theUpdate Parameterspanel.Thereis alsoa blackbuttonwhich turnsoff all theupdateboxesanda half red/halfblackbuttonwhich togglesthecurrentstateof theupdateboxes.
4.7 Edit
TheEdit tool allows you to view or changethepropertiesof anobjectusinga dialogpopup.Themostcommoneditsare
� alteringthecontentof a stringof text
� changingtext justificationleft, right or center
� changingthepoint sizeof a text string
� enablingthe specialflag on a text segmentso LATEX will processit asa specialsymbol. Don’t forget toenclosethetext stringin $ signs,asrequiredby LATEX , if thestringrepresentsa mathsymbol.
� changingthewidth of a line segment
� changingthedepth of anobjectsothatit is displayedaboveor below someotherobject.Objectsat level 0areon top,highernumberedobjectsareat lower (possiblyhidden)levels.
10
4.8 Horizontal and Vertical Flips
Not muchto say: they work asadvertized.In addition,for theseandtherotationbuttons,pressingmousebutton2 insteadof 1 will first makea copy of theobjectthenflip or rotateit.
4.9 Rotations
Again,prettystraightforward,but noticethattherotationanglecanbechangedin theParameterDisplaylist.
4.10 Spline to/fr om Straight Line Segment/ Box to/fr om Ar c-Box
Thiswill converta splineto anordinaryline or abox to anarc-boxandviceversa.
4.11 Add / RemoveArr owhead
Not only doesit work, but thealgorithmis smartenoughto know which way thearrow shouldpoint. Workswithall typesof lines,too,not juststraightones.To removearrowheads,click mousebutton2.
5 Importing and Tracing: the PictureObject Tool
It is possibleto import a ’picture object’, suchasa bitmap(GIF, JPEG,etc.) or a drawing or photographthathasbeenscanned,into XFig. Thismaythenbescaled,rotated,andincorporatedinto thefinal drawing. FormatssuchasEPS,GIF, JPEG,TIFF, andothersaresupported.
I found this very useful in the productionof a textbook. The authorhadproduceda largenumberof hand-drawn chartsandgraphsthatwereto beincorporatedinto thefinal text. UsingaflatbedscanneronaDOSsystemat the university, I scannedeachof the imagesinto an epsfile. This wasaggravatedby frequentcrashesof theDOSsystem,andthefileshadto bescannedat low resolutionto fit ontoafloppy disk.
Thequalityof thescanwasunuseablein thefinal text: line widthswerevariableandtherewasa lot of imagenoise.I loadedeachepsimageinto XFig, tracedtheimage,andthendeletedtheepsimage.Theresultanttracingwasof a form thatcouldbe incorporateddirectly into the text, with thebonusthat it wasnot only of far higherquality thanthescan,but alsoa muchsmallerfile size.
Tracingthe imagewasfacilitatedby the XFig undo feature. In the processof tracing,I would periodicallydeletetheepsimageto comparethetracingwith theoriginal. Then,whenI knew whathadto befixed,I wouldundo thedeleteto restoretheepsimagefor furthertracing.
In anothercase,I wishedto produceanannotatedphotograph:a photographcontainingdescriptive text withpointersto differentareasof thephoto.This is easy:import thephoto,markit up with lines,arrowsandtext, andthenexportor print it.
Theprocedurefor importinga pictureimagetakesseveralsteps:
1. Ensurethatthepictureimage(foo.eps,for example)is in a known locationin thefile system.
2. Selectthepictur eobject tool by clicking on it. Nothinghappensjust yet.
3. UsingButton1 of themouse,draga rectangle(any size,it doesn’t matter)ontothedrawing canvas.
4. Click Button1 againto lock thesizeof therectangle.A dialogbox appears.
11
5. Type the file name(foo.eps)into the file selectorfield and click on Apply. The imageloads into therectangle.
6. Click ontheuseorig sizebuttonto establishtheepsimageat its originalsize,or enterapercentof full-sizevalueandclick theScaleby % buttonandthenclick theApply buttonagain.The imageadjustsitself tothecorrectsize.
7. Click on Doneto exit thedialogbox.
Thepictureimagecannow berotated,movedandsizedasdesired.
6 Creating SchematicDrawings
Extremelycomplex electronicdiagramsmay be donewith easeusingXFig. I’ ve movedaway from pencil andpaper:onceI have a roughideaof the circuit, I draw it out usingXFig andthenproceedto analyseandtest itfurther. Pencildrawingsnow seemtoo slow anddifficult to change.
I havecreatedalibrary of schematicsymbolsasonexfig drawing,calledsymbols.fig, which is shown in figure3. In version3.2.1of XFig with theadditionof theLibrary Tool, thesesymbolshave beenincorporatedinto theElectrical andLogic librariesto make it easyto createschematics.
You simply click on theLibrary Tool buttonto popup the library panelandpull down themenuof currentlibrariesandchoosetheoneyouwant.This loadsthelibrary of objectsinto xfig wherethey appearin ascrollablelist. Singleclicking onanobjectwill makeits imageappearin theObjectPreview window. Whenyouhavefoundtheobjectyou wantpresstheSelectobjectbuttonto selectit andpopdown thelibrary panel.Doubleclicking ontheobjectnamewill selectit andpopdown thepanelin onestep.
Now, asyou move themouseover thecanvasyou will seetheobjectyou aredragging.If you needto rotateit or flip it beforeplacingit, press‘r’ to rotateit clockwise(right), ‘l’ for counter-clockwise(left), ‘h’ to flip ithorizontally, or ‘v’ to flip it vertically.
Whenyou have it in thecorrectorientationandpositionon thecanvasclick mousebutton1 to placeit. Youcanplacethesameobjectoverandoveragain.
If you want to selectanotherobjectfrom the library, click mousebutton2 andthe library panelwill popupagain.
As with all xfig operations,clicking mousebutton3 cancelsthelibrary operation.BesidesusingtheLibrary Tool, therearevariouswaysto usepartsof existing figuresto createnew figures.
The MergeLoad
To merge anotherdrawing into your drawing without destroying the drawing, underthe File menu,choosethefiguretomergeandpresstheMergebutton.Thiswill mergethenew figureintoyourexistingfigureasacompoundobjectwhich thenmaybemoved,scaled,etc.
Alternatively, you cancutandpastefrom anotherinstanceof XFig, asdescribednext.
Cutting and Pasting
Unix is amulti-taskingoperatingsystem,soit is possibleto invokemorethanoneinstanceof XFig. StartupXFigtwice: oneinstancewill beusedto draw thepicture,which I will call schematic.fig. Theotherinstanceshouldbestarted,andthefile symbols.figloadedinto it. I will call this symbols.fig.
It is now possibleto cutandpastesymbolsfrom symbols.figinto schematic.fig.
12
1. View thesymbols.figdrawing by openingits window.
2. Selectthecopy function.A little box ’handle’ appearswith eachsymbol.
3. RightClick (button3) on thehandle.A message’object copiedto scrapfile.fig’appearson thestatusline.
4. View the schematic.figdrawing by openingits window. Click on the PASTE function at the top of thewindow, andtheselectedsymbolwill appearin yourdrawing.
If you only needa few symbols,you cancut andpasteoneat a time. If you needa bunch,make a groupinsymbols.figandpastethatgroupinto schematic.fig.
An exampleof a schematicdiagramcreatedwith this process,is shown in figure4.
13
Q
Q’
D
+
-
RTCT
Q
Q’
+
B
A
CHARPIXEL
CEP
CET
CP
TCAC161
MR Q0 Q1 Q2 Q3
PE P0 P1 P2 P3
CLKLOADINHIBITCLK
15 1 2
Qh 9
F G HE
3 4 5 6
A B C D
11 12 13 14
HC165SER10
HC244
17
15
13
11
2
4
6
812
14
16
18
9
7
5
3
1
19
Vref-V-Comp
V+VlcVref+
MSB LSBData
DAC0800LCN
14
15
1
16 3 5 6 7 8 9 10 11 12
4
2
13
Iout
Iout*
Y0
Y1
Y2
Y3
4
5
6
7
G1
A
B2
3
1/2 HC139
1QB
+
CLR
15QA
2QC
QD3
QE4
QF5
6QG
QHQH’
9
HC595
OE
DATA
SCK
RCLCK
10 13
7
14
11
12
Q8 Q9 Q10Q11Q12
141213 15 1
Clk10
Reset
11
Q1 ;Q2 Q3 Q4 Q5 Q6 Q7
4235679
74HC4040
4
2
1
15
14
13
12
3
7ENBL
11
10
9
S0
S1
S2
AC151
I7
I6
I5
I4
I3
I2
I1
I0
6
Z
5
Z
A
B
C
G1
G2A
G2B
74LS138
Y0
Y1
Y2
Y3
Y4
Y5
Y6
Y7
Figure3: SchematicSymbols
14
+
- R2 5k1
+
-
+
-
+
-
D2
1N4001
Ryerson Polytechnic University
Revision: 0.1
Motor Speed Controller
Peter Hiscocks, October 30, 1997
File: motcon2.fig
Print at 70%
1
U1
B C E
Q1
R2
25k 21
3
D11N4148
Speed
5k1R3
R4
5k1
9
10
8
5k1R5 R6
C1100n
12
1314
R7
3k9
R8
1k0
5
67
11
4
Q1
TIP120
C2
16u, 10V
R175k
Supply
5VDC
Motor
0.2 ohm
800mA, 1 ohmR9
NOTES:
Q1 may be any NPN type TIP series Darlington transistor.
Q1 must be on a heat sink, area 3 inches squared
Op amps are from Quad Op Amp, LM324N or LM324AN (DIP package).
Recalculate resistor values to suit other components.
For D1, any small signal silicon diode may be substituted
For D2, any 1N4000 series diode or 1 amp diode may be substituted.
10k
U1AU1C
U1B
U1D
R9 is 5, 1 ohm resistors in parallel
Figure4: Motor ControlCircuit
15
As time passes,you will build up a library of usefulfunctionsthat you canaddto the installedlibrariesoryourown libraries.Or youcancutandpastefiguresfrom previousprojectsinto new projects.For example,I havecreatedanelaborate68HC11boardschematicthathasbeenpastedinto variousprojectschematics.
Why not usea SchematicCAD Program?
Programsfor thedesignof printedcircuit boardsoftenincludea schematiceditor. Theprintedcircuit layoutsarefine, but I’m not a big fanof theschematicdrawingsthey produce.Thedrawingsareoftendifficult to readanddo not show a logical flow from left to right, top to bottom.Thepointswherewiresattachto a symbolareoftenfixed,regardlessof thepositionof thesymbol,whichmakesfor aconfusingdrawing. Ontheotherhand,theCADschematicinterfacesdirectly with thelayoutfunction: if theschematicis correct,thelayoutwill becorrect.
It would be nice if it were possibleto convert a schematic,drawn underXFig, into a form that could beimportedinto a printed-circuitboarddesignprogram,suchasORCAD.
7 Incorporating Figuresin Text
XFig includesanExport facility, in which thefile descriptionmaybeexportedto differentfile formats.ThemostusefulonesareLatex Picture, Pictex, Postscript, EncapsulatedPostscript andbitmapformatssuchasGIF ,JPEG, TIFF andseveralothers.
Thedifferentfile formatsallow figures,drawn in XFig to bereadbyothercomputerprogramsandincorporatedin varioustext documents.
Theadvantages,disadvantagesandusesof theseformatsareasfollows:
7.1 Latex PictureFormat
TheLATEX text processinglanguagehasa limited numberof drawing commands:circle,box,andline, andthesemaybeusedto draw simplepictures.For theLatex Picture format,XFig copiesout a descriptionof thepicturein commandsthatcanbedirectly processedby LATEX. Thefile maybe calledinto themain text documentwiththeLATEXcommands:
\begin{figure}[htb]\begin{center}\input{figures/cooling-function.lat ex}\end{center}\caption{Cooling Functions}\label{fig:cooling-function}\end{figure}
wherethe figure to be incorporatedis in the sub-directoryfiguresandis namedcooling-function.latex. Thefigurewill becentred,haveacaptionCooling Functions, andmaybereferredto in thetext by its symbolicname,fig:cooling-function. (Thatway, theprogramnumbersthefiguresautomatically, andtheauthordoesn’t have tobeconcernedwith thatchore.)
Latex figuresareprocessedquickly, which is not thecasefor someotherformats.Onebig advantageof theLatex Picture format is thatany LATEX symbolor mathematicalexpressionmaybe incorporatedin the picture.In electricalengineering,onequiteoftenneedssuchsymbolsas
�and � on drawings. This is accomplishedby
writing $\Omega$ and$\mu$ on thediagramwherethey arerequired. If the Text Flag for that text is setto
16
Special, then it will be incorporatedverbatimin the descriptionof the drawing andLATEX will put the correctsymbolon thedrawing.
The Text Flagmay be accessedby selectingthe XFig Edit functionandthenselectingsometext. The editdialogbox thenpopsup andincludesaswitchthatcanmake thetext Special.
WhentheText drawing modeis selected,theSpecialswitchis accessibleundertheText Flagscontrolat thebottomof thedrawing canvas.
7.2 PictexFormat
Therearecertaindrawing elementsthat LATEX cannotcopewith directly. For example,lines at certainslopes,circlesof certaindiameter, andcontinuoussplinecurvesarenot allowed. To copewith this, the Pictex formatdoesall drawing by placinga seriesof points.As a result,thethePictex formatcandescribeextremelycompleximages,but thereis a priceto pay. ThePictex formatis bothlargerandslower to process(much slower) thantheLatex format.A documentwith many Pictex inclusionscanbringa 486-66to its knees,soit is bestto usePictexonly whenneeded.
ThePictex formathastheadvantagethat,like theLatex format,it canincorporateLATEX symbolsdirectly.The incantationto includea Pictex imageis exactly the sameasshown above for a Latex image,with the
differenceof thefile namesuffix, which is .pictex, of course.Thestartof theLATEX documentmustincludethestatement
\usepackage{piclatex} % Pictex drawing package
sothatit includesthenecessarymacrosto processpictex drawings.(If you usethis package,youwill gettheseerrormessagesat thebeginningof processingthedocument:
l.1444 \setplotsymbol({\fiverm .})% ** initialize plotsymboll.1730 \setshadesymbol ({\fiverm .})% ** initialize plotsymbol
Simply pressreturnto getpastthis: themessagesmaybeignored.)
7.3 Postscript Format
Many printersacceptpostscriptformattedfiles directly. The Ghostview previewer may be usedto observe apostscriptfile, andcanprint selectedpagesfrom the postscriptfile to a printer. Thus, if you werecreatingadocumentto betakento anotherprinterandprinted,youwould probablyexport to thepostscriptformat.
Whenexporting aspostscript,alwayspreview the imageusingGhostscript,to ensurethe imageis the rightsizeandorientation.
Postscriptimagesarenotdirectlyimportableintodocuments:thatis thefunctionof theEncapsulatedPostscrip-t format.
7.4 EncapsulatedPostscript
Thereis very little differencebetweena postscriptfile andan epsfile: only the differenceof the boundingboxstatement.Thepreambleof thepostscriptfile says
%%BoundingBox: 65 242 547 550
Thepreambleof theepsfile says
17
%%BoundingBox: 0 0 482 308
Thepostscriptfile specifiesan absolutepositionfor the image: the epsfile is intendedto beoffsetby someamount,determinedby the programincorporatingthe diagram. This is useful to know, sinceonehasoften toconvert from one form to another, and this can be doneby editing the BoundingBox statement. The otherdifferenceis that the PostScriptfile containsa showpage commandwhich tells the printer to actuallyprint thepageafterrenderingit.
EncapsulatedPostscriptfilesmaybeincorporatedin a LATEX drawing with anincantationlike thefollowing:
\begin{figure}[htb]\begin{center}\epsfig{file=figures/symbols.eps}\end{center}\caption{Schematic Symbols}\label{fig:symbols}\end{figure}
wherethediagramis in thefiguressubdirectoryandis namedsymbols.eps.Thestartof theLATEX documentmustalsoincludethestatement:
\usepackage{epsfig}
to tell LATEX to incorporatethenecessarymacrosto processepsdocuments.For reasonsnotedbelow, the processingof epsimagesis instantbecauseLATEX doesnot processthem. It
simply makesanoteof thelocationof thedrawing andits size.Thebig disadvantageof encapsulatedpostscriptformatis thatit cannoteasilyincorporateLATEX symbols:the
XFig Specialflagdoesnotwork. Therearewaysto getaroundthis,but they arecomplicatedand,in my opinion,it is easierto simply usethePictex formatwhenthediagramis complex andLATEX mathor greeksymbolsmustappearon thediagram.
The Caseof the Missing Pictures
Thereis oneimportantthing to understandaboutincorporatingepsdocumentsin a LATEX document.WhenyouprocessLATEX , it producesa .dvi (Device Independent)file. Thenthis file may be previewed usingthe viewerprogramXDVI, which showsveryniceimagesof thegeneratedtext andits includedpicturesanddrawings.
Now, the epsfiles that constitutethe imagesin the documentarenot actuallyprocessedinto the text of the.dvi file. The .dvi file includespointersto theepsfiles (andboundingbox information),andXDVI simply goestothosefiles whenit needsto displaya picture. This is fine: if you have anepsimagebeingshown by XDVI andyou edit theimagein someway, thenthatedit will bereflectedimmediatelyin theXDVI display:you don’t haveto re-LATEX thefile.
However, if you wereto carry the .dvi file to anotherlocationandthendisplayor print the file, the imageswouldnot bepresentunlessyou explicity broughtthemalong.
The solutionto this is to ensurethat any documentcontainingepsimagesis convertedto postscriptformatbeforetransportingit. Theprogramdvipsis commonlyusedfor this, andit inhalesboththe .dvi text file andthe.epsimagefiles,andgeneratesa compositepostscript(.ps) file. This postscriptfile is now thefinal material,textandpictures,andit canbepreviewedusingghostview.
18
7.5 GIF Format
I have not actuallyusedthis facility (version2.1 doesn’t includeit) but it shouldmake it possibleto incorporateXFig picturesin Windows-basedprogramssuchasWordPerfector MicrosoftWord.
Microsoft Word claimsto beableto import epsfiles, but it requiresa TIFF-basedpreview bitmapin theepsfile to view it on thescreen.It will, howeverprint correctlyevenwithouta preview.
8 Printed Cir cuit Board Design: Filled Ar eas
XFig canserve asa printedcircuit boardlayout tool for simplePC boarddesigns,whenmostof the circuit isdiscretecomponents.It’snot really up to a complex designor onewherea largenumberof IC’sareinvolved,butfor analogcircuitsor preliminarylayoutof a design,it’squiteuseful.
Thefirst hurdleis thescalefactor. Integratedcircuitsandelectroniccomponentsarelaid outonahundred-milgrid: 0.1 inchesor somemultiple thereof.TheXFig grid, on theotherhand,is sixteendivisionsto aninch. (Thisrefersto version3.2patchlevel 1 of XFig, andlaterversionsmaydiffer.)
Onesolutionis to definetwo XFig divisionsas0.1 inches. They areactually0.125inches,so the drawingmustbescaledby a factorof 0.8 to producea full-sizedprint. Fortunately, thereis a Magnification functiononthePrint dialogbox,whichcanbeusedto print at a magnificationof 80%.
To draw acopperareaonaPCboard,useoneof theclosedpolygonfunctions.Whenoneof theseis selected,afill styleselectorappearson thebottomline of thescreen.Thedefaultfill patternis none. Popthiscontrolopenandthenselecta desiredfill pattern.(To save ink, chooseoneof thelessdensepatterns.)
Now you’rereadyto createthedesign.Usetheoutlinesfrom theElectrical Library file. Move thepackagesarounduntil you havewhat lookslike a
feasiblelayout.Eachconnectionon thePCboard,betweentwo or morepins,is an islandof copper. To createanisland,start
by drawing anarbitraryshadedpolygon.Don’t worry abouttheshapeor sizeat this point, just getsomepolygondrawn. Youcanusethesmooth-edgedpolygonor theonecomposedof straightline segments.
TherearethreeEdit Mode tools to modify the shapeof this polygon: move point, addpoint, deletepoint.Whenyou selectoneof thesetools,theverticesof thepolygonareshown ashandles.Usingthethreetools,youcanmodify anddragthepolygoninto any shapeyou want. Adding andmoving pointsallows you to spreadthepolygonto the requiredlocations.Removing pointsallows you to undomistakesor cleanup busy areasof thedrawing.
Whentheboardis finally laid out, print thedrawing at 80%(full size)andthenusea copierto print ontoanadhesive film material. Peeloff the paperbackingandstick the now-printedfilm to a barecopperboard. (It’ simportantthat theboardcoppersurfacebecleanandfreeof contaminants.Polishtheboardwith fine steelwooluntil it shines. Thenwipe the boardwith nailpolish remover to remove any chemicalcontaminants.It’s alsocritical thattheadhesivefilm bewell attachedto thecopper, andnot containany air bubbles.)
Usingtheprintedpatternasa guide,usea razorknife to cut away thefilm wheretheboardshouldbeetched.Whenthis is complete,immersetheboardin ferric-chlorideetchantto createthefinal board.
An exampledrawing of a boardmadewith this techniqueis shown in figure5.
19
F1
C4
Pow
er S
uppl
y La
yout
Foi
l Sid
e V
iew
C6
Mov
R2
D2
R4
F2
R1
F3
C1
U2
L3
D3
R6
D4
L3
VR
2
R10
R8
U3
R9
D1
C2
C10
L1
BE
Q1 C
BE
CQ2
C3
U1
L2
C9
LED
1
LED
2
LED
3
R7
R3
VR
1
R5
C7
C5
Mic
rogr
id 3
R
221
U4
P.H
isco
cks,
Feb
1996
C8
L5
Figure5: PowerSupplyLayout
20
9 Perf Board Layout
Prototypeelectroniccircuits areoften constructedon uncladperforatedboard. Wire wrap socketsanddiscretecomponentsaregluedto theboard,andthenwiresrun betweentheIC anddiscretecomponentpins.
Alternatively, sometypesof prototypeboardsuchasVeroboardhavecopperstripson thewiring sidethatcanbeusedto make connections.You install wire jumpersrunningNorth-Southon thecomponentsideof theboardandconnecttheseto coppertraceson thewiring sideto run East-West. Thecoppertracesarebrokenat variouspoints,usinga twist drill to eataway thecopper. Theresultsarecompact,reliableandattractive.
XFig is usefulin layingout a prototypecircuit of this type.Thepartsarepositionedon thedrawing andlinesdrawn to indicatethewiring connectionsthatwill take place.Onecolourof line canbeusedto indicatewiresonthecomponentside,andasecondcolourto indicatecopperconnectionsonthewiring side.Partsandconnectionscanbemovedoverandoveruntil thedesignis optimizedfor neatnessandsize.Copperrunbreakscanbeindicatedon thedrawing.
Whenthedesignis finalized,it canbeprintedat full sizeandgluedto theperf board.Theprintedpatternis averyusefulguideto thepositionof components,connectionsandcopperbreakpoints.Thisgreatlysimplifiestheconstructionanddebuggingtask:building theboardbecomesanexercisein following thedrawing pattern.
An exampledesignof this type is shown in figure6. Notice that theboardconsistsof two identicalcircuits.This is wherea drawing programlike XFig is really useful: generatingthe secondlayout is simply a matterofcopying theoriginal.
R4
R6
R5 R
9A
R9B
R9C
R9D
R9E
R7
R2
D6
R8
D1
R3
R4
R6
R5 R
9A
R9B
R9C
R9D
R9E
R7
R2
D6
R8
D1
R3
R1
C2
R1
C2
Ryerson Polytechnic University
Revision: 0.1
Motor Speed Controller, Vero Layout
Print at 80% for full scale print
File: motcon-layout.fig
Peter Hiscocks, Oct 30, 1997Motor-Motor+
Pot WiperPot Gnd
Pot Supply
VccGnd
Motor-Motor+
Pot WiperPot Gnd
Pot Supply
VccGnd
U1
C1
Q1
2.9"
1.6"
U1
C1
Q1
Figure6: VeroboardLayout
21
10 ScreenCapture to Xfig
Theprogramxv is anotherwonderfullyusefulprogramavailablein theUnix world. It is ageneralpurposeimagecaptureandmanipulationprogram.
For thisdocument,weneededimagesof thetoolbarsof theXFig program.Fortunately, amongits many usefulfeatures,xv hasa grab functionwhich allowsoneto captureanareaof thevideoscreen.
First,xv wasusedto grabthetoolbarareaof anXFig window. Then,usingotherxv tools,theimagewasthende-coloured(convertedto grey scale)andthresholdedto a black andwhite image. The xv ’crop tool wasusedtwice on theblack-whiteimageof theXFig toolbarsto make to thedraw andedit toolbars,which weresavedaspostscript(ps) files. (Thereis no optionto saveanimageasanepsfile, sopostscriptis thenext bestthing.)
Eachpostscriptfile wasthenloadedinto XFig, markedup with textual annotations,andsavedasanepsfile.Ghostview wasusedto preview theseepsfiles to ensurethat everythingwasthere.Theepsfile wasthencalledinto theLATEX documentto make thedesiredfigure.
Astonishingly, it all worked.You canalsocapturewindowsandareasof thescreenusingthePictureObject feature,but XFig unmapsall
of its windowsfrom thescreenduringthisoperationto ‘get outof yourway’ soyouwouldhaveto run two XFigsat thesametime anduseoneto capturepartsof theother.
11 Making OverheadsusingXfig
Xfig is a greattool for creatingthe overheadsfor a slide show. Often, the situationis this: you have createdadocumenton a particulartopic andnow youneedto do a presentation.Eachof theoverheadsis to bea summaryof oneof theimportantideasin theoriginalpaper.
Luckily, you don’t needto retypeeachof the overheads.The text canbe cut andpastedfrom the originaldocument.Thefacility to do this is really useful,but really well hidden.
You needto ensurethat the’ text-paste’operationis setup properly. I can’t speakfor othermachines,but onmine(the’Manhattan’distributionof RedHat)thefunctionof this key is definedin thefile
/usr/X11R6/lib/X11/app-defaults/F ig
Edit thisfile, looking for thefollowing stanza:
! make the F20 key paste text in the canvasFig*canvas.translations: #override \n\
<Key>F1: PasteCanv()\n
In this particularcase,thetext-pasteoperationis definedto bethe’F1’ key. Originally, it was’F18’ or someotherstrangevalueandI hadto changeit. You canchangeit to ’F1’ or someotherkey of yourchoice.
Now you’rereadyfor apasteoperation:
� Selectthetext widgetin Xfig.
� Selectany of theXfig text attributes,suchasFont andSizethatyou wantthepastedtext to have.
� Positionthetext cursorwhereyouwantthetext to appearin theXfig window.
� Setup thetext to bepastedsothatit’s visible in anXTerm.
22
� In theXTermwindow, usetheleft mousebuttonto highlight thetext to becopied.
� Movethefocusbackto theXfig window andpressbuttonF1.
� Thetext shouldpastecorrectlyinto theXfig window.
An exampleis shown in figure7. I selectedthe ’Bookman-LightItalic’ 12 point font in Xfig. ThenI copiedthe text from a previousparagraphof this paragraphinto Xfig. I outlinedthe text with a box andsaved it asanencapsulated-postscriptfile at70%magnification.ThenI addedtheinstructionsto thisLATEX documentto importtheepsfile asfigure7.
����� �� �� ��� ������� ����� ��������� ������� ������������ ���!�����#"���$���%�&�� � "��������')(+* ��� ���+,+�-����� �-.������ ���/� ��������10���.2���+� �3��� ����� ��"4�&"��1��.�56�����1���2�&7%���8�-� ��.�� ���%� ��7%� ��(�9:��'0���.2�#����"4� ��"���� 7%� ��������-����� ����(�;<�#���&�-��-���3��� ���!������"�=� �� �.�5)5>��� 0?�-�3�������-����#�=� 5@7����!�����+��� "�����=� �/���������!� ��� �����A7%��7����!(
Figure7: PastedText
Initially, thebox wasthewrongsize. I hadto adjustit in Xfig andre-export thedrawing until it wascorrect.If you’reusingthexdvi viewer, eachtime you resave theepsfile, thenew versionappearsautomaticallyin xdvi.(Youdo have to closeandopenthexdvi window.) Youdon’t have to reprocesstheLATEX document.
Now, how wouldyouassemblea bunchof theseslidesasa slideshow?Onemethodwould beto createa LATEX documentthat importseachoverheadasa separatepagein thedoc-
ument.As you madeup theslideshow, you couldprocessit asa LATEX documentandpreview it usingthexdvipreviewer. If you needto incorporatemathematicsinto the overheads,pastein the LATEX text, mark it as ’spe-cial’ text in Xfig, andexport it to a file format suchasPictex that understandsmathsymbols.Whenthe entireslideshow is assembled,usedvipsto convert it to a postscriptdocument.This is thecompletedslideshow. Useghostview to presenttheoverheadsoneafteranotheror in whateverorderis appropriate.
11.1 Lar geFonts
In theconstructionof overheadsandotherfor someotherapplicationsit is necessaryto havevery largetypefaces.Dependingon your installation,you probablydon’t have typefacesbeyondmuchbeyond24 point. You canaskfor a60point typefacein thetext size entrywidget,but thetext limits at its maximum,whichisn’t thatlarge.Youcanhowevergeneratereally largetypeby exportingthetypein magnifiedform andthenre-importingit backinto xfig. For example:
1. Createthe text, usingthe appropriatetypeface. If it’s not all onesentence,thenusethe groupingtool tomake it oneobject. (If you areusingthis text in a presentation,you might want to usea pencolourotherthanblack.Ghostview cancopewith colours.
2. SelecttheEXPORTmenu,postscriptoption.
3. SettheMagnif% controlto somethinglarge,like400%.Exportthetext to a file test.ps .
You could load the file into ghostview to view it at this point. Or you could load the enlargedimageintest.ps into xv or thegimp imagemanipulationprogramfor furtherprocessing.
To incorporatethismagnifiedtext with otherdrawing elements,re-importthepostscriptfile backinto xfig :
23
1. Click on theCamera icon to import thepostscriptfile.
2. Pressthe right mousebutton, draw a rectangleandthenenterthe nameof the file, test.ps . The textwill appearon thecanvasdrawing area,magnifiedto 400%. It will have significantjaggies(steps)on thecharactersbecauseof xfig’s limitationsin renderingpostscriptcharacters.Ignorethis.
3. Add theadditionaldrawing elements- lines,text, whatever - andthenresave thedrawing.
4. Printor export thedrawing asrequired.
If you areexporting one line of text, you will notice that the postscriptfile imageof the magnifiedtext istruncated:a few pixels are missingfrom the bottom of eachcharacter. To eliminatethis, addsomedrawingelementsuchasa line, below the line of text. Thenthe exportedfile expandsto includethe whole character,without flatteningthebottomsof thecharacters.If the line is objectionable,changeits colour to thesameasthebackground(eg, white) to make it disappear.
The overall resultof this processis not perfect- the final imagestill containssomestair-stepping.But theresultsarequiteacceptablefor mostpresentationgraphics.
12 Automatically ChangingExported Sizeand Format
Considerthe following scenario:you have produceda large numberof diagramsfor inclusionin someTEX orLATEX document.They wereall produced(let ussay)aspictex formattedimagesat 85%magnification.Now yourealizethat they needto be bigger, 115%magnification.You could load the .fig versionof eachfile into xfigandre-export it at thecorrectmagnification,but this is tedious.
A bettersolutionis to usethefig2dev programin a shellscriptto automatetheprocess.The fig2dev programconvertsa .fig formatteddiagraminto somedifferentoutputformat,suchasla-
tex , pictex or postscript . Whenxfig exportsa diagram,it usesfig2dev to generatethe correctlyformattedfile.
Thefig2dev programis partof thetransfig softwarepackage.If theexport functionof xfig workscorrectly, thenfig2dev is installedandworking.
For example,thefollowing commandline will generatethepictex formattedversionof a file foo.fig at amagnificationof 115%.
transfig -L pictex -m 1.15 foo.fig > foo.pictex
The-l optionselectstheconversionto use,in this case,fig to pictex . The-m optionselectsthemagnifi-cation.For all thedetails,consultthemanentryfor fig2dev .
To applythis to a groupof files, you couldput fig2dev in a shellscriptsuchasthefollowing, which I callmakepictex :
#!/bin/bash# This script renames all .tex files to .pictex.# Run it with the full directory path to ensure you run this one# and not some other ’rename’ script.
for i in *.figdo
j=‘basename $i .fig‘
24
fig2dev -L pictex -m 1.15 $i > $j.pictexdone
You canedit the fig2dev line to accomplishthe desiredproductions.The line j=‘basename $i .fig‘stripsoff thesuffix of a file name:for thefile foo.fig , thevariablej becomesfoo by itself. The fig2devcommandthenprocesseseachfig file into pictex formatin afile namedfoo.pictex . Makesurethescriptis executable
chmod u+x makepictex
and invoke it with the full path nameof the directory that it’s in. For example, if it’s in the subdirectory/home/phiscock/papers/op-amps/figur es thenyouwouldexecutethecommand:
/home/phiscock/papers/op-amps/figur es/mak epict ex
Anotherscenariowhereyou might find this useful:yourdocumentcontainsmany diagramssoto save space,you archive the .fig versionof eachdiagramandnot the exportedfile. At somepoint, you find you needtoregenerateall theexportedfiles. A batchfile similarto theabovecanaccomplishthis in onefell swoop.Of course,all themagnificationsmustbethesame,sothesizeof thediagrammustbespecifiedin thedocumentitself. Thisis a goodargumentfor keepingthe xfig export magnificationfactorasunity whenever you export a diagram.Specifythesizeyou needwith thecommandthatimportsthefigureinto thedocument.
13 Configuring Xfig
Theinstallationandconfigurationprocesshasthreestages:� Install theprogram� Fit thescreensize� Getcoloursto work.
13.1 Installation
On a RedhatLinux system,or someothersystemthatusestheRPM (RedhatPackageManagement)system,theinstallationstepsareasfollows:
� Mount theCDROM thatcamewith thedistribution.� Find theRedhatdirectory� In thatdirectory, find thexfig package,which will benamedsomethinglikexfig3.2.2.rpm .� Install it with theRPMcommand:
rpm -i xfig2.2.2.rpm
(Grizzledold Unix veteransnow heardmutteringabouthow easypeoplehave it thesedays,not having to useMAKE filesetcetc.)Thexfig packageis alsoavailableon theweb. You coulduseGoogleto find it.
A Slakwaresystemissimilar, exceptthatpackagesendin a.tgz extensionandthecommandis installpkg .If you aregeneratingoutputsin latex or otherformatsfor incorporationin documents,you will alsoneedto
install the transfig package.This handlesthetranslationof thedocumentdescriptionfrom fig into variousotherformats.
25
13.2 ScreenSize
It is not uncommonwhenstartingxfig for thefirst time to find that thewindow exceedsthescreensizeandthecoloursare missing. Fortunately, xfig andX Window are extremelyconfigurable,so theseglitchescan befixed.
Thescreensizemaybereducedto fit by meansof thecommandline optionsthatsetthewidth of thecanvas,theheightof thecanvas,andthenumberof buttonsperrow on thecontrolpanel.(Referto themanentryfor xfigfor a list of all theoptions.)
For example,to make xfig fit on my Toshibalaptop,for which thescreenresolutionis 800x600pixels,I usedthecommandline
xfig -pwidth 8 -pheight 5.5 -but_per_row 3
Thissquishesthecanvasdown to 8 inchesby 5.5 inchesandstacksthebuttonsthreeto a row.To avoid having to type in this commandline every time you start xfig, you cancreatean alias in oneof
the shell configurationfiles. In my case,a linux system,the shell is BashandI addedthe following line to the.bashrc file:
alias xfig=’xfig -pwidth 8 -pheight 5.5 -but_per_row 3 &’
Theampersandin thecommandline putsthexfig processin thebackgroundsothatyougetthecommandpromptbackafter startingxfig. (Remember, to list files thatbegin with a dot, you mustusethe -a option to ls , asinls -a .)
To get this aliasto take effect, you needto logoutandlogin againor usethesource commandto getBashto readtheconfigurationfile, asin source .bashrc .
Typing ’xfig’ now invokesthisentirecommandline automatically.Incidentally, you canfind out which shellyoursystemis usingwith thecommand
echo $SHELL
If you areusingsomeshellotherthanBash,you’ll have to readthemanualentryon thatshell to determinethenamesof theconfigurationfiles, their configurationfiles,andsyntaxof theentries.
13.3 Colour
Whenxfig is installed,its X Window configurationfiles will alsohave beenautomaticallyinstalledin anap-plication defaults directory. Onmy Redhatsystem,this is
/usr/X11R6/lib/X11/app-defaults
andon theSlakwaresystem
/usr/X11R6/lib/app-defaults
There,you will find configurationfiles for many X Window programs,amongwhich shouldbeFig andFig-color . (NonAmericansshouldtakespecialnoticethespellingof color, whichBrits andCanadiansspellcolour).
Theobjective is to getxfig to readtheFig-color file whenit startsup.WhenX Window startsup, it executesa programxinit (seethe man entry for xinit ). This program
looks for a file named.xinitrc in the user’s homedirectory. The .xinitrc script is an importantfile – itspecifiestheX window managerandthevariousX windowsprogramsthatappearon thedesktopat startup.The.xinitrc file in turn identifiesa configurationfile named.Xdefaults . To get xfig to readit’s applicationdefaultfile Fig-color , addto the.Xdefaults text themagicline:
26
Fig*customization: -color
In somecases,the X configurationsare containedin a file named.Xresources . In that case,edit the.xinitrc file to readthatinstead.
RestartX Windows. Dependingon your system,simply pressing<ctrl><alt><backspace> will takeyoubackto thelogonscreen.Log on asnormalandstartxfig . It shouldbein gloriouscolour.
On somemachines,pressing<ctrl><alt><backspace> takes you back to the commandline dumbterminalscreen.Runstartx to restartX Window.
If thereis no file .xinitrc in your homedirectory, usethe locate commandto searchfor .xinitrcor xinitrc . Therewill probablybe an examplesomewherein the systemthat canbe copiedinto your homedirectoryandeditedto suit.
If thereis no file .Xdefaults in your homedirectory, simply createit, containingthe magic line givenabove.
13.4 HELP Doesn’t Work
Someof thefiles calledby thexfig HELPmenuarein .PDF format. Thestandardprogramfor reading.PDFfiles is acroread . On my system,acroread wasn’t installed,sotheHELP menufailed. This wasnot good:peoplecouldn’t readthewonderfuldocument’UsingXfig’!
However, I discoveredthatghostview will display.PDF just aswell aspostscriptdocuments.
The EasyWay
Thesimpleway to fix HELP1 is to edit theapplicationsdefault file Fig (aspreviouslydescribedin section13.3above) in /usr/X11R6/lib/X11/app-defaults . Therelevantlinesthatappearas:
! pdfviewer - put your favorite pdf viewer here.! This is for viewing the xfig how-to guide and man pagesFig.pdfviewer: acroread
changeacroread to ghostview . You’ll needto be root to edit the file. That’s it, HELPshouldnow workproperly.
The Hard Way
I put a symboliclink in my bin directoryto createa ’pseudo-acroread’,usingthefollowing steps:
1. Checkthat you have a bin subdirectoryin your homedirectory. If you don’t have a bin subdirectory,simplycreateit with thecommand:
˜/bin
2. Checkto seeit’spartof yourPATHby doingthecommand(assumingthebash shell)
echo $PATH
1Someoneis boundto point out thatyoucan’t readthis fix unlessyoucanusetheHELP facility in thefirst place,a classicchicken& eggscenario.However, this file is availableonmy webpage.Or a resourcefuloperatorwill find thefile in theinnardsof their system,andreaditthere.
27
3. If thebin subdirectoryis not partof thepathspecification,adda line to your .bash_profile file likethis:
PATH=$PATH:$HOME/bin
You’ll have to log out andbackin for this to haveaneffect,or execute
source .bash_profile
4. Executethewhich commandto find thelocationof ghostview . (It might alsobeknown asgv ):
which ghostview
Thiswill show youwhereghostview lives.Onmy system,it’s in
/usr/X11R6/bin/ghostview
5. Finally, link acroread to ghostview with the following command(or whatever’s appropriatefor thelocationof ghostview in yoursystem):
ln -s /usr/X11R6/bin/ghostview ˜/bin/acroread
Now the xfig HELP menuitem shouldwork, andwhetheryou wantedto be or not, you’re on your way tobecominga Linux Guru.
It wouldbecrazyto dothiswhenyoucouldusethesimplemethodandedit theapp-defaults file instead,right?Well, maybenot.
Whenyou backup your system,the critical thing to backupis your /home directory. Unlessyou make apoint of backingup app-defaults , Fig, Fig-colorandtheeditsyou madearenot archived. By makinga linkthat’s storedin the/home/bin directory, if you archivethehome, thelink getsbackedup.
13.5 References
To learnthedetailsof BASH andits configurationfiles, thereis:
Learning the BASH Shell,2nd EditionCameronNewhamandBill RosenblattO’Reilly & AssociatesInc, 1998
For moreinformationon usingandconfiguringtheX Window System,youmight wantto read
X Window SystemUser’sGuide, Volume3ValerieQuerciaandTim O’ReillyO’Reilly & AssociatesInc, 1993
28