107 enum class WorkspaceMode :
int {
114 MODE_DRAG_INSERT_TEXT,
123 Workspace(wxWindow* parent, wxString name = wxEmptyString, wxStatusBar* statusBar =
nullptr, wxAuiNotebook* auiNotebook =
nullptr);
126 void SetColourTheme();
127 wxString GetName()
const {
return m_name; }
128 std::vector<Element*> GetElementList()
const;
129 std::vector< std::shared_ptr<PowerElement> > GetElementSharedList()
const {
return m_elementList; }
130 std::vector< std::shared_ptr<Text> > GetTextList()
const {
return m_textList; }
131 std::vector<Element*> GetAllElements()
const;
132 WorkspaceMode GetWorkspaceMode()
const {
return m_mode; }
133 Camera* GetCamera()
const {
return m_camera; }
134 void CopySelection();
136 void SaveCurrentState();
138 void SetPreviousState();
139 void CopyToClipboard();
140 void ExportAsSVG(wxString path);
142 wxFileName GetSavedPath()
const {
return m_savedPath; }
143 void SetName(wxString name);
144 void SetElementList(std::vector< std::shared_ptr<PowerElement> > elementList);
145 void SetElementList(std::vector<Element*> elementList);
146 void SetTextList(
const std::vector< std::shared_ptr<Text> >& textList);
147 void SetStatusBarText(wxString text) { m_statusBar->SetStatusText(text); }
148 void SetWorkspaceMode(WorkspaceMode mode) { m_mode = mode; }
149 void SetSavedPath(wxFileName savedPath) { m_savedPath = savedPath; }
150 void SetJustOpened(
bool justOpened) { m_justOpened = justOpened; }
152 virtual void Redraw() { m_workspacePanel->Refresh(); }
154 void RotateSelectedElements(
bool clockwise =
true);
155 void DeleteSelectedElements();
156 bool GetElementsCorners(wxPoint2DDouble& leftUpCorner,
157 wxPoint2DDouble& rightDownCorner,
158 std::vector<Element*> elementList);
161 void EnableHeatMap(
const bool& enable =
true);
162 bool IsHeatMapEnable()
const {
return m_showHM; }
163 HMPlane* GetHeatMap()
const {
return m_hmPlane; }
164 void EnableAutoHeatMapLabel(
const bool& enable =
true) { m_hmAutomaticLabel = enable; }
165 bool IsHeatMapAutoLabelEnable()
const {
return m_hmAutomaticLabel; }
169 bool InsertTextElement(
int textID,
Element* parentElement, ElectricalUnit unit = ElectricalUnit::UNIT_NONE,
int precision = 2);
171 void RemoveAllTextElements();
173 void CheckSlackBusDuplication(
Element* newSlackBus);
175 void ValidateBusesVoltages(
Element* initialBus);
176 void ValidateElementsVoltages();
178 void UpdateElementsID();
179 bool UpdateTextElements();
180 void UpdateHeatMap();
182 int GetElementNumber(ElementID elementID) {
return m_elementNumber[elementID]; }
183 void IncrementElementNumber(ElementID elementID) { m_elementNumber[elementID]++; }
185 std::vector<double> GetStabilityTimeVector()
const {
return m_stabilityTimeVector; }
186 bool IsContinuousCalculationActive()
const {
return m_continuousCalc; }
187 void SetContinuousCalculationActive(
bool value =
true) { m_continuousCalc = value; }
188 void ResetAllVoltages();
189 bool RunPowerFlow(
bool resetVoltages =
false,
bool showBusyInfo =
true);
192 bool RunStaticStudies();
194 bool RunHarmonicDistortion(
bool runPowerFlowBefore =
true);
195 bool RunFrequencyResponse();
197 virtual void OnMiddleDoubleClick(wxMouseEvent& event);
198 virtual void OnIdle(wxIdleEvent& event);
199 virtual void OnTimer(wxTimerEvent& event);
200 virtual void OnLeftDoubleClick(wxMouseEvent& event);
201 virtual void OnRightClickDown(wxMouseEvent& event);
202 virtual void OnLeftClickUp(wxMouseEvent& event);
203 virtual void OnScroll(wxMouseEvent& event);
204 virtual void OnMiddleDown(wxMouseEvent& event);
205 virtual void OnMiddleUp(wxMouseEvent& event);
206 virtual void OnMouseMotion(wxMouseEvent& event);
207 virtual void OnKeyDown(wxKeyEvent& event);
208 virtual void OnLeftClickDown(wxMouseEvent& event);
209 virtual void OnPaint(wxPaintEvent& event);
210 virtual void OnPopupClick(wxCommandEvent& event);
211 virtual void OnResize(wxSizeEvent& event);
214 virtual void OnHeatMapTime(wxTimerEvent& event);
217 void UpdateStatusBar();
218 int GetElementNumberFromList(
Element* element);
219 void GetStateListsCopy(
const std::vector< std::shared_ptr<PowerElement> >& elementsList,
220 const std::vector< std::shared_ptr<Text> >& textList,
221 std::vector< std::shared_ptr<PowerElement> >& elementsListCopy,
222 std::vector< std::shared_ptr<Text> >& textListCopy);
224 void DrawScene(wxGraphicsContext* gc);
225 void DrawScene(wxDC& dc);
228 wxStatusBar* m_statusBar =
nullptr;
229 wxAuiNotebook* m_auiNotebook =
nullptr;
230 Camera* m_camera =
nullptr;
231 wxTipWindow::Ref m_tipWindow;
234 WorkspaceMode m_mode = WorkspaceMode::MODE_EDIT;
235 WorkspaceMode m_oldStatusMode = WorkspaceMode::MODE_EDIT;
238 std::vector< std::shared_ptr<PowerElement> > m_elementList;
239 int m_elementNumber[NUM_ELEMENTS];
242 std::vector< std::shared_ptr<Text> > m_textList;
245 std::vector< std::vector< std::shared_ptr<PowerElement> > > m_elementListState;
247 std::vector< std::vector< std::shared_ptr<Text> > > m_textListState;
248 int m_currenteState = -1;
249 int m_maxStates = 100;
251 wxFileName m_savedPath;
253 wxRect2DDouble m_selectionRect;
254 wxPoint2DDouble m_startSelRect;
258 std::vector<double> m_stabilityTimeVector;
260 bool m_continuousCalc =
false;
261 bool m_disconnectedElement =
false;
262 bool m_justOpened =
false;
265 float m_height = 0.0;
272 bool m_showHM =
false;
273 bool m_showHMTimer =
false;
274 bool m_hmAutomaticLabel =
false;
276 std::unique_ptr<ControlEditorManager> m_CEMngr;
277 std::unique_ptr<ChartWindowManager> m_CWMngr;
Element that shows power element informations in workspace.