Antares Simulator
Power System Simulator
study.h
1 /*
2 ** Copyright 2007-2025, 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_STUDY_H__
22 #define __ANTARES_APPLICATION_STUDY_H__
23 
24 #include <yuni/yuni.h>
25 #include "../toolbox/wx-wrapper.h"
26 #include <antares/study/study.h>
27 #include <antares/study/output.h>
28 #include <yuni/core/event.h>
29 #include <list>
30 #include <antares/locator/locator.h>
31 
32 #include "ui/simulator/toolbox/components/map/settings.h"
33 
34 namespace Antares
35 {
36 enum SaveResult
37 {
38  svsError = 0,
39  svsSaved,
40  svsDiscard,
41  svsCancel
42 };
43 
47 extern wxString gLastOpenedStudyFolder;
48 
52 void NewStudy();
53 
59 void OpenStudyFromFolder(wxString folder);
60 
64 SaveResult SaveStudy();
65 
69 SaveResult SaveStudyAs(const Yuni::String& path, bool copyoutput, bool copyuserdata, bool copylogs);
70 
74 void SetCurrentStudy(std::shared_ptr<Data::Study> study);
75 
79 std::shared_ptr<Data::Study> GetCurrentStudy();
80 
84 bool CurrentStudyIsValid();
85 
86 
90 SaveResult ExportMap(const Yuni::String& path,
91  bool transparentBackground,
92  const wxColour& backgroundColor,
93  const std::list<uint16_t>& layers,
94  int nbSplitParts,
95  Antares::Map::mapImageFormat format);
96 
102 bool CloseTheStudy(bool updateGUI = true);
103 
107 bool CheckIfInsideAStudyFolder(const AnyString& path, bool quiet = false);
108 
118 void RunSimulationOnTheStudy(Data::Study::Ptr study,
119  const YString& simuName,
120  const YString& simuComments,
121  bool ignoreWarnings,
122  Solver::Feature features = Solver::standard,
123  bool preproOnly = false,
124  const std::string& solverName = "sirius");
125 
129 void UpdateGUIFromStudyState();
130 
134 bool StudyRenameArea(Data::Area* area, const AnyString& newname, Data::Study* study = nullptr);
135 
139 void MarkTheStudyAsModified();
140 
144 void MarkTheStudyAsModified(const Data::Study::Ptr& study);
145 
146 void ResetTheModifierState(bool v);
147 
154 bool StudyHasBeenModified();
155 
163 uint64_t StudyInMemoryRevisionID();
164 
168 void RefreshListOfOutputsForTheCurrentStudy();
169 
170 void StudyRefreshCalendar();
171 
173 
174 
179 extern Yuni::Event<void()> OnStudyLoaded;
180 
186 extern Yuni::Event<void()> OnStudyClosed;
187 
191 extern Yuni::Event<void()> OnStudySaved;
192 
196 extern Yuni::Event<void()> OnStudySavedAs;
197 
202 extern Yuni::Event<void(Data::Study&)> OnStudyChanged;
203 
207 extern Yuni::Event<void()> OnStudyAreasChanged;
208 
209 extern Yuni::Event<void()> OnStudySettingsChanged;
210 
214 extern Yuni::Event<void(const Data::Output::List&, const Data::Output::Ptr)>
215  OnStudyUpdateOutputInfo;
216 
220 extern Yuni::Event<void(Data::Area*)> OnStudyAreaRename;
221 
225 extern Yuni::Event<void(Data::Area*)> OnStudyAreaAdded;
226 
230 extern Yuni::Event<void(Data::Area*)> OnStudyAreaDelete;
231 
238 extern Yuni::Event<void(Data::Area*)> OnStudyAreaColorChanged;
239 
243 extern Yuni::Event<void(Data::AreaLink*)> OnStudyLinkAdded;
244 
248 extern Yuni::Event<void(Data::AreaLink*)> OnStudyLinkDelete;
249 
253 extern Yuni::Event<void(Data::AreaLink*)> OnStudyLinkChanged;
254 
258 extern Yuni::Event<void(Data::BindingConstraint*)> OnStudyConstraintAdded;
259 
263 extern Yuni::Event<void(Data::BindingConstraint*)> OnStudyConstraintDelete;
264 
268 extern Yuni::Event<void(Data::BindingConstraint*)> OnStudyConstraintModified;
269 
275 extern Yuni::Event<void()> OnStudyNodalOptimizationChanged;
276 
280 extern Yuni::Event<void()> OnStudySimulationSettingsChanged;
281 
285 extern Yuni::Event<void()> OnStudyUpdatePlaylist;
286 
290 extern Yuni::Event<void()> OnStudyReloadAllComponentsWithJITData;
291 
297 extern Yuni::Event<void()> OnStudyThermalClusterCommonSettingsChanged;
298 
299 extern Yuni::Event<void(Data::ThermalCluster*)> OnStudyThermalClusterRenamed;
300 extern Yuni::Event<void(Data::Area*)> OnStudyThermalClusterGroupChanged;
301 
307 extern Yuni::Event<void()> OnStudyRenewableClusterCommonSettingsChanged;
308 
309 extern Yuni::Event<void(Data::RenewableCluster*)> OnStudyRenewableClusterRenamed;
310 extern Yuni::Event<void(Data::Area*)> OnStudyRenewableClusterGroupChanged;
311 
317 extern Yuni::Event<void()> OnStudyScenarioBuilderDataAreLoaded;
318 
326 extern Yuni::Event<void()> OnStudyBeginUpdate;
332 extern Yuni::Event<void()> OnStudyEndUpdate;
333 
335 extern Yuni::Event<void(const void*)> OnInspectorRefresh;
336 
338 extern Yuni::Event<void()> OnMainNotebookChanged;
340 
342 extern Yuni::Event<void()> OnLayerNodeUIChanged;
344 
346 extern Yuni::Event<void(const wxString*)> OnMapLayerChanged;
348 
349 extern Yuni::Event<void(const wxString*)> OnMapLayerAdded;
350 extern Yuni::Event<void(const wxString*)> OnMapLayerRemoved;
351 extern Yuni::Event<void(const wxString*)> OnMapLayerRenamed;
352 
354 //
355 // You should not have to call these routines yourselves
357 void MemoryFlushBeginUpdate();
360 void MemoryFlushEndUpdate();
362 bool CanPerformMemoryFlush();
364 
365 extern bool SystemParameterHaveChanged;
366 
370 extern bool GUIFlagInvalidateAreas;
371 
373 extern Antares::Data::Output::List ListOfOutputsForTheCurrentStudy;
374 
378 extern Yuni::String LastPathForOpeningAFile;
379 
384 class StudyUpdateLocker final
385 {
386 public:
388  {
389  OnStudyBeginUpdate();
390  }
392  {
393  OnStudyEndUpdate();
394  }
395 };
396 
400 class MemoryFlushLocker final
401 {
402 public:
404  {
405  MemoryFlushBeginUpdate();
406  }
408  {
409  MemoryFlushEndUpdate();
410  }
411 };
412 
413 } // namespace Antares
414 
415 #endif // __ANTARES_APPLICATION_STUDY_H__
Definition for a single area.
Definition: area.h:51
Definition: BindingConstraint.h:49
std::list< Ptr > List
List.
Definition: output.h:43
std::shared_ptr< Output > Ptr
Smartptr.
Definition: output.h:41
Definition: cluster.h:40
Definition: study.h:57
A single thermal cluster.
Definition: cluster.h:76
Avoid the execution of a memory flush.
Definition: study.h:401
Avoid the use of the data related to a study for the lifetime of the object (RAII)
Definition: study.h:385