#include "wx/wxprec.h" #include /*#ifdef __BORLANDC__ #pragma hdrstop #endif*/ #ifndef WX_PRECOMP #include "wx/wx.h" #endif //------------------------------------------------------------------------------ #include "wxWin1.h" BEGIN_EVENT_TABLE(TMyFrame, wxFrame) EVT_BUTTON(ID_APP_QUIT, TMyFrame::OnQuit) EVT_BUTTON(ID_EXEC, TMyFrame::OnExecuter) EVT_MENU(App_Quit, TMyFrame::OnQuit) EVT_MENU(Nouveau, TMyFrame::OnNouveau) EVT_MENU(Ouvrir, TMyFrame::OnOuvrir) EVT_MENU(Enregister, TMyFrame::OnEnregistrer) EVT_MENU(Limites, TMyFrame::OnLimites) EVT_MENU(Parametres_Simu, TMyFrame::OnParam) END_EVENT_TABLE() //Tables des event de LimitesFrame BEGIN_EVENT_TABLE(LimitesFrame, wxFrame) EVT_BUTTON(ID_Submit, LimitesFrame::OnSubmit) END_EVENT_TABLE() //Tables des event de ParametresFrame BEGIN_EVENT_TABLE(ParametresFrame, wxFrame) EVT_BUTTON(ID_Param, ParametresFrame::OnSubmit) END_EVENT_TABLE() /**********************************************************/ IMPLEMENT_APP(TMyApp) //------------------------------------------------------------------------------ bool TMyApp::OnInit() { TMyFrame *frame = new TMyFrame("ChannelFlow", wxPoint(150, 150), wxSize(780, 560)); frame->Show(true); return true; } //------------------------------------------------------------------------------ TMyFrame::TMyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(NULL, -1, title, pos, size, style) { SetIcon(wxICON(monicone)); SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); /*MonBouton2 = new wxButton(this,ID_APP_QUIT,"Quitter", wxPoint(20,60), wxDefaultSize);*/ // wxPanel *panel = new wxPanel(); //Construction du menu wxMenu *menuFichier = new wxMenu; menuFichier->Append(Nouveau,"Nouveau"); menuFichier->Append(Ouvrir,"Ouvrir..."); menuFichier->Append(Enregister,"Enregister sous..."); menuFichier->AppendSeparator(); menuFichier->Append(App_Quit,"Quitter l'application"); wxMenu *menuLimites = new wxMenu; menuLimites->Append(Limites,"Definir les conditions limites"); wxMenu *menuParametres = new wxMenu; menuParametres->Append(Parametres_Simu,"Definir les paramètres de simulation"); wxMenuBar *menuBarre = new wxMenuBar(); menuBarre->Append(menuFichier,("Fichier")); //menuBarre->Append(menuDonnees,("Données")); menuBarre->Append(menuLimites,("Conditions limites")); menuBarre->Append(menuParametres,("Paramètres de Simulation")); SetMenuBar(menuBarre); ///////////////////// //Bouton d'exécution MonBouton = new wxButton(this,ID_EXEC,"Exécuter", wxPoint(550,450),wxDefaultSize); //////////////////////// //Définir le modèle laminaire ou turbulent Label_mod = new wxStaticText(this,-1,"1.Définir le modèle à utiliser ",wxPoint(20,60), wxSize(200, 30),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); RadioBouton1 = new wxRadioButton(this,-1,"Régime turbulent",wxPoint(50,95),wxDefaultSize,wxRB_GROUP); RadioBouton2 = new wxRadioButton(this,-1,"Régime laminaire",wxPoint(200,95),wxDefaultSize); /////////////////////////////////////////////////////////////// //Définir les paramètres de l'écoulement Label_typeFlow = new wxStaticText(this,-1," 2.Définir les paramètres de l'écoulement: ",wxPoint(20,150), wxSize(250, 15),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); Debit = new wxStaticText(this,-1," Débit [m³/s]: ",wxPoint(60,180),wxSize(60, 15),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); mlTextCtrl_Debit = new wxTextCtrl(this,-1,"",wxPoint(200,178),wxSize(120, 20)); mlTextCtrl_Debit->SetEditable(true); Viscosite = new wxStaticText(this,-1," Viscosité [m²/s]: ",wxPoint(60,210),wxSize(60, 15),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); mlTextCtrl_Viscosite = new wxTextCtrl(this,-1,"",wxPoint(200,208),wxSize(120, 20)); mlTextCtrl_Viscosite->SetEditable(true); ///////////////////////////////////////////// //Définition de la géométrie du canal Label_geomCanal = new wxStaticText(this,-1," 3.Définir la géométrie du canal: ",wxPoint(0,265), wxSize(250, 15),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); Length = new wxStaticText(this,-1," Longueur (X) canal [m]: ",wxPoint(60,295),wxSize(120, 30),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); mlTextCtrl_Length = new wxTextCtrl(this,-1,"",wxPoint(200,293),wxSize(120, 20)); mlTextCtrl_Length->SetEditable(true); Width = new wxStaticText(this,-1," Largeur (Y) canal [m]: ",wxPoint(60,325),wxSize(120, 30),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); mlTextCtrl_Width = new wxTextCtrl(this,-1,"",wxPoint(200,323),wxSize(120, 20)); mlTextCtrl_Width->SetEditable(true); Height = new wxStaticText(this,-1," Hauteur (Z) canal [m]: ",wxPoint(60,355),wxSize(120, 30),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); mlTextCtrl_Height = new wxTextCtrl(this,-1,"",wxPoint(200,353),wxSize(120, 20)); mlTextCtrl_Height->SetEditable(true); //////////////////////////////////////////////////////////////// Label_geomCellule = new wxStaticText(this,-1," 4.Définir la taille du maillage: ",wxPoint(400,60), wxSize(250, 30),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); Label_dx = new wxStaticText(this,-1," dx [m]: ",wxPoint(460,95),wxSize(60, 30),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); mlTextCtrl_dx = new wxTextCtrl(this,-1,"",wxPoint(540,93),wxSize(120, 20)); mlTextCtrl_dx->SetEditable(true); Label_dy = new wxStaticText(this,-1," dy [m]: ",wxPoint(460,125),wxSize(60, 30),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); mlTextCtrl_dy = new wxTextCtrl(this,-1,"",wxPoint(540,123),wxSize(120, 20)); mlTextCtrl_dy->SetEditable(true); Label_dz = new wxStaticText(this,-1," dz [m]: ",wxPoint(460,155),wxSize(60, 30),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); mlTextCtrl_dz = new wxTextCtrl(this,-1,"",wxPoint(540,153),wxSize(120, 20)); mlTextCtrl_dz->SetEditable(true); //CheckBox_turb = new wxCheckBox(this, ID_CHECKBOX, "Régime turbulent",wxPoint(50,50),wxSize(140,30),style = 0,wxDefaultValidator,"chexk"); //CheckBox_turb = new wxCheckBox(panel); //CheckBox_turb = new wxCheckBox( panel, -1, _T("&Disable"), wxPoint(20,170) ); /* Label_dx = new wxStaticText(this,-1,"Taille_dx: ",wxPoint(50,280), wxSize(100, 80),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); Label_dx->SetFont(wxFont(10, wxSWISS , wxNORMAL, wxBOLD, false, "Arial")); Label_dy = new wxStaticText(this,-1,"Taille_dy: ",wxPoint(50,310), wxSize(100, 80),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); Label_dy->SetFont(wxFont(10, wxSWISS , wxNORMAL, wxBOLD, false, "Arial")); Label_dz = new wxStaticText(this,-1,"Taille_dz: ",wxPoint(50,440), wxSize(100, 80),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); Label_dz->SetFont(wxFont(10, wxSWISS , wxNORMAL, wxBOLD, false, "Arial"));*/ } //------------------------------------------------------------------------------ void TMyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) { Close(true); } //------------------------------------------------------------------------------ void TMyFrame::OnChgTitre(wxCommandEvent& WXUNUSED(event)) { SetTitle("Nouveau Titre"); } void TMyFrame::OnExecuter(wxCommandEvent& WXUNUSED(event)) { //Methode verifiant si length/dx= integer, width/dy= integer, height/dz= integer mlTextCtrl_Length->GetValue().ToDouble(&length);//Va chercher la valeur tapée dans la cellule text de length et la converti en double mlTextCtrl_Width->GetValue().ToDouble(&width);//Va chercher la valeur tapée dans la cellule text de length et la converti en double; mlTextCtrl_Height->GetValue().ToDouble(&height);//Va chercher la valeur tapée dans la cellule text de length et la converti en double; mlTextCtrl_dx->GetValue().ToDouble(&dx);//Va chercher la valeur tapée dans la cellule text de length et la converti en double mlTextCtrl_dy->GetValue().ToDouble(&dy);//Va chercher la valeur tapée dans la cellule text de length et la converti en double; mlTextCtrl_dz->GetValue().ToDouble(&dz);//Va chercher la valeur tapée dans la cellule text de length et la converti en double; mlTextCtrl_Debit->GetValue().ToDouble(&debit);//Va chercher la valeur tapée dans la cellule text de length et la converti en double; mlTextCtrl_Viscosite->GetValue().ToDouble(&viscosite);//Va chercher la valeur tapée dans la cellule text de length et la converti en double; if( floor(length/dx)!=length/dx || floor(width/dy)!=width/dy || floor(height/dz)!=height/dz){ //if(length%dx!=0. || width%dy!=0. ||height%dz!=0.){ wxMessageDialog MsgDlg(this,"Modifier dx, dy, dz car le nombre de cellules selon x, y, z doivent être des nombres entier!"); MsgDlg.ShowModal(); if(floor(length/dx)!=length/dx){ // créer un flux de sortie afin de transformer un double en string ostringstream oss; // écrire un nombre dans le flux oss << 0.; // récupérer une chaîne de caractères std::string result = oss.str(); mlTextCtrl_dx->SetValue(result); } if(floor(width/dy)!=length/dy){ // créer un flux de sortie afin de transformer un double en string ostringstream oss; // écrire un nombre dans le flux oss << 0.; // récupérer une chaîne de caractères std::string result = oss.str(); mlTextCtrl_dy->SetValue(result); } if(floor(height/dz)!=length/dz){ // créer un flux de sortie afin de transformer un double en string ostringstream oss; // écrire un nombre dans le flux oss << 0.; // récupérer une chaîne de caractères std::string result = oss.str(); mlTextCtrl_dz->SetValue(result); } } modele_turb=RadioBouton1->GetValue(); //Assigne la valeur choisie par l'utilisateur==> laminaire/turbulent if( debit!=0. && viscosite!=0. && length!=0. && height!=0. && width!=0. && dx!=0. && dy!=0. && dz!=0.) { //Lancer le programme } else { wxMessageDialog MsgDlg(this,"Certaines données n'ont pas été entrées!"); MsgDlg.ShowModal(); } cout<<"LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOL"; } void TMyFrame::OnNouveau(wxCommandEvent& WXUNUSED(event)) { } //------------------------------------------------------------------------------ void TMyFrame::OnOuvrir(wxCommandEvent& WXUNUSED(event)) { /* wxString nomfichier = wxFileSelector("Ouvrir" ,"" ,"" ,"", "cpp files (*.cpp;*.h)|*.h;*.cpp|resources files (*.rc)|*.rc",wxOPEN); if (!nomfichier.empty()) { mlTextCtrl->LoadFile(nomfichier); TextChg = false; }*/ } //------------------------------------------------------------------------------ void TMyFrame::OnEnregistrer(wxCommandEvent& WXUNUSED(event)) { /*wxString nomfichier = wxFileSelector("Enregistrer" ,"" ,"" ,"", "cpp files (*.cpp;*.h)|*.h;*.cpp|resources files (*.rc)|*.rc",wxSAVE); if (!nomfichier.empty()) { mlTextCtrl->SaveFile(nomfichier); TextChg = false; }*/ } void TMyFrame::OnLimites(wxCommandEvent& WXUNUSED(event)) { LimitesFrame *frame = new LimitesFrame("Conditions Limites", wxPoint(250, 250), wxSize(780, 560)); frame->Show(true); } void TMyFrame::OnParam(wxCommandEvent& WXUNUSED(event)) { ParametresFrame *frame = new ParametresFrame("Paramètres de simulation", wxPoint(250, 250), wxSize(780, 560)); frame->Show(true); } LimitesFrame::LimitesFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(NULL, -1, title, pos, size, style) { SetIcon(wxICON(monicone)); SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); ::opened=true; //Bouton d'exécution MonBouton = new wxButton(this,ID_Submit,"Submit", wxPoint(550,450),wxDefaultSize); //////////////////////// //Paroi Sud Label_Sud = new wxStaticText(this,-1," 1.Définir les conditions limites parois Sud",wxPoint(20,60), wxSize(250, 30),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); RadioBouton1 = new wxRadioButton(this,-1,"Wall Condition",wxPoint(50,95),wxDefaultSize,wxRB_GROUP);//wxRB_GROUP permet de définir un nouveau groupe de radiobutton RadioBouton2 = new wxRadioButton(this,-1,"Symetry Condition",wxPoint(200,95),wxDefaultSize); if(opened){ //Permet de définir l'option sélectionnée précédemment RadioBouton1->SetValue(south_wall); RadioBouton2->SetValue(!south_wall); } /////////////////////////////////////////////////////////////// //Paroi nord Label_Nord = new wxStaticText(this,-1," 2.Définir les conditions limites parois Nord: ",wxPoint(20,150), wxSize(250, 30),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); RadioBouton3 = new wxRadioButton(this,-1,"Wall Condition",wxPoint(50,185),wxDefaultSize,wxRB_GROUP); RadioBouton4 = new wxRadioButton(this,-1,"Symetry Condition",wxPoint(200,185),wxDefaultSize); if(opened){ //Permet de définir l'option sélectionnée précédemment RadioBouton3->SetValue(north_wall); RadioBouton4->SetValue(!north_wall); } //Paroi Bottom Label_Bottom = new wxStaticText(this,-1," 3.Définir les conditions limites parois Bottom: ",wxPoint(20,240), wxSize(250, 30),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); RadioBouton5 = new wxRadioButton(this,-1,"Wall Condition",wxPoint(50,275),wxDefaultSize,wxRB_GROUP); RadioBouton6 = new wxRadioButton(this,-1,"Symetry Condition",wxPoint(200,275),wxDefaultSize); if(opened){ //Permet de définir l'option sélectionnée précédemment RadioBouton5->SetValue(bottom_wall); RadioBouton6->SetValue(!bottom_wall); } //Paroi Surface Label_Surface = new wxStaticText(this,-1," 4.Définir les conditions limites de Surface: ",wxPoint(20,330), wxSize(250, 30),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); RadioBouton7 = new wxRadioButton(this,-1,"Surface Condition",wxPoint(50,365),wxDefaultSize,wxRB_GROUP); RadioBouton8 = new wxRadioButton(this,-1,"Symetry Condition",wxPoint(200,365),wxDefaultSize); if(opened){ //Permet de définir l'option sélectionnée précédemment RadioBouton7->SetValue(top_surface); RadioBouton8->SetValue(!top_surface); } //Conditions de pression de sortie Label_P_out = new wxStaticText(this,-1," 5.Définir les conditions de pression de sortie: ",wxPoint(400,60), wxSize(250, 30),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); RadioBouton9 = new wxRadioButton(this,-1,"Pression hydrostatique",wxPoint(430,95),wxDefaultSize,wxRB_GROUP); RadioBouton10 = new wxRadioButton(this,-1,"Gradient nul",wxPoint(580,95),wxDefaultSize); if(opened){ //Permet de définir l'option sélectionnée précédemment RadioBouton9->SetValue(P_hydrostat); RadioBouton10->SetValue(!P_hydrostat); } } void LimitesFrame::OnSubmit(wxCommandEvent& WXUNUSED(event)) //Va stocker les options sélectionnées { south_wall= RadioBouton1->GetValue(); north_wall= RadioBouton3->GetValue(); bottom_wall= RadioBouton5->GetValue(); top_surface= RadioBouton7->GetValue(); P_hydrostat= RadioBouton9->GetValue(); Close(true); } ParametresFrame::ParametresFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(NULL, -1, title, pos, size, style) { SetIcon(wxICON(monicone)); SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); //Bouton d'exécution MonBouton = new wxButton(this,ID_Param,"Submit", wxPoint(550,450),wxDefaultSize); //Définir les paramètres de l'écoulement Label_Param = new wxStaticText(this,-1," 1.Définir les paramètres de simulation: ",wxPoint(20,150), wxSize(250, 15),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); Label_ConvParam = new wxStaticText(this,-1," Critère de convergence de correction de pression: ",wxPoint(34,180),wxSize(300, 15),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); mlTextCtrl_ConvParam = new wxTextCtrl(this,-1,"",wxPoint(360,178),wxSize(120, 20)); mlTextCtrl_ConvParam->SetEditable(true); Max_Iter_I = new wxStaticText(this,-1," Nombre max d'itérations I: ",wxPoint(60,210),wxSize(120, 15),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); mlTextCtrl_Max_Iter_I = new wxTextCtrl(this,-1,"",wxPoint(200,208),wxSize(120, 20)); mlTextCtrl_Max_Iter_I->SetEditable(true); Max_Iter_J = new wxStaticText(this,-1," Nombre max d'itérations J: ",wxPoint(60,240),wxSize(120, 15),wxALIGN_CENTRE | wxST_NO_AUTORESIZE ); mlTextCtrl_Max_Iter_J = new wxTextCtrl(this,-1,"",wxPoint(200,238),wxSize(120, 20)); mlTextCtrl_Max_Iter_J->SetEditable(true); if(opened_param){ //Permet de définir l'option sélectionnée précédemment /*// créer un flux de sortie afin de transformer un double en string ostringstream oss; // écrire un nombre dans le flux oss << ConvParam; // récupérer une chaîne de caractères std::string result = oss.str(); mlTextCtrl_ConvParam->SetValue(result); // créer un flux de sortie afin de transformer un double en string ostringstream oss1; // écrire un nombre dans le flux oss1 << MaxIter_I; // récupérer une chaîne de caractères result = oss1.str(); mlTextCtrl_Max_Iter_I->SetValue(result); // créer un flux de sortie afin de transformer un double en string ostringstream oss2; // écrire un nombre dans le flux oss2 << MaxIter_J; // récupérer une chaîne de caractères result = oss2.str(); mlTextCtrl_Max_Iter_J->SetValue(result);*/ } //////////////////////// } void ParametresFrame::OnSubmit(wxCommandEvent& WXUNUSED(event)) //Va stocker les options sélectionnées { /*mlTextCtrl_ConvParam->GetValue().ToDouble(&ConvParam);//Va chercher la valeur tapée dans la cellule text de length et la converti en double mlTextCtrl_Max_Iter_I->GetValue().ToDouble(&MaxIter_I);//Va chercher la valeur tapée dans la cellule text de length et la converti en double; mlTextCtrl_Max_Iter_J->GetValue().ToDouble(&MaxIter_J);//Va chercher la valeur tapée dans la cellule text de length et la converti en double; opened_param=true;*/ Close(true); }