You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/firefly-api-overview.md
+59-6Lines changed: 59 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,7 @@ More information about lower level API can be found here:
26
26
-[Dispatching and Watching Actions](#dispatching-and-watching-actions)
27
27
-[Other utilities](#other-utility-methods)
28
28
-[Utility methods for FITS visualization](#utility-methods-for-fits-visualization)
29
+
-[Adding Context Extensions to FITS viewer](#adding-context-extensions-to-fits-viewer)
29
30
-[Region Support](#region-support)
30
31
31
32
@@ -266,7 +267,7 @@ function getImagePt(pt) {
266
267
267
268
*Example:*
268
269
```js
269
-
firefly.getViewer().showImage('imageDiv', {
270
+
firefly.showImage('imageDiv', {
270
271
plotId:'p1',
271
272
Service:'TWOMASS',
272
273
Title :'2MASS from service',
@@ -292,9 +293,61 @@ To use minimal readout, do the following:
292
293
);
293
294
```
294
295
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
+
varextFunc=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*
`firefly.action.dispatchCreateRegionLayer(regionId, layerTitle, fileOnServer ='', regionAry=[], plotId = [])` - overlay region data on an image plots with the given ids
300
353
@@ -309,7 +362,7 @@ To use minimal readout, do the following:
309
362
Note: if no plotId is given, the region layer is created on all plots.
0 commit comments