Skip to content

Commit

Permalink
Refactored into Paclet
Browse files Browse the repository at this point in the history
  • Loading branch information
flip phillips committed Jun 6, 2018
1 parent 8dffd61 commit 7a5d7e8
Show file tree
Hide file tree
Showing 18 changed files with 285 additions and 99 deletions.
9 changes: 7 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.paclet
.DS_Store
MonitorUtilities/Globals.wl
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cSpell.words": [
"Buzing's",
"paclet"
]
}
22 changes: 22 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Monitor Utilities
### Added

- Development / test stuff
- paclet build

## [1.0.0] - 2017-11-01

Expand Down
89 changes: 0 additions & 89 deletions MonitorUtilities.wl

This file was deleted.

57 changes: 57 additions & 0 deletions MonitorUtilities/Conversions.wl
Original file line number Diff line number Diff line change
@@ -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)]
Git LFS file not shown
3 changes: 3 additions & 0 deletions MonitorUtilities/Documentation/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
29 changes: 29 additions & 0 deletions MonitorUtilities/MonitorUtilities.wl
Original file line number Diff line number Diff line change
@@ -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[];
36 changes: 36 additions & 0 deletions MonitorUtilities/PacletInfo.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Paclet[
Name -> "MonitorUtilities",
Description -> "Tools for monitor / viewing calculations",
Creator -> "Flip Phillips <[email protected]>",
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`"} }
}
]
30 changes: 30 additions & 0 deletions MonitorUtilities/Usage.wl
Original file line number Diff line number Diff line change
@@ -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."
55 changes: 55 additions & 0 deletions build.wls
Original file line number Diff line number Diff line change
@@ -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"]
3 changes: 0 additions & 3 deletions icon.jpg

This file was deleted.

3 changes: 3 additions & 0 deletions icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions install.wls
Original file line number Diff line number Diff line change
@@ -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"]
Loading

0 comments on commit 7a5d7e8

Please sign in to comment.