0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 1 function g_LoadFromBlockCallback(currPanel,varargin)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 2 % This callback is called whenever the user selects a From block.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 3
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 4 global guiFontSize
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 5 panelDimens = get(currPanel, 'Position');
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 6 backColor = get(currPanel, 'BackgroundColor');
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 7
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 8 % Button: 'Find origin'
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 9 uicontrol('Parent',currPanel,'Units','pixels','HorizontalAlignment','center','Position',[(panelDimens(4)-200)/2 panelDimens(4)-100 200 30],'String','Find origin','FontSize',guiFontSize+1,'Visible','on','Enable','on','Callback',@FindOriginCallback,'Style','pushbutton');
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 10
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 11
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 12
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 13 %----------------------------------------------------------------------
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 14 function FindOriginCallback(varargin)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 15 % This callback is called whenever click on the 'Find Origin' button,
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 16 % having selected a 'From' block.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 17
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 18 varName = get(gcbh,'GotoTag');
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 19 origin = utils.prog.find_in_models(bdroot,'LookUnderMasks','all','BlockType','Goto','GotoTag',varName);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 20 if numel(origin)>1
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 21 % Error text: there are multiple origins.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 22 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[(panelDimens(4)-400)/2 panelDimens(4)-160 400 30],'String','Error: there are multiple sources','Visible','on','Style','text');
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 23 elseif numel(origin)==1
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 24 % Text: full path of the origin.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 25 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[(panelDimens(4)-400)/2 panelDimens(4)-160 400 30],'String',origin{1},'Visible','on','Style','text');
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 26 else
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 27 % Error text: no origin found.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 28 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[(panelDimens(4)-400)/2 panelDimens(4)-160 400 30],'String','Error: no source found','Visible','on','Style','text');
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 29 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 30 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 31 %----------------------------------------------------------------------
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 32
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 33 end