Allegro System Capture AppNote - Custom GUIs
Allegro System Capture AppNote - Custom GUIs
© 2022 Cadence Design Systems, Inc. All rights reserved worldwide. Cadence and the Cadence logo are
registered trademarks of Cadence Design Systems, Inc. All others are the property of their respective
holders.
Contents
Introduction .................................................................................................................. 4
Tcl APIs ....................................................................................................................... 4
Displaying a web page within a workspace tab ........................................................ 4
Displaying a web page within a dialog ..................................................................... 4
Displaying a web page within a dialog with a close handler ..................................... 5
Setting the visibility of a dialog ................................................................................. 6
Displaying a web page within a docked panel .......................................................... 6
Displaying a web page within a docked panel with a close handler ......................... 7
Setting the tcl procedure on dialog/docked panel close ........................................... 8
The Hybrid App ............................................................................................................ 9
Creating the HTML Page ......................................................................................... 9
Calling Tcl Procedures from JavaScript ................................................................. 13
Tcl Script for Initializing the HTML Page ................................................................ 13
Tcl Driver Script...................................................................................................... 16
Drawing a Pie Chart with JavaScript ...................................................................... 18
Output .................................................................................................................... 20
Introduction
Allegro System Capture provides a framework for developing custom user interfaces
with HTML5 and JavaScript.
Tcl APIs
You can display hybrid content within docked panels, dialogs and workspace tabs in
Allegro System Capture using the sdaUI Tcl package.
This section shows sample Tcl APIs that display hybrid content within an Allegro
System Capture session, consistent with its theme.
Command
sdaUI::openURLTab <title> <url> <id> <name>
Parameters
Name Description Data Type Optional Default
Value
title Title of the tab String No None
url URL of the content to host String (URL style) No None
id Unique identifier for the tab String No None
name Name of the hybrid component. This String No None
name can be used for looking up the
component handle using
cps::findComponentByName
Example
sdaUI::openURLTab CADENCE www.cadence.com id_testtab01 testtab01
Parameters
Name Description Data Type Optional Default
Value
title Title of the tab String No None
url URL of the content to host String (URL style) No None
name Name of the hybrid component. This String No None
name can be used for looking up the
component handle using
cps::findComponentByName
Example
sdaUI::openURLDialog CADENCE www.cadence.com testtab02 {} {0 0} {1000 400} 1 1
Parameters
Name Description Data Type Optional Default
Value
title Title of the tab String No None
url URL of the content to host String (URL style) No None
name Name of the hybrid component. Use this String No None
name to look up the component handle
using cps::findComponentByName.
close_handler Name of Tcl procedure to receive a String No None
callback whenever a dialog is closed by
user or visibility of dialog changes to
hidden. Syntax of close handler should
be
proc onCloseDialog {handle} {
}
Example
proc onCloseDialog { handle} {
# whenever the dialog is closed by user this proc will be called.
}
TCL> sdaUI::openURLDialogWithCloseHandler CADENCE www.cadence.com testtab02 onCloseDock
Command
sdaUI::hybridDialog <title> <url> <name> ?icon? ?position? ?size? ?isModal? ?isResizable?
Parameters
Name Description Data Type Optional Default
Value
title Title of the tab String No None
url URL of the content to host String (URL style) No None
name Name of the hybrid component. Use this String No None
name to look up the component handle
using cps::findComponentByName.
icon Path to the dialog icon String Yes {}
position Position of the web-view within the Tcl list of points Yes {0 0}
dialog. This is reserved for future
use
size Size of the dialog in width and height Tcl list of two Yes {800 800}
integers {width height}
isModal Modality of the dialog. A 1 would Boolean (1/0) Yes 1
indicate a modal dialog
isResizable Resizability of the dialog Boolean (1/0) Yes 0
Example
Tcl> set ret [sdaUI::hybridDialog TESTDATA www.cadence.com testcadence]
Tcl> puts $ret
dialogHandle 42 hybridHandle 39
Tcl> # query the visible property of the web widget
Tcl> # getProperty takes value of hybridHandle as its first argument, which is at position 3 rd
shown above
Tcl> cps::getProperty [lindex $ret 3] visible
False
Tcl> #setVisibility takes value of dialogHandle as its first argument, which is at position 1 st
Tcl> sdaUI::setVisibility [lindex $ret 1] 1
Tcl> cps::getProperty [lindex $ret 3] visible
true
Parameters
Name Description Data type Optional Default Value
title Title of the docked panel. String No None
url URL of the content to host String (url No None
style)
Examples
sdaUI::openHybridDock CADENCE www.cadence.com testtab02
Command
sdaUI::openHybridDockWithCloseHandler <title> <url> <dockName> <close_handler> ?isFloating?
?pos? ?size? ?dockArea?
Parameter
Name Description Data Optional Default value
type
title Title of the docked panel String No None
url Url of the content to host String No None
(url
style)
dockname Name of the docked panel String No None
close_handler Name of tcl procedure to receive a callback String No None
whenever a docked panel is closed by user or
visibility of docked panel changes to hidden.
Syntax of close handler should be
Proc onclosedock {handle} {
}
Example
proc onCloseDock { handle} {
# whenever the docked panel is closed by user this proc will be called.
}
TCL> sdaUI::openHybridDockWithCloseHandler CADENCE www.cadence.com testtab02 onCloseDock
Command
sdaUI::setCloseTCLHandler <handle> <Tcl_procedure>
Parameters
Name Description Data type Optional Default
value
handle Handle of dialog/docked panel String No None
tcl_procedure Name of tcl procedure String (Name of tcl No None
procedure)
Examples
Tcl> set ret [sdaUI::hybridDialog TESTDATA www.cadence.com testcadence]
Tcl> puts $ret
dialogHandle 42 hybridHandle 39
Tcl> set dlgHandle [dict get $ret dialogHandle]
# set the Tcl procedure to receive a callback
Tcl> sdaUI::setCloseTCLHandler $dlgHandle “Tcl_procedure”
#container {
margin: 0 auto;
padding: 5px;
text-align: center;
width: 250px;
}
.debug {
font-family: "Consolas", Consolas, monospace;
font-size: 0.7em
}
</style>
<!-- Logging functions for debugging, emulated browser JavaScript console -->
<script type="text/javascript" charset="utf-8" src="customLogger.js"></script>
<script>
// colors for the pie sweeps
var colors = [ "#FFDAB9", "#E6E6FA", "#E0FFFF", "#DAFDDA" ];
if (!initialized) {
context.translate(0.5, 0.5);
initialized = true;
}
// dumps a string
function debugStr(str) {
console.log(str);
}
if (isHosted()) {
getPageData(function (pageDataStr){
if (pageDataStr != null) {
var pageData = JSON.parse(pageDataStr);
if (!isEmpty(pageData)) {
loadPie('pieChart', pageData, colors);
}
}
if (!isHosted()) {
debugStr(++loadCount);
}
});
} else {
pageDataStr = '{ "labels": \
</script>
<body onload="showPageSummary();">
<div id="container">
<canvas id="pieChart" width="200" height="200"></canvas>
<button id="summary" type="button" onclick='showPageSummary()'>Refresh</button>
<div id="debugArea" class="debug"></div>
</div>
</body>
</html>
...
...
// calls the Tcl procedure getCurrentPageData
// and returns the result to its caller
function getPageData() {
var tclFunction = "getCurrentPageData";
var tclParams = "";
return callTcl(tclFunction, tclParams);
}
set nGUILoaded {}
set nHandle {}
}
set labelsLst {}
set countsLst {}
foreach item $data {
set name [lindex $item 0]
set count [lindex $item 1]
set label [getLabel $name]
if { $count > 0 } {
if { $label != {} } {
lappend labelsLst $label
lappend countsLst $count
}
}
}
return $ret
}
set ::customGUI::nGUILoaded 1
set ::customGUI::nHandle $hybridHandle
}
cps::setDockedWidgetVisibility $::customGUI::nHybridName
}
#end of file
#############################################################################
# Procedure Name : sdaCustomGUIEntry #
# Description : Creates menus for the Loading Custom GUIs #
#############################################################################
proc sdaCustomGUIEntry {} {
set menuName "Custom Utils"
set context "sch"
addMenuToMenuBar $menuName {} 1 Help $context
addActionToMenu $menuName \
"Page Summary" {customGUILoad} {} "Display page summary" 0 “sch”
uplevel 1 {
source [file join $::customGUILoader::nThisDir \
$::customGUILoader::nDirName \
$::customGUILoader::nScriptFile]
}
# register callbacks to automatically refresh the content
# of the custom GUI when user opens a page or switches to a page
cps::registerCommand cps::openItem {} sdaCustomGUIOnPageChange
cps::registerCommand cps::selectItem {} sdaCustomGUIOnPageChange
}
# Call loader function on script load
sdaCustomGUIEntry
context.beginPath();
context.moveTo(centerX, centerY);
context.arc(centerX, centerY, radius, startingAngle, endingAngle, false);
context.closePath();
context.restore();
if (!isHosted) {
console.log("Angle for " + labels[i] + " is: " + startAngleDegrees);
}
context.textAlign = "right";
var fontSize = Math.floor(canvas.height / 25);
context.font = fontSize + "pt";
var text = labels[i] + "(" + data[i] + ")";
context.restore();
}
// end of file
Output
When this functionality is integrated with Allegro System Capture, you can click the
Custom Util -> Page Summary menu to view the widget displayed on the docking pane
on the left.