Skip to content
Snippets Groups Projects
Commit 820359a1 authored by Lemmer, Jan's avatar Lemmer, Jan
Browse files

Merge branch '83-positionierung-der-id-an-legende' into 'development'

Add PinToAxis option

See merge request !57
parents 1d1581e2 04362bfe
No related branches found
No related tags found
2 merge requests!62Introduce changes for V1.0 RC 1,!57Add PinToAxis option
Pipeline #653251 passed
......@@ -24,6 +24,7 @@ arguments
options.Position (1,2) {mustBeVector} = [1,0.4] % default for east
options.Rotation (1,1) {mustBeReal} = NaN
options.ConfigFileName (1,:) {mustBeText} = 'config.json'
options.PinToLegend (1,1) {mustBeNumericOrLogical} = false % Pins ID on Legend
options.QRcode (1,1) {mustBeNumericOrLogical} = false %experimental
options.QRsize (1,1) {mustBeNonnegative} = 0.15 % size of the QRCode
end
......@@ -36,7 +37,7 @@ end
switch options.Location
case 'north'
y = 1 - options.DistanceToAxis
y = 1 - options.DistanceToAxis;
options.Position = [0.4,y];
Rotation = 0;
case 'east'
......@@ -76,16 +77,35 @@ for n = 1:numel(figs)
IDs{n} = PlotID.CreateID; % Create ID
IDs{n} = [options.ProjectID,'-',IDs{n}]; % add options.ProjectID
pltAxes = get(figs(n),'CurrentAxes'); % Axes object for text annotation
% Limits for relative Positioning
% Limits for relative positioning
ylim =get(pltAxes,'YLim');
xlim =get(pltAxes,'XLim');
%ID
position = [options.Position(1), options.Position(2)];
xlim =get(pltAxes,'XLim');
if options.PinToLegend
if options.QRcode
warning(['PinToLegend and QRCode can not be used at the same time',...
newline, 'QRcode is deactivated.']);
options.QRcode = false;
end
lobj = findobj(figs(n), 'Type', 'Legend');
if isempty(lobj)
set(0, 'CurrentFigure', figs(n))
lobj = legend();
end
% new position based on legend
posVec = get(lobj,'Position');
options.Position(1) = posVec(1)+.04;
options.Position(2) = posVec(2);
end
% add text label
position = [options.Position(1), options.Position(2)];
t=text(pltAxes,position(1),position(2), IDs{n},'Fontsize',options.Fontsize,...
'Rotation',Rotation, 'VerticalAlignment','bottom','Color',...
options.Color,'BackgroundColor','w', 'Units', 'normalized');
set(figs(n),'Tag', IDs{n});
if options.QRcode
% this should be seen and use as a proof of concept
qrCode = PlotID.plotQR(IDs{n});
......@@ -94,6 +114,8 @@ for n = 1:numel(figs)
imshow(qrCode);
t.Visible = 'off';
end
end
if numel(figs) == 1
......
{
"Author": "CI-Test",
"ProjectID": "CI-001"
}
\ No newline at end of file
......@@ -48,12 +48,20 @@ you find the options for TagPlot below. The data type is in curled braces and th
- ProjectID {mustBeText}= ''
- Fontsize {mustBeInteger} = 8
- Color {mustBeNonnegative} = 0.65*[1 1 1]
- Location {mustBeText} = 'east'
- Position {mustBeVector} = [1,0.4]
- Rotation {mustBeInteger} = 0
- DistanceToAxis {mustBeReal} = .02
- Rotation {mustBeInteger} = 0
- PinToLegend {mustBeNumericOrLogical} = false
- QRcode {mustBeNumericOrLogical} = false
- QRsize {mustBeNonnegative} = 0.15
`options.ProjectID` is the project number (string or char), if empty the ID from the config file is used
The ID is placed on the 'east' of the figure per default, if you want it somwhere else, use the `'Location'` option. 'north', 'east', 'south', 'west' are predefined, otherwise use the `'custom'` option and provide the desired 'Position' as a vector relative to your x- and y-axis limits `[relX, relY]` .
`options.PinToLegend` pins the ID to the figure's legend. If no legend was defined, plotID will create one.
</details>
## CreateID()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment