Index: trunk/demos/OpticalFlow/uav/src/DemoOpticalFlow.cpp
===================================================================
--- trunk/demos/OpticalFlow/uav/src/DemoOpticalFlow.cpp	(revision 122)
+++ trunk/demos/OpticalFlow/uav/src/DemoOpticalFlow.cpp	(revision 124)
@@ -26,4 +26,5 @@
 #include <GroupBox.h>
 #include <DoubleSpinBox.h>
+#include <PushButton.h>
 #include <FrameworkManager.h>
 #include <MetaDualShock3.h>
@@ -49,51 +50,54 @@
 uav->GetVerticalCamera()->SetLogFormat(Camera::LogFormat::JPG);
 getFrameworkManager()->AddDeviceToLog(uav->GetVerticalCamera());
-    greyCameraImage=new CvtColor(uav->GetVerticalCamera(),"gray",CvtColor::Conversion_t::GRAY);
+	
+	startOpticalflow=new PushButton(GetButtonsLayout()->NewRow(),"start optical flow");
 
-    uav->GetVerticalCamera()->UseDefaultPlot(greyCameraImage->Output()); // Le defaultPlot de la caméra peut afficher n'importe quoi?
+	greyCameraImage=new CvtColor(uav->GetVerticalCamera(),"gray",CvtColor::Conversion_t::ToGray);
 
-    //optical flow stack
-    opticalFlow=new OpticalFlow(greyCameraImage,uav->GetVerticalCamera()->GetLayout()->NewRow(),"flux optique");
-    opticalFlowSpeed=new OpticalFlowSpeed(opticalFlow,"vitesse du flux optique");
+	uav->GetVerticalCamera()->UseDefaultPlot(greyCameraImage->Output()); // Le defaultPlot de la caméra peut afficher n'importe quoi?
 
-    cvmatrix_descriptor* desc=new cvmatrix_descriptor(2,1);
-    for(int i=0;i<2;i++) {
-        desc->SetElementName(i,0,opticalFlowSpeed->Output()->Name(i,0));
-    }
-    cvmatrix* prev_value=new cvmatrix((const Thread*)this,desc,floatType,uav->ObjectName()); // diamond inheritance
-    for(int i=0;i<2;i++) {
-        prev_value->SetValue(i,0,0);
-    }
+	//optical flow stack
+	opticalFlow=new OpticalFlow(greyCameraImage,uav->GetVerticalCamera()->GetLayout()->NewRow(),"flux optique");
+	opticalFlowSpeed=new OpticalFlowSpeed(opticalFlow,"vitesse du flux optique");
 
-    opticalFlowSpeedFiltered=new LowPassFilter(opticalFlowSpeed,uav->GetVerticalCamera()->GetLayout()->NewRow(),"passe bas",prev_value);
+	cvmatrix_descriptor* desc=new cvmatrix_descriptor(2,1);
+	for(int i=0;i<2;i++) {
+			desc->SetElementName(i,0,opticalFlowSpeed->Output()->Name(i,0));
+	}
+	cvmatrix* prev_value=new cvmatrix((const Thread*)this,desc,floatType,uav->ObjectName()); // diamond inheritance
+	for(int i=0;i<2;i++) {
+			prev_value->SetValue(i,0,0);
+	}
+
+	opticalFlowSpeedFiltered=new LowPassFilter(opticalFlowSpeed,uav->GetVerticalCamera()->GetLayout()->NewRow(),"passe bas",prev_value);
 // delete prev_value?
 
-    getFrameworkManager()->AddDeviceToLog(opticalFlowSpeed);
+	getFrameworkManager()->AddDeviceToLog(opticalFlowSpeed);
 
-    Tab* opticalFlowTab=new Tab(getFrameworkManager()->GetTabWidget(),"flux optique");
-    DataPlot1D* xVelocityPlot=new DataPlot1D(opticalFlowTab->NewRow(),"x_velocity",-5,5);
-    DataPlot1D* yVelocityPlot=new DataPlot1D(opticalFlowTab->LastRowLastCol(),"y_velocity",-5,5);
+	Tab* opticalFlowTab=new Tab(getFrameworkManager()->GetTabWidget(),"flux optique");
+	DataPlot1D* xVelocityPlot=new DataPlot1D(opticalFlowTab->NewRow(),"x_velocity",-5,5);
+	DataPlot1D* yVelocityPlot=new DataPlot1D(opticalFlowTab->LastRowLastCol(),"y_velocity",-5,5);
 
-    xVelocityPlot->AddCurve(opticalFlowSpeed->Output()->Element(0,0));
-    xVelocityPlot->AddCurve(opticalFlowSpeedFiltered->Matrix()->Element(0,0),DataPlot::Blue);
-    yVelocityPlot->AddCurve(opticalFlowSpeed->Output()->Element(1,0));
-    yVelocityPlot->AddCurve(opticalFlowSpeedFiltered->Matrix()->Element(1,0),DataPlot::Blue);
+	xVelocityPlot->AddCurve(opticalFlowSpeed->Output()->Element(0,0));
+	xVelocityPlot->AddCurve(opticalFlowSpeedFiltered->Matrix()->Element(0,0),DataPlot::Blue);
+	yVelocityPlot->AddCurve(opticalFlowSpeed->Output()->Element(1,0));
+	yVelocityPlot->AddCurve(opticalFlowSpeedFiltered->Matrix()->Element(1,0),DataPlot::Blue);
 
-    u_x=new Pid(setupLawTab->At(1,0),"u_x");
-    u_x->UseDefaultPlot(graphLawTab->NewRow());
-    u_y=new Pid(setupLawTab->At(1,1),"u_y");
-    u_y->UseDefaultPlot(graphLawTab->LastRowLastCol());
+	u_x=new Pid(setupLawTab->At(1,0),"u_x");
+	u_x->UseDefaultPlot(graphLawTab->NewRow());
+	u_y=new Pid(setupLawTab->At(1,1),"u_y");
+	u_y->UseDefaultPlot(graphLawTab->LastRowLastCol());
 
-    opticalFlowGroupBox=new GroupBox(GetJoystick()->GetTab()->NewRow(),"consignes fo");
-    maxXSpeed=new DoubleSpinBox(opticalFlowGroupBox->NewRow(),"debattement x"," m/s",-5,5,0.1,1);
-    maxYSpeed=new DoubleSpinBox(opticalFlowGroupBox->LastRowLastCol(),"debattement y"," m/s",-5,5,0.1,1);
+	opticalFlowGroupBox=new GroupBox(GetJoystick()->GetTab()->NewRow(),"consignes fo");
+	maxXSpeed=new DoubleSpinBox(opticalFlowGroupBox->NewRow(),"debattement x"," m/s",-5,5,0.1,1);
+	maxYSpeed=new DoubleSpinBox(opticalFlowGroupBox->LastRowLastCol(),"debattement y"," m/s",-5,5,0.1,1);
 
-    opticalFlowReference=new cvmatrix((const Thread*)this,2,1,floatType);
-    xVelocityPlot->AddCurve(opticalFlowReference->Element(0,0),DataPlot::Green,"consigne");
-    yVelocityPlot->AddCurve(opticalFlowReference->Element(1,0),DataPlot::Green,"consigne");
+	opticalFlowReference=new cvmatrix((const Thread*)this,2,1,floatType);
+	xVelocityPlot->AddCurve(opticalFlowReference->Element(0,0),DataPlot::Green,"consigne");
+	yVelocityPlot->AddCurve(opticalFlowReference->Element(1,0),DataPlot::Green,"consigne");
 
-    customReferenceOrientation= new AhrsData(this,"reference");
-    uav->GetAhrs()->AddPlot(customReferenceOrientation,DataPlot::Yellow);
-    AddDataToControlLawLog(customReferenceOrientation);
+	customReferenceOrientation= new AhrsData(this,"reference");
+	uav->GetAhrs()->AddPlot(customReferenceOrientation,DataPlot::Yellow);
+	AddDataToControlLawLog(customReferenceOrientation);
 }
 
@@ -107,4 +111,22 @@
 }
 
+void DemoOpticalFlow::StartOpticalFlow(void) {
+	if (SetOrientationMode(OrientationMode_t::Custom)) {
+			Thread::Info("(Re)entering optical flow mode\n");
+			u_x->Reset();
+			u_y->Reset();
+	} else {
+			Thread::Warn("Could not enter optical flow mode\n");
+	}
+}
+
+void DemoOpticalFlow::ExtraCheckPushButton(void) {
+	if(startOpticalflow->Clicked()) {
+        //StartOpticalFlow();
+				GetUav()->GetVerticalCamera()->SavePictureToFile("./toto.jpg");
+				
+	}
+}
+
 void DemoOpticalFlow::ExtraCheckJoystick(void) {
     static bool wasOpticalFlowModeButtonPressed=false;
@@ -113,11 +135,5 @@
         if (!wasOpticalFlowModeButtonPressed) {
             wasOpticalFlowModeButtonPressed=true;
-            if (SetOrientationMode(OrientationMode_t::Custom)) {
-                Thread::Info("(Re)entering optical flow mode\n");
-                u_x->Reset();
-                u_y->Reset();
-            } else {
-                Thread::Warn("Could not enter optical flow mode\n");
-            }
+            StartOpticalFlow();
         }
     } else {
