Skip to content

Commit

Permalink
BESA mesh support, overlapping overlays (https://www.nitrc.org/forum/…
Browse files Browse the repository at this point in the history
  • Loading branch information
neurolabusc committed Aug 5, 2019
1 parent 881e684 commit f33164c
Show file tree
Hide file tree
Showing 21 changed files with 748 additions and 257 deletions.
6 changes: 3 additions & 3 deletions _windows.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
REM COMPILE Surf Ice
D:
cd D:\pas\surfice
cd D:\pas\surf-ice

REM NO LONGER REQUIRED: we now use glcorearb.pas for OpenGL core
REM copy new version of GLEXT that supports geometry shaders
Expand All @@ -11,14 +11,14 @@ REM create core version
rmdir /S /Q lib
copy /Y .\optsCore.inc .\opts.inc
d:\lazarus\lazbuild --cpu=x86_64 -B surfice.lpi
move /Y "D:\pas\surfice\surfice.exe" "D:\neuro\Surf_Ice\surfice.exe"
move /Y "D:\pas\surf-ice\surfice.exe" "D:\neuro\Surf_Ice\surfice.exe"


REM create legacy version with geometry support
rmdir /S /Q lib
copy /Y .\optsCompat.inc .\opts.inc
d:\lazarus\lazbuild --cpu=x86_64 -B surfice.lpi
move /Y "D:\pas\surfice\surfice.exe" "D:\neuro\Surf_Ice\surficeOld.exe"
move /Y "D:\pas\surf-ice\surfice.exe" "D:\neuro\Surf_Ice\surficeOld.exe"


del d:\neuro\Surf_Ice\*.ini
Expand Down
17 changes: 17 additions & 0 deletions colorTable.pas
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ TLUTnodes = record
function UpdateTransferFunction (var lIndex: integer; isInvert: boolean): TLUT;//change color table
function CLUTDir: string;
function blendRGBA(c1, c2: TRGBA ): TRGBA;
function blendRGBAover(ca, cb: TRGBA ): TRGBA;
function maxRGBA(c1, c2: TRGBA ): TRGBA;
//function inten2rgb(intensity, mn, mx: single; lut: TLUT): TRGBA;
function inten2rgb(intensity, mn, mx: single; lut: TLUT; mode: integer): TRGBA; overload;
Expand All @@ -43,6 +44,22 @@ function isFreeSurferLUT(lIndex: integer): boolean;
result := (lIndex >= 15) and (lIndex <= 18);
end;

function blendRGBAover(ca, cb: TRGBA ): TRGBA;
//https://en.wikipedia.org/wiki/Alpha_compositing#Analytical_derivation_of_the_over_operator
var
aa, ab, ao: single;
begin
if cb.A = 0 then exit(ca);
if ca.A = 0 then exit(cb);
aa := ca.A / 255;
ab := cb.A / 255;
ao := 1.0 - (1.0-aa)*(1.0-ab);
result.R := round(((aa*ca.r)+(1-aa)*ab*cb.r)/ao) ;
result.G := round(((aa*ca.g)+(1-aa)*ab*cb.g)/ao) ;
result.B := round(((aa*ca.b)+(1-aa)*ab*cb.b)/ao) ;
result.A := round(ao * 255.0);
end;

function blendRGBA(c1, c2: TRGBA ): TRGBA;
var
frac1, frac2: single;
Expand Down
11 changes: 10 additions & 1 deletion commandsu.pas
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ procedure OVERLAYTRANSLUCENT(lOverlay: integer; TRANSLUCENT: boolean);
procedure OVERLAYOPACITY(lOverlay: integer; OPACITY: byte);
procedure OVERLAYINVERT(lOverlay: integer; INVERT: boolean);
procedure OVERLAYSMOOTHVOXELWISEDATA (SMOOTH: boolean);
procedure OVERLAYOVERLAPOVERWRITE (OVERWRITE: boolean);
procedure QUIT;
procedure RESETDEFAULTS;
procedure SAVEBMP(lFilename: string);
Expand Down Expand Up @@ -88,7 +89,7 @@ procedure WAIT (MSEC: integer);
(Ptr:@VERSION;Decl:'VERSION';Vars:'(): string')
);

knProc = 68;
knProc = 69;
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 @@ -140,6 +141,7 @@ procedure WAIT (MSEC: integer);
(Ptr:@OVERLAYTRANSLUCENT;Decl:'OVERLAYTRANSLUCENT';Vars:'(lOverlay: integer; TRANSLUCENT: boolean)'),
(Ptr:@OVERLAYINVERT;Decl:'OVERLAYINVERT';Vars:'(lOverlay: integer; INVERT: boolean)'),
(Ptr:@OVERLAYSMOOTHVOXELWISEDATA;Decl:'OVERLAYSMOOTHVOXELWISEDATA';Vars:'(SMOOTH: boolean)'),
(Ptr:@OVERLAYOVERLAPOVERWRITE;Decl:'OVERLAYOVERLAPOVERWRITE';Vars:'(OVERWRITE: boolean)'),
(Ptr:@QUIT;Decl:'QUIT';Vars:''),
(Ptr:@RESETDEFAULTS;Decl:'RESETDEFAULTS';Vars:''),
(Ptr:@SAVEBMP;Decl:'SAVEBMP';Vars:'(lFilename: string)'),
Expand Down Expand Up @@ -852,6 +854,13 @@ procedure OVERLAYINVERT(lOverlay: integer; INVERT: boolean);
GLForm1.OverlayInvert(lOverlay, INVERT);
end;

procedure OVERLAYOVERLAPOVERWRITE (OVERWRITE: boolean);
begin
if (gMesh.OverlappingOverlaysOverwrite <> OVERWRITE) then GLForm1.OverlayTimer.Enabled := true;
gMesh.OverlappingOverlaysOverwrite := OVERWRITE;

end;

procedure OVERLAYSMOOTHVOXELWISEDATA (SMOOTH: boolean);
begin
gPrefs.SmoothVoxelwiseData:= SMOOTH;
Expand Down
2 changes: 1 addition & 1 deletion define_types.pas
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface
{$endif}

const
kVers = 'v1.0.20190720';
kVers = 'v1.0.20190803';
NaN : double = 1/0;
kTab = chr(9);
kCR = chr (13);
Expand Down
82 changes: 44 additions & 38 deletions mainunit.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ object GLForm1: TGLForm1
Align = alLeft
BorderStyle = bsNone
ClientHeight = 514
ClientWidth = 246
ClientWidth = 261
Constraints.MaxWidth = 272
Constraints.MinWidth = 4
ParentFont = False
TabOrder = 2
object OverlayBox: TGroupBox
Left = 0
Height = 181
Height = 182
Hint = 'Click on name to hide, control+click to reverse palette'
Top = 0
Width = 246
Width = 261
Align = alTop
AutoSize = True
Caption = 'Overlays'
ClientHeight = 163
ClientWidth = 238
ClientWidth = 251
Constraints.MinHeight = 2
ParentFont = False
ParentShowHint = False
Expand All @@ -54,7 +54,7 @@ object GLForm1: TGLForm1
Height = 72
Hint = 'Right-click for options'
Top = 0
Width = 238
Width = 251
Align = alTop
Constraints.MaxHeight = 72
ItemHeight = 0
Expand Down Expand Up @@ -190,14 +190,14 @@ object GLForm1: TGLForm1
end
object ClipBox: TGroupBox
Left = 0
Height = 81
Top = 284
Width = 246
Height = 82
Top = 286
Width = 261
Align = alTop
AutoSize = True
Caption = 'Clipping'
ClientHeight = 63
ClientWidth = 238
ClientWidth = 251
ParentFont = False
TabOrder = 0
OnDblClick = DepthLabelDblClick
Expand Down Expand Up @@ -304,14 +304,14 @@ object GLForm1: TGLForm1
object TrackBox: TGroupBox
Tag = 270
Left = 0
Height = 103
Top = 181
Width = 246
Height = 104
Top = 182
Width = 261
Align = alTop
AutoSize = True
Caption = 'Tracks'
ClientHeight = 85
ClientWidth = 238
ClientWidth = 251
ParentFont = False
TabOrder = 2
Visible = False
Expand Down Expand Up @@ -478,14 +478,14 @@ object GLForm1: TGLForm1
object NodeBox: TGroupBox
Tag = 270
Left = 0
Height = 106
Top = 365
Width = 246
Height = 107
Top = 368
Width = 261
Align = alTop
AutoSize = True
Caption = 'Nodes'
ClientHeight = 88
ClientWidth = 238
ClientWidth = 251
ParentFont = False
TabOrder = 3
Visible = False
Expand Down Expand Up @@ -688,14 +688,14 @@ object GLForm1: TGLForm1
object EdgeBox: TGroupBox
Tag = 270
Left = 0
Height = 84
Top = 471
Width = 246
Height = 85
Top = 475
Width = 261
Align = alTop
AutoSize = True
Caption = 'Edges'
ClientHeight = 66
ClientWidth = 238
ClientWidth = 251
ParentFont = False
TabOrder = 4
Visible = False
Expand Down Expand Up @@ -873,14 +873,14 @@ object GLForm1: TGLForm1
object MeshColorBox: TGroupBox
Tag = 270
Left = 0
Height = 60
Top = 555
Width = 246
Height = 61
Top = 560
Width = 261
Align = alTop
AutoSize = True
Caption = 'Mesh Color'
ClientHeight = 42
ClientWidth = 238
ClientWidth = 251
ParentFont = False
TabOrder = 6
Visible = False
Expand Down Expand Up @@ -948,14 +948,14 @@ object GLForm1: TGLForm1
end
object BackgroundBox: TGroupBox
Left = 0
Height = 59
Top = 615
Width = 246
Height = 60
Top = 621
Width = 261
Align = alTop
AutoSize = True
Caption = 'Background Mesh'
ClientHeight = 41
ClientWidth = 238
ClientWidth = 251
ParentFont = False
TabOrder = 5
object meshAlphaTrack: TTrackBar
Expand Down Expand Up @@ -1055,14 +1055,14 @@ object GLForm1: TGLForm1
end
object ShaderBox: TGroupBox
Left = 0
Height = 281
Top = 674
Width = 246
Height = 282
Top = 681
Width = 261
Align = alClient
AutoSize = True
Caption = 'Render'
ClientHeight = 263
ClientWidth = 238
ClientWidth = 251
ParentFont = False
TabOrder = 7
OnResize = ShaderBoxResize
Expand Down Expand Up @@ -1485,7 +1485,7 @@ object GLForm1: TGLForm1
Left = 0
Height = 54
Top = 209
Width = 238
Width = 251
Align = alBottom
Lines.Strings = (
''
Expand Down Expand Up @@ -1579,14 +1579,14 @@ object GLForm1: TGLForm1
Width = 8
Align = alClient
Caption = 'Scripting'
ClientHeight = 496
ClientHeight = 495
ClientWidth = 0
ParentFont = False
TabOrder = 0
OnDblClick = ScriptPanelDblClick
object ScriptMemo: TMemo
Left = 0
Height = 290
Height = 289
Top = 0
Width = 0
Align = alClient
Expand All @@ -1608,7 +1608,7 @@ object GLForm1: TGLForm1
object ScriptOutputMemo: TMemo
Left = 0
Height = 200
Top = 296
Top = 295
Width = 0
Align = alBottom
BorderStyle = bsNone
Expand All @@ -1625,7 +1625,7 @@ object GLForm1: TGLForm1
Cursor = crVSplit
Left = 0
Height = 6
Top = 290
Top = 289
Width = 0
Align = alBottom
ResizeAnchor = akBottom
Expand Down Expand Up @@ -2233,6 +2233,12 @@ object GLForm1: TGLForm1
Hint = 'overlayvisible (overlay: integer; visible: boolean) This feature allows you to make individual overlays visible or invisible.'
OnClick = InsertCommand
end
object overlayoverlapoverwrite1: TMenuItem
Tag = 1
Caption = 'overlayoverlapoverwrite'
Hint = 'overlayoverlapoverwrite (overwrite: boolean) Will overlapping overlays by blended together or will the top overlay hide overlays beneath it.'
OnClick = InsertCommand
end
object overlaysmoothvoxelwisedata1: TMenuItem
Tag = 1
Caption = 'overlaysmoothvoxelwisedata'
Expand Down
Loading

0 comments on commit f33164c

Please sign in to comment.