.. image:: imgs/ITS_Serv-C_101axfig.jpg :align: center :width: 800 | Using Xfig for Drawings ======================= Sometimes in scientific work you need to make professional looking drawings. These can be simple block diagrams like this, in which you display the basic layout of an experiment: .. image:: imgs/test.jpg or a more complex figures and scematics, such as these examples: .. image:: imgs/icepic.png ------------------ .. image:: imgs/ide.png Both of these images, and the one at the beginning of this chapter, were made using **Xfig**. | Starting Xfig ============= To start the program, open a shell and type: **xfig &** at the prompt. Do so now, so that you can follow along. This will open a new window that looks like this. .. image:: imgs/screen_map.png Shown in the figure are the various areas of the program. The two main tool panels are the + **Drawing Mode Panel** This selects the kind of object you wish to draw: Circles, Ellipses, Arcs, Boxes, Lines, Parallelograms, Text, and Images. We'll talk about these in more detail below. + **Editting Mode Panel** These tools let you manipulate items that you have drawn already. You can Delete, Move, Align, Scale, Rotate/Flip, and group objects into a single Compound Object . + **Attribute Panel** At the bottom of the screen are buttons which determine the attributes of whatever tool has been chosen. For example, if you are using the Line Drawing Tool, attributes would be line width, line style (solid, dashed, etc.), arrow heads , etc. Xfig and the Unix Mouse ----------------------- Look at the " **Mouse Function Indicator**" in the picture above (upper right part of the Xfig window). There are rectangles which represent the mouse buttons; notice that there are three . This is because the Unix/Xwindows world uses 3 button mice. **On a PC** The **Center** button should be emulated by pressing both mice buttons at once. Thus your mouse buttons are: + Unix **Left** = PC **Left** + Unix **Center** = PC **Both** + Unix **Right** = PC **Right** **On a Mac** Apparently, the recent versions of Fedora Linux/VirtualBox running on Mac OS *does not* include a way for Mac users to emulate a 3-button mouse, as described for PC users above. *However*, if you simply plug in a 3-button (USB) mouse, or a more commonly found 2-button mouse, *with a clickable center scroll-wheel*, it will work fine. *Office Depot* carries mice like this for about \$10. Unfortunately, I don't know any other way to use Xfig with a Mac. | .. note:: Copy and Paste in Unix Windows One of the nice features of Unix/Xwindows is that when you highlight text in an Xwindow, it is automatically **copied** to the clipboard . Compare this to the PC method: first hightlight text, then click the Edit->Copy OR do CTRL-C. In Unix, the *copy* is automatic whenever you highlight something. To **Paste** text, you simply position the cursor and click with the Middle mouse button. On a PC that means click both mouse buttons. Try this: Open a terminal (if one is not open), and type some text at the prompt. Anything will do **salkfjdhla** Now use the **Left** mouse button to highlight this text. Next, in the same xterm window, click the **Center** mouse button---i.e. **push** both PC mouse buttons simultaneously . This should **Paste** the text that you automatically copied when you highlighted the previous text. Using Xfig ========== Now that you have an **xfig** window up and running, let's start to play with it. It's fairly intuitive I think---just remember that some actions are done with the **Center** mouse button. Drawing ------- + **Make a circle**: Click the Circle Drawing tool at the top left of the Drawing tools. Now, **Left**-click and **drag** to adjust the size of the circle. When you have a circle of about 1-3 cm in radius, **Left**-click to fix the size and attach the circle to your canvas. + **Make a Line**: Now, click the Line Drawing Tool (the line segments--4th down on the right column). **Left** click on the canvas; this starts a line. Move the mouse and **Left** click again. Each Left click gives the line a new vertex. Now, **Right**-click. Did your line disappear? Right clicking, with the Line Drawing Tool, means Cancel . Restart a line segment sequence as shown at the beginning of this paragraph. After a few vertices, **Middle**-click ( BOTH buttons together). This should attach the line to your canvas. Ok. Do you see how it works? It's pretty easy; you just have to get used to the tools. + **Try each of the Drawing Tools**. + What kind of Object does it create? + Understand how it works---what do Right, Center, and Left mouse buttons do? + What Attributes does it have? What do the different options do? Now let's do a simple exercise using the **Edit Tools**. Editting -------- + Click the **Delete** Tool button: 7th up from the bottom on the left column in the **Edit Tool Menu**. A number of little squares should appear on your drawing, and your cursor should become a "Skull and Crossbones". + *Left-click* on one of the items in your drawing. Did it disappear? It should have. That's what the Delete tool does! + Now click the **Move** Tool button. Your curson should become a pointing hand. + *Left-Click* on one of the little squares on one of the objects in your diagram. You should be able to Click-drag it around your canvas, and leave it at a new location. Saving and Exporting -------------------- Open **xfig** and make some simple figure using the techniques you learned above. Anything will do, even just a line or circle. Once you have a figure, there are two ways to store it on disk.. | **Save/Save As...** To Save your figure in *Native Xfig Format* (as a **.fig** file), you click *File->Save* on the upper left menu bar. This opens the *Save* dialog box: .. image:: imgs/xfigsavebox2.jpg The essential items are circled in red above: + The *filename*. Without an extension, your file will be saved with the xfig extension: *.fig*. + The directory in which your file will be saved: `/home/jhetrick/` in the screenshot. + The *Save* button. This will save your figure *in Xfig* format, so that you can read it back into **xfig** and continue editing it. *However, this format is only readable by xfig*. I usually save my figures in this format *and* export them to an image format. That way, if I decide later to change the figure, I can re-open the *\*.fig* file and make changes. You can't do that with the exported image file. | **Exporting to an image** When you have the figure in its final form, you are ready to *Export* it to an image file, suitable for inclusion in another document--either a Latex or Word document, or perhaps an HTML page on the web. To *Export* your figure to an image file: *Click* `File->Export` This brings up the *Export* dialog box: .. image:: imgs/xfigexport1.jpg Notice: + The "*Language*" menu--this really means the *image format*: EPS, JPEG, TIFF, PDF, etc. + The *Output File*. This is the name of the exported file. If you already saved your figure (as `mycoolfiure.fig` in this case), then there will be a "*Default File*" with the same name and an extension corresponding to the *Language* of file type you chose. + *Current Dir*\ectory, where the image file will be saved. If you *Click* on the "Language" dropdown, you can see all the possible export formats: .. image:: imgs/xfigexport2.jpg I've highlighted some of the more popular: PDF, JPEG, and PNG. Note that each of these is a format that can be easily included into a *Latex* document. Once you have chosen your export format (JPEG shown below), you can see that the *Default File* name shows the appropriate suffix, and you are ready to click the *Export* button at the bottom of the dialog box. .. image:: imgs/xfigexport3.jpg ----------------------------- **A Handy Tutorial** Below is a link to a nice tutorial I found on the web if you are interested in delving further into Xfig. + `Xfig Tutorial by Peter Hickocks `_ | Homework ======== Homework for Chapter 9 is `here `_