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 CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by