1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
| function programe
clear all;
close all;
hFig=figure('units','normalized','outerposition',[0 0.05 1 0.95],'Name','Dépouillement','NumberTitle','off','toolbar','figure');
hTabGroup = uitabgroup('Parent', hFig);
setappdata(0,'Panel_group',hTabGroup);
hTabs(1) = uitab('Parent', hTabGroup, 'Title', 'Paramètres','Tag','Panel_1');
hTabs(2) = uitab('Parent', hTabGroup, 'Title', 'Dépouillement','Tag','Panel_2');
hTabs(3) = uitab('Parent', hTabGroup, 'Title', 'Comparaison','Tag','Panel_9');
%set(hTabGroup, 'SelectedTab', hTabs(1));
firstPanel = uipanel('Title', 'Informations Principales', 'Parent', hTabs(1));
secondPanel = uipanel('Title', 'Traitement d''un seul fichier de mesure', 'Parent', hTabs(2));
thirdPanel= uipanel('Title', 'Comparaison de plusieurs fichiers de mesures', 'Parent', hTabs(3));
main_0(firstPanel);
main_1(secondPanel);
main_2(thirdPanel);
set(hFig, 'CloseRequestFcn', @my_closereq)
clc;
function my_closereq(src,evt)
if (isappdata(0,'fichier')==1)
rmappdata(0,'fichier');
end
if (isappdata(0,'fichier_1')==1)
rmappdata(0,'fichier_1');
end
if (isappdata(0,'fichier_2')==1)
rmappdata(0,'fichier_2');
end
if (isappdata(0,'fichier_3')==1)
rmappdata(0,'fichier_3');
end
delete(src)
end
end
function main_0(parent)
%Fenêtre expliquant les fonctionnement du programme
instruction={'Ce programme fonctionne de la manière suivante:' '' '1- Entrez le chemin du dossier comprenant les fichiers à dépouiller.' '2- Si vous souhaitez comparer plusieurs fichiers, entrez un à un le chemin des dossier comprenant les fichiers à comparer.'};
uicontrol('Parent',parent,'style','text','units','normalized',...
'String',instruction,...
'HorizontalAlignment','left','position',[0.025 0.85 0.8 0.1],'FontSize',11);
end
%% Onglet Dépouillement
function main_1(parent)
%Définition de la position du graph
axes('Parent',parent,'Units','normalized','position',[0.25 0.1 0.69 0.82],'Tag','Onglet_1');
plot(magic(5))
end
function main_2(parent)
%Définition de la position du graph
axes('Parent',parent,'Units','normalized','position',[0.5 0.1 0.4 0.82],'Tag','Onglet_2');
uicontrol('Parent',parent, ...
'Style', 'pushbutton', ...
'String', 'TRACE', ...
'Units','normalized','Position', [0.1 0.7 0.1 0.1], ...
'Callback',@tracecourbe)
function tracecourbe(src,evt)
x=rand(5,1);
y1=rand(5,1);
y2=rand(5,1);
y3=rand(5,1);
plotyy(x,y1,x,y2)
hold on
plot(x,y3)
end
uicontrol('Parent',parent, ...
'Style', 'pushbutton', ...
'String', 'SAVE F', ...
'Units','normalized','Position', [0.83 0.01 0.03 0.03], ...
'Callback', @save,'Tooltip','Enregistrement de toute la figure dans le Fichier All_figure.emf');
function save (src,evt)
%Désactivation de la fonction cuseur lors de la relecture du code
test_save=1;
setappdata(0,'Cursor_controle',test_save)
%Détection numéro de l'onglet activé
activate_panel=get(getappdata(0,'Panel_group'),'SelectedIndex');
%Handle de l'onglet
hPanel=findobj('Tag','Panel_9');
%Création d'un nouvelle figure
hNewFig = figure('units','normalized','outerposition',[0 0.05 1 0.95],'Visible','on');
%Déplacement de l'onglet dans la nouvelle figure
set(hPanel,'parent',hNewFig);
%Mise à jour du graphique
drawnow;
%Nom de fichier disponible
%Recherche des fichiers emf
chemin=fullfile(pwd,'*.emf');
%Nombre de chemin trouvé
list=dir(chemin);
%Création du premier nom de fichier
nom_de_fichier_potentiel='All_figure_0.emf';
%Initialisation du compteur à 1
compteur=1;
increment=0;
while compteur ~= 0
increment=increment+1;
compteur=0;
for i=1:length(list)
nom_de_fichier=list(i,1).name;
compteur_temp=strcmp(nom_de_fichier,nom_de_fichier_potentiel);
compteur=compteur+compteur_temp;
end
compteur=sum(compteur);
if compteur > 0
nom_de_fichier_potentiel=['All_figure_',num2str(increment),'.emf'];
else
end
end
%Enregistrement de la figure dans un fichier.emf
print(hNewFig,'-dmeta','-r250',nom_de_fichier_potentiel);
%Déplacement de l'onglet dans la figure d'origine
set(hPanel,'parent',getappdata(0,'Panel_group'));
%Suppression de la figure annexe
delete(hNewFig);
%Réactivation de la fonction curseur
test_save=0;
setappdata(0,'Cursor_controle',test_save)
%Repositionnonement dans l'onglet de départ
set(getappdata(0,'Panel_group'),'SelectedIndex', activate_panel);
end
uicontrol('Parent',parent, ...
'Style', 'pushbutton', ...
'String', 'COPY F', ...
'Units','normalized','Position', [0.861 0.01 0.03 0.03], ...
'Callback', @save2,'Tooltip','Copie de toute la figure (Ctrl C) --> Ctrl + V');
function save2 (src,evt)
test_save=1;
setappdata(0,'Cursor_controle',test_save)
activate_panel=get(getappdata(0,'Panel_group'),'SelectedIndex');
hPanel=findobj('Tag','Panel_9');
hNewFig = figure('units','normalized','outerposition',[0 0.05 1 0.95],'Visible','on');
set(hPanel,'parent',hNewFig);
drawnow;
hgexport(hNewFig,'-clipboard')
set(hPanel,'parent',getappdata(0,'Panel_group'));
delete(hNewFig);
test_save=0;
setappdata(0,'Cursor_controle',test_save)
end
uicontrol('Parent',parent, ...
'Style', 'pushbutton', ...
'String', 'SAVE G', ...
'Units','normalized','Position', [0.892 0.01 0.03 0.03], ...
'Callback', @save3,'Tooltip','Enregistrement du graphique dans le Fichier Just_graph.emf');
function save3 (src,evt)
test_save=1;
setappdata(0,'Cursor_controle',test_save)
activate_panel=get(getappdata(0,'Panel_group'),'SelectedIndex');
hPanel=findobj('Tag','Panel_9');
hNewFig = figure('units','normalized','outerposition',[0 0.05 1 0.95],'Visible','off');
set(hPanel,'parent',hNewFig);
drawnow;
g = findall(gcf,'type','axes');
ftmp = figure('units','normalized','outerposition',[0.2 0.1 0.6 0.8],'Visible','off');
copyobj(g(1:2),ftmp)
set(findall(gcf,'type','axes'),'Position',[0.1 0.1 0.8 0.8])
%Nom de fichier disponible
%Recherche des fichiers emf
chemin=fullfile(pwd,'*.emf');
%Nombre de chemin trouvé
list=dir(chemin);
%Création du premier nom de fichier
nom_de_fichier_potentiel='Just_graph_0.emf';
%Initialisation du compteur à 1
compteur=1;
increment=0;
while compteur ~= 0
increment=increment+1;
compteur=0;
for i=1:length(list)
nom_de_fichier=list(i,1).name;
compteur_temp=strcmp(nom_de_fichier,nom_de_fichier_potentiel);
compteur=compteur+compteur_temp;
end
compteur=sum(compteur);
if compteur > 0
nom_de_fichier_potentiel=['Just_graph_',num2str(increment),'.emf'];
else
end
end
print(ftmp,'-dmeta','-r250',nom_de_fichier_potentiel);
set(hPanel,'parent',getappdata(0,'Panel_group'));
delete(hNewFig);
delete(ftmp);
test_save=0;
setappdata(0,'Cursor_controle',test_save)
set(getappdata(0,'Panel_group'),'SelectedIndex',activate_panel);
tracecourbe()
end
uicontrol('Parent',parent, ...
'Style', 'pushbutton', ...
'String', 'COPY G', ...
'Units','normalized','Position', [0.923 0.01 0.03 0.03], ...
'Callback', @save4,'Tooltip','Copie du graphique (Ctrl C) --> Ctrl + V');
function save4 (src,evt)
test_save=1;
setappdata(0,'Cursor_controle',test_save)
activate_panel=get(getappdata(0,'Panel_group'),'SelectedIndex');
hPanel=findobj('Tag','Panel_9');
hNewFig = figure('units','normalized','outerposition',[0 0.05 1 0.95],'Visible','off');
set(hPanel,'parent',hNewFig);
drawnow;
g = findall(gcf,'type','axes');
ftmp = figure('units','normalized','outerposition',[0.2 0.1 0.6 0.8],'Visible','off');
copyobj(g,ftmp)
set(findall(gcf,'type','axes'),'Position',[0.1 0.1 0.8 0.8])
hgexport(ftmp,'-clipboard');
set(hPanel,'parent',getappdata(0,'Panel_group'));
delete(hNewFig);
delete(ftmp);
test_save=0;
setappdata(0,'Cursor_controle',test_save)
set(getappdata(0,'Panel_group'),'SelectedIndex',activate_panel);
tracecourbe()
end
end |
Partager