Code: Select all
/***************************************************************
* Name: MachineLearningLinkerMain.cpp
* Purpose: Code for Application Frame
* Author: ()
* Created: 2019-07-27
* Copyright: ()
* License:
**************************************************************/
#include "MachineLearningLinkerMain.h"
#include <wx/msgdlg.h>
//(*InternalHeaders(MachineLearningLinkerFrame)
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/listctrl.h>
#include <boost/property_tree/ptree.hpp>
#include "boost\foreach.hpp"
#include "boost\property_tree\json_parser.hpp"
#include <boost/property_tree/xml_parser.hpp>
#include <boost/algorithm/string.hpp>
#include <wx/sizer.h>
#include <wx/treebase.h>
#include <unordered_map>
#include <array>
#include <wx/treectrl.h>
#include <wx/dcclient.h>
//*)
//helper functions
enum wxbuildinfoformat {
short_f, long_f
};
wxString wxbuildinfo(wxbuildinfoformat format)
{
wxString wxbuild(wxVERSION_STRING);
if (format == long_f)
{
#if defined(__WXMSW__)
wxbuild << _T("-Windows");
#elif defined(__UNIX__)
wxbuild << _T("-Linux");
#endif
#if wxUSE_UNICODE
wxbuild << _T("-Unicode build");
#else
wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
}
return wxbuild;
}
//(*IdInit(MachineLearningLinkerFrame)
const long MachineLearningLinkerFrame::ID_MENUITEM1 = wxNewId();
const long MachineLearningLinkerFrame::idMenuAbout = wxNewId();
const long MachineLearningLinkerFrame::ID_STATUSBAR1 = wxNewId();
//*)
BEGIN_EVENT_TABLE(MachineLearningLinkerFrame, wxFrame)
//(*EventTable(MachineLearningLinkerFrame)
EVT_PAINT(MachineLearningLinkerFrame::on_paint)
//*)
END_EVENT_TABLE()
MachineLearningLinkerFrame::MachineLearningLinkerFrame(wxWindow* parent, wxWindowID id)
{
//(*Initialize(MachineLearningLinkerFrame)
wxMenu* Menu1;
wxMenu* Menu2;
wxMenuBar* MenuBar1;
wxMenuItem* MenuItem1;
wxMenuItem* MenuItem2;
wxPanel* mainPanel;
wxBoxSizer* verticalSizer = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* horizontalSizer = new wxBoxSizer(wxHORIZONTAL);
wxPaintDC* wxPaint;
Create(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("wxID_ANY"));
SetClientSize(wxSize(529, 450));
mainPanel = new wxPanel(this, wxID_ANY);
wxPaint = new wxPaintDC(mainPanel);
mainPanel->SetSizer(verticalSizer);
verticalSizer->Add(horizontalSizer, 1, wxEXPAND | wxALL, 10);
MenuBar1 = new wxMenuBar();
Menu1 = new wxMenu();
MenuItem1 = new wxMenuItem(Menu1, ID_MENUITEM1, _("Quit\tAlt-F4"), _("Quit the application"), wxITEM_NORMAL);
Menu1->Append(MenuItem1);
MenuBar1->Append(Menu1, _("&File"));
Menu2 = new wxMenu();
MenuItem2 = new wxMenuItem(Menu2, idMenuAbout, _("About\tF1"), _("Show info about this application"), wxITEM_NORMAL);
Menu2->Append(MenuItem2);
MenuBar1->Append(Menu2, _("Help"));
SetMenuBar(MenuBar1);
StatusBar1 = new wxStatusBar(this, ID_STATUSBAR1, 0, _T("ID_STATUSBAR1"));
int __wxStatusBarWidths_1[1] = { -1 };
int __wxStatusBarStyles_1[1] = { wxSB_NORMAL };
StatusBar1->SetFieldsCount(1, __wxStatusBarWidths_1);
StatusBar1->SetStatusStyles(1, __wxStatusBarStyles_1);
SetStatusBar(StatusBar1);
wxListCtrl* list;
list = new wxListCtrl(mainPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_LIST);
wxTreeCtrl* treeList;
treeList = new wxTreeCtrl(mainPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize);
treeList->AddRoot("Pavneet");
horizontalSizer->Add(list, 2, wxEXPAND | wxALL, 10);
horizontalSizer->Add(treeList, 1, wxEXPAND | wxALL, 10);
boost::property_tree::ptree pt1;
boost::property_tree::ptree pt2;
boost::property_tree::read_xml("C:/Users/pavne/Downloads/model_meta_data.xml", pt1);
std::string text = pt1.get_child("ModelMetaData").get_child("categories").get_value<std::string>();
std::vector<std::string> results;
boost::split(results, text, [](char c)
{
return c == ',';
}
);
for (int i = 0; i < 3; i++)
{
list->InsertItem(i, results[i]);
}
Connect(ID_MENUITEM1, wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction)& MachineLearningLinkerFrame::OnQuit);
Connect(idMenuAbout, wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction)& MachineLearningLinkerFrame::OnAbout);
//*)
}
MachineLearningLinkerFrame::~MachineLearningLinkerFrame()
{
//(*Destroy(MachineLearningLinkerFrame)
//*)
}
void MachineLearningLinkerFrame::OnQuit(wxCommandEvent& event)
{
Close();
}
void MachineLearningLinkerFrame::OnAbout(wxCommandEvent& event)
{
wxString msg = wxbuildinfo(long_f);
wxMessageBox(msg, _("Welcome to..."));
}
void MachineLearningLinkerFrame::on_paint(wxPaintEvent& WXUNUSED(event))
{
}