Skip to content

Commit ccde58d

Browse files
committed
Merge branch 'feedback-generator'
2 parents 9400723 + 067ae46 commit ccde58d

File tree

12 files changed

+961
-579
lines changed

12 files changed

+961
-579
lines changed

Plot.m

Lines changed: 200 additions & 184 deletions
Large diffs are not rendered by default.

Point.m

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
%% Point: Contains the Data for a Point on a Plot
2+
%
3+
% stores the coordinate, marker, and color for a point on a plot
4+
%
5+
%%% Fields
6+
%
7+
% * X:
8+
%
9+
% * Y:
10+
%
11+
% * Z:
12+
%
13+
% * Marker:
14+
%
15+
% * Color:
16+
%
17+
%%% Methods
18+
%
19+
% * Point: makes the points. Give it a 1x2 vec or a 1x3 vec. Doesnt matter.
20+
% Give it one input if there is no marker. give it 3 if there is bc color
21+
% matter
22+
%
23+
% * Equals: obviously returns if two points are the same
24+
%
25+
% * dataEquals: does equals but ignores color and marker.
26+
%
27+
%%% Remarks
28+
%
29+
% hey
30+
31+
classdef Point < handle
32+
properties (Access = public)
33+
X;
34+
Y;
35+
Z;
36+
Marker = '';
37+
Color;
38+
end
39+
methods (Access = public)
40+
function this = Point(coord,marker,color)
41+
%% Constructor
42+
%
43+
% creates an instance of Points from a vector containing
44+
% coordinate data, char vec of marker, and char vec of color
45+
%
46+
%%% Remarks
47+
% makes the points. Give it a 1x2 vec or a 1x3 vec. Doesnt
48+
% matter. Give it one input if there is no marker. give it 3 if
49+
% there is bc color matter
50+
if nargin == 0
51+
return;
52+
end
53+
this.X = coord(1);
54+
this.Y = coord(2);
55+
if length(coord) == 3
56+
this.Z = coord(3);
57+
else
58+
this.Z = 0;
59+
end
60+
if nargin > 1
61+
this.Marker = marker;
62+
this.Color = color;
63+
else
64+
this.Marker = '';
65+
this.Color = [0 0 0];
66+
end
67+
end
68+
function areEqual = equals(this,that)
69+
%% Equals: does the equals thing
70+
% you know this
71+
if isempty(this)
72+
areEqual = [];
73+
return;
74+
elseif isempty(that)
75+
areEqual = false;
76+
return;
77+
end
78+
orig = this;
79+
this = reshape(this, 1, []);
80+
that = reshape(that, 1, []);
81+
if isscalar(that)
82+
tmp(numel(this)) = that;
83+
tmp(:) = that;
84+
that = tmp;
85+
tmp = tmp(false);
86+
end
87+
if isscalar(this)
88+
tmp(numel(that)) = this;
89+
tmp(:) = this;
90+
this = tmp;
91+
end
92+
areEqual = this.dataEquals(that) ...
93+
& strcmp({this.Marker},{that.Marker}) ...
94+
& cellfun(@isequal, {this.Color}, {that.Color});
95+
if isscalar(orig)
96+
areEqual = reshape(areEqual, size(that));
97+
else
98+
areEqual = reshape(areEqual, size(orig));
99+
end
100+
end
101+
function tf = ne(this, that)
102+
tf = ~this.equals(that);
103+
end
104+
function tf = eq(this, that)
105+
tf = this.equals(that);
106+
end
107+
function areEqual = dataEquals(this,that)
108+
%% dataEquals: does the equals thing
109+
% you know this too
110+
areEqual = [this.X] == [that.X] ...
111+
& [this.Y] == [that.Y] ...
112+
& [this.Z] == [that.Z];
113+
areEqual = reshape(areEqual, size(this));
114+
end
115+
116+
function [sorted, inds] = sort(points, varargin)
117+
if isempty(points)
118+
sorted = points;
119+
inds = [];
120+
return;
121+
elseif isscalar(points)
122+
sorted = points;
123+
inds = 1;
124+
return;
125+
end
126+
xx = reshape([points.X], [], 1);
127+
yy = reshape([points.Y], [], 1);
128+
zz = reshape([points.Z], [], 1);
129+
colors = vertcat(points.Color);
130+
markers = reshape(string({points.Marker}), [], 1);
131+
tmp = compose('%0.5f %0.5f %0.5f %d %d %d %s', ...
132+
[xx, yy, zz], ...
133+
colors, ...
134+
markers);
135+
[~, inds] = sort(tmp, varargin{:});
136+
sorted = points(inds);
137+
end
138+
139+
140+
end
141+
end

Segment.m

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
%% Segment: A single connection between two points
2+
%
3+
% A single connection between two points without marker!
4+
%
5+
%%% Fields
6+
%
7+
% * Start: A Point that represents where this segment starts
8+
%
9+
% * Stop: A Point that represents where this segment ends
10+
%
11+
% * Color: A 1x3 vector that represents the color
12+
%
13+
% * Style: A character vector that represents the style (i.e., dashed.
14+
% etc.)
15+
%
16+
%%% Methods
17+
%
18+
% * Segment
19+
%
20+
% * equals
21+
%
22+
% * dataEquals
23+
%
24+
%%% Remarks
25+
%
26+
% This class keeps data for a single segment - a connection. It does not
27+
% care about what the endpoints look like - only where they are.
28+
%
29+
% The Point will not have a style - just coordinates
30+
%
31+
classdef Segment < handle
32+
properties (Access = public)
33+
Start;
34+
Stop;
35+
Color double;
36+
Style char;
37+
end
38+
39+
methods
40+
%% Constructor
41+
%
42+
% Segment(S, E, C, L) will use start S and stop E to make a
43+
% segment, with color C and line style L.
44+
%
45+
%%% Remarks
46+
%
47+
% S and E can be Points or coordinates - if the latter, they will
48+
% be constructed into points
49+
function this = Segment(start, stop, color, style)
50+
if nargin == 0
51+
return;
52+
end
53+
if isa(start, 'Point')
54+
this.Start = start;
55+
this.Stop = stop;
56+
else
57+
this.Start = Point(start);
58+
this.Stop = Point(stop);
59+
end
60+
pts = sort([this.Start, this.Stop]);
61+
this.Start = pts(1);
62+
this.Stop = pts(2);
63+
this.Color = color;
64+
if strcmp(style, 'none')
65+
this.Style = '';
66+
else
67+
this.Style = style;
68+
end
69+
end
70+
end
71+
methods (Access = public)
72+
function tf = equals(this, that)
73+
if isempty(this)
74+
tf = [];
75+
return;
76+
elseif isempty(that)
77+
tf = false;
78+
return;
79+
end
80+
orig = this;
81+
this = reshape(this, 1, []);
82+
that = reshape(that, 1, []);
83+
if isscalar(that)
84+
tmp(numel(this)) = that;
85+
tmp(:) = that;
86+
that = tmp;
87+
tmp = tmp(false);
88+
end
89+
if isscalar(this)
90+
tmp(numel(that)) = this;
91+
tmp(:) = this;
92+
this = tmp;
93+
94+
end
95+
tf = this.dataEquals(that) ...
96+
& cellfun(@isequal, {this.Color}, {that.Color}) ...
97+
& strcmp({this.Style}, {that.Style});
98+
if isscalar(orig)
99+
tf = reshape(tf, size(that));
100+
else
101+
tf = reshape(tf, size(orig));
102+
end
103+
end
104+
105+
function tf = eq(this, that)
106+
tf = this.equals(that);
107+
end
108+
109+
function tf = ne(this, that)
110+
tf = ~this.equals(that);
111+
end
112+
113+
function tf = dataEquals(this, that)
114+
if isempty(this) || isempty(that)
115+
tf = [];
116+
else
117+
tf = dataEquals([this.Start], [that.Start]) ...
118+
& dataEquals([this.Stop], [that.Stop]);
119+
tf = reshape(tf, size(this));
120+
end
121+
end
122+
123+
function [sorted, inds] = sort(segments, varargin)
124+
if isempty(segments)
125+
sorted = segments;
126+
inds = [];
127+
return;
128+
elseif isscalar(segments)
129+
sorted = segments;
130+
inds = 1;
131+
return;
132+
end
133+
% sort by Point start -> stop
134+
starts = [segments.Start];
135+
xx1 = reshape([starts.X], [], 1);
136+
yy1 = reshape([starts.Y], [], 1);
137+
zz1 = reshape([starts.Z], [], 1);
138+
stops = [segments.Stop];
139+
xx2 = reshape([stops.X], [], 1);
140+
yy2 = reshape([stops.Y], [], 1);
141+
zz2 = reshape([stops.Z], [], 1);
142+
styles = reshape(string({segments.Style}), [], 1);
143+
tmp = compose('%0.5f %0.5f %0.5f %0.5f %0.5f %0.5f %s', ...
144+
[xx1, yy1, zz1, xx2, yy2, zz2], styles);
145+
[~, inds] = sort(tmp, varargin{:});
146+
sorted = segments(inds);
147+
sorted = reshape(sorted, size(segments));
148+
end
149+
end
150+
end

build.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
delete(['.' filesep 'release' filesep '*']);
1818
% pcode Plot
1919
pcode('Plot.m');
20+
pcode('Segment.m');
21+
pcode('Point.m');
2022
pcode('checkPlots.m');
2123
movefile('*.p', ['.' filesep 'release']);
2224

0 commit comments

Comments
 (0)