MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / OnInit

Method OnInit

lib/mdflib/mdfviewer/src/mdfviewer.cpp:61–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59wxEND_EVENT_TABLE()
60
61bool MdfViewer::OnInit() {
62
63 if (!wxApp::OnInit()) {
64 return false;
65 }
66
67 // Setup correct localization when formatting date and times
68 boost::locale::generator gen;
69 std::locale::global(gen(""));
70
71 // Setup system basic configuration
72 SetVendorDisplayName("MdfLib");
73 SetVendorName("MdfLib");
74 SetAppName("MdfViewer");
75 SetAppDisplayName("MDF File Viewer");
76
77 // Set up the log file.
78 auto& log_config = LogConfig::Instance();
79 log_config.Type(LogType::LogToFile);
80 log_config.SubDir("mdflib/log");
81 log_config.BaseName("mdfviewer");
82 log_config.CreateDefaultLogger();
83 LOG_INFO() << "Log File created. Path: " << log_config.GetLogFile();
84
85 MdfLogStream::SetLogFunction1(LogFunc);
86 notepad_ = util::log::FindNotepad();
87
88 // Find the path to the 'gnuplot.exe'
89 try {
90 auto gp = boost::process::environment::find_executable("gnuplot");
91 gnuplot_ = gp.string();
92 LOG_INFO() << "GnuPlot found. Path: " << gnuplot_;
93 } catch(const std::exception& ) {
94 gnuplot_.clear();
95 LOG_INFO() << "GnuPlot was not found.";
96 }
97
98 // Create a temporary directory for this app
99 try {
100 auto temp_dir = std::filesystem::temp_directory_path();
101 auto unique = boost::filesystem::unique_path("MdfViewer%%%%");
102 temp_dir.append(unique.string());
103 std::filesystem::remove_all(temp_dir);
104 std::filesystem::create_directories(temp_dir);
105 my_temp_dir_ = temp_dir.string();
106 LOG_INFO() << "Create a temporary directory. Path: " << my_temp_dir_;
107 } catch (const std::exception& error) {
108 LOG_ERROR() << "Error when creating temporary directory. Error:" << error.what();
109 }
110
111 auto* app_config = wxConfig::Get();
112 wxPoint start_pos;
113 app_config->Read("/MainWin/X",&start_pos.x, wxDefaultPosition.x);
114 app_config->Read("/MainWin/Y",&start_pos.y, wxDefaultPosition.x);
115 wxSize start_size;
116 app_config->Read("/MainWin/XWidth",&start_size.x, 1200);
117 app_config->Read("/MainWin/YWidth",&start_size.y, 800);
118 bool maximized = false;

Callers

nothing calls this directly

Calls 9

FindNotepadFunction · 0.85
SubDirMethod · 0.80
BaseNameMethod · 0.80
CreateDefaultLoggerMethod · 0.80
GetLogFileMethod · 0.80
TypeMethod · 0.45
clearMethod · 0.45
appendMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected