Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
studylogs.h
1/*
2** Copyright 2007-2024, RTE (https://www.rte-france.com)
3** See AUTHORS.txt
4** SPDX-License-Identifier: MPL-2.0
5** This file is part of Antares-Simulator,
6** Adequacy and Performance assessment for interconnected energy networks.
7**
8** Antares_Simulator is free software: you can redistribute it and/or modify
9** it under the terms of the Mozilla Public Licence 2.0 as published by
10** the Mozilla Foundation, either version 2 of the License, or
11** (at your option) any later version.
12**
13** Antares_Simulator is distributed in the hope that it will be useful,
14** but WITHOUT ANY WARRANTY; without even the implied warranty of
15** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16** Mozilla Public Licence 2.0 for more details.
17**
18** You should have received a copy of the Mozilla Public Licence 2.0
19** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20*/
21#ifndef __ANTARES_APPLICATION_WINDOWS_STUDY_LOGS_H__
22#define __ANTARES_APPLICATION_WINDOWS_STUDY_LOGS_H__
23
24#include <mutex>
25#include <antares/study/study.h>
26#include <yuni/core/event.h>
27
28#include <wx/htmllbox.h>
29#include <wx/html/htmlwin.h>
30#include <wx/stattext.h>
31#include <wx/timer.h>
32#include <wx/treectrl.h>
33
34#include "../application/study.h"
35#include "../toolbox/components/datagrid/renderer/logfile.h"
36#include <ui/common/component/frame/local-frame.h>
37#include <ui/common/component/spotlight.h>
38
39namespace Antares
40{
41namespace Window
42{
43class CompareDesc final
44{
45public:
46 bool operator()(const wxString& s1, const wxString& s2) const;
47};
48
49using MapFileList = std::map<wxString, YString, CompareDesc>;
50
51class StudyLogs;
53{
54public:
56 using Ptr = std::shared_ptr<FileListProvider>;
57
58 explicit FileListProvider(StudyLogs& frame);
59 ~FileListProvider() override;
60
61 FileListProvider(const FileListProvider&) = delete;
62 FileListProvider& operator=(const FileListProvider&) = delete;
63
64 void search(Spotlight::IItem::Vector& out,
65 const Spotlight::SearchToken::Vector& tokens,
66 const Yuni::String& text = "") override;
67 bool onSelect(Spotlight::IItem::Ptr& item) override;
68 bool onSelect(const Spotlight::IItem::Vector&) override;
69 void refreshFileList(bool showAll);
70
71private:
72 StudyLogs& pFrame;
74 bool pAutoTriggerSelection;
75 bool pShowAll;
76 MapFileList pAllSimuLogs;
77 MapFileList pAllUILogs;
78 std::shared_ptr<wxBitmap> pBmpFile;
79}; // class FileListProvider
80
82{
83public:
86
87 class LogFilenameInfo final
88 {
89 public:
91 struct ltstr final
92 {
93 bool operator()(const Yuni::String& s1, const Yuni::String& s2) const
94 {
95 return s2 < s1;
96 }
97 };
98
100 using Map = std::map<Yuni::String, LogFilenameInfo, ltstr>;
101
102 public:
104 wxString html;
105 wxClientData* clientData;
106 };
107
108public:
109 // \name Constructors & Destructor
111
114 StudyLogs(wxFrame* parent);
116 virtual ~StudyLogs();
118
119 void refreshListOfAllAvailableLogs();
120
121 void loadFromFile(const Yuni::String& filename);
122
123 const Yuni::String& lastLogFile() const
124 {
125 return pLastLogFile;
126 }
127
128 void reloadFromData(LogEntryContainer::Ptr entries, LogEntryContainer::Ptr errors);
129
130private:
134 void onButtonRefreshFileList(void*);
138 void onReloadLogFile(void*);
139
143 void onClose(wxCloseEvent& evt);
144
148 void enterLoadingMode(const Yuni::String& filename);
149
150 void onChangeShowAllAdvanced(wxCommandEvent&);
151
152private:
154 Yuni::String pLastLogFile;
156 Component::Button* pBtnLogFilenameRefresh;
158 wxStaticText* pTxtFromFolder;
162 Component::Datagrid::Component* pLogDisplayErrors;
164 Component::Notebook* pNotebook;
165
169 Component::Datagrid::Renderer::LogFile* pRendererEntriesErrors;
176 wxSplitterWindow* pSplitter;
177
179 bool pCanCloseTheWindow;
180
182 LogFilenameInfo::Map pLogFilenameInfo;
183
184 std::mutex pLoadingMutex;
185
187 bool pShowAllLogsFiles;
188
189 FileListProvider::Ptr mProvider;
190
192 Yuni::Event<void(bool)> onRefreshListOfFiles;
193
194 // Event Table
195 DECLARE_EVENT_TABLE()
196
197}; // class StudyLogs
198
199} // namespace Window
200} // namespace Antares
201
202#endif // __ANTARES_APPLICATION_WINDOWS_STUDY_LOGS_H__
Definition button.h:34
A datagrid with virtual values.
Definition component.h:84
std::shared_ptr< LogEntryContainer > Ptr
The most suitable smart pointer for the class.
Definition logfile.h:86
Definition local-frame.h:36
Notebook.
Definition notebook.h:38
Data Provider.
Definition spotlight.h:31
Definition spotlight.h:40
Definition studylogs.h:44
Definition studylogs.h:53
std::map< Yuni::String, LogFilenameInfo, ltstr > Map
Map.
Definition studylogs.h:100
wxString html
The html display code.
Definition studylogs.h:104
Definition studylogs.h:82
StudyLogs(wxFrame *parent)
Constructor with a parent window and a study.
Definition studylogs.cpp:654
virtual ~StudyLogs()
Destructor.
Definition studylogs.cpp:806
Comparison.
Definition studylogs.h:92