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
|
#include "IHM_Commande.h"
#define ID_AFFICHAGE_IMAGE 10101
#define ID_QUITTER 10103
#define ID_TIMER 10104
IHM_Commande::IHM_Commande(const wxString& title,
Stockage_Image *pStockage_Image_)
: wxFrame(NULL, wxID_ANY, title, wxPoint(0,0),wxDefaultSize, wxDEFAULT_FRAME_STYLE)
{
pStockage_Image = pStockage_Image_ ;
pAcquisiotn = NULL ;
pTimerImage = new wxTimer(this,ID_TIMER);
Create_Thread(title);
}
IHM_Commande::~IHM_Commande() {
// TODO Auto-generated destructor stub
}
BEGIN_EVENT_TABLE(IHM_Commande, wxFrame)
EVT_BUTTON(ID_AFFICHAGE_IMAGE,IHM_Commande::AffichageCamera)
EVT_BUTTON(ID_QUITTER, IHM_Commande::Quitter)
EVT_TIMER(ID_TIMER, IHM_Commande::ActionTimer )
END_EVENT_TABLE()
void IHM_Commande::Create_IHM_Commande(const wxString &title) {
// TODO Auto-generated destructor stub
wxStaticText *pTXT_Vide1 = new wxStaticText(this, -1, _(""),wxDefaultPosition,wxDefaultSize);
wxButton *pButtonAffichageCamera = new wxButton(this, ID_AFFICHAGE_IMAGE,
_("Affichage Vision Camera"));
wxButton *pButtonQuitter = new wxButton(this, ID_QUITTER,
_("Quitter"));
wxFlexGridSizer *pFGridSizerCadreCommande = new wxFlexGridSizer(2, 2, 0, 0);
this->SetSizer(pFGridSizerCadreCommande);
pFGridSizerCadreCommande->Add(pButtonAffichageCamera, 1, wxALIGN_CENTER_HORIZONTAL|
wxALIGN_CENTER_VERTICAL|wxALL,5) ;
pFGridSizerCadreCommande->Add(pTXT_Vide1,1, wxALIGN_CENTER_HORIZONTAL|
wxALIGN_CENTER_VERTICAL|wxALL, 1);
pFGridSizerCadreCommande->Add(pButtonQuitter,1, wxALIGN_CENTER_HORIZONTAL|
wxALIGN_CENTER_VERTICAL|wxALL,5) ;
pFGridSizerCadreCommande->Fit(this);
pFGridSizerCadreCommande->SetSizeHints(this);
}
void IHM_Commande::AffichageCamera(wxCommandEvent& event) {
/* en multi thread */
pAcquisition_Thread = new Acquisition_Thread(
pStockage_Image);
if (!pAcquisition_Thread->IsRunning()){
wxMessageBox(_("Thread ne tourne pas encore "),
_("Thread ne tourne pas encore"),
wxOK|wxICON_INFORMATION,this);
pAcquisition_Thread->Create();
pAcquisition_Thread->Run();
if (pAcquisition_Thread->IsRunning()){
wxMessageBox(_("Thread tourne "),
_("Thread tourne "),wxOK|wxICON_INFORMATION,this);
}
}
else {
wxMessageBox(_("Thread tourne deja"),
_("Thread tourne deja "),wxOK|wxICON_INFORMATION,this);
}
sleep(2);
pTimerImage->Start(10);
}
void IHM_Commande::Quitter(wxCommandEvent& event) {
/* en multi thread */
if(pAcquisition_Thread->IsRunning()){
pAcquisition_Thread->Pause();
pAcquisition_Thread->Delete();
pTimerImage->Stop();
delete pTimerImage ;
}
cout << " IHM_Commande::Quitter "<< endl;
Close(TRUE);
}
void IHM_Commande::ActionTimer(wxTimerEvent& event)
{
namedWindow("Image Camera ", CV_WINDOW_NORMAL );
imshow("Image Camera ",pStockage_Image->get_Image_RGB());
} |
Partager