Skip to content

Commit

Permalink
Additional option for flipping the Z axis
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesra committed May 16, 2019
1 parent 51be9c2 commit 69c299c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 28 deletions.
28 changes: 22 additions & 6 deletions CreateRenderingFigure.m
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
function [ hFig, hAxes ] = CreateRenderingFigure(varargin)
%CREATERENDERINGFIGURE Create the figure used to render meshes
%WindowSize - Size of window, tuple
%Renderer - Renderer to use, string
%ReverseZ - bool, if true reverse the Z-axis

WindowSize = [0 0 1024 768];
renderer = 'opengl';
ZDir = 'normal';
light_elevation = 30;

optargin = size(varargin,2);
if(optargin == 1)
if(optargin >= 1)
WindowSize = varargin{1};
elseif(optargin == 2)
WindowSize = varargin{1};
end
if(optargin >= 2)
renderer = varargin{2};
end
if(optargin >= 3)
ReverseZ = varargin{3};
if(ReverseZ)
ZDir = 'reverse';
light_elevation = -light_elevation;
end
end



hFig = figure('Units', 'Pixels', ...
'OuterPosition', WindowSize, ...
Expand All @@ -23,12 +37,14 @@
'YColor', [.5 .5 .5], ...
'ZColor', [.5 .5 .5], ...
'Position', [0 0 1 1], ...
'DataAspectRatio', [1 1 1]);
'DataAspectRatio', [1 1 1], ...
'ZDir', ZDir);

hold on;

lightangle(45,30);
lightangle(225,30);

lightangle(45,light_elevation);
lightangle(225,light_elevation);

end

26 changes: 11 additions & 15 deletions PPlot2.m
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,7 @@ function PPlot2(Structs, Locs, LocLinks, scale_struct, VolumeName, varargin)
% scale_struct.X.Value = .001;
% scale_struct.Y.Value = .001;
% scale_struct.Z.Value = .045;


if InvertZ
scale_struct.Z.Value = scale_struct.Z.Value * -1;
end


%Scale the coordinates, keeps a copy of the original data
if(~isnan(MinZ))
MinZ = scale_struct.Z.Value * MinZ;
Expand All @@ -167,6 +162,12 @@ function PPlot2(Structs, Locs, LocLinks, scale_struct, VolumeName, varargin)
MaxZ = scale_struct.Z.Value * MaxZ;
end

if(MinZ > MaxZ)
temp = MinZ;
MinZ = MaxZ;
MaxZ = temp;
end

Locs = ScaleLocations(Locs, scale_struct);

for(iStruct = 1:numStructs)
Expand Down Expand Up @@ -685,7 +686,7 @@ function PPlot2(Structs, Locs, LocLinks, scale_struct, VolumeName, varargin)
end

disp('Creating figure...');
[hFig, hAxes] = CreateRenderingFigure();
[hFig, hAxes] = CreateRenderingFigure(WindowSize, renderer, InvertZ);

%
% hFig = figure('Units', 'Pixels', ...
Expand All @@ -701,11 +702,6 @@ function PPlot2(Structs, Locs, LocLinks, scale_struct, VolumeName, varargin)
% 'Position', [0 0 1 1], ...
% 'DataAspectRatio', [1 1 1]);

hold on;

lightangle(45,30);
lightangle(225,30);

disp('Rendering structures...');
SceneBox = [];
for iPID = 1:length(StructureIDs)
Expand Down Expand Up @@ -759,9 +755,9 @@ function PPlot2(Structs, Locs, LocLinks, scale_struct, VolumeName, varargin)
% 'String', 'Y');
% set(get(gca,'ZLabel'), 'Color', [0.5 0.5 0.5], ...
% 'String', 'IPL Depth (nm)');
set(gca, 'YTick', []);
camroll(180);

% set(gca, 'YTick', []);
%camroll(180);
% title('Laminae of Inner Nuclear Layer Cells');
%

Expand Down
8 changes: 4 additions & 4 deletions VikingPlot.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function VikingPlot( varargin )

disp('');
disp('Version: 1.0.2019.04.09');
disp('Version: 1.0.2019.04.23');
disp('');

dbstop if error
Expand Down Expand Up @@ -31,7 +31,7 @@ function VikingPlot( varargin )
ColladaPath = []; %The path to write .dae files to, if not specified .dae files are not written
Query = {};
IDFileNames = {};
InvertZ = false;
InvertZ = true;
MinZ = NaN;
MaxZ = NaN;

Expand Down Expand Up @@ -136,9 +136,9 @@ function VikingPlot( varargin )
ColladaPath = varargin{iArg+1};
SkipNextArgument = true;
elseif(strcmpi(varargin{iArg},'-z'))
InvertZ = true;
InvertZ = false;
elseif(strcmpi(varargin{iArg},'-InvertZ'))
InvertZ = true;
InvertZ = false;
elseif(strcmpi(varargin{iArg},'-MinZ') )
MinZ = str2num(varargin{iArg+1});
SkipNextArgument = true;
Expand Down
9 changes: 6 additions & 3 deletions VikingPlot.prj
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<deployment-project plugin="plugin.ezdeploy" plugin-version="1.0">
<configuration build-checksum="3996273110" file="C:\src\git\VikingPlot\VikingPlot.prj" location="C:\src\git\VikingPlot" name="VikingPlot" preferred-package-location="C:\src\git\VikingPlot\VikingPlot\for_redistribution" preferred-package-type="package.type.exe" target="target.ezdeploy.standalone" target-name="Application Compiler">
<configuration build-checksum="2565003330" file="C:\src\git\VikingPlot\VikingPlot.prj" location="C:\src\git\VikingPlot" name="VikingPlot" preferred-package-location="C:\src\git\VikingPlot\VikingPlot\for_redistribution" preferred-package-type="package.type.exe" target="target.ezdeploy.standalone" target-name="Application Compiler">
<param.appname>VikingPlot</param.appname>
<param.icon />
<param.icons />
<param.version>1.07</param.version>
<param.version>1.09</param.version>
<param.authnamewatermark>James Anderson</param.authnamewatermark>
<param.email>[email protected]</param.email>
<param.company>University of Utah</param.company>
<param.summary>VikingPlot creates 3D renderings of cells for the Viking Annotation system</param.summary>
<param.description />
<param.screenshot>${PROJECT_ROOT}\VikingPlotThumbnail.png</param.screenshot>
<param.guid />
<param.installpath.string>VikingPlot-1.03.2016.09.23</param.installpath.string>
<param.installpath.string>VikingPlot-1.03.2019.04.09</param.installpath.string>
<param.installpath.combo>option.installpath.programfiles</param.installpath.combo>
<param.logo />
<param.install.notes />
Expand Down Expand Up @@ -45,6 +45,9 @@
<unset>
<param.icon />
<param.icons />
<param.authnamewatermark />
<param.email />
<param.company />
<param.description />
<param.guid />
<param.installpath.combo />
Expand Down

0 comments on commit 69c299c

Please sign in to comment.