Problem with figure reduction

1 回表示 (過去 30 日間)
Baptiste Ranguetat
Baptiste Ranguetat 2017 年 8 月 7 日
コメント済み: Jan 2017 年 8 月 10 日
Hi, i am plotting robot position that i update with a while loop on a figure, but there is an issue. I cannot reduce the window. In fact, i can but at every new iteration the figure just come back on the foreground. Is there a solution to fix it ? Thank you, Baptiste.
  3 件のコメント
Baptiste Ranguetat
Baptiste Ranguetat 2017 年 8 月 7 日
Here is my while loop
while(self.ctrl.simulateur.simulationEnCours==1)
self.ctrl.simulateur.deplacementRobot();
self.dessinerSimulation();
self.dessinerReconstruction();
set(self.lblInfoEtape,'String',['Etape ',num2str(self.ctrl.getNumeroEtapeEnCours()),' sur ',num2str(self.ctrl.getTaillePattern()),' : ',self.ctrl.getDesignationEtapeEnCours()]);
set(self.lblTimerEtape,'String',['Timer étape : ',self.convertirIterationTemps(self.ctrl.getTimerEtapeEnCours())]);
set(self.lblTimerTotal,'String',['Timer total : ',self.convertirIterationTemps(self.ctrl.getTimerPattern())]);
set(self.lblForme,'String',['Forme : ',char(self.ctrl.simulateur.piscineReconstruite.forme)]);
set(self.lblProfil,'String',['Profil : ',char(self.ctrl.simulateur.piscineReconstruite.profil)]);
set(self.lblLongueur,'String',['Longueur : ',num2str(self.ctrl.simulateur.piscineReconstruite.longueur),' mm']);
set(self.lblLargeur,'String',['Largeur : ',num2str(self.ctrl.simulateur.piscineReconstruite.largeur),' mm']);
pause(0.01);
end
Baptiste Ranguetat
Baptiste Ranguetat 2017 年 8 月 7 日
And here are the two function i called
function dessinerReconstruction(self)
if(~isempty(self.ctrl.simulateur.piscineReconstruite.piscine))
cla(self.axeReconstruction);
[f,v] = self.ctrl.simulateur.piscineReconstruite.piscine.getFacesVertices();
patch('Faces',f,'Vertices',v,...
'FaceColor', [0.8 0.8 1.0], ...
'EdgeColor', 'none', ...
'FaceLighting', 'gouraud', ...
'AmbientStrength', 0.30,...
'parent', self.axeReconstruction);
axes(self.axeReconstruction);
material('dull');
camlight('headlight');
set(self.axeReconstruction,'CameraPosition', [0 0 8000]);
end
function dessinerSimulation(self)
cla(self.axeSimulation);
%Dessin du robot
repRobot = self.ctrl.getRepresentationRobot();
vertexRobot = zeros(8,3);
for i=1:8
vertexRobot(i,:) = [repRobot(1,i) repRobot(2,i) repRobot(3,i)];
end
facesRobot = [1 2 4 3; 8 7 5 6; 1 2 6 5 ; 3 4 8 7 ; 4 2 6 8 ; 1 3 7 5];
patch('vertices',vertexRobot,...
'faces', facesRobot,...
'parent', self.axeSimulation,...
'edgecolor','w',...
'FaceLighting', 'none',...
'FaceColor', 'flat',...
'FaceVertexCData', [0 1 1 0 0.8 0.8;
0 1 1 0 0.8 0.8;
0 1 0 1 0.8 0.8]');
%Dessin de la piscine
[fPiscine,vPiscine] = self.ctrl.getFacesVerticesPiscine();
patch('Faces',fPiscine,'Vertices',vPiscine,...
'FaceColor', [0.8 0.8 1.0], ...
'EdgeColor', 'none', ...
'FaceLighting', 'gouraud', ...
'AmbientStrength', 0.30,...
'parent', self.axeSimulation);
axes(self.axeSimulation);
material('dull');
camlight('headlight');
hold on;
grid on;
xlabel(self.axeSimulation, 'X (mm)');
ylabel(self.axeSimulation, 'Y (mm)');
end

サインインしてコメントする。

回答 (1 件)

Amy
Amy 2017 年 8 月 10 日
Both of your functions include the line
axes(self.axeSimulation);
This command makes 'self.axeSimulation' the current axes AND brings its parent figure into focus, which is why your figure is returning to the foreground. If you just want to set 'self.axeSimulation' as the current axes without bringing it into focus you can replace the call to 'axes' with a call to 'set' (where 'fig' is the handle to the parent figure of 'self.axeSimulation'):
set(fig, 'CurrentAxes', self.axeSimulation);
  1 件のコメント
Jan
Jan 2017 年 8 月 10 日
The 'CurrentAxes' property might be changed, during the code runs, when a user dares to click in the GUI. Better do not rely on the 'CurrentAxes', but define the 'Parent' property directly.
Unfortunately, material and camlight do not expect a Parent as input. Sigh.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by