X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FwxCDMMainFrame.cpp;h=d60b3173dc21433c11ce50cb26bd9f6e56fec003;hb=d63809f12ef02087c94159a16a83ec0f31ae0d74;hp=630c1f85c8712072b2f40888aa29396d028e3804;hpb=17824854619941a12697fea8524f4218f9a14ef9;p=crea.git diff --git a/lib/creaDevManagerLib/wxCDMMainFrame.cpp b/lib/creaDevManagerLib/wxCDMMainFrame.cpp index 630c1f8..d60b317 100755 --- a/lib/creaDevManagerLib/wxCDMMainFrame.cpp +++ b/lib/creaDevManagerLib/wxCDMMainFrame.cpp @@ -2,8 +2,10 @@ # --------------------------------------------------------------------- # # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image -# pour la Santé) +# pour la Sant�) # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton +# Previous Authors : Laurent Guigues, Jean-Pierre Roux +# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil # # This software is governed by the CeCILL-B license under French law and # abiding by the rules of distribution of free software. You can use, @@ -20,56 +22,58 @@ # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL-B license and that you accept its terms. -# ------------------------------------------------------------------------ */ +# ------------------------------------------------------------------------ + */ #include "wxCDMMainFrame.h" +#include + +#include +#include "CDMUtilities.h" + #include "creaDevManagerIds.h" #include "wxCDMMainDescriptionPanel.h" #include "wxCDMProjectActionsPanel.h" #include "wxCDMNewProjectDialog.h" -#include - - - BEGIN_EVENT_TABLE(wxCDMMainFrame, wxFrame) - EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject) - EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject) - EVT_MENU(ID_MENU_OPEN_RECENT, wxCDMMainFrame::OnMenuOpenRecent) - EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject) - EVT_MENU(ID_MENU_CLOSE_ALL_PROJECTS, wxCDMMainFrame::OnMenuCloseAllProjects) - EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy) - EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit) - EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject) - EVT_MENU(ID_MENU_CUT, wxCDMMainFrame::OnMenuMenuCut) - EVT_MENU(ID_MENU_COPY, wxCDMMainFrame::OnMenuMenuCopy) - EVT_MENU(ID_MENU_PASTE, wxCDMMainFrame::OnMenuMenuPaste) - EVT_MENU(ID_MENU_DELETE, wxCDMMainFrame::OnMenuMenuDelete) - EVT_MENU(ID_MENU_SELECT_ALL, wxCDMMainFrame::OnMenuSelectAll) - EVT_MENU(ID_MENU_SELECT_NONE, wxCDMMainFrame::OnMenuSelectNone) - EVT_MENU(ID_MENU_EVENT_LOG, wxCDMMainFrame::OnMenuEventLog) - EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor) - EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools) - EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor) - EVT_MENU(ID_MENU_COMMAND_LINE, wxCDMMainFrame::OnMenuCommandLine) - EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp) - EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug) - EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager) - EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis) - EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject) - EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject) +EVT_MENU(ID_MENU_NEW_PROJECT, wxCDMMainFrame::OnMenuNewProject) +EVT_MENU(ID_MENU_OPEN_PROJECT, wxCDMMainFrame::OnMenuOpenProject) +EVT_MENU(ID_MENU_OPEN_RECENT, wxCDMMainFrame::OnMenuOpenRecent) +EVT_MENU(ID_MENU_CLOSE_PROJECT, wxCDMMainFrame::OnMenuCloseProject) +EVT_MENU(ID_MENU_CLOSE_ALL_PROJECTS, wxCDMMainFrame::OnMenuCloseAllProjects) +EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy) +EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit) +EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject) +EVT_MENU(ID_MENU_CUT, wxCDMMainFrame::OnMenuMenuCut) +EVT_MENU(ID_MENU_COPY, wxCDMMainFrame::OnMenuMenuCopy) +EVT_MENU(ID_MENU_PASTE, wxCDMMainFrame::OnMenuMenuPaste) +EVT_MENU(ID_MENU_DELETE, wxCDMMainFrame::OnMenuMenuDelete) +EVT_MENU(ID_MENU_SELECT_ALL, wxCDMMainFrame::OnMenuSelectAll) +EVT_MENU(ID_MENU_SELECT_NONE, wxCDMMainFrame::OnMenuSelectNone) +EVT_MENU(ID_MENU_EVENT_LOG, wxCDMMainFrame::OnMenuEventLog) +EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor) +EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools) +EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor) +EVT_MENU(ID_MENU_COMMAND_LINE, wxCDMMainFrame::OnMenuCommandLine) +EVT_MENU(ID_MENU_HELP, wxCDMMainFrame::OnMenuHelp) +EVT_MENU(ID_MENU_REPORT_BUG, wxCDMMainFrame::OnMenuReportBug) +EVT_MENU(ID_MENU_ABOUT_CREADEVMANAGER, wxCDMMainFrame::OnMenuAboutCreaDevManager) +EVT_MENU(ID_MENU_ABOUT_CREATIS, wxCDMMainFrame::OnMenuAboutCreatis) +EVT_BUTTON(ID_BUTTON_NEWPROJECT, wxCDMMainFrame::OnMenuNewProject) +EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMMainFrame::OnMenuOpenProject) END_EVENT_TABLE() wxCDMMainFrame::wxCDMMainFrame( - wxWindow* parent, - wxWindowID id, - const wxString& caption, - const wxPoint& pos, - const wxSize& size, - long style + wxWindow* parent, + wxWindowID id, + const wxString& caption, + const wxPoint& pos, + const wxSize& size, + long style ) { Create(parent, id, caption, pos, size, style); @@ -81,12 +85,12 @@ wxCDMMainFrame::~wxCDMMainFrame() } bool wxCDMMainFrame::Create( - wxWindow* parent, - wxWindowID id, - const wxString& caption, - const wxPoint& pos, - const wxSize& size, - long style + wxWindow* parent, + wxWindowID id, + const wxString& caption, + const wxPoint& pos, + const wxSize& size, + long style ) { wxFrame::Create(parent, id, caption, pos, size, style); @@ -102,51 +106,51 @@ void wxCDMMainFrame::CreateMenus() //FileMenu menu_File = new wxMenu(); - menu_File->Append(ID_MENU_NEW_PROJECT, wxString("&New Project...")); - menu_File->Append(ID_MENU_OPEN_PROJECT, wxString("&Open Project...")); - menu_File->Append(ID_MENU_OPEN_RECENT, wxString("Open &Recent")); + menu_File->Append(ID_MENU_NEW_PROJECT, wxT("&New Project...")); + menu_File->Append(ID_MENU_OPEN_PROJECT, wxT("&Open Project...")); + menu_File->Append(ID_MENU_OPEN_RECENT, wxT("Open &Recent")); menu_File->AppendSeparator(); - menu_File->Append(ID_MENU_CLOSE_PROJECT, wxString("&Close Project")); - menu_File->Append(ID_MENU_CLOSE_ALL_PROJECTS, wxString("C&lose All Projects")); + menu_File->Append(ID_MENU_CLOSE_PROJECT, wxT("&Close Project")); + menu_File->Append(ID_MENU_CLOSE_ALL_PROJECTS, wxT("C&lose All Projects")); menu_File->AppendSeparator(); - menu_File->Append(ID_MENU_EXPORT_HIERARCHY, wxString("&Export Project Hierarchy...")); + menu_File->Append(ID_MENU_EXPORT_HIERARCHY, wxT("&Export Project Hierarchy...")); menu_File->AppendSeparator(); - menu_File->Append(ID_MENU_EXIT, wxString("E&xit")); + menu_File->Append(ID_MENU_EXIT, wxT("E&xit")); - menuBar->Append(menu_File, wxString("&File")); + menuBar->Append(menu_File, wxT("&File")); //EditMenu menu_Edit = new wxMenu(); - menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxString("&Refresh Project")); + menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxT("&Refresh Project")); menu_Edit->AppendSeparator(); - menu_Edit->Append(ID_MENU_CUT, wxString("Cu&t")); - menu_Edit->Append(ID_MENU_COPY, wxString("&Copy")); - menu_Edit->Append(ID_MENU_PASTE, wxString("&Paste")); + menu_Edit->Append(ID_MENU_CUT, wxT("Cu&t")); + menu_Edit->Append(ID_MENU_COPY, wxT("&Copy")); + menu_Edit->Append(ID_MENU_PASTE, wxT("&Paste")); menu_Edit->AppendSeparator(); - menu_Edit->Append(ID_MENU_DELETE, wxString("&Delete")); - menu_Edit->Append(ID_MENU_SELECT_ALL, wxString("Select &All")); - menu_Edit->Append(ID_MENU_SELECT_NONE, wxString("Ca&ncel Selection")); + menu_Edit->Append(ID_MENU_DELETE, wxT("&Delete")); + menu_Edit->Append(ID_MENU_SELECT_ALL, wxT("Select &All")); + menu_Edit->Append(ID_MENU_SELECT_NONE, wxT("Ca&ncel Selection")); - menuBar->Append(menu_Edit, wxString("&Edit")); + menuBar->Append(menu_Edit, wxT("&Edit")); //ToolsMenu menu_Tools = new wxMenu(); - menu_Tools->Append(ID_MENU_EVENT_LOG, wxString("Event &Log")); - menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxString("BBTK &Graphical Editor")); - menu_Tools->Append(ID_MENU_MINITOOLS, wxString("&MiniTools")); - menu_Tools->Append(ID_MENU_CODE_EDITOR, wxString("&Code Editor")); - menu_Tools->Append(ID_MENU_COMMAND_LINE, wxString("&Command Line")); + menu_Tools->Append(ID_MENU_EVENT_LOG, wxT("Event &Log")); + menu_Tools->Append(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxT("BBTK &Graphical Editor")); + menu_Tools->Append(ID_MENU_MINITOOLS, wxT("&MiniTools")); + menu_Tools->Append(ID_MENU_CODE_EDITOR, wxT("&Code Editor")); + menu_Tools->Append(ID_MENU_COMMAND_LINE, wxT("&Command Line")); - menuBar->Append(menu_Tools, wxString("&Tools")); + menuBar->Append(menu_Tools, wxT("&Tools")); //HelpMenu menu_Help = new wxMenu(); - menu_Help->Append(ID_MENU_HELP, wxString("&Help")); - menu_Help->Append(ID_MENU_REPORT_BUG, wxString("Report &Bug")); - menu_Help->Append(ID_MENU_ABOUT_CREADEVMANAGER, wxString("&About CreaDevManager")); - menu_Help->Append(ID_MENU_ABOUT_CREATIS, wxString("A&bout CREATIS")); + menu_Help->Append(ID_MENU_HELP, wxT("&Help")); + menu_Help->Append(ID_MENU_REPORT_BUG, wxT("Report &Bug")); + menu_Help->Append(ID_MENU_ABOUT_CREADEVMANAGER, wxT("&About CreaDevManager")); + menu_Help->Append(ID_MENU_ABOUT_CREATIS, wxT("A&bout CREATIS")); - menuBar->Append(menu_Help, wxString("&Help")); + menuBar->Append(menu_Help, wxT("&Help")); //Set Bar SetMenuBar(menuBar); @@ -164,38 +168,38 @@ void wxCDMMainFrame::CreateControls() tree_Projects = new wxCDMProjectsTreeCtrl( - this, - ID_TREE_PROJECTS, - wxDefaultPosition, - wxSize(300,400), - wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS + this, + ID_TREE_PROJECTS, + wxDefaultPosition, + wxSize(300,400), + wxTR_HAS_BUTTONS | wxTR_AQUA_BUTTONS ); tree_Projects->SetMinSize(wxSize(200,200)); panel_Properties = new wxCDMMainDescriptionPanel( - this, - ID_WINDOW_PROPERTIES, - wxString("Description Panel"), - wxDefaultPosition, - wxSize(300, 400), - 0 + this, + ID_WINDOW_PROPERTIES, + wxT("Description Panel"), + wxDefaultPosition, + wxSize(300, 400), + 0 ); panel_ProjectActions = new wxCDMProjectActionsPanel( - this, - ID_WINDOW_PROJ_ACTIONS, - wxString("Project Actions Panel"), - wxDefaultPosition, - wxSize(600,200), - 0 + this, + ID_WINDOW_PROJ_ACTIONS, + wxT("Project Actions Panel"), + wxDefaultPosition, + wxSize(600,200), + 0 ); panel_ProjectActions->SetMinSize(wxSize(500, 100)); - auiManager.AddPane(tree_Projects, wxLEFT, wxString("Projects Tree")); - auiManager.AddPane(panel_ProjectActions, wxBOTTOM, wxString("Project Actions")); - auiManager.AddPane(panel_Properties, wxCENTER, wxString("Properties")); + auiManager.AddPane(tree_Projects, wxLEFT, wxT("Projects Tree")); + auiManager.AddPane(panel_ProjectActions, wxBOTTOM, wxT("Project Actions")); + auiManager.AddPane(panel_Properties, wxCENTER, wxT("Properties")); auiManager.Update(); auiManager.GetPane(tree_Projects).CloseButton(false).MaximizeButton(true); @@ -211,42 +215,54 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event) userResponse = dialog->ShowModal(); if(userResponse == wxID_FORWARD) - { - //TODO createProject - std::cerr << "should create Project here" << std::endl; - //tree_Projects->BuildTree(this->model->GetActiveProjects()); - } + { + std::string* result; + if(!this->model->CreateProject( + crea::wx2std(dialog->GetProjectName()), + crea::wx2std(dialog->GetProjectLocation()), + result, + crea::wx2std(dialog->GetPackageAuthor()), + crea::wx2std(dialog->GetPackageDescription()) + )) + { + wxMessageBox(crea::std2wx(*result),_T("New Project - Error!"),wxOK | wxICON_ERROR); + } + wxMessageBox(_T("New Project created!"),_T("New Project - Success!"), wxOK | wxICON_INFORMATION); + + //TODO: populate model + //TODO: populate tree control + + //tree_Projects->BuildTree(this->model->GetActiveProjects()); + auiManager.Update(); + } event.Skip(); } void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event) { - /* long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST; - wxDirDialog* FD = new wxDirDialog(this, wxString("Select the project directory"), wxString(""), style); + wxDirDialog* FD = new wxDirDialog(this, wxT("Select the project directory"), wxT(""), style); long userResponse; userResponse = FD->ShowModal(); if(userResponse == wxID_OK) - { - switch(this->controller->OpenProject(crea::wx2std (FD->GetPath()))) { - case 1: - wxMessageBox( wxT("No project selected."), wxT("Open Project - Error"), wxICON_ERROR); - event.Skip(); - break; - case 2: - wxMessageBox( wxString("Sources not found."), wxString("Open Project - Error"), wxICON_ERROR); - event.Skip(); - break; - case 0: - break; - }; - - ((wxCreaDevManagerTreeCtrl*)tree_Projects)->BuildTree(controller->GetActiveProjects()); - - auiManager.Update(); - } - */ + std::cout << "Selection to open: " << crea::wx2std (FD->GetPath()) << std::endl; + std::string path = crea::wx2std (FD->GetPath()); + + std::string* result; + if (!this->model->OpenProject(path, result)) + { + wxMessageBox( crea::std2wx(result->c_str()), wxT("Open Project - Error"), wxICON_ERROR); + event.Skip(); + }; + + //TODO: populate model + //TODO: populate tree control + + //((wxCreaDevManagerTreeCtrl*)tree_Projects)->BuildTree(controller->GetActiveProjects()); + auiManager.Update(); + } + event.Skip(); } void wxCDMMainFrame::OnMenuOpenRecent(wxCommandEvent& event)