Commit 846aa6d7 authored by Andrew Cohen's avatar Andrew Cohen

new repo for leverjs - dropping cloneview history

parents
#Ignore thumbnails created by Windows
Thumbs.db
#Ignore files built by Visual Studio
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
[Bb]in
[Dd]ebug*/
*.lib
*.sbr
obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
.vs/
#Nuget packages folder
packages/
*.VC.db
/node_modules/*
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "server",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}\\server.js",
"args":["/z/leverjs/demo"],
"protocol": "inspector"
},
{
"name": "Main Process",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}/elever",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/electron/dist/electron.exe"
},
"args": [
],
"program": "${workspaceRoot}/elever/main.js",
"protocol": "auto"
},
{
"name": "Render Process",
"type": "chrome",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"runtimeArgs": [
"${workspaceRoot}/elever/main.js",
"--remote-debugging-port=9222"
],
"webRoot": "${workspaceRoot}/wwwroot"
}
]
}
\ No newline at end of file
module.exports = {
/**
* Application configuration section
* http://pm2.keymetrics.io/docs/usage/application-declaration/
*/
apps : [
{
name : 'Conrad',
script : 'leverServer.js',
args : ' --port=3002 g:/leverjs/Conrad'
},
{
name : 'Temple August 2017',
script : 'leverServer.js',
args : ' --port=3000 "g:/leverjs/Temple/August 2017"'
}
]
};
\ No newline at end of file
https://github.com/electron-userland/electron-builder
npm run dist
\ No newline at end of file
# Do not edit. File was generated by node-gyp's "configure" step
{
"target_defaults": {
"cflags": [],
"default_configuration": "Release",
"defines": [],
"include_dirs": [],
"libraries": []
},
"variables": {
"asan": 0,
"coverage": "false",
"debug_devtools": "node",
"force_dynamic_crt": 0,
"host_arch": "x64",
"icu_data_file": "icudt57l.dat",
"icu_data_in": "..\\..\\deps/icu-small\\source/data/in\\icudt57l.dat",
"icu_endianness": "l",
"icu_gyp_path": "tools/icu/icu-generic.gyp",
"icu_locales": "en,root",
"icu_path": "deps/icu-small",
"icu_small": "true",
"icu_ver_major": "57",
"node_byteorder": "little",
"node_enable_d8": "false",
"node_enable_v8_vtunejit": "false",
"node_install_npm": "true",
"node_module_version": 48,
"node_no_browser_globals": "false",
"node_prefix": "/usr/local",
"node_release_urlbase": "https://nodejs.org/download/release/",
"node_shared": "false",
"node_shared_cares": "false",
"node_shared_http_parser": "false",
"node_shared_libuv": "false",
"node_shared_openssl": "false",
"node_shared_zlib": "false",
"node_tag": "",
"node_use_bundled_v8": "true",
"node_use_dtrace": "false",
"node_use_etw": "true",
"node_use_lttng": "false",
"node_use_openssl": "true",
"node_use_perfctr": "true",
"node_use_v8_platform": "true",
"openssl_fips": "",
"openssl_no_asm": 0,
"shlib_suffix": "so.48",
"target_arch": "x64",
"v8_enable_gdbjit": 0,
"v8_enable_i18n_support": 1,
"v8_inspector": "true",
"v8_no_strict_aliasing": 1,
"v8_optimized_debug": 0,
"v8_random_seed": 0,
"v8_use_snapshot": "true",
"want_separate_host_toolset": 0,
"nodedir": "C:\\Users\\ANDYR\\.node-gyp\\6.9.5",
"copy_dev_lib": "true",
"standalone_static_library": 1
}
}
CC0 1.0 Universal
==================
Statement of Purpose
---------------------
The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others.
For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights.
--------------------------------
A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and
vii. other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof.
2. Waiver.
-----------
To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback.
----------------------------
Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose.
4. Limitations and Disclaimers.
--------------------------------
a. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work.
d. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work.
# electron-quick-start
**Clone and run for a quick way to see Electron in action.**
This is a minimal Electron application based on the [Quick Start Guide](http://electron.atom.io/docs/tutorial/quick-start) within the Electron documentation.
**Use this app along with the [Electron API Demos](http://electron.atom.io/#get-started) app for API code examples to help you get started.**
A basic Electron application needs just these files:
- `package.json` - Points to the app's main file and lists its details and dependencies.
- `main.js` - Starts the app and creates a browser window to render HTML. This is the app's **main process**.
- `index.html` - A web page to render. This is the app's **renderer process**.
You can learn more about each of these components within the [Quick Start Guide](http://electron.atom.io/docs/tutorial/quick-start).
## To Use
To clone and run this repository you'll need [Git](https://git-scm.com) and [Node.js](https://nodejs.org/en/download/) (which comes with [npm](http://npmjs.com)) installed on your computer. From your command line:
```bash
# Clone this repository
git clone https://github.com/electron/electron-quick-start
# Go into the repository
cd electron-quick-start
# Install dependencies
npm install
# Run the app
npm start
```
Learn more about Electron and its API in the [documentation](http://electron.atom.io/docs/).
## Other Example Apps
For more example apps, see the
[list of boilerplates](http://electron.atom.io/community/#boilerplates)
created by the awesome electron community.
#### License [CC0 1.0 (Public Domain)](LICENSE.md)
const electron = require('electron')
// Module to control application life.
const app = electron.app
// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow
const path = require('path')
const url = require('url')
const {ipcMain} = require('electron')
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow
function createWindow () {
console.log(process.argv);
// Create the browser window.
mainWindow = new BrowserWindow({width: 800, height: 600})
mainWindow.maximize();
console.log(process.cwd())
//and load the index.html of the app.
console.log('dirname '+__dirname)
console.log(path.join(__dirname,'..','leverjs', 'ExperimentWindow.html'))
mainWindow.loadURL(url.format({
pathname: path.join(__dirname,'..','leverjs', 'ExperimentWindow.html'),
protocol: 'file:',
slashes: true
}))
/*
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, '..','leverjs', 'ImageWindow.html'),
protocol: 'file:',
slashes: true
}))
*/
// Open the DevTools.
// mainWindow.webContents.openDevTools()
// Emitted when the window is closed.
mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null
})
console.log(process.cwd())
require('./menu.js');
}
ipcMain.on('captureScreenFinalize',(event) => {
const movieMaker=require('./movieMaker.js');
movieMaker.finalizeMovie(leverFile);
});
ipcMain.on('captureScreen', (event,t,leverFile) => {
const movieMaker=require('./movieMaker.js');
movieMaker.captureFrame(event,mainWindow,leverFile,t);
});
ipcMain.on('locateImageFolder', (event,strDialogTitle) => {
const {dialog} = require('electron')
const fs = require('fs')
dialog.showOpenDialog({ title: strDialogTitle, properties:['openDirectory']},
function (fileNames) {
// fileNames is an array that contains all the selected
if(fileNames === undefined){
console.log("No file selected");
}else{
// send back the filename
event.sender.send('locatedImageFolder',fileNames[0]);
}
});
});
ipcMain.on('locateFolder', (event,strDialogTitle) => {
const {dialog} = require('electron')
const fs = require('fs')
dialog.showOpenDialog({ title: strDialogTitle, properties:['openDirectory']},
function (fileNames) {
// fileNames is an array that contains all the selected
if(fileNames === undefined){
console.log("No file selected");
}else{
// send back the filename
event.sender.send('locatedFolder',fileNames[0]);
}
});
});
function launchDataWindow(strFileName)
{
// get output folder path
const {dialog} = require('electron');
var strTitle='output folder for '+strFileName;
dialog.showOpenDialog({ title: strTitle, properties:['openDirectory']},
function (fileNames) {
// fileNames is an array that contains all the selected
if(fileNames === undefined){
// ??? ACK
}else{
// send back the filename
var strUrlFile=url.format({
pathname: path.join(__dirname, 'DataWindow', 'DataWindow.html'),
protocol: 'file:',
search: strFileName+'?'+fileNames[0],
slashes: true});
mainWindow.loadURL(strUrlFile);
}
});
} // launchDataWindow
// full path to the db file
var leverFile;
ipcMain.on('openFile', (event) => {
const {dialog} = require('electron');
const fs = require('fs');
const path = require('path');
// first, check for a .LEVER file in the arg list
for (var i = 0 ; i<process.argv.length; i++) {
if (process.argv[i]=='-captureMovieAndExit') {
console.log('main: setting movieMaker mode');
event.sender.send('setArgs',process.argv[i]);
}
else if (process.argv[i].includes('.LEVER')) {
console.log('main: opening db ' + process.argv[i]);
leverFile=process.argv[i];
event.sender.send('fileName',process.argv[i]);
return;
}
}
dialog.showOpenDialog({filters: [
{name:'LEVER', extensions:['LEVER']},
{name:'JSON' , extensions:['json']},
{name:'other', extensions:['*']}
]},
function (fileNames) {
// fileNames is an array that contains all the selected
if(fileNames === undefined){
console.log("No file selected");
}else{
// send back the filename
//
if ('.LEVER'!==path.extname(fileNames[0])) {
launchDataWindow(fileNames[0]);
}
else {
leverFile=fileNames[0];
event.sender.send('fileName',leverFile);
}
}
})
})
//Open a directory
ipcMain.on('getDir', (event) => {
const {dialog} = require('electron');
const {fs} = require('fs');
const {path} = require('path');
dialog.showOpenDialog({ title: 'Select a Directory Please', properties:['openDirectory']},
function (fileNames) {
// fileNames is an array that contains all the selected
if(fileNames === undefined){
console.log('Why')
}else{
event.sender.send('getDir',fileNames[0]);
console.log('NO')
}
});
})
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
// app.on('ready', createWindow)
app.on('ready', () => {
createWindow();
// Register a shortcut listener.
/*const ret = electron.globalShortcut.register('CommandOrControl+o', () => {
console.log('CommandOrControl+o is pressed');
mainWindow.webContents.send('global-shortcut', "open");
})
if (!ret) {
console.log('registration failed')
}
*/
// Check whether a shortcut is registered.
// console.log(globalShortcut.isRegistered('CommandOrControl+X'))
})
// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow()
}
})
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
// menu.js
const {Menu} = require('electron')
const template = [
{
label: '&File',
submenu: [
{
label: 'open .LEVER file',
accelerator: 'CmdOrCtrl+o',
role: 'reload'
},
{
label: 'import .JSON file (from utils/microscope reader)',
accelerator: 'CmdOrCtrl+i'
},
{
label: 'convert micrscope data file (requires utils/microscope reader) ',
accelerator: 'CmdOrCtrl+c'
},
]
},
{
label: 'Vie&w',
submenu: [
{
role: 'reload'
},
{
role: 'toggledevtools'
},
{
type: 'separator'
},
{
label: 'reset zoom(ctrl+0)'
},
{
label: 'zoom in (ctrl++)'
},
{
label: 'zoom out (ctrl+-)'
},
{
type: 'separator'
},
{
role: 'togglefullscreen'
}
]
},
{
role: 'help',
submenu: [
{
label: 'Learn More',
click () { require('electron').shell.openExternal('http://bioimage.coe.drexel.edu') }
},
{
label: 'about leverjs (tbd)'
}
]
}
]
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
// movieMaker.js
//leverFile is the full path to the .LEVER
function finalizeMovie(leverFile)
{
console.log('finalizing movie');
const spawn = require('child_process').spawn;
const path=require('path');
var ffmpeg;
var ffmpegPath;
imageFolder=path.join(path.dirname(leverFile), path.basename(leverFile,'.LEVER') + '_movieFrames');
// used to detect windows vs unix for process spawn command line
var isWin = /^win/.test(process.platform);
var inFiles = path.join(imageFolder,'Fucci-231cells-untreated'+'_%d.png');
var outFile = path.join(path.dirname(leverFile), 'Fucci-231cells-untreated'+'.mp4');
args=['-i',inFiles,'-c:v', 'libx264', '-pix_fmt', 'yuv420p','-profile:v','main', '-level', '4.1','-y',outFile];
console.log('inFiles: '+inFiles+' outFile:'+outFile);
console.log('args:' +args);
if (isWin)
ffmpeg = spawn('ffmpeg.exe',args);
else
ffmpeg = spawn('ffmpeg',args);
ffmpeg.on('error', (err) => {
console.log('Failed to start child process.' + err);
});
ffmpeg.stdout.on('data', (data) => {
console.log(`ffmpeg: ${data}`);
});
ffmpeg.stderr.on('data', (data) => {
console.log(`ffmpeg: ${data}`);
});
ffmpeg.on('close', (code) => {
console.log(`ffmpeg process exited with code ${code}`);
process.exit(1);
});
} // finalizeMovie
function captureFrame(event,window,leverFile,t)
{
console.log('captureFrame : ' + t);
const fs = require('fs');
const path=require('path');
var imageFolder;
var fnameIm;
// fullLeverFile is e.g. \path\to\{DATSETNAME}.LEVER
// we want to put the movie frames in \path\to\{DATASETNAME}_movie\frames
imageFolder=path.join(path.dirname(leverFile), path.basename(leverFile,'.LEVER') + '_movieFrames');
// if the folder doesn't exist, make it
if (!fs.existsSync(imageFolder)) {
fs.mkdirSync(imageFolder);
console.log('made output folder:' + imageFolder);
}
window.capturePage(function(image){
// write canvas to file
fnameIm=path.join(imageFolder,path.basename(leverFile,'.LEVER') +'_'+ t + '.png');
// use built in electron image toPng to get our output
fs.writeFile(fnameIm, image.toPng(), function (err) {
if(err)
console.log(err);
}); // writeFile
// ac 3 25 17 -- can't get streams to work -- will use filesystem for now...
// ffmpeg.stdin.write(image);
console.log('done captureScreen, t='+t);
// this reply lets the browser process know it can render the next frame
event.sender.send('doneCapture',t);
}) // capturePage
} // captureFrame
module.exports.finalizeMovie=finalizeMovie;
module.exports.captureFrame=captureFrame;
\ No newline at end of file
This diff is collapsed.
<!--
Copyright 2015 Andrew Cohen
This file is part of CloneView - the tool for displaying stem cell lineaging in a webpage.
CloneView is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CloneView is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License