From 7a5d7e826d055fbba69340e6a968c26cc38a5899 Mon Sep 17 00:00:00 2001 From: flip phillips Date: Wed, 6 Jun 2018 13:19:07 -0400 Subject: [PATCH] Refactored into Paclet --- .gitattributes | 9 +- .gitignore | 3 + .vscode/settings.json | 6 ++ .vscode/tasks.json | 22 +++++ CHANGELOG.md | 1 + MonitorUtilities.wl | 89 ------------------- MonitorUtilities/Conversions.wl | 57 ++++++++++++ .../English/Guides/MonitorUtilities.nb | 3 + MonitorUtilities/Documentation/icon.png | 3 + {Kernel => MonitorUtilities/Kernel}/init.wl | 0 MonitorUtilities/MonitorUtilities.wl | 29 ++++++ MonitorUtilities/PacletInfo.m | 36 ++++++++ MonitorUtilities/Usage.wl | 30 +++++++ build.wls | 55 ++++++++++++ icon.jpg | 3 - icon.png | 3 + install.wls | 24 +++++ version.json | 11 +-- 18 files changed, 285 insertions(+), 99 deletions(-) create mode 100644 .gitignore create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json delete mode 100644 MonitorUtilities.wl create mode 100644 MonitorUtilities/Conversions.wl create mode 100644 MonitorUtilities/Documentation/English/Guides/MonitorUtilities.nb create mode 100644 MonitorUtilities/Documentation/icon.png rename {Kernel => MonitorUtilities/Kernel}/init.wl (100%) create mode 100644 MonitorUtilities/MonitorUtilities.wl create mode 100644 MonitorUtilities/PacletInfo.m create mode 100644 MonitorUtilities/Usage.wl create mode 100755 build.wls delete mode 100644 icon.jpg create mode 100644 icon.png create mode 100755 install.wls diff --git a/.gitattributes b/.gitattributes index f366e6d..8d7f9cb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,8 @@ -*.jpg filter=lfs diff=lfs merge=lfs -text -*.png filter=lfs diff=lfs merge=lfs -text *.nb filter=lfs diff=lfs merge=lfs -text +*.mx filter=lfs diff=lfs merge=lfs -text + +*.png filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.ply filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +*.psd filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0b733b6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.paclet +.DS_Store +MonitorUtilities/Globals.wl diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b324ffc --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "cSpell.words": [ + "Buzing's", + "paclet" + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..305c558 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,22 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "type": "shell", + "command": "/usr/bin/env wolframscript -f build.wls", + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "install", + "type": "shell", + "command": "/usr/bin/env wolframscript -f install.wls", + "group": "build" + } + ] +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index ff3ed3c..7662be8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ Monitor Utilities ### Added - Development / test stuff +- paclet build ## [1.0.0] - 2017-11-01 diff --git a/MonitorUtilities.wl b/MonitorUtilities.wl deleted file mode 100644 index 4de8432..0000000 --- a/MonitorUtilities.wl +++ /dev/null @@ -1,89 +0,0 @@ -(* ::Package:: *) - -(* display utilities *) -(* uses associations to represent the monitor *) -(* units are cm, degrees, and pixels throughout *) - - -BeginPackage["MonitorUtilities`"] - - -MonitorUtilities::usage="A package for doing monitor computation. Needs an association with xres,yres,xsize,ysize, and distance defined." - - -PixelsPerCM::usage="PixelsPerCM[mon] returns pixels per centimeter for the given mon." -CMPerPixel::usage="CMPerPixel[mon] returns centimeters per pixel for mon." - - -DegreesPerCM::usage="DegreesPerCM[distance] gives the degrees per 1 centimeter at a particular distance. Optionally, DegreesPerCM[distance,length] allows specification of the length on the screen." -CMPerDegree::usage="CMPerDegree[distance] gives the centimeters, on the screen." - - -DegreesPerPixel::usage="DegreesPerPixel[mon] gives the given degrees per pixel for monitor mon. DegreesPerPixel[mon,vp] at viewpoint vp." -PixelsPerDegree::usage="PixelsPerDegree[mon] or PixelsPerDegree[mon,vp]" - - -CartesianToMonitor::usage="CartesianToMonitor[mon,p] projects p onto monitor space." -MonitorToImage::usage="MonitorToImage[mon,p] projects monitor position to image space {row,col} style." -MonitorToDegrees::usage="MonitorToDegrees[mon,p] projects monitor position degrees." -DegreesToMonitor::usage="DegreesToMonitor[mon,va] projects a point at va to monitor space." - - -Begin["`Private`"] - -(* Implementation of the package *) - - -(* ::Text:: *) -(*We'll just do this in x axis for now... but should be better than all that*) - - -PixelsPerCM[mon_]:=mon["xres"]/mon["xsize"] - - -CMPerPixel[mon_]:=1/PixelsPerCM[mon] - - -DegreesPerCM[distance_,length_:1.0]:=ArcTan[distance,length]/Degree - - -CMPerDegree[distance_,length_:1.0]:=1/DegreesPerCM[distance,length] - - -DegreesPerPixel[mon_,vp_]:=DegreesPerCM[vp]/PixelsPerCM[mon] - - -DegreesPerPixel[mon_]:=DegreesPerCM[mon["distance"]]/PixelsPerCM[mon] - - -PixelsPerDegree[mon_,vp_]:=1/DegreesPerPixel[mon,vp] - - -PixelsPerDegree[mon_]:=1/DegreesPerPixel[mon,mon["distance"]] - - -(* this shit makes me crazy *) - - -CartesianToMonitor[mon_,p_]:={p[[1]],mon["yres"]-p[[2]]} - - -(* row,col *) - - -MonitorToImage[mon_,p_]:={mon["yres"]-p[[2]],p[[1]]} - - -(* Note this is POSITION not size!!! y inverted! Screen space *) - - -MonitorToDegrees[mon_,p_]:=(CartesianToMonitor[mon,p]-{mon["xres"],mon["yres"]}/2)/PixelsPerDegree[mon] - - -DegreesToMonitor[mon_,va_]:=CartesianToMonitor[mon,(va*PixelsPerDegree[mon])+({mon["xres"],mon["yres"]}/2)] - - -End[] - - -EndPackage[] diff --git a/MonitorUtilities/Conversions.wl b/MonitorUtilities/Conversions.wl new file mode 100644 index 0000000..4644b16 --- /dev/null +++ b/MonitorUtilities/Conversions.wl @@ -0,0 +1,57 @@ +(* ::Package:: *) + +(* display utilities *) +(* uses associations to represent the monitor *) +(* units are cm, degrees, and pixels throughout *) + + +(* Implementation of the package *) + + +(* ::Text:: *) +(*We'll just do this in x axis for now... but should be better than all that*) + + +PixelsPerCM[mon_]:=mon["xres"]/mon["xsize"] + + +CMPerPixel[mon_]:=1/PixelsPerCM[mon] + + +DegreesPerCM[distance_,length_:1.0]:=ArcTan[distance,length]/Degree + + +CMPerDegree[distance_,length_:1.0]:=1/DegreesPerCM[distance,length] + + +DegreesPerPixel[mon_,vp_]:=DegreesPerCM[vp]/PixelsPerCM[mon] + + +DegreesPerPixel[mon_]:=DegreesPerCM[mon["distance"]]/PixelsPerCM[mon] + + +PixelsPerDegree[mon_,vp_]:=1/DegreesPerPixel[mon,vp] + + +PixelsPerDegree[mon_]:=1/DegreesPerPixel[mon,mon["distance"]] + + +(* this shit makes me crazy *) + + +CartesianToMonitor[mon_,p_]:={p[[1]],mon["yres"]-p[[2]]} + + +(* row,col *) + + +MonitorToImage[mon_,p_]:={mon["yres"]-p[[2]],p[[1]]} + + +(* Note this is POSITION not size!!! y inverted! Screen space *) + + +MonitorToDegrees[mon_,p_]:=(CartesianToMonitor[mon,p]-{mon["xres"],mon["yres"]}/2)/PixelsPerDegree[mon] + + +DegreesToMonitor[mon_,va_]:=CartesianToMonitor[mon,(va*PixelsPerDegree[mon])+({mon["xres"],mon["yres"]}/2)] diff --git a/MonitorUtilities/Documentation/English/Guides/MonitorUtilities.nb b/MonitorUtilities/Documentation/English/Guides/MonitorUtilities.nb new file mode 100644 index 0000000..11e0232 --- /dev/null +++ b/MonitorUtilities/Documentation/English/Guides/MonitorUtilities.nb @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:127919a4ad44ceb24165f3dcfcd436c6c5d87b2e679a3ad219d1cd6102527796 +size 417164 diff --git a/MonitorUtilities/Documentation/icon.png b/MonitorUtilities/Documentation/icon.png new file mode 100644 index 0000000..9119292 --- /dev/null +++ b/MonitorUtilities/Documentation/icon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:24b5a9f55f8334bbabffd0c96cc3922515be5c38f209bbbbaea866f2fe76a847 +size 221727 diff --git a/Kernel/init.wl b/MonitorUtilities/Kernel/init.wl similarity index 100% rename from Kernel/init.wl rename to MonitorUtilities/Kernel/init.wl diff --git a/MonitorUtilities/MonitorUtilities.wl b/MonitorUtilities/MonitorUtilities.wl new file mode 100644 index 0000000..f80a6da --- /dev/null +++ b/MonitorUtilities/MonitorUtilities.wl @@ -0,0 +1,29 @@ +(* As borrowed from Arnoud's templates *) + +PrintTemporary["Loading ",ToString[Length[Names["MonitorUtilities`*"]]], " MonitorUtilities functions"]; + +BeginPackage["MonitorUtilities`",{"PacletManager`"}]; + +Get[FileNameJoin[{DirectoryName[$InputFileName],"Usage.wl"}]]; + +Begin["`Private`"]; + +Module[{files}, + + (* load in any session *) + files={"Globals.wl","Conversions.wl"}; + + Map[Get[FileNameJoin[{DirectoryName[$InputFileName], #}]] &, files]; + + (* only load in a notebook session *) +(* + If[ Head[$FrontEnd] === FrontEndObject, + files = {"Dock.wl","Notebook.wl"}; + Map[ Get[ FileNameJoin[{DirectoryName[$InputFileName], #}] ] &, files ]; + ] +*) + +]; + +End[]; +EndPackage[]; diff --git a/MonitorUtilities/PacletInfo.m b/MonitorUtilities/PacletInfo.m new file mode 100644 index 0000000..6dc88f4 --- /dev/null +++ b/MonitorUtilities/PacletInfo.m @@ -0,0 +1,36 @@ +Paclet[ + Name -> "MonitorUtilities", + Description -> "Tools for monitor / viewing calculations", + Creator -> "Flip Phillips ", + Publisher -> "Skidmore Vision Lab", + Copyright -> "1997- Flip Phillips", + License -> "MIT", + Version -> "1.2.0", + BuildNumber -> "17", + MathematicaVersion -> "11.2+", + URL -> "https://github.com/flipphillips/MonitorUtilities", + Thumbnail -> "Documentation/icon.png", + Loading -> Automatic, + Extensions -> { + { "Documentation", + MainPage -> "Guides/MonitorUtilities", + Language -> "English"}, + { "Kernel", + Symbols -> { + (* globals *) + "MonitorUtilities`$MonitorUtilitiesVersion","MonitorUtilities`$MonitorUtilitiesDebug", + + "MonitorUtilities`PixelsPerCM", + "MonitorUtilities`CMPerPixel", + "MonitorUtilities`DegreesPerCM", + "MonitorUtilities`CMPerDegree", + "MonitorUtilities`DegreesPerPixel", + "MonitorUtilities`PixelsPerDegree", + "MonitorUtilities`CartesianToMonitor", + "MonitorUtilities`MonitorToImage", + "MonitorUtilities`MonitorToDegrees", + "MonitorUtilities`DegreesToMonitor" + }, + Context -> {"MonitorUtilities`"} } + } +] \ No newline at end of file diff --git a/MonitorUtilities/Usage.wl b/MonitorUtilities/Usage.wl new file mode 100644 index 0000000..af6fbe8 --- /dev/null +++ b/MonitorUtilities/Usage.wl @@ -0,0 +1,30 @@ +(* ::Package:: *) + + +(* ::Section:: *) +(*Automatically Generated*) + + +$MonitorUtilitiesVersion::usage = "$MonitorUtilitiesVersion gives its best guess as to the version we're using."; +$MonitorUtilitiesDebug::usage = "$MonitorUtilitiesDebug let's us know if the package was built with any debugging tools."; + + +(* MonitorUtilities::usage="A package for doing monitor computation. Needs an association with xres,yres,xsize,ysize, and distance defined." *) + + +PixelsPerCM::usage="PixelsPerCM[mon] returns pixels per centimeter for the given mon." +CMPerPixel::usage="CMPerPixel[mon] returns centimeters per pixel for mon." + + +DegreesPerCM::usage="DegreesPerCM[distance] gives the degrees per 1 centimeter at a particular distance. Optionally, DegreesPerCM[distance,length] allows specification of the length on the screen." +CMPerDegree::usage="CMPerDegree[distance] gives the centimeters, on the screen." + + +DegreesPerPixel::usage="DegreesPerPixel[mon] gives the given degrees per pixel for monitor mon. DegreesPerPixel[mon,vp] at viewpoint vp." +PixelsPerDegree::usage="PixelsPerDegree[mon] or PixelsPerDegree[mon,vp]" + + +CartesianToMonitor::usage="CartesianToMonitor[mon,p] projects p onto monitor space." +MonitorToImage::usage="MonitorToImage[mon,p] projects monitor position to image space {row,col} style." +MonitorToDegrees::usage="MonitorToDegrees[mon,p] projects monitor position degrees." +DegreesToMonitor::usage="DegreesToMonitor[mon,va] projects a point at va to monitor space." diff --git a/build.wls b/build.wls new file mode 100755 index 0000000..ad05e73 --- /dev/null +++ b/build.wls @@ -0,0 +1,55 @@ +#!/usr/bin/env wolframscript +# +# paclet builder +# + +(* gerbils *) +$packageName="MonitorUtilities"; +$versionFile="version.json"; +$globalsFile="Globals.wl"; + +directory = Directory[]; +pacletDirectory = FileNameJoin[{directory, $packageName}]; + +Print["Building from: ", directory]; + +(* bump build *) +VersionBumpBuild[directory]; + +(* globals *) +Unprotect[{$MonitorUtilitiesDebug,$MonitorUtilitiesVersion}] +$MonitorUtilitiesDebug=False; +$MonitorUtilitiesVersion=VersionString[directory,"Build"->True]; + +(* create global file *) +gfile=FileNameJoin[{directory,$packageName,$globalsFile}]; +If[FileExistsQ[gfile], DeleteFile[gfile]]; +Save[gfile, {$MonitorUtilitiesDebug, $MonitorUtilitiesVersion}]; + +(* delete old paclet *) +files = FileNames["*.paclet", directory]; +Print["Found paclets (to be deleted): ", files]; +DeleteFile /@ files; + +(* build new paclet *) +Print["Building new paclet"]; +UpdatePacletFile[pacletDirectory,directory]; +paclet = PackPaclet[pacletDirectory]; +Print["New paclet: ", paclet]; + +paclets = PacletFind[$packageName]; +Print["Found the following old paclets (uninstalling): ", Map[ #["Location"]&, paclets]]; +Map[ PacletUninstall, paclets ]; + + +(* install new paclet *) +Print["Installing new paclet"] +PacletInstall[paclet, IgnoreVersion -> True]; + +(* Build wiki docs *) +wikidir=FileNameJoin[{"..",$packageName<>".wiki"}]; + +Print["Building wiki at ",wikidir] +BuildWikiDocumentation[wikidir,$packageName]; + +Print["Done"] diff --git a/icon.jpg b/icon.jpg deleted file mode 100644 index 55c0a3b..0000000 --- a/icon.jpg +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d62f3cb16997a9ae53254f5c83b342c9bbe7d9f9c4196421de2f6651ce38d684 -size 54434 diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..9119292 --- /dev/null +++ b/icon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:24b5a9f55f8334bbabffd0c96cc3922515be5c38f209bbbbaea866f2fe76a847 +size 221727 diff --git a/install.wls b/install.wls new file mode 100755 index 0000000..e15a0b1 --- /dev/null +++ b/install.wls @@ -0,0 +1,24 @@ +#!/usr/bin/env wolframscript +# +# paclet installer +# + +(* gerbils *) +$packageName="MonitorUtilities"; +$versionFile="version.json"; +$globalsFile="Globals.wl"; + +directory = Directory[]; +pacletDirectory = FileNameJoin[{directory, $packageName}]; + +Print["Installing from: ", directory]; + +paclets = PacletFind[$packageName]; +Print["Found the following old paclets (uninstalling): ", Map[ #["Location"]&, paclets]]; +Map[ PacletUninstall, paclets ]; + +(* install new paclet *) +Print["Installing new paclet"] +PacletInstall[FileNames["*.paclet", directory], IgnoreVersion -> True]; + +Print["Done"] diff --git a/version.json b/version.json index 33e9706..642ab13 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,7 @@ { - "major_version": 1, - "minor_version": 1, - "revision_number": 0, - "build_number": 1 -} + "major_version":1, + "minor_version":2, + "revision_number":0, + "build_number":17, + "date":"Wed 6 Jun 2018 13:17:44" +} \ No newline at end of file