Skip to content

Commit d7432e3

Browse files
committed
updated firefly api doc
1 parent 6d92bb9 commit d7432e3

File tree

1 file changed

+59
-6
lines changed

1 file changed

+59
-6
lines changed

docs/firefly-api-overview.md

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ More information about lower level API can be found here:
2626
- [Dispatching and Watching Actions](#dispatching-and-watching-actions)
2727
- [Other utilities](#other-utility-methods)
2828
- [Utility methods for FITS visualization](#utility-methods-for-fits-visualization)
29+
- [Adding Context Extensions to FITS viewer](#adding-context-extensions-to-fits-viewer)
2930
- [Region Support](#region-support)
3031

3132

@@ -266,7 +267,7 @@ function getImagePt(pt) {
266267

267268
*Example:*
268269
```js
269-
firefly.getViewer().showImage('imageDiv', {
270+
firefly.showImage('imageDiv', {
270271
plotId: 'p1',
271272
Service: 'TWOMASS',
272273
Title : '2MASS from service',
@@ -292,9 +293,61 @@ To use minimal readout, do the following:
292293
);
293294
```
294295

296+
297+
### Adding Context Extensions to FITS viewer
298+
299+
Context extensions make it possible to add user-defined actions on certain operations. When an extension is added, FITS viewer will present an extra menu item in the context menu of the operation, on which the extension is defined. These are the operations on which context extensions can be added:
300+
301+
- Area Select (square)
302+
- Line Select
303+
- Point Select
304+
- Circle Select (*coming soon*)
305+
306+
The best way to describe how to add an extension, is to see the code.
307+
308+
```js
309+
var extFunc= function(data) {
310+
// do something when the extension is selected called.
311+
}
312+
var extension= { // object literal to create extension definition
313+
id : 'MySpecialExt', // extension id
314+
plotId : 'primaryID', // plot to put extension on
315+
title : 'My Op', // title use sees
316+
toolTip : "a tool tip", // tooltip
317+
extType: "POINT", // type of extension
318+
callback: extFunc // function (defined above) for callback
319+
};
320+
firefly.util.image.extensionAdd(extension);
321+
// to remove the extension added above, use firefly.util.image.extensionRemove('MySpecialExt')
322+
```
323+
324+
325+
To add an extension to a fits viewer create a object literal with the following fields:
326+
327+
| name | type | description |
328+
| ---- | ---- | ----- |
329+
| id | string | any string id that you want to give the extension |
330+
| plotId | string | the plot ID to put the extension on. (will be the same as the div name)|
331+
| imageUrl | string, url |url of an image icon (icon should be 24x24) to show in the context menu |
332+
| title | string | title that the user will see if not image icon is supplied |
333+
| toolTip | string | tooltip the viewer will use for your extension |
334+
| extType | string | extension type, must be 'AREA_SELECT', 'LINE_SELECT', 'POINT', or 'CIRCLE_SELECT' (*details below*) |
335+
| callback | function | the function to call when the extension is selected (*details below*) |
336+
337+
extType details:
338+
339+
- 'AREA_SELECT' - When the user draws a square this menu will be activate
340+
- 'LINE_SELECT' - When the user draw a line this menu will be activated.
341+
- 'POINT' - When any point on the plot is clicked
342+
- 'CIRCLE_SELECT' - When the user draws a circle (*not yet supported, coming soon*)
343+
344+
callback function takes one parameter, an object literal, the fields vary depend on the extension type -
345+
*todo - need to document callback object literal parameters*
346+
347+
295348
### Region Support
296349

297-
#####**firefly.action.dispatchCreateRegionLayer** method
350+
##### **firefly.action.dispatchCreateRegionLayer** method
298351

299352
`firefly.action.dispatchCreateRegionLayer(regionId, layerTitle, fileOnServer ='', regionAry=[], plotId = [])` - overlay region data on an image plots with the given ids
300353

@@ -309,7 +362,7 @@ To use minimal readout, do the following:
309362
Note: if no plotId is given, the region layer is created on all plots.
310363

311364

312-
#####**firefly.action.dispatchDeleteRegionLayer** method
365+
##### **firefly.action.dispatchDeleteRegionLayer** method
313366

314367
`firefly.action.dispatchDeleteRegionLayer(regionId, plotId)` - remove region layer from the given plot
315368

@@ -321,7 +374,7 @@ Note: if no plotId is given, the region layer is created on all plots.
321374
Note: if no plotId is given, the region layer is removed from all plots.
322375

323376

324-
#####**firefly.action.dispatchAddRegionEntry** method
377+
##### **firefly.action.dispatchAddRegionEntry** method
325378

326379
`firefly.action.dispatchAddRegionEntry(regionId, regionChanges)` - add region data to the given region layer
327380

@@ -330,7 +383,7 @@ Note: if no plotId is given, the region layer is removed from all plots.
330383
| regionId | string | region layer id |
331384
| regionChanges | array | an array of strings, each describing a ds9 region |
332385

333-
#####**firefly.action.dispatchRemoveRegionEntry** method
386+
##### **firefly.action.dispatchRemoveRegionEntry** method
334387

335388
`firefly.action.dispatchRemoveRegionEntry(regionId, regionChanges)` - remove region data from the given region layer
336389

@@ -551,4 +604,4 @@ firefly.addXYPlot('xyplot_div', {tbl_id: tblReq.tbl_id, xCol: 'w1mpro+w4mpro', y
551604

552605
### More Code Examples
553606

554-
[see firefly-api-code-examples.md](firefly-api-code-examples.md)
607+
[see firefly-api-code-examples.md](../tutorial/firefly-api-code-examples.md)

0 commit comments

Comments
 (0)