Windows-Specific Information
Exchanging Image Data Using the Clipboard
Under Windows, the Clipboard provides a convenient mechanism for transferring image data to and from PV-WAVE. You can copy data to and from the Clipboard using either 1) command line functions, or 2) functions on the graphics window Control menu.
Any graphics application that accepts Device Independent Bitmap (DIB) or enhanced-format metafile (EMF) graphics can be exchanged with PV-WAVE through the Clipboard. For example, you can copy graphics from a graphics window into a Microsoft Paintbrush window using the copy and paste functions provided by these two applications.
Depending on the options you have selected, the graphics that are copied to and from the Clipboard are either in bitmap (DIB) or metafile (EMF) format. By default, bitmap graphics are displayed in graphics windows; however, providing the /
Meta keyword with either the DEVICE or WINDOW procedure creates a metafile.
Table 9-15: DIB and EMF Graphic Differences highlights some of the differences between DIB and EMF graphics:
Command Line Clipboard Functions
Either of these commands can be entered at the WAVE> prompt in the Console window:
WCOPY—Copies the contents of a graphics window to the Clipboard. The following example copies the contents of window number 1 to the Clipboard:
status=WCOPY(1)
WPASTE—Pastes the contents of the Clipboard into a specified graphics window. The following example pastes the contents of the Clipboard into the graphics window with index number 1.
status=WPASTE(1)
For detailed information on these functions, see their descriptions in the PV‑WAVE Reference.
Clipboard Functions on the Graphics Window Control Menu
Either of these options can be selected from the Control menu of any graphics window:
Copy to Clipboard—Copies the contents of a graphics window to the Clipboard.
Paste from Clipboard—Pastes the contents of the Clipboard into a specified graphics window.
Input and Output of DIB and Metafile Images
Several commands are provided for the transfer of Device Independent Bitmap (DIB) and enhanced-format metafile (EMF) images. These commands fall into two general categories: 1) commands that transfer data between variables and files, and 2) commands that transfer data between graphics windows and files.
Commands that Transfer Data Between Variables and Files
The following functions allow you to import and export DIB data between variables and files. For more information on these functions, see their descriptions in the PV‑WAVE Reference.
DC_READ_DIB—Reads data from a DIB format file into a variable.
DC_WRITE_DIB—Writes image data from a variable to a DIB format file.
Commands that Transfer Data Between Files and Windows
The following functions allow you to import and export DIB and EMF data between data files and graphics windows. For more information on these functions, see their descriptions in the PV‑WAVE Reference.
WREAD_DIB—Loads a DIB from a file into a graphics window.
WWRITE_DIB—Saves the contents of a graphics window to a file using the DIB format.
WREAD_META—Loads an EMF image from a file into a graphics window. (EMF graphics cannot be pasted into 16-bit applications.)
WWRITE_META—Saves the contents of a graphics window to a file using the EMF format. (EMF graphics cannot be pasted into 16-bit applications.)
The graphics window Control menu contains two functions that let you interactively import and export DIB and EMF data:
Export Graphics—Writes the contents of the graphics window to a file. Your choice of output format depends on how the window was created. If the window was created with a metafile option (either by specifying the
Meta or
Redraw keyword), then the exported file can either be a DIB or an EMF format file. The filename extension,
.bmp for DIB format and
.emf for EMF format, determines the type of output file. If the window was created without a metafile option, then the only choice is to export DIB format data.
Import Graphics—Reads the contents of a file into a PV-WAVE graphics window. The file’s contents must be in either DIB or EMF format.
By default, the Import Graphics dialog box looks for files with a
.bmp or
.emf extension. If the graphics window was created with the /
Meta or /
Redraw option enabled, then
.emf files are expected. Otherwise,
.bmp files are expected. For information on the /
Meta and /
Redraw options, see the discussions of the DEVICE and WINDOW procedures in the PV‑WAVE
Reference.
Transferring Data from PV‑WAVE to Microsoft® Excel
This section describes a method for exporting data from PV-WAVE into a Microsoft Excel spreadsheet. You can apply this method with any application that allows you to import comma-separated value (CSV) data.
First, have PV-WAVE write the data to a file; the output must be in CSV format. You can do this with the DC_WRITE_FREE function.
; Create some example data, such as a 10-by-10 array of integers.
data = INDGEN(10, 10)
status = DC_WRITE_FREE('data.csv', data, /Column)
This DC_WRITE_FREE command writes a file called data.csv, which contains CSV data that can be read directly into a Microsoft Excel spreadsheet.
Now you can import the file into Excel as a CSV format file.
note | It is also possible to run Excel directly from PV-WAVE using the SPAWN procedure. SPAWN lets you execute external programs from within PV-WAVE. For detailed information on SPAWN, see the PV‑WAVE Reference. The following SPAWN command tells Excel to start and load the CSV data file that was created using PV-WAVE: WAVE> SPAWN, 'C:\excel.exe C:\data.csv', /Nowait The input file to Excel must be in CSV format and must have an .csv extension. |
For more information on DC_WRITE_FREE, see its description in the PV‑WAVE
Reference. For information on how to transfer data from Microsoft Excel to PV-WAVE, see
"Transferring Data from Microsoft® Excel to PV‑WAVE".
Transferring Data from Microsoft® Excel to PV‑WAVE
This section describes a method for reading comma-separated value (CSV) data from a Microsoft Excel spreadsheet into PV-WAVE. Once the data is imported into PV-WAVE, you can use graphics functions such as PLOT and OPLOT to visualize it. This method of transferring data from another application to PV-WAVE will work with any application as long as the application can export CSV data.
First, save the data from your Excel spreadsheet using the Save File as Type: CSV option on the Save As dialog box. This option saves the data in a text file containing values separated by commas. Blank cells are written as “,,” (a pair of commas) which PV-WAVE interprets as zeros.
For example, if your spreadsheet contains the following array of cells:
when it is saved as CSV data, the resulting file looks like this:
Q1, Q2, Q3, Q4
50,, 25, 200
40, 100, 50,,
200, 50, 50, 100
note | The blank cells in the spreadsheet are saved as “,,” (a pair of commas). These blank values are interpreted as zeros when they are imported into PV-WAVE. |
Now, you can read the CSV data file into PV-WAVE. First, create arrays to hold the text of the column headings, then create an array to hold the data:
headings = STRARR(4)
sales = INTARR(4, 3)
Next, use the DC_READ_FREE function to read the data into the arrays headings and sales. For detailed information on the DC_READ_FREE function, see its description in the PV‑WAVE Reference.
; The first parameter is the name of the data file to read. The
; next two parameters are the names of the variables into which
; the data is read.
status = DC_READ_FREE('region1.csv', headings, sales)
Enter the following commands to check that the data was read correctly:
PRINT, headings
; PV-WAVE prints: Q1 Q2 Q3 Q4
PRINT, sales
; PV-WAVE prints the following:
; 50, 0, 25, 200
; 40, 100, 50, 0
; 200, 50, 50, 100
Notice that the empty cells have been replaced by zeros.
For information on how to transfer data from PV‑WAVE to Microsoft Excel, see
"Transferring Data from PV‑WAVE to Microsoft® Excel".