Setting the Size of Graph Windows Associated with Graph Layout Objects for More WYSIWYG Behavior

// To get WYSIWYG behavior in a page layout, the size of each graph object in the layout
// must match, or at least be close to, the size of the associated graph window.
// The SetLayoutGraphsWidthAndHeight procedure allows you to set the size of the graph
// window associated with each layout graph object in a particular layout window.
// For example, assume you have a layout containing some number of graph objects
// and you want to set the associated graph windows to be 6.5 inches by 6.5 inches
// without changing the top/left position of the graph windows on the screen.
// You can execute:
//  SetLayoutGraphsWidthAndHeight("Layout0", 72*6.5, 72*6.5)    // Convert from inches to points
// The factor of 72 converts from inches to points. To convert from centimeters
// to points, use 182.88.

// SetWindowWidthAndHeight(windowName, width, height)
// Sets a windows width and height without moving its top/left corner.
// Width and height are in points.
// Example:
//  SetWindowWidthAndHeight("Graph0_PCM", 72*6.54, 72*6.39) // Convert from inches to points
Function SetWindowWidthAndHeight(windowName, width, height)
    String windowName       // e.g., "Graph0_PCM"
    Variable width, height  // In points
    GetWindow $windowName, wsize
    MoveWindow /W=$windowName  V_left, V_top, V_left+width, V_top+height

// SetLayoutGraphsWidthAndHeight(layoutName, width, height)
// Sets the width and height of the graph windows associated with each
// graph object in a layout.
// Width and height are in points.
// Example:
//  SetLayoutGraphsWidthAndHeight("Layout0", 72*6.54, 72*6.39)  // Convert from inches to points
Function SetLayoutGraphsWidthAndHeight(layoutName, width, height)
    String layoutName       // e.g., "Layout0"
    Variable width, height  // In points
    if (WinType(layoutName) != 3)
        Abort "Expected name of a layout window"
    Variable debug = 1
    if (debug)
        DoWindow /F $layoutName
    Variable numGraphs = 0

    String info
    Variable objectNumber = 0
        // Get information about the next object in the layout
        String objectIdentifier
        sprintf objectIdentifier, "%d", objectNumber
        info = LayoutInfo(layoutName, objectIdentifier)
        if (strlen(info) == 0)
        // Get the object's type
        String typeStr = StringByKey("TYPE", info)
        if (CmpStr(typeStr,"GRAPH") != 0)
            objectNumber += 1
            continue                // We want graphs only
        // Get the object's name which will be the graph name
        String name = StringByKey("NAME", info)
        if (debug)
            DoWindow /F $name
        // Set the graph window's width and height
        SetWindowWidthAndHeight("Graph0_PCM", width, height)
        numGraphs += 1
        objectNumber += 1
    Printf "Set the size of %d graphs\r", numGraphs
    return 0




Igor Pro 8

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More