Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
neurolabusc committed Aug 1, 2019
1 parent fc89907 commit 881e684
Show file tree
Hide file tree
Showing 8 changed files with 733 additions and 219 deletions.
12 changes: 11 additions & 1 deletion commandsu.pas
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ procedure OVERLAYMINMAX (lOverlay: integer; lMin,lMax: single);
procedure OVERLAYTRANSPARENCYONBACKGROUND(lPct: integer);
procedure OVERLAYVISIBLE(lOverlay: integer; VISIBLE: boolean);
procedure OVERLAYTRANSLUCENT(lOverlay: integer; TRANSLUCENT: boolean);
procedure OVERLAYOPACITY(lOverlay: integer; OPACITY: byte);
procedure OVERLAYINVERT(lOverlay: integer; INVERT: boolean);
procedure OVERLAYSMOOTHVOXELWISEDATA (SMOOTH: boolean);
procedure QUIT;
Expand Down Expand Up @@ -87,7 +88,7 @@ procedure WAIT (MSEC: integer);
(Ptr:@VERSION;Decl:'VERSION';Vars:'(): string')
);

knProc = 67;
knProc = 68;
kProcRA : array [1..knProc] of TScriptRec = (
(Ptr:@ATLASSTATMAP;Decl:'ATLASSTATMAP';Vars:'(ATLASNAME, STATNAME: string; const Intensities: array of integer; const Intensities: array of single)'),
(Ptr:@ATLASSATURATIONALPHA;Decl:'ATLASSATURATIONALPHA';Vars:'(lSaturation, lTransparency: single)'),
Expand Down Expand Up @@ -133,6 +134,7 @@ procedure WAIT (MSEC: integer);
(Ptr:@OVERLAYCOLORNAME;Decl:'OVERLAYCOLORNAME';Vars:'(lOverlay: integer; lFilename: string)'),
(Ptr:@OVERLAYLOAD;Decl:'OVERLAYLOAD';Vars:'(lFilename: string)'),
(Ptr:@OVERLAYMINMAX;Decl:'OVERLAYMINMAX';Vars:'(lOverlay: integer; lMin,lMax: single)'),
(Ptr:@OVERLAYOPACITY;Decl:'OVERLAYOPACITY';Vars:'(lOverlay: integer; OPACITY: byte)'),
(Ptr:@OVERLAYTRANSPARENCYONBACKGROUND;Decl:'OVERLAYTRANSPARENCYONBACKGROUND';Vars:'(lPct: integer)'),
(Ptr:@OVERLAYVISIBLE;Decl:'OVERLAYVISIBLE';Vars:'(lOverlay: integer; VISIBLE: boolean)'),
(Ptr:@OVERLAYTRANSLUCENT;Decl:'OVERLAYTRANSLUCENT';Vars:'(lOverlay: integer; TRANSLUCENT: boolean)'),
Expand Down Expand Up @@ -862,6 +864,14 @@ procedure OVERLAYTRANSLUCENT(lOverlay: integer; TRANSLUCENT: boolean);
else
GLForm1.OverlayVisible(lOverlay, kLUTopaque);
end;

procedure OVERLAYOPACITY(lOverlay: integer; OPACITY: byte);
begin
if OPACITY > 100 then
OPACITY := 100;
GLForm1.OverlayVisible(lOverlay, OPACITY);
end;

procedure OVERLAYVISIBLE(lOverlay: integer; VISIBLE: boolean);
begin
if VISIBLE then
Expand Down
47 changes: 27 additions & 20 deletions mainunit.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -2189,47 +2189,48 @@ object GLForm1: TGLForm1
Hint = 'overlaycloseall () This function has no parameters. All open overlays will be closed.'
OnClick = InsertCommand
end
object overlaycolorfromzero1: TMenuItem
Tag = 1
Caption = 'overlaycolorfromzero'
Hint = 'overlaycolorfromzero (fromzero: boolean) If set to false, then the full color range is used to show the overlay.'
Visible = False
OnClick = InsertCommand
end
object overlaycolorname1: TMenuItem
Tag = 1214
Caption = 'overlaycolorname'
Hint = 'overlaycolorname (overlay: integer; filename: string) Set the colorscheme for the target overlay to a specified name.'
OnClick = InsertCommand
end
object overlayinvert1: TMenuItem
Tag = 1211
Caption = 'overlayinvert'
Hint = 'overlayinvert (overlay: integer; invert: boolean) toggle whether overlay color scheme is inverted.'
OnClick = InsertCommand
end
object overlayminmax1: TMenuItem
Tag = 1223
Caption = 'overlayminmax'
Hint = 'overlayminmax (overlay: integer; min, max: float) Sets the color range for the overlay.'
OnClick = InsertCommand
end
object overlaytransparencyonbackground1: TMenuItem
Tag = 2
Caption = 'overlaytransparencyonbackground'
Hint = 'overlaytransparencyonbackground (percent: integer) Controls the opacity of the overlays on the background.'
OnClick = InsertCommand
end
object overlaycolorfromzero1: TMenuItem
Tag = 1
Caption = 'overlaycolorfromzero'
Hint = 'overlaycolorfromzero (fromzero: boolean) If set to false, then the full color range is used to show the overlay.'
Visible = False
OnClick = InsertCommand
end
object overlayvisible1: TMenuItem
Tag = 1211
Caption = 'overlayvisible'
Hint = 'overlayvisible (overlay: integer; visible: boolean) This feature allows you to make individual overlays visible or invisible.'
object overlayopacity1: TMenuItem
Tag = 22
Caption = 'overlayopacity'
Hint = 'overlayopacity (overlay, opacity: integer) This feature allows you to make individual overlays range from transparent (0) to opaque (100).'
OnClick = InsertCommand
end
object overlaytranslucent1: TMenuItem
Tag = 1211
Caption = 'overlaytranslucent'
Hint = 'overlaytranslucent (overlay: integer; translucent: boolean) This feature allows you to make individual overlays translucent or opaque.'
Visible = False
OnClick = InsertCommand
end
object overlayinvert1: TMenuItem
object overlayvisible1: TMenuItem
Tag = 1211
Caption = 'overlayinvert'
Hint = 'overlayinvert (overlay: integer; invert: boolean) toggle whether overlay color scheme is inverted.'
Caption = 'overlayvisible'
Hint = 'overlayvisible (overlay: integer; visible: boolean) This feature allows you to make individual overlays visible or invisible.'
OnClick = InsertCommand
end
object overlaysmoothvoxelwisedata1: TMenuItem
Expand All @@ -2238,6 +2239,12 @@ object GLForm1: TGLForm1
Hint = 'overlaysmoothvoxelwisedata (smooth: boolean) Determines if overlays are loaded using interpolation (smooth) or nearest neighbor (un-smoothed) interpolation.'
OnClick = InsertCommand
end
object overlaytransparencyonbackground1: TMenuItem
Tag = 2
Caption = 'overlaytransparencyonbackground'
Hint = 'overlaytransparencyonbackground (percent: integer) Controls the opacity of the overlays on the background.'
OnClick = InsertCommand
end
object meshoverlayorder1: TMenuItem
Tag = 1
Caption = 'meshoverlayorder'
Expand Down
56 changes: 55 additions & 1 deletion mainunit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ TGLForm1 = class(TForm)
CenterPanel: TPanel;
LayerAOMapMenu: TMenuItem;
LayerPainHideMenu: TMenuItem;
overlayopacity1: TMenuItem;
PaintModeAutomatic: TMenuItem;
PaintModeHideBrightHideDarkMenu: TMenuItem;
PaintModeHideDarkShowBrightMenu: TMenuItem;
Expand Down Expand Up @@ -1100,6 +1101,16 @@ function PyOVERLAYTRANSLUCENT(Self, Args : PPyObject): PPyObject; cdecl;
OVERLAYTRANSLUCENT(I,Bool(B));
end;

function PyOVERLAYOPACITY(Self, Args : PPyObject): PPyObject; cdecl;
var
B,I: integer;
begin
Result:= GetPythonEngine.PyBool_FromLong(Ord(True));
with GetPythonEngine do
if Bool(PyArg_ParseTuple(Args, 'ii:overlaytranslucent', @I,@B)) then
OVERLAYOPACITY(I,B);
end;

function PyEDGETHRESH(Self, Args : PPyObject): PPyObject; cdecl;
var
A,B: single;
Expand Down Expand Up @@ -1647,6 +1658,7 @@ procedure TGLForm1.PyModInitialization(Sender: TObject);
AddMethod('overlayinvert', @PyOVERLAYINVERT, ' overlayinvert(overlaLayer, invert) -> Toggle whether overlay color scheme is inverted.');
AddMethod('overlayload', @PyOVERLAYLOAD, ' overlayload(filename) -> Load an image on top of prior images.');
AddMethod('overlayminmax', @PyOVERLAYMINMAX, ' overlayminmax(layer, min, max) -> Sets the color range for the overlay (layer 0 = background).');
AddMethod('overlayopacity', @PyOVERLAYOPACITY, ' overlayopacity(overlayLayer, opacity) -> This feature allows you to adjust individual overlays transparency from transparent (0) to opaque (100).');
AddMethod('overlaysmoothvoxelwisedata', @PyOVERLAYSMOOTHVOXELWISEDATA, ' overlaysmoothvoxelwisedata(smooth) -> Determines if overlays are loaded using interpolation (smooth, 1) or nearest neighbor (un-smoothed, 0) interpolation.');
AddMethod('overlaytranslucent', @PyOVERLAYTRANSLUCENT, ' overlaytranslucent(overlayLayer, translucent) -> This feature allows you to make individual overlays translucent or opaque.');
AddMethod('overlaytransparencyonbackground', @PyOVERLAYTRANSPARENCYONBACKGROUND, ' overlaytransparencyonbackground(percent) -> Controls the opacity of the overlays on the background.');
Expand Down Expand Up @@ -2633,6 +2645,45 @@ function isVtkMesh (filename: string): boolean; //vtk files can be tracks (" LIN
if (pos('TRIANGLE_STRIPS ', Str) > 0) then result := true; //faces
end;

function isVtkTrack (filename: string): boolean; //vtk files can be volumes(DATASET STRUCTURED_POINTS) tracks (" LINES" ->Tracks/Open) or meshes ("POLYGONS " -> File/Open, Overlay/Open)
var
f: file;
Str: string;
szRead: integer;
begin
result := false;
if not fileexistsF(filename) then exit;
FileMode := fmOpenRead;
AssignFile(f, FileName);
Reset(f,1);
FileMode := fmOpenRead;
szRead := FileSize(f);
SetLength(Str, szRead);
BlockRead(f, Str[1],szRead);
CloseFile(f);
if (pos('POINTS ', Str) > 0)and (pos('LINES ', Str) > 0) then result := true; //faces
end;


function isVtkVolume (filename: string): boolean; //vtk files can be volumes(DATASET STRUCTURED_POINTS) tracks (" LINES" ->Tracks/Open) or meshes ("POLYGONS " -> File/Open, Overlay/Open)
var
f: file;
Str: string;
szRead: integer;
begin
result := false;
if not fileexistsF(filename) then exit;
FileMode := fmOpenRead;
AssignFile(f, FileName);
Reset(f,1);
FileMode := fmOpenRead;
szRead := FileSize(f);
SetLength(Str, szRead);
BlockRead(f, Str[1],szRead);
CloseFile(f);
if ((pos('STRUCTURED_POINTS', Str) > 0) and (pos('POINT_DATA ', Str) > 0)) then result := true;
end;

function isGiiMesh (filename: string): boolean;
//returns true if file is a valid mesh (faces+vertices), returns false if overlay map
var
Expand Down Expand Up @@ -2717,9 +2768,12 @@ function TGLForm1.OpenMesh(FilenameIN: string): boolean;
if (ext2 = '.1D.DSET') or (ext = '.COL') or (ext = '.ANNOT') or (ext = '.MGH') or (ext = '.MGZ') or (ext = '.NII') or (ext = '.HDR') or (ext = '.NII.GZ') or (ext = '.DPV') or (ext = '.ANNOT') or (ext = '.W') or (ext = '.CURV') then begin
OpenOverlay(Filename);
exit;
end else if (ext = '.VTK') and (not isVtkMesh (Filename)) then begin
end else if (ext = '.VTK') and (isVtkTrack (Filename)) then begin
OpenTrack(Filename); //.vtk files can be either meshes or tracks - autodetect
exit;
end else if (ext = '.VTK') and (length(gMesh.Faces) > 0) and (isVtkVolume (Filename))then begin
OpenOverlay(Filename); //.vtk files can be either meshes or tracks - autodetect
exit;
end else if (length(gMesh.Faces) > 0) and (ext = '.MZ3') and (not isMz3Mesh (Filename)) then begin
OpenOverlay(Filename); //GIfTI files can be meshes or overlays - autodetect
exit;
Expand Down
Loading

0 comments on commit 881e684

Please sign in to comment.