diff options
author | Thales Lima Oliveira <thaleslima.ufu@gmail.com> | 2020-06-09 18:33:54 -0300 |
---|---|---|
committer | Thales Lima Oliveira <thaleslima.ufu@gmail.com> | 2020-06-09 18:33:54 -0300 |
commit | 5e68e62fb23f15f26e24823bf21b012ab4dfd1e0 (patch) | |
tree | 6ea2989fbcee7eeb1fa8ee9ebe946a8de1be1e82 | |
parent | c5636d2031b20e673441e095d90ba94942698e7c (diff) | |
download | PSP.git-5e68e62fb23f15f26e24823bf21b012ab4dfd1e0.tar.gz PSP.git-5e68e62fb23f15f26e24823bf21b012ab4dfd1e0.tar.xz PSP.git-5e68e62fb23f15f26e24823bf21b012ab4dfd1e0.zip |
Control Editor device context draw imp init
-rw-r--r-- | Project/ControlEditor.h | 6 | ||||
-rw-r--r-- | Project/ControlEditorDC.cpp | 31 | ||||
-rw-r--r-- | Project/ControlEditorDC.h | 24 | ||||
-rw-r--r-- | Project/Project.project | 2 | ||||
-rw-r--r-- | Project/WorkspaceDC.cpp | 4 | ||||
-rw-r--r-- | Project/compile_flags.txt | 11 |
6 files changed, 70 insertions, 8 deletions
diff --git a/Project/ControlEditor.h b/Project/ControlEditor.h index fbd8f79..3f77422 100644 --- a/Project/ControlEditor.h +++ b/Project/ControlEditor.h @@ -138,7 +138,7 @@ class ControlEditor : public ControlEditorBase virtual void SetElementsList(std::vector<ControlElement*> elementList) { m_elementList = elementList; } virtual void SetConnectionsList(std::vector<ConnectionLine*> connectionList) { m_connectionList = connectionList; } virtual void SetControlContainer(ControlElementContainer* ctrlContainer) { m_ctrlContainer = ctrlContainer; } - protected: + virtual void OnClose(wxCloseEvent& event); virtual void OnTestClick(wxCommandEvent& event); virtual void OnButtonOKClick(wxCommandEvent& event) { Close(); } @@ -155,8 +155,10 @@ class ControlEditor : public ControlEditorBase virtual void OnMouseMotion(wxMouseEvent& event); virtual void OnPaint(wxPaintEvent& event); virtual void LeftClickDown(wxMouseEvent& event); - + void BuildControlElementPanel(); + + protected: void SetViewport(); int GetNextID(); diff --git a/Project/ControlEditorDC.cpp b/Project/ControlEditorDC.cpp new file mode 100644 index 0000000..84e212d --- /dev/null +++ b/Project/ControlEditorDC.cpp @@ -0,0 +1,31 @@ +#include "ControlEditorDC.h" +#include "Camera.h" + +ControlEditorDC::ControlEditorDC(wxWindow* parent, int ioflags) : ControlEditor(parent, nullptr, ioflags) +{ + BuildControlElementPanel(); + m_camera = new Camera(); + m_selectionRect = wxRect2DDouble(0, 0, 0, 0); + // m_camera->SetScale(1.2); + m_ioFlags = ioflags; + + this->GetSizer()->Remove(this->GetSizer()->GetChildren()[0]->GetId()); // remove m_glCanvas object from sizer + + delete m_glCanvas; // Delete GLCanvas to allow drawing with wxDC + m_glCanvas = nullptr; + SetBackgroundColour(wxColour(255, 255, 255)); + SetBackgroundStyle(wxBG_STYLE_PAINT); // To allow wxBufferedPaintDC works properly. + Redraw(); +} + +ControlEditorDC::~ControlEditorDC() +{ + // Recreate the GLCanvas. This is necessary to prevent WorkspaceBase destructor access nullpr. + // Also avoid the code editing of WorkspaceBase, since is automatically generated by wxCrafter. + // TODO(?): Find a better way to solve this problem. + m_glCanvas = new wxGLCanvas(this); +} + +void ControlEditorDC::OnPaint(wxPaintEvent& event) +{ +} diff --git a/Project/ControlEditorDC.h b/Project/ControlEditorDC.h new file mode 100644 index 0000000..74e509a --- /dev/null +++ b/Project/ControlEditorDC.h @@ -0,0 +1,24 @@ +#ifndef CONTROLEDITORDC_H +#define CONTROLEDITORDC_H + +#include "ControlEditor.h" + +#include <wx/graphics.h> +#include <wx/dcbuffer.h> + +class ControlEditorDC : public ControlEditor +{ +public: + ControlEditorDC(wxWindow* parent, + int ioflags = IOControl::IN_TERMINAL_VOLTAGE | IOControl::IN_VELOCITY | IOControl::OUT_FIELD_VOLTAGE | + IOControl::OUT_MEC_POWER); + ~ControlEditorDC(); + + virtual void Redraw() { this->Refresh(); } + +protected: + virtual void OnPaint(wxPaintEvent& event); + virtual void OnIdle(wxIdleEvent& event) {} // Prevent OpenGL checks +}; + +#endif // CONTROLEDITORDC_H diff --git a/Project/Project.project b/Project/Project.project index 25c00fe..5acb911 100644 --- a/Project/Project.project +++ b/Project/Project.project @@ -124,6 +124,7 @@ <File Name="Workspace.cpp"/> </VirtualDirectory> <VirtualDirectory Name="simulation GUI"> + <File Name="ControlEditorDC.cpp"/> <File Name="StabilityEventList.cpp"/> <File Name="ChartView.cpp"/> <File Name="ControlEditor.cpp"/> @@ -258,6 +259,7 @@ <File Name="Workspace.h"/> </VirtualDirectory> <VirtualDirectory Name="simulation GUI"> + <File Name="ControlEditorDC.h"/> <File Name="StabilityEventList.h"/> <File Name="ChartView.h"/> <File Name="ControlEditor.h"/> diff --git a/Project/WorkspaceDC.cpp b/Project/WorkspaceDC.cpp index 947b248..1333314 100644 --- a/Project/WorkspaceDC.cpp +++ b/Project/WorkspaceDC.cpp @@ -65,10 +65,6 @@ WorkspaceDC::WorkspaceDC(wxWindow* parent, wxString name, wxStatusBar* statusBar this->GetSizer()->Remove(this->GetSizer()->GetChildren()[0]->GetId()); // remove m_glCanvas object from sizer - //for (int i = 0; i < this->GetSizer()->GetChildren().GetCount(); ++i) { - //wxMessageBox(wxString::Format("%d", this->GetSizer()->GetChildren()[i]->GetId())); - //} - delete m_glCanvas; // Delete GLcanvas to allow drawing with wxDC m_glCanvas = nullptr; SetBackgroundColour(wxColour(255, 255, 255)); diff --git a/Project/compile_flags.txt b/Project/compile_flags.txt index 2bba831..9ea7d4d 100644 --- a/Project/compile_flags.txt +++ b/Project/compile_flags.txt @@ -1,4 +1,10 @@ --IC:\Users\thale\Documents\GitHub\PSP\Project +-IC:\mingw64\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++ +-IC:\mingw64\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\x86_64-w64-mingw32 +-IC:\mingw64\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\backward +-IC:\mingw64\lib\gcc\x86_64-w64-mingw32\8.1.0\include +-IC:\mingw64\lib\gcc\x86_64-w64-mingw32\8.1.0\include-fixed +-IC:\mingw64\x86_64-w64-mingw32\include +-IC:\Users\andre\Documents\GitHub\PSP\Project -IC:\wxWidgets-3.1.3\lib\gcc_dll\mswu -IC:\wxWidgets-3.1.3\include -D_UNICODE @@ -7,5 +13,6 @@ -D__WXMSW__ -DNDEBUG -DUNICODE +-std=c++11 -target -i686-pc-windows-gnu +x86_64-pc-windows-gnu |