105 enum class WorkspaceMode :
int {
112 MODE_DRAG_INSERT_TEXT,
121 Workspace(wxWindow* parent, wxString name = wxEmptyString, wxStatusBar* statusBar =
nullptr, wxAuiNotebook* auiNotebook =
nullptr);
124 wxString GetName()
const {
return m_name; }
125 std::vector<Element*> GetElementList()
const;
126 std::vector< std::shared_ptr<PowerElement> > GetElementSharedList()
const {
return m_elementList; }
127 std::vector< std::shared_ptr<Text> > GetTextList()
const {
return m_textList; }
128 std::vector<Element*> GetAllElements()
const;
129 WorkspaceMode GetWorkspaceMode()
const {
return m_mode; }
130 Camera* GetCamera()
const {
return m_camera; }
131 void CopySelection();
133 void SaveCurrentState();
135 void SetPreviousState();
136 void CopyToClipboard();
137 void ExportAsSVG(wxString path);
139 wxFileName GetSavedPath()
const {
return m_savedPath; }
140 void SetName(wxString name);
141 void SetElementList(std::vector< std::shared_ptr<PowerElement> > elementList);
142 void SetElementList(std::vector<Element*> elementList);
143 void SetTextList(
const std::vector< std::shared_ptr<Text> >& textList);
144 void SetStatusBarText(wxString text) { m_statusBar->SetStatusText(text); }
145 void SetWorkspaceMode(WorkspaceMode mode) { m_mode = mode; }
146 void SetSavedPath(wxFileName savedPath) { m_savedPath = savedPath; }
147 void SetJustOpened(
bool justOpened) { m_justOpened = justOpened; }
149 virtual void Redraw() { m_workspacePanel->Refresh(); }
151 void RotateSelectedElements(
bool clockwise =
true);
152 void DeleteSelectedElements();
153 bool GetElementsCorners(wxPoint2DDouble& leftUpCorner,
154 wxPoint2DDouble& rightDownCorner,
155 std::vector<Element*> elementList);
158 void EnableHeatMap(
const bool& enable =
true);
159 bool IsHeatMapEnable()
const {
return m_showHM; }
160 HMPlane* GetHeatMap()
const {
return m_hmPlane; }
161 void EnableAutoHeatMapLabel(
const bool& enable =
true) { m_hmAutomaticLabel = enable; }
162 bool IsHeatMapAutoLabelEnable()
const {
return m_hmAutomaticLabel; }
163 bool InsertTextElement(
int textID,
Element* parentElement,
ElectricalUnit unit = ElectricalUnit::UNIT_NONE,
int precision = 2);
165 void RemoveAllTextElements();
166 void CheckSlackBusDuplication(
Element* newSlackBus);
168 void ValidateBusesVoltages(
Element* initialBus);
169 void ValidateElementsVoltages();
171 void UpdateElementsID();
172 bool UpdateTextElements();
173 void UpdateHeatMap();
175 int GetElementNumber(ElementID elementID) {
return m_elementNumber[elementID]; }
176 void IncrementElementNumber(ElementID elementID) { m_elementNumber[elementID]++; }
178 std::vector<double> GetStabilityTimeVector()
const {
return m_stabilityTimeVector; }
179 bool IsContinuousCalculationActive()
const {
return m_continuousCalc; }
180 void SetContinuousCalculationActive(
bool value =
true) { m_continuousCalc = value; }
181 void ResetAllVoltages();
182 bool RunPowerFlow(
bool resetVoltages =
false,
bool showBusyInfo =
true);
185 bool RunStaticStudies();
187 bool RunHarmonicDistortion(
bool runPowerFlowBefore =
true);
188 bool RunFrequencyResponse();
190 virtual void OnMiddleDoubleClick(wxMouseEvent& event);
191 virtual void OnIdle(wxIdleEvent& event);
192 virtual void OnTimer(wxTimerEvent& event);
193 virtual void OnLeftDoubleClick(wxMouseEvent& event);
194 virtual void OnRightClickDown(wxMouseEvent& event);
195 virtual void OnLeftClickUp(wxMouseEvent& event);
196 virtual void OnScroll(wxMouseEvent& event);
197 virtual void OnMiddleDown(wxMouseEvent& event);
198 virtual void OnMiddleUp(wxMouseEvent& event);
199 virtual void OnMouseMotion(wxMouseEvent& event);
200 virtual void OnKeyDown(wxKeyEvent& event);
201 virtual void OnLeftClickDown(wxMouseEvent& event);
202 virtual void OnPaint(wxPaintEvent& event);
203 virtual void OnPopupClick(wxCommandEvent& event);
204 virtual void OnResize(wxSizeEvent& event);
207 virtual void OnHeatMapTime(wxTimerEvent& event);
210 void UpdateStatusBar();
211 int GetElementNumberFromList(
Element* element);
212 void GetStateListsCopy(
const std::vector< std::shared_ptr<PowerElement> >& elementsList,
213 const std::vector< std::shared_ptr<Text> >& textList,
214 std::vector< std::shared_ptr<PowerElement> >& elementsListCopy,
215 std::vector< std::shared_ptr<Text> >& textListCopy);
217 void DrawScene(wxGraphicsContext* gc);
218 void DrawScene(wxDC& dc);
221 wxStatusBar* m_statusBar =
nullptr;
222 wxAuiNotebook* m_auiNotebook =
nullptr;
223 Camera* m_camera =
nullptr;
224 wxTipWindow* m_tipWindow =
nullptr;
227 WorkspaceMode m_mode = WorkspaceMode::MODE_EDIT;
228 WorkspaceMode m_oldStatusMode = WorkspaceMode::MODE_EDIT;
231 std::vector< std::shared_ptr<PowerElement> > m_elementList;
232 int m_elementNumber[NUM_ELEMENTS];
235 std::vector< std::shared_ptr<Text> > m_textList;
238 std::vector< std::vector< std::shared_ptr<PowerElement> > > m_elementListState;
240 std::vector< std::vector< std::shared_ptr<Text> > > m_textListState;
241 int m_currenteState = -1;
242 int m_maxStates = 100;
244 wxFileName m_savedPath;
246 wxRect2DDouble m_selectionRect;
247 wxPoint2DDouble m_startSelRect;
251 std::vector<double> m_stabilityTimeVector;
253 bool m_continuousCalc =
false;
254 bool m_disconnectedElement =
false;
255 bool m_justOpened =
false;
258 float m_height = 0.0;
265 bool m_showHM =
false;
266 bool m_showHMTimer =
false;
267 bool m_hmAutomaticLabel =
false;
Element that shows power element informations in workspace.