|
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.
Grid Controls
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.
Executing Scripts from Grid Windows and Grid Panes
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.
Usage
|
Construction
|
Object = new_gridview()
Object = attach_gridview()
Object = attachlist_gridview()
Object = CGridView:new()
Object = CGridView:Attach()
Object = CGridView:AttachFromList()
|
|
Destruction
|
Object:delete()
|
Creator Functions
These functions are normally used to create and
attach a new CGridView object as an alternative to the
class-based construction methods.
|
new_gridview
|
Creates a new instance of the CGridView
class. The grid defaults may also be set using the
GridParams table.
|
|
attach_gridview_by_name
|
Directly attaches a grid window from the Mira
desktop using the window title, without selecting the window from a
list as with
attachlist_gridview. It creates and returns a new
CGridView object.
|
|
attach_gridview
|
Creates a new CGridView object attached to
the top-most grid window on the Mira desktop. This is equivalent to
the
Attach class method.
|
|
attachlist_gridview
|
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.
|
Construction and Destruction - Class Methods
|
new
|
Creates a new instance of a CGridView
object. The grid defaults may also be set using the
GridParams table.
|
|
delete
|
Deletes the instance of the CGridView
object.
|
|
Attach
|
Creates a new CGridView object and attaches
it to the top-most grid window on the Mira desktop.
|
|
GetGridCtrl
|
Returns the
CGridCtrl object owned by the CGridView
object.
|
|
AttachFromList
|
Creates a new CGridView object and attaches
it to a grid window selected from a list of grid windows on the
Mira desktop.
|
|
Close
|
Closes the CGridView window
|
|
GridParams table
|
The GridParams table may be used to
initialize the properties of the new CGridView object when
created.
|
CGridView Methods
|
GetCellStart
|
Returns the grid column and row where the mouse
button was last pressed to mark a cell or begin a selection.
|
|
GetCellEnd
|
Returns thegrid column and row where the mouse
button was last released to mark the last cell of a selection.
|
|
GetCellDblClick
|
Returns the grid column and row where the mouse
button was last double-clicked.
|
|
GetNum
|
Returns the numeric value in a grid cell.
|
|
GetMaxCol
|
Returns the index of the maximum grid column
containing data.
|
|
GetMaxRow
|
Returns the index of the maximum grid row
containing data.
|
|
GetNumCols
|
Returns the number of columns in the grid.
|
|
GetNumRows
|
Returns the number of rows in the grid.
|
|
GetNumSheets
|
Returns the number of sheets in the grid.
|
|
GetSheet
|
Returns the index of the currently selected
sheet.
|
|
GetStr
|
Returns the string value in a grid cell.
|
|
GetType
|
Returns the data type for a grid cell.
|
|
GetVal
|
Returns the data and pixel type of a grid
cell.
|
|
GetTitle
|
Gets the grid window title.
|
|
GotoCell
|
Sends the grid cursor to the specified cell.
|
|
JoinCells
|
Joins a block of cells into a single cell.
|
|
Optimize
|
Optimizes the width of one or more columns.
|
|
Refresh
|
Refreshes the grid to update undisplayed
changes.
|
|
SelectSheet
|
Selects a specified sheet and brings it to the top
of the grid window.
|
|
SetBkColor
|
Sets the background color of a cell.
|
|
SetFontColor
|
Sets the text color of a cell.
|
|
SetNum
|
Sets a numeric value to a grid cell.
|
|
SetNumCols
|
Sets number of columns in the grid.
|
|
SetNumRows
|
Sets the number of rows in the grid.
|
|
SetStr
|
Sets a string value to a grid cell.
|
|
SetTab
|
Sets the label of the tab for a sheet.
|
|
SetType
|
Sets the data type of a cell. Cells default to
string data type.
|
|
SetVal
|
Sets a cell value and pixel type in the grid.
|
|
SetTitle
|
Sets the grid window title.
|
|
SetHorzAlign
|
Set the horizontal alignment of specific cells or
an entire column. The default alignment is "left".
|
|
SetVertAlign
|
Set the vertical alignment of specific cells or an
entire row. The default alignment is "vertical center".
|
|
UnJoinCells
|
Breaks a block of joined cells into individual
grid cells.
|
Related Topics
Script Classes
CGridCtrl class
CGrid class
Contents
Mira Pro x64 Script User's Guide, v.8.76 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.
|