Mercurial > hg > ltpda
diff m-toolbox/m/gui/ltpdv/callbacks/ltpdv_buildImportPanel.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/m/gui/ltpdv/callbacks/ltpdv_buildImportPanel.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,638 @@ +function ltpdv_buildImportPanel(ph, mainfig) + + Gproperties = getappdata(mainfig, 'Gproperties'); + + pmarg = 0.025; + % Build a panel to contain this tab + % panh = uipanel('Parent', ph, 'Position', [pmarg pmarg 1-2*pmarg 1-2*pmarg]); + + %% Add new sub tabbed panel + + Hmargin = 0.025; + Vmargin = 0.025; + + PanLeft = Hmargin; + Tleft = Hmargin; + Theight = 1-2*Vmargin; + Tbottom = (1 - Theight - Vmargin); + Twidth = 1-2*Hmargin; + + Pcol = [1 1 0.9]; + + htab = uitabgroup('Parent', ph, ... + 'Units','normalized',... + 'Tag', 'LTPDVimportTabPanel', ... + 'Position',[Tleft Tbottom Twidth Theight], 'SelectionChangeFcn', {@ltpdv_tabChanged}); + mt1 = uitab(htab, 'title', 'Server'); + mt2 = uitab(htab, 'title', 'Workspace'); + mt3 = uitab(htab, 'title', 'Build'); + + %-------------- Build Server Panel + buildServerPanel(mt1, mainfig); + %-------------- Build Workspace Panel + h = buildWorkspacePanel(mt2, mainfig); + %-------------- Build Build Panel + buildBuildPanel(mt3, mainfig); +end + +%-------------------------------------------------------------------------- +% Build import from server panel +function buildBuildPanel(hp, mainfig) + + + EditFontSize = 11; + vmarg = 0.03; + pmarg = 0.01; + CommHeight = EditFontSize/400; + ph = 1; + htab = uipanel('Parent', hp, 'Position', [pmarg 1-ph-pmarg 1-2*pmarg ph]); + set(htab, 'Units', 'Normalized') + set(htab, 'Title', '') + set(htab, 'BackgroundColor', [0.6 0.6 0.8]); + set(htab, 'ForegroundColor', 'w'); + + + %----- Class selector + bh = CommHeight; + bl = pmarg; + bw = 0.15; + bb = 1-bh-1*vmarg; + sth = uicontrol(htab, 'Style','text',... + 'String', 'Object Class',... + 'Units', 'normalized', ... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw bh]); + bl = bl+bw+pmarg; + bw = 0.2; + clsh = uicontrol(htab, ... + 'Style', 'popupmenu', ... + 'Units', 'normalized',... + 'Fontsize', EditFontSize, ... + 'BackgroundColor', 'w', ... + 'String', utils.helper.ltpda_userclasses, ... + 'Position', [bl bb bw bh],... + 'Tag', 'LTPDVbuildObjectClass', ... + 'Callback', {@ltpdv_build_class_select, mainfig}); + + %----- Set selector + bl = bl+bw+pmarg; + bw = 0.15; + sth = uicontrol(htab, 'Style','text',... + 'String', 'Parameter Set',... + 'Units', 'normalized', ... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw bh]); + bl = bl+bw+pmarg; + bw = 0.3; + dtypeh = uicontrol(htab, ... + 'Style', 'popupmenu', ... + 'Units', 'normalized',... + 'Fontsize', EditFontSize, ... + 'BackgroundColor', 'w', ... + 'String', ' ', ... + 'Position', [bl bb bw bh],... + 'Tag', 'LTPDVbuildSetSelect', ... + 'Callback', {@ltpdv_build_set_select, mainfig}); + + % Parameter panel + ph = 0.8; + ppan = uipanel('Parent', htab, 'Position', [pmarg 0.08+vmarg 1-2*pmarg ph]); + set(ppan, 'Units', 'Normalized') + set(ppan, 'Title', 'Parameters') + set(ppan, 'BackgroundColor', [0.7 0.7 0.8]); + set(ppan, 'ForegroundColor', 'w'); + set(ppan, 'Tag', 'LTPDVbuildParamsPanel'); + + pbh = uicontrol(htab,'Style','pushbutton',... + 'String','Build object',... + 'Callback', {@ltpdv_build_buildobject, mainfig}, ... + 'Units', 'normalized', ... + 'Fontsize', EditFontSize, ... + 'Position',[pmarg vmarg 0.15 2*bh]); + + % call back + ltpdv_build_class_select(clsh, mainfig) + +% +% bh = CommHeight; +% bl = pmarg; +% bw = 1-2*pmarg; +% bb = vmarg; +% sth = uicontrol(hp, 'Style','text',... +% 'String', 'Build objects with the ''constructor helper'' then import from workspace.',... +% 'Units', 'normalized', ... +% 'BackgroundColor', 'w', ... +% 'Fontsize', EditFontSize, ... +% 'Position',[bl bb bw bh]); + +end +%-------------------------------------------------------------------------- +% Build import from server panel +function buildServerPanel(hp, mainfig) + + % Data type + EditFontSize = 11; + vmarg = 0.03; + pmarg = 0.01; + CommHeight = EditFontSize/80; + + % Import button + bw = 0.12; + bh = 0.05; + bl = pmarg; + bb = pmarg; + pbh = uicontrol(hp,'Style','pushbutton',... + 'String','Import',... + 'Callback', {@ltpdv_server_import, mainfig}, ... + 'Units', 'normalized', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw bh]); + + %======== New tab panel + Tleft = pmarg; + Theight = 0.8; + Tbottom = 1-Theight - pmarg; + Twidth = 1-2*pmarg; + % htab = uitabgroup('Parent', hp, ... + % 'Units','normalized',... + % 'Position',[Tleft Tbottom Twidth Theight], 'SelectionChangeFcn', {@ltpdv_tabChanged}); + % t1 = uitab(htab, 'title', 'Server Details'); + % t2 = uitab(htab, 'title', 'Times'); + % t3 = uitab(htab, 'title', 'Channels'); + + % ======= Server Details + + ph = 0.3; + htab = uipanel('Parent', hp, 'Position', [pmarg 1-ph-pmarg 1-2*pmarg ph]); + set(htab, 'Units', 'Normalized') + set(htab, 'Title', 'Server settings') + set(htab, 'BackgroundColor', [0.3 0.7 0.3]); + set(htab, 'ForegroundColor', 'w'); + + bh = CommHeight; + bl = pmarg; + bw = 0.1; + bb = 1-bh-3*vmarg; + sth = uicontrol(htab, 'Style','text',... + 'String', 'Data type',... + 'Units', 'normalized', ... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw bh]); + bl = bl+bw+pmarg; + bw = 0.17; + dtypeh = uicontrol(htab, ... + 'Style', 'popupmenu', ... + 'Units', 'normalized',... + 'Fontsize', EditFontSize, ... + 'BackgroundColor', 'w', ... + 'String', {'frame data','h(t) frames', 'raw data', 'hour trends', 'day trends'}, ... + 'Position', [bl bb bw bh],... + 'Tag', 'LTPDVserverDataType', ... + 'Callback', {@ltpdv_server_datatype_select, mainfig}); + + % Statistic + bl = bl + bw + pmarg; + bw = 0.1; + sth = uicontrol(htab, 'Style','text',... + 'String', 'Statistic',... + 'Units', 'normalized', ... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw bh]); + bl = bl+bw+pmarg; + bw = 0.12; + th = uicontrol(htab, ... + 'Style', 'popupmenu', ... + 'Units', 'normalized',... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'String', {'rms','min', 'max', 'avg'}, ... + 'Position', [bl bb bw bh],... + 'Tag', 'LTPDVserverStat'); + + % Server drop-down box + bl = pmarg; + bw = 0.1; + bb = bb - bh - vmarg; + sth = uicontrol(htab, 'Style','text',... + 'String', 'Server',... + 'Units', 'normalized', ... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw bh]); + bl = bl+bw+pmarg; + bw = 0.25; + th = uicontrol(htab, ... + 'Style', 'popupmenu', ... + 'Units', 'normalized',... + 'BackgroundColor', 'w', ... + 'String', {'130.75.117.159','130.75.117.73', '130.75.117.164', 'localhost'}, ... + 'Fontsize', EditFontSize, ... + 'Position', [bl bb bw bh],... + 'Tag', 'LTPDVserverServer', ... + 'Callback', {@ltpdv_server_server_select, mainfig}); + + % Server entry box + bl = bl+bw+pmarg; + bw = 0.22; + th = uicontrol(htab, ... + 'Style', 'edit', ... + 'Units', 'normalized',... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'String', '', ... + 'Position', [bl bb bw bh],... + 'Tag', 'LTPDVserverServerEdit'); + + % Port entry + bl = bl+bw+pmarg; + bw = 0.07; + sth = uicontrol(htab, 'Style','text',... + 'String', 'Port',... + 'Units', 'normalized', ... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw bh]); + bl = bl+bw+pmarg; + bw = 0.1; + th = uicontrol(htab, ... + 'Style', 'edit', ... + 'Units', 'normalized',... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'String', '', ... + 'Position', [bl bb bw bh],... + 'Tag', 'LTPDVserverPortEdit'); + + % RDS + bl = pmarg; + bw = 0.1; + bb = bb - bh - vmarg; + sth = uicontrol(htab, 'Style','text',... + 'String', 'RDS Level',... + 'Units', 'normalized', ... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw bh]); + bl = bl+bw+pmarg; + bw = 0.05; + th = uicontrol(htab, ... + 'Style', 'edit', ... + 'Units', 'normalized',... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'String', '', ... + 'Position', [bl bb bw bh],... + 'Tag', 'LTPDVserverRdsEdit'); + + % CAL + bl = pmarg + bl + bw; + bw = 0.1; + sth = uicontrol(htab, 'Style','text',... + 'String', 'Cal Ver',... + 'Units', 'normalized', ... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw bh]); + bl = bl+bw+pmarg; + bw = 0.05; + th = uicontrol(htab, ... + 'Style', 'edit', ... + 'Units', 'normalized',... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'String', '', ... + 'Position', [bl bb bw bh],... + 'Tag', 'LTPDVserverCalEdit'); + + + % call callbacks + ltpdv_server_server_select(0, mainfig); + ltpdv_server_datatype_select(dtypeh, mainfig); + + % Query server button + bw = 0.13; + bb = vmarg; + bl = pmarg; + pbh = uicontrol(htab,'Style','pushbutton',... + 'String','Query Server',... + 'Callback', {@ltpdv_server_queryServer, mainfig}, ... + 'Units', 'normalized', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw 1.4*CommHeight]); + + % Get latest button + bl = bl + bw + pmarg; + pbh = uicontrol(htab,'Style','pushbutton',... + 'String','Get latest',... + 'Callback', {@ltpdv_server_getLatest, mainfig}, ... + 'Units', 'normalized', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw 1.4*CommHeight]); + + + %---------------- Time entry + + ph = 0.3; + htab = uipanel('Parent', hp, 'Position', [pmarg 1-2*ph-2*pmarg 1-2*pmarg ph]); + set(htab, 'Units', 'Normalized') + set(htab, 'Title', 'Times settings') + set(htab, 'BackgroundColor', [0.7 0.3 0.3]); + set(htab, 'ForegroundColor', 'w'); + + % time and channel lists + bb = 1-0.7*bh-pmarg; + bl = pmarg+0.4; + bw = 0.5; + timesH = uicontrol(htab, 'Style','text',... + 'String', 'Times',... + 'Units', 'normalized', ... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw 0.7*bh]); + + bl = pmarg + 0.4; + bh = 0.7; + bb = bb - bh; + lh = uicontrol(htab, 'Style', 'listbox', ... + 'String', '',... + 'BackgroundColor', 'w', ... + 'Value',1, 'Units', 'normalized', ... + 'Fontsize', EditFontSize, ... + 'Max', 1000, ... + 'Tag', 'LTPDVtimesList', ... + 'Position',[bl bb bw bh], ... + 'Callback', {@ltpdv_server_timeslist, mainfig}); + + % delete times + bw = (0.5 - 3*pmarg)/ 4; + bh = CommHeight; + bb = bb - bh - vmarg; + pbh = uicontrol(htab,'Style','pushbutton',... + 'String','Delete times',... + 'Callback', {@ltpdv_server_deleteTimes, mainfig}, ... + 'Units', 'normalized', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw bh]); + % clear list + bl = bl + pmarg + bw; + pbh = uicontrol(htab,'Style','pushbutton',... + 'String','Clear list',... + 'Callback', {@ltpdv_server_clearTimes, mainfig}, ... + 'Units', 'normalized', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw bh]); + % save list + bl = bl + pmarg + bw; + pbh = uicontrol(htab,'Style','pushbutton',... + 'String','Save list',... + 'Callback', {@ltpdv_server_saveTimes, mainfig}, ... + 'Units', 'normalized', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw bh]); + % load list + bl = bl + pmarg + bw; + pbh = uicontrol(htab,'Style','pushbutton',... + 'String','Load list',... + 'Callback', {@ltpdv_server_loadTimes, mainfig}, ... + 'Units', 'normalized', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw bh]); + + % start time + pos = get(timesH, 'Position'); + bl = pmarg; + bw = 0.1; + bh = CommHeight; + bb = pos(2)-2*vmarg; + sth = uicontrol(htab, 'Style','text',... + 'String', 'Start',... + 'Units', 'normalized', ... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw bh]); + bl = bl+bw+pmarg; + bw = 0.25; + th = uicontrol(htab, ... + 'Style', 'edit', ... + 'Units', 'normalized',... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'String', '', ... + 'Position', [bl bb bw bh],... + 'Callback', {@ltpdv_server_start_edit, mainfig}, ... + 'Tag', 'LTPDVserverStartEdit'); + % stop time + bl = pmarg; + bw = 0.1; + bb = bb - bh - vmarg; + sth = uicontrol(htab, 'Style','text',... + 'String', 'Stop',... + 'Units', 'normalized', ... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw bh]); + bl = bl+bw+pmarg; + bw = 0.25; + th = uicontrol(htab, ... + 'Style', 'edit', ... + 'Units', 'normalized',... + 'BackgroundColor', 'w', ... + 'String', '', ... + 'Fontsize', EditFontSize, ... + 'Position', [bl bb bw bh],... + 'Callback', {@ltpdv_server_stop_edit, mainfig}, ... + 'Tag', 'LTPDVserverStopEdit'); + + % duration display + bw = 0.1; + bl = pmarg; + bb = bb - bh - vmarg; + sth = uicontrol(htab, 'Style','text',... + 'String', 'Duration',... + 'Units', 'normalized', ... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw bh]); + bl = bl + bw + pmarg; + bw = 0.25; + sth = uicontrol(htab, 'Style','text',... + 'String', '',... + 'Units', 'normalized', ... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'Tag', 'LTPDVserverDurationDisplay', ... + 'Position',[bl bb bw bh]); + + % comment + pos = get(sth, 'Position'); + bl = pmarg; + bw = pos(1) + pos(3) - pmarg; + bb = bb - 0.7*bh - vmarg; + sth = uicontrol(htab, 'Style','text',... + 'String', 'Comment',... + 'Units', 'normalized', ... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw bh*0.7]); + bb = bb - bh - pmarg; + bl = pmarg; + th = uicontrol(htab, ... + 'Style', 'edit', ... + 'Units', 'normalized',... + 'BackgroundColor', 'w', ... + 'String', '', ... + 'Fontsize', EditFontSize, ... + 'Position', [bl bb bw bh],... + 'Tag', 'LTPDVserverCommentEdit'); + + % Add time button + bl = pmarg; + bb = bb - bh - vmarg; + pbh = uicontrol(htab,'Style','pushbutton',... + 'String','Add to list',... + 'Fontsize', EditFontSize, ... + 'Callback', {@ltpdv_server_addTime, mainfig}, ... + 'Units', 'normalized', ... + 'Position',[bl bb bw bh]); + + + % ----------------- Channel list + ph = 0.3; + htab = uipanel('Parent', hp, 'Position', [pmarg pmarg+2*vmarg 1-2*pmarg ph]); + set(htab, 'Units', 'Normalized') + set(htab, 'Title', 'Channel settings') + set(htab, 'BackgroundColor', [0.3 0.3 0.7]); + set(htab, 'ForegroundColor', 'w'); + + bw = 0.5; + bb = 1 - vmarg - 0.7*bh; + bl = pmarg; + sth = uicontrol(htab, 'Style','text',... + 'String', 'Channels',... + 'Units', 'normalized', ... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw 0.7*bh]); + bh = 0.8; + bb = bb - bh; + lh = uicontrol(htab, 'Style', 'listbox', ... + 'String', '',... + 'BackgroundColor', 'w', ... + 'Value',1, 'Units', 'normalized', ... + 'Fontsize', EditFontSize, ... + 'Max', 1000, ... + 'Tag', 'LTPDVchannelList', ... + 'Position',[bl bb bw bh], ... + 'Callback', {@ltpdv_server_channellist, mainfig}); + + % include control chans + % bw = 0.3; + % bh = CommHeight; + % bb = bb - bh - pmarg; + % th = uicontrol(htab, ... + % 'Style', 'checkbox', ... + % 'Units', 'normalized',... + % 'BackgroundColor', 'w', ... + % 'String', 'Include control', ... + % 'Fontsize', EditFontSize, ... + % 'Position', [bl bb bw bh],... + % 'ForegroundColor', 'w',... + % 'Tag', 'LTPDVchannelIncludeControl'); + + % search box + bl = 0.55; + bw = 0.08; + bh = CommHeight; + bb = 1 - vmarg - bh; + sth = uicontrol(htab, 'Style','text',... + 'String', 'Search',... + 'Units', 'normalized', ... + 'BackgroundColor', 'w', ... + 'Fontsize', EditFontSize, ... + 'Position',[bl bb bw bh]); + bl = bl+bw+pmarg; + bw = 0.17; + th = uicontrol(htab, ... + 'Style', 'edit', ... + 'Units', 'normalized',... + 'BackgroundColor', 'w', ... + 'String', '', ... + 'Fontsize', EditFontSize, ... + 'Position', [bl bb bw bh],... + 'Callback', {@ltpdv_search_channels, mainfig}, ... + 'Tag', 'LTPDVchannelSearchEdit'); + pos = get(sth, 'Position'); + bl = pos(1); + bb = bb - bh - vmarg; + pbh = uicontrol(htab,'Style','pushbutton',... + 'String','Get channels',... + 'Fontsize', EditFontSize, ... + 'Callback', {@ltpdv_server_getChannels, mainfig}, ... + 'Units', 'normalized', ... + 'Position',[bl bb bw bh]); +end +%-------------------------------------------------------------------------- +% Build import from workspace panel +function th = buildWorkspacePanel(hp, mainfig) + + % Object list + pmarg = 0.025; + Lleft = pmarg; + Lbottom = 0.4+pmarg; + Lwidth = 1-2*pmarg; + Lheight = 1-Lbottom-pmarg; + th = uitable(hp, ... + 'Units', 'normalized',... + 'ColumnName', {'Name','Type', 'Size', 'kB'}, ... + 'Position', [Lleft Lbottom Lwidth Lheight],... + 'Tag', 'LTPDVworkspaceList', ... + 'CellSelectionCallback', {@ltpdv_workspaceList_select, mainfig}); + + % set data + ltpdv_workspaceList_set_data(th); + + % Make refresh button + pl = pmarg; + ph = 0.05; + pb = Lbottom - ph - pmarg; + pw = 0.1; + pbh = uicontrol(hp,'Style','pushbutton',... + 'String','Refresh',... + 'Callback', {@ltpdv_workspaceList_set_data, th}, ... + 'Units', 'normalized', ... + 'Position',[pl pb pw ph]); + + % Make import button + pl = pmarg + pw + pmarg; + ph = 0.05; + pb = Lbottom - ph - pmarg; + pw = 0.1; + pbh = uicontrol(hp,'Style','pushbutton',... + 'String','Import',... + 'Callback', {@ltpdv_importObjs, mainfig, th}, ... + 'Units', 'normalized', ... + 'Position',[pl pb pw ph]); + + % Selection box for renamin with var names + pl = pl + pw + pmarg; + ph = 0.05; + pb = Lbottom - ph - pmarg; + pw = 0.3; + ch = uicontrol(hp, 'Style', 'checkbox', ... + 'String', 'use var name', ... + 'TooltipString', 'Set object name to workspace variable name.', ... + 'Units', 'normalized', ... + 'Position', [pl pb pw ph], ... + 'Value', 1, ... + 'Tag', 'LTPDVusevarnameChk'); + +end + + + + +