CGridView Class Description
The CGridView class provides an interface to a 2-dimensional grid of values like those used by the Mira user interface to report measurements or other values. This class can create a grid window for output from the script or attach a grid window already on the Mira desktop. A script can be used to work with the cell data for, example to do further processing like computing statistics using the CStats class, performing least squares fitting using the CLsqFit class, and so forth. If your script creates a grid, the Grid Window has full access to the Mira GUI functions such as Mira pull-down and pop-up menus, or it can execute a new script as described below.
This class is similar to the CGrid class but offers more functionality. The primary differences between the CGridView and CGrid classes are as follows:
The CGrid does not support all features of the CGridView class, including multiple grid sheets.
Whereas the CGridView class can either create a grid window or attach to an existing grid window, the CGrid class can only create a dialog window and cannot attach to an existing grid.
Note that scripts executed from a CGrid dialog, Mira Grid View window, or Grid Pane are all provided a CGridView object for manipulating the grid window that launched the script.
A grid control is a table consisting of cells arranged in a rectangular grid defined by the number of columns wide and the number of rows tall. Just as a Mira image window holds an image set consisting of multiple images, the Mira grid window holds a set of grids called "sheets". By default, a CGridView is created with 1 sheet, but you may create it with additional sheets using the GridParams table or add sheets later by using AddSheet. You may switch between sheets using the tab below the grid window or using SelectSheet in a script. NOTE: All grid commands work with the top-most sheet in the grid window.
Below is a simple grid view window created by the CGridView class.
The Execute Script menu command may be used to open and execute a script directly from a Mira Grid Window. When a script is executed from this command, it is automatically sent a CGridView object named ParentGrid that provides access to the window's grid control. You can use this name directly in the script or you can rename it, like G = ParentGrid. A sample script to be called from a Grid Window is provided, named Execute from Grid Window test.lua.
A script can also be executed from a Grid Pane (e.g., containing measurements) attached to an Image Window. In this case, the Execute Script command is available only using the pane's pop-up menu opened using a right mouse click. A sample script to be called from a Grid Pane is provided, named Execute from Grid Pane test.lua.
Construction |
Object = new_gridview() Object = attach_gridview() Object = attachlist_gridview() Object = CGridView:new() Object = CGridView:Attach() Object = CGridView:AttachFromList() |
Destruction |
Object:delete() |
These functions are normally used to create and attach a new CGridView object as an alternative to the class-based construction methods.
Creates a new instance of the CGridView class. The grid defaults may also be set using the GridParams table. |
|
Creates a new CGridView object attached to the top-most grid window on the Mira desktop. This is equivalent to the Attach class method. |
|
Creates a new CGridView object attached to a grid window selected from a list of grid windows on the Mira desktop. This is equivalent to the AttachFromList class method. |
Creates a new instance of a CGridView object. The grid defaults may also be set using the GridParams table. |
|
Deletes the instance of the CGridView object. |
|
Creates a new CGridView object and attaches it to the top-most grid window on the Mira desktop. |
|
Creates a new CGridView object and attaches it to a grid window selected from a list of grid windows on the Mira desktop. |
|
Closes the CGridView window |
|
The GridParams table may be used to initialize the properties of the new CGridView object when created. |
Adds a sheet to the CGridView object. |
|
Adjusts the grid within the window for best fit over a range of columns. |
|
Finds the column containing the specified string. This is often used to find a grid column using its top heading title. You may also search for the string within a specific row. |
|
Finds the row containing the specified string. This is often used to find a grid row using its side heading title. You may also search for the string within a specific column. |
|
Sets grid cells to the contents of a 2-dimensional table. |
|
Returns the grid column and row where the mouse button was last pressed to mark a cell or begin a selection. |
|
Returns thegrid column and row where the mouse button was last released to mark the last cell of a selection. |
|
Returns the grid column and row where the mouse button was last double-clicked. |
|
Returns a 1-dimensional table containing the contents of a grid column. |
|
Returns the numeric value in a grid cell. |
|
Returns the index of the maximum grid column containing data. |
|
Returns the index of the maximum grid row containing data. |
|
Returns the number of columns in the grid. |
|
Returns the number of rows in the grid. |
|
Returns the number of sheets in the grid. |
|
Returns a 2-dimensional table containing the contents of a grid rectangle. |
|
Returns a 1-dimensional table containing the contents of a grid row. |
|
Returns the index of the currently selected sheet. |
|
Returns the string value in a grid cell. |
|
Returns the data type for a grid cell. |
|
Returns the data and pixel type of a grid cell. |
|
Gets the grid window title. |
|
Sends the grid cursor to the specified cell. |
|
Joins a block of cells into a single cell. |
|
Optimizes the width of one or more columns. |
|
Refreshes the grid to update undisplayed changes. |
|
Selects a specified sheet and brings it to the top of the grid window. |
|
Sets the background color of a cell. |
|
Sets the text color of a cell. |
|
Saves the contents of a 1-dimensional table to a grid column. |
|
Sets a numeric value to a grid cell. |
|
Sets number of columns in the grid. |
|
Sets the number of rows in the grid. |
|
Sets the values inside a rectangle of the grid. |
|
Sets a string value to a grid cell. |
|
Sets the label of the tab for a sheet. |
|
Sets the data type of a cell. Cells default to string data type. |
|
Sets a cell value and pixel type in the grid. |
|
Sets the grid window title. |
|
Converts the grid contents to a 2-dimensional table. |
|
Set the horizontal alignment of specific cells or an entire column. The default alignment is "left". |
|
Set the vertical alignment of specific cells or an entire row. The default alignment is "center". |
|
Breaks a block of joined cells into individual grid cells. |
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.