Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ellipsoid.plot create axes labels #22

Open
pgagarinov opened this issue Oct 12, 2015 · 0 comments
Open

Make ellipsoid.plot create axes labels #22

pgagarinov opened this issue Oct 12, 2015 · 0 comments

Comments

@pgagarinov
Copy link
Member

Deadline - 16th of November, by that time the changes and the new tests should be in "master branch

Right now ellipsoid.plot doesn't create any axis labels neither for 2d nor for 3d case.
We need to make "plot" method create labels in "x_i" format where i is the axis number.
When creating a label one needs to keep in mind that
a) plot method can be called for an array of ellipsoids like this

ellVec=[ellipsoid(eye(2)),ellipsoid(eye(2)*2)];
ellVec.plot

in which case all ellipsoids are created on the same axes unless "newFigure" property is specified.
So one needs to make sure that labels are only created once for each axes in both cases.
Also, when creating a label one should use the following approach:

% hAxes is some axes handle
set(get(hAxes,'XLabel'),'String','x_1','Interpreter','tex');

get(hAxes,'XLabel') will return a non-empty axes handle even when the axes didn't have any labels prior to the call.

b) plot has a few input properties including 'relDataPlotter'. This property is used to pass in a RelationDataPlotter object that is a container for all future graphical objects. See the tests for RelationDataPlotter in \lib+smartdb+disp+test\mlunit_test_disp.m for more
details. Anyways, if RelationDataPlotter is not specified it is created internally so that all plotting is performed by an internal
RelationDataPlotter object. This object makes sure that there are no any untracked graphical objects (text labels are also graphical objects)
and throws an exception ("no all handles are tracked") if this is not the case. To avoid such exceptions one needs to return handles for all newly created graphical objects from internal plotting functions like

function hVec=axesSetPropDoNothingFunc(hAxes,)
axis(hAxes,'on');
axis(hAxes,'auto');
grid(hAxes,'on');
hold(hAxes,'on');
hVec=[];
end
%
function hVec=axesSetPropDoNothing2Func(hAxes,
)
axis(hAxes,'on');
axis(hAxes,'auto');
grid(hAxes,'on');
hold(hAxes,'off');
hVec=[];
end

subfunctions in +elltool+plot\plotgeombodyarr.m function.

Presumably adding labels will require changing one (or both) of these functions and replacing an empty list of properties (column names in a relation) for these functions in the following code (line 147 from plotgeombodyarr)

if isObj
rel=smartdb.relations.DynamicRelation(SData);
if (nDim==2)||(nDim == 1)
plObj.plotGeneric(rel,@figureGetGroupNameFunc,{'figureNameCMat'},...
@figureSetPropFunc,{},...
@axesGetNameSurfFunc,{'axesNameCMat','axesNumCMat'},...
@axesSetPropDoNothingFunc,{},...
@plotCreateFillPlotFunc,...
{'xCMat','faceCMat','clrVec','fill','shadVec', ...
'widVec','plotPatch'},...
'axesPostPlotFunc',postFun,...
'isAutoHoldOn',false);
elseif (nDim==3)
plObj.plotGeneric(rel,@figureGetGroupNameFunc,{'figureNameCMat'},...
@figureSetPropFunc,{},...
@axesGetNameSurfFunc,{'axesNameCMat','axesNumCMat'},...
@axesSetPropDoNothingFunc,{},...
@plotCreatePatchFunc,...
{'verCMat','faceCMat','faceVertexCDataCMat',...
'shadVec','clrVec','plotPatch',...
},'axesPostPlotFunc',postFun,...
'isAutoHoldOn',false);
end

with some information that can be used to determine a dimensionality of axis.

  1. One needs to account for potential cases when 3d and 2d ellipsoids are displayed on the same axes. Surely,
    a call like this ellVec=[ellipsoid(eye(2)),ellipsoid(eye(3))]; is not supported right now but one can specify relation data plotter containing some 2d ellipsoids to plot 3d ellipsoids. This should not result into axes being renamed (x_2 becoming x_1 when we add 3d ellipsoid to 2d plot)

4)The implemented functionality should be covered with tests implemented in the following test pack.
+elltool+core+test+mlunit\GenEllipsoidPlotTestCase. In the test one needs to consider different combinations of input parameters and array sizes. Negative tests are also required. See Wiki for an example of a negative test (mlunitext.test_case.runAndCheckError).

  1. No copy-pasting, compliance with the coding style (see Wiki) and presence of code comments.
    No commented out code, no blank lines, no long lines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants