summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThales1330 <thaleslima.ufu@gmail.com>2017-01-25 19:45:45 -0200
committerThales1330 <thaleslima.ufu@gmail.com>2017-01-25 19:45:45 -0200
commit9f17be8af02011f04d188ce991921f6eb0ecf792 (patch)
tree16ee4a2ef24b55af7dfb02a50d57acc384c48526
parentbdb0625280d827ba7333b6fc9d6c6534e0720100 (diff)
downloadPSP.git-9f17be8af02011f04d188ce991921f6eb0ecf792.tar.gz
PSP.git-9f17be8af02011f04d188ce991921f6eb0ecf792.tar.xz
PSP.git-9f17be8af02011f04d188ce991921f6eb0ecf792.zip
Several graphic tools implemented, tf start
-rw-r--r--Project/ControlEditor.cpp123
-rw-r--r--Project/ControlEditor.h1
-rw-r--r--Project/ControlEditor.wxcp9
-rw-r--r--Project/ControlEditorBase.cpp4
-rw-r--r--Project/ControlEditorBase.h1
-rw-r--r--Project/Element.cpp2
-rw-r--r--Project/Element.h2
-rw-r--r--Project/PowerElement.cpp1
-rw-r--r--Project/PowerElement.h1
-rw-r--r--Project/Project.mk22
-rw-r--r--Project/Project.project2
-rw-r--r--Project/Project.txt2
-rw-r--r--Project/Text.cpp2
-rw-r--r--Project/TransferFunction.cpp53
-rw-r--r--Project/TransferFunction.h15
-rw-r--r--Project/Workspace.cpp10
16 files changed, 214 insertions, 36 deletions
diff --git a/Project/ControlEditor.cpp b/Project/ControlEditor.cpp
index f75478c..03cbfdf 100644
--- a/Project/ControlEditor.cpp
+++ b/Project/ControlEditor.cpp
@@ -197,7 +197,9 @@ void ControlEditor::AddElement(ControlElementButtonID id)
wxLogMessage("io");
} break;
case ID_TF: {
- wxLogMessage("tf");
+ m_mode = MODE_INSERT;
+ TransferFunction* tf = new TransferFunction();
+ m_elementList.push_back(tf);
} break;
case ID_SUM: {
wxLogMessage("sum");
@@ -233,6 +235,11 @@ void ControlEditor::OnPaint(wxPaintEvent& event)
glScaled(m_camera->GetScale(), m_camera->GetScale(), 0.0); // Scale
glTranslated(m_camera->GetTranslation().m_x, m_camera->GetTranslation().m_y, 0.0); // Translation
+ for(auto it = m_elementList.begin(), itEnd = m_elementList.end(); it != itEnd; ++it) {
+ Element* element = *it;
+ element->Draw(m_camera->GetTranslation(), m_camera->GetScale());
+ }
+
// Selection rectangle
glLineWidth(1.0);
glColor4d(0.0, 0.5, 1.0, 1.0);
@@ -254,14 +261,38 @@ void ControlEditor::OnPaint(wxPaintEvent& event)
m_glCanvas->SwapBuffers();
event.Skip();
}
+
void ControlEditor::OnDoubleClick(wxMouseEvent& event) {}
void ControlEditor::OnLeftClickDown(wxMouseEvent& event)
{
wxPoint2DDouble clickPoint = event.GetPosition();
+ bool foundElement = false;
+
+ if(m_mode == MODE_INSERT) {
+ m_mode = MODE_EDIT;
+ } else {
+ for(auto it = m_elementList.begin(), itEnd = m_elementList.end(); it != itEnd; ++it) {
+ Element* element = *it;
+
+ // Set movement initial position (not necessarily will be moved).
+ element->StartMove(m_camera->ScreenToWorld(clickPoint));
+
+ // Click in an element.
+ if(element->Contains(m_camera->ScreenToWorld(clickPoint))) {
+ if(!foundElement) {
+ element->SetSelected();
+ foundElement = true;
+ }
+ m_mode = MODE_MOVE_ELEMENT;
+ }
+ }
+ }
- m_mode = MODE_SELECTION_RECT;
- m_startSelRect = m_camera->ScreenToWorld(clickPoint);
+ if(!foundElement) {
+ m_mode = MODE_SELECTION_RECT;
+ m_startSelRect = m_camera->ScreenToWorld(clickPoint);
+ }
Redraw();
event.Skip();
@@ -269,16 +300,65 @@ void ControlEditor::OnLeftClickDown(wxMouseEvent& event)
void ControlEditor::OnLeftClickUp(wxMouseEvent& event)
{
+ for(auto it = m_elementList.begin(), itEnd = m_elementList.end(); it != itEnd; it++) {
+ Element* element = *it;
+ if(m_mode == MODE_SELECTION_RECT) {
+ if(element->Intersects(m_selectionRect)) {
+ element->SetSelected();
+ } else if(!event.ControlDown()) {
+ element->SetSelected(false);
+ }
+ } else if(!event.ControlDown()) {
+ if(!element->Contains(m_camera->ScreenToWorld(event.GetPosition()))) {
+ element->SetSelected(false);
+ }
+ }
+ }
+
+ m_selectionRect = wxRect2DDouble(0, 0, 0, 0);
if(m_mode != MODE_INSERT) {
m_mode = MODE_EDIT;
}
- m_selectionRect = wxRect2DDouble(0, 0, 0, 0);
+
Redraw();
event.Skip();
}
-void ControlEditor::OnMiddleDown(wxMouseEvent& event) {}
-void ControlEditor::OnMiddleUp(wxMouseEvent& event) {}
+void ControlEditor::OnMiddleDown(wxMouseEvent& event)
+{
+ // Set to drag mode.
+ switch(m_mode) {
+ case MODE_INSERT: {
+ m_mode = MODE_DRAG_INSERT;
+ } break;
+ case MODE_PASTE: {
+ m_mode = MODE_DRAG_PASTE;
+ } break;
+ default: {
+ m_mode = MODE_DRAG;
+ } break;
+ }
+ m_camera->StartTranslation(m_camera->ScreenToWorld(event.GetPosition()));
+}
+
+void ControlEditor::OnMiddleUp(wxMouseEvent& event)
+{
+ switch(m_mode) {
+ case MODE_DRAG_INSERT: {
+ m_mode = MODE_INSERT;
+ } break;
+ case MODE_DRAG_PASTE: {
+ m_mode = MODE_PASTE;
+ } break;
+ case MODE_INSERT:
+ case MODE_PASTE: {
+ // Does nothing.
+ } break;
+ default: {
+ m_mode = MODE_EDIT;
+ } break;
+ }
+}
void ControlEditor::OnMouseMotion(wxMouseEvent& event)
{
@@ -286,6 +366,26 @@ void ControlEditor::OnMouseMotion(wxMouseEvent& event)
bool redraw = false;
switch(m_mode) {
+ case MODE_INSERT: {
+ Element* newElement = *(m_elementList.end() - 1); // Get the last element in the list.
+ newElement->SetPosition(m_camera->ScreenToWorld(clickPoint));
+ redraw = true;
+ } break;
+ case MODE_DRAG:
+ case MODE_DRAG_INSERT:
+ case MODE_DRAG_PASTE: {
+ m_camera->SetTranslation(clickPoint);
+ redraw = true;
+ } break;
+ case MODE_MOVE_ELEMENT: {
+ for(auto it = m_elementList.begin(), itEnd = m_elementList.end(); it != itEnd; it++) {
+ Element* element = *it;
+ if(element->IsSelected()) {
+ element->Move(m_camera->ScreenToWorld(clickPoint));
+ redraw = true;
+ }
+ }
+ } break;
case MODE_SELECTION_RECT: {
wxPoint2DDouble currentPos = m_camera->ScreenToWorld(clickPoint);
double x, y, w, h;
@@ -310,6 +410,17 @@ void ControlEditor::OnMouseMotion(wxMouseEvent& event)
default:
break;
}
+
if(redraw) Redraw();
event.Skip();
}
+
+void ControlEditor::OnScroll(wxMouseEvent& event)
+{
+ if(event.GetWheelRotation() > 0)
+ m_camera->SetScale(event.GetPosition(), +0.05);
+ else
+ m_camera->SetScale(event.GetPosition(), -0.05);
+
+ Redraw();
+}
diff --git a/Project/ControlEditor.h b/Project/ControlEditor.h
index e121690..0652e1d 100644
--- a/Project/ControlEditor.h
+++ b/Project/ControlEditor.h
@@ -63,6 +63,7 @@ public:
virtual void Redraw() { m_glCanvas->Refresh(); }
protected:
+ virtual void OnScroll(wxMouseEvent& event);
virtual void OnDoubleClick(wxMouseEvent& event);
virtual void OnLeftClickDown(wxMouseEvent& event);
virtual void OnLeftClickUp(wxMouseEvent& event);
diff --git a/Project/ControlEditor.wxcp b/Project/ControlEditor.wxcp
index b587276..a0f5e46 100644
--- a/Project/ControlEditor.wxcp
+++ b/Project/ControlEditor.wxcp
@@ -773,7 +773,7 @@
"m_closeButton": false,
"m_minButton": true,
"m_maxButton": false,
- "m_pinButton": false,
+ "m_pinButton": true,
"m_toolbarPane": false
},
"m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"],
@@ -1133,6 +1133,13 @@
"m_functionNameAndSignature": "OnMouseMotion(wxMouseEvent& event)",
"m_description": "Process a wxEVT_MOTION event",
"m_noBody": false
+ }, {
+ "m_eventName": "wxEVT_MOUSEWHEEL",
+ "m_eventClass": "wxMouseEvent",
+ "m_eventHandler": "wxMouseEventHandler",
+ "m_functionNameAndSignature": "OnScroll(wxMouseEvent& event)",
+ "m_description": "Process a wxEVT_MOUSEWHEEL event",
+ "m_noBody": false
}],
"m_children": []
}]
diff --git a/Project/ControlEditorBase.cpp b/Project/ControlEditorBase.cpp
index bc0a1aa..32dcc88 100644
--- a/Project/ControlEditorBase.cpp
+++ b/Project/ControlEditorBase.cpp
@@ -59,7 +59,7 @@ ControlEditorBase::ControlEditorBase(wxWindow* parent, wxWindowID id, const wxSt
m_panelControlElements = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1,-1)), wxTAB_TRAVERSAL);
m_panelControlElements->SetBackgroundColour(wxColour(wxT("rgb(255,255,255)")));
- m_auimgr->AddPane(m_panelControlElements, wxAuiPaneInfo().Name(wxT("m_controlElementsPanel")).Caption(_("Control elements")).Direction(wxAUI_DOCK_LEFT).Layer(0).Row(0).Position(0).BestSize(200,200).MinSize(10,10).MaxSize(200,200).CaptionVisible(true).MaximizeButton(false).CloseButton(false).MinimizeButton(true).PinButton(false));
+ m_auimgr->AddPane(m_panelControlElements, wxAuiPaneInfo().Name(wxT("m_controlElementsPanel")).Caption(_("Control elements")).Direction(wxAUI_DOCK_LEFT).Layer(0).Row(0).Position(0).BestSize(200,200).MinSize(10,10).MaxSize(200,200).CaptionVisible(true).MaximizeButton(false).CloseButton(false).MinimizeButton(true).PinButton(true));
m_panelWorkspace = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1,-1)), wxTAB_TRAVERSAL);
@@ -104,6 +104,7 @@ ControlEditorBase::ControlEditorBase(wxWindow* parent, wxWindowID id, const wxSt
m_glCanvas->Connect(wxEVT_MIDDLE_DOWN, wxMouseEventHandler(ControlEditorBase::OnMiddleDown), NULL, this);
m_glCanvas->Connect(wxEVT_MIDDLE_UP, wxMouseEventHandler(ControlEditorBase::OnMiddleUp), NULL, this);
m_glCanvas->Connect(wxEVT_MOTION, wxMouseEventHandler(ControlEditorBase::OnMouseMotion), NULL, this);
+ m_glCanvas->Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(ControlEditorBase::OnScroll), NULL, this);
}
@@ -116,6 +117,7 @@ ControlEditorBase::~ControlEditorBase()
m_glCanvas->Disconnect(wxEVT_MIDDLE_DOWN, wxMouseEventHandler(ControlEditorBase::OnMiddleDown), NULL, this);
m_glCanvas->Disconnect(wxEVT_MIDDLE_UP, wxMouseEventHandler(ControlEditorBase::OnMiddleUp), NULL, this);
m_glCanvas->Disconnect(wxEVT_MOTION, wxMouseEventHandler(ControlEditorBase::OnMouseMotion), NULL, this);
+ m_glCanvas->Disconnect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(ControlEditorBase::OnScroll), NULL, this);
m_auimgr->UnInit();
delete m_auimgr;
diff --git a/Project/ControlEditorBase.h b/Project/ControlEditorBase.h
index 5bee173..e3b7a94 100644
--- a/Project/ControlEditorBase.h
+++ b/Project/ControlEditorBase.h
@@ -55,6 +55,7 @@ protected:
virtual void OnMiddleDown(wxMouseEvent& event) { event.Skip(); }
virtual void OnMiddleUp(wxMouseEvent& event) { event.Skip(); }
virtual void OnMouseMotion(wxMouseEvent& event) { event.Skip(); }
+ virtual void OnScroll(wxMouseEvent& event) { event.Skip(); }
public:
wxToolBar* GetToolbarMain() { return m_toolbarMain; }
diff --git a/Project/Element.cpp b/Project/Element.cpp
index fa08905..48d1342 100644
--- a/Project/Element.cpp
+++ b/Project/Element.cpp
@@ -1,6 +1,6 @@
#include "Element.h"
-Element::Element() {}
+Element::Element() { m_selectionColour.SetRGBA(0.0, 0.5, 1.0, 0.5); }
Element::~Element() {}
diff --git a/Project/Element.h b/Project/Element.h
index 8a9f56f..d3a733d 100644
--- a/Project/Element.h
+++ b/Project/Element.h
@@ -594,6 +594,8 @@ protected:
wxPoint2DDouble m_movePos;
bool m_online = true;
+
+ OpenGLColour m_selectionColour;
};
#endif // ELEMENT_H
diff --git a/Project/PowerElement.cpp b/Project/PowerElement.cpp
index 06fb4aa..03ab97e 100644
--- a/Project/PowerElement.cpp
+++ b/Project/PowerElement.cpp
@@ -8,7 +8,6 @@ PowerElement::PowerElement()
m_offlineElementColour.SetRGBA(0.5, 0.5, 0.5, 1.0);
m_closedSwitchColour.SetRGBA(0.0, 0.4, 0.0, 1.0);
m_openedSwitchColour.SetRGBA(1.0, 0.1, 0.1, 1.0);
- m_selectionColour.SetRGBA(0.0, 0.5, 1.0, 0.5);
m_powerFlowArrowColour.SetRGBA(1.0, 0.51, 0.0, 1.0);
}
diff --git a/Project/PowerElement.h b/Project/PowerElement.h
index c8108b7..7399fe8 100644
--- a/Project/PowerElement.h
+++ b/Project/PowerElement.h
@@ -173,7 +173,6 @@ protected:
OpenGLColour m_offlineElementColour;
OpenGLColour m_closedSwitchColour;
OpenGLColour m_openedSwitchColour;
- OpenGLColour m_selectionColour;
OpenGLColour m_powerFlowArrowColour;
};
diff --git a/Project/Project.mk b/Project/Project.mk
index 6fb7752..0d908f4 100644
--- a/Project/Project.mk
+++ b/Project/Project.mk
@@ -13,7 +13,7 @@ CurrentFileName :=
CurrentFilePath :=
CurrentFileFullPath :=
User :=Thales
-Date :=24/01/2017
+Date :=25/01/2017
CodeLitePath :="C:/Program Files/CodeLite"
LinkerName :=C:/TDM-GCC-64/bin/g++.exe
SharedObjectLinkerName :=C:/TDM-GCC-64/bin/g++.exe -shared -fPIC
@@ -67,8 +67,8 @@ WXCFG:=gcc_dll\mswu
Objects0=$(IntermediateDirectory)/main.cpp$(ObjectSuffix) $(IntermediateDirectory)/win_resources.rc$(ObjectSuffix) $(IntermediateDirectory)/ElementDataObject.cpp$(ObjectSuffix) $(IntermediateDirectory)/Element.cpp$(ObjectSuffix) $(IntermediateDirectory)/ArtMetro.cpp$(ObjectSuffix) $(IntermediateDirectory)/wxGLString.cpp$(ObjectSuffix) $(IntermediateDirectory)/MainFrame.cpp$(ObjectSuffix) $(IntermediateDirectory)/Workspace.cpp$(ObjectSuffix) $(IntermediateDirectory)/FileHanding.cpp$(ObjectSuffix) $(IntermediateDirectory)/ControlEditor.cpp$(ObjectSuffix) \
$(IntermediateDirectory)/Camera.cpp$(ObjectSuffix) $(IntermediateDirectory)/MainFrameBitmaps.cpp$(ObjectSuffix) $(IntermediateDirectory)/WorkspaceBitmaps.cpp$(ObjectSuffix) $(IntermediateDirectory)/BusFormBitmaps.cpp$(ObjectSuffix) $(IntermediateDirectory)/ElementFormBitmaps.cpp$(ObjectSuffix) $(IntermediateDirectory)/ControlEditorBitmaps.cpp$(ObjectSuffix) $(IntermediateDirectory)/MainFrameBase.cpp$(ObjectSuffix) $(IntermediateDirectory)/WorkspaceBase.cpp$(ObjectSuffix) $(IntermediateDirectory)/ElementForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/ControlEditorBase.cpp$(ObjectSuffix) \
$(IntermediateDirectory)/Bus.cpp$(ObjectSuffix) $(IntermediateDirectory)/Line.cpp$(ObjectSuffix) $(IntermediateDirectory)/Transformer.cpp$(ObjectSuffix) $(IntermediateDirectory)/Machines.cpp$(ObjectSuffix) $(IntermediateDirectory)/SyncGenerator.cpp$(ObjectSuffix) $(IntermediateDirectory)/IndMotor.cpp$(ObjectSuffix) $(IntermediateDirectory)/Branch.cpp$(ObjectSuffix) $(IntermediateDirectory)/SyncMotor.cpp$(ObjectSuffix) $(IntermediateDirectory)/Shunt.cpp$(ObjectSuffix) $(IntermediateDirectory)/Load.cpp$(ObjectSuffix) \
- $(IntermediateDirectory)/Inductor.cpp$(ObjectSuffix) $(IntermediateDirectory)/Capacitor.cpp$(ObjectSuffix) $(IntermediateDirectory)/PowerElement.cpp$(ObjectSuffix) $(IntermediateDirectory)/ElectricCalculation.cpp$(ObjectSuffix) $(IntermediateDirectory)/PowerFlow.cpp$(ObjectSuffix) $(IntermediateDirectory)/Fault.cpp$(ObjectSuffix) $(IntermediateDirectory)/Text.cpp$(ObjectSuffix) $(IntermediateDirectory)/GraphicalElement.cpp$(ObjectSuffix) $(IntermediateDirectory)/ControlElement.cpp$(ObjectSuffix) $(IntermediateDirectory)/BusForm.cpp$(ObjectSuffix) \
- $(IntermediateDirectory)/GeneratorStabForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/LineForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/SwitchingForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/TransformerForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/LoadForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/ReactiveShuntElementForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/IndMotorForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/SyncMachineForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/TextForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/TransferFunction.cpp$(ObjectSuffix) \
+ $(IntermediateDirectory)/Inductor.cpp$(ObjectSuffix) $(IntermediateDirectory)/Capacitor.cpp$(ObjectSuffix) $(IntermediateDirectory)/PowerElement.cpp$(ObjectSuffix) $(IntermediateDirectory)/ElectricCalculation.cpp$(ObjectSuffix) $(IntermediateDirectory)/PowerFlow.cpp$(ObjectSuffix) $(IntermediateDirectory)/Fault.cpp$(ObjectSuffix) $(IntermediateDirectory)/Text.cpp$(ObjectSuffix) $(IntermediateDirectory)/GraphicalElement.cpp$(ObjectSuffix) $(IntermediateDirectory)/ControlElement.cpp$(ObjectSuffix) $(IntermediateDirectory)/TransferFunction.cpp$(ObjectSuffix) \
+ $(IntermediateDirectory)/BusForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/GeneratorStabForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/LineForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/SwitchingForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/TransformerForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/LoadForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/ReactiveShuntElementForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/IndMotorForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/SyncMachineForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/TextForm.cpp$(ObjectSuffix) \
@@ -406,6 +406,14 @@ $(IntermediateDirectory)/ControlElement.cpp$(DependSuffix): ControlElement.cpp
$(IntermediateDirectory)/ControlElement.cpp$(PreprocessSuffix): ControlElement.cpp
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/ControlElement.cpp$(PreprocessSuffix) ControlElement.cpp
+$(IntermediateDirectory)/TransferFunction.cpp$(ObjectSuffix): TransferFunction.cpp $(IntermediateDirectory)/TransferFunction.cpp$(DependSuffix)
+ $(CXX) $(IncludePCH) $(SourceSwitch) "C:/Users/Thales/Documents/GitHub/PSP/Project/TransferFunction.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/TransferFunction.cpp$(ObjectSuffix) $(IncludePath)
+$(IntermediateDirectory)/TransferFunction.cpp$(DependSuffix): TransferFunction.cpp
+ @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/TransferFunction.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/TransferFunction.cpp$(DependSuffix) -MM TransferFunction.cpp
+
+$(IntermediateDirectory)/TransferFunction.cpp$(PreprocessSuffix): TransferFunction.cpp
+ $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/TransferFunction.cpp$(PreprocessSuffix) TransferFunction.cpp
+
$(IntermediateDirectory)/BusForm.cpp$(ObjectSuffix): BusForm.cpp $(IntermediateDirectory)/BusForm.cpp$(DependSuffix)
$(CXX) $(IncludePCH) $(SourceSwitch) "C:/Users/Thales/Documents/GitHub/PSP/Project/BusForm.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/BusForm.cpp$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/BusForm.cpp$(DependSuffix): BusForm.cpp
@@ -486,14 +494,6 @@ $(IntermediateDirectory)/TextForm.cpp$(DependSuffix): TextForm.cpp
$(IntermediateDirectory)/TextForm.cpp$(PreprocessSuffix): TextForm.cpp
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/TextForm.cpp$(PreprocessSuffix) TextForm.cpp
-$(IntermediateDirectory)/TransferFunction.cpp$(ObjectSuffix): TransferFunction.cpp $(IntermediateDirectory)/TransferFunction.cpp$(DependSuffix)
- $(CXX) $(IncludePCH) $(SourceSwitch) "C:/Users/Thales/Documents/GitHub/PSP/Project/TransferFunction.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/TransferFunction.cpp$(ObjectSuffix) $(IncludePath)
-$(IntermediateDirectory)/TransferFunction.cpp$(DependSuffix): TransferFunction.cpp
- @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/TransferFunction.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/TransferFunction.cpp$(DependSuffix) -MM TransferFunction.cpp
-
-$(IntermediateDirectory)/TransferFunction.cpp$(PreprocessSuffix): TransferFunction.cpp
- $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/TransferFunction.cpp$(PreprocessSuffix) TransferFunction.cpp
-
-include $(IntermediateDirectory)/*$(DependSuffix)
##
diff --git a/Project/Project.project b/Project/Project.project
index c03c768..b6d6ae0 100644
--- a/Project/Project.project
+++ b/Project/Project.project
@@ -38,6 +38,7 @@
<File Name="Element.cpp"/>
<VirtualDirectory Name="control element">
<File Name="ControlElement.cpp"/>
+ <File Name="TransferFunction.cpp"/>
</VirtualDirectory>
</VirtualDirectory>
<VirtualDirectory Name="view">
@@ -104,7 +105,6 @@
<VirtualDirectory Name="control element">
<File Name="ControlElement.h"/>
<File Name="TransferFunction.h"/>
- <File Name="TransferFunction.cpp"/>
</VirtualDirectory>
</VirtualDirectory>
<VirtualDirectory Name="view">
diff --git a/Project/Project.txt b/Project/Project.txt
index c70cfdf..5cc3566 100644
--- a/Project/Project.txt
+++ b/Project/Project.txt
@@ -1 +1 @@
-./Release/main.cpp.o ./Release/win_resources.rc.o ./Release/ElementDataObject.cpp.o ./Release/Element.cpp.o ./Release/ArtMetro.cpp.o ./Release/wxGLString.cpp.o ./Release/MainFrame.cpp.o ./Release/Workspace.cpp.o ./Release/FileHanding.cpp.o ./Release/ControlEditor.cpp.o ./Release/Camera.cpp.o ./Release/MainFrameBitmaps.cpp.o ./Release/WorkspaceBitmaps.cpp.o ./Release/BusFormBitmaps.cpp.o ./Release/ElementFormBitmaps.cpp.o ./Release/ControlEditorBitmaps.cpp.o ./Release/MainFrameBase.cpp.o ./Release/WorkspaceBase.cpp.o ./Release/ElementForm.cpp.o ./Release/ControlEditorBase.cpp.o ./Release/Bus.cpp.o ./Release/Line.cpp.o ./Release/Transformer.cpp.o ./Release/Machines.cpp.o ./Release/SyncGenerator.cpp.o ./Release/IndMotor.cpp.o ./Release/Branch.cpp.o ./Release/SyncMotor.cpp.o ./Release/Shunt.cpp.o ./Release/Load.cpp.o ./Release/Inductor.cpp.o ./Release/Capacitor.cpp.o ./Release/PowerElement.cpp.o ./Release/ElectricCalculation.cpp.o ./Release/PowerFlow.cpp.o ./Release/Fault.cpp.o ./Release/Text.cpp.o ./Release/GraphicalElement.cpp.o ./Release/ControlElement.cpp.o ./Release/BusForm.cpp.o ./Release/GeneratorStabForm.cpp.o ./Release/LineForm.cpp.o ./Release/SwitchingForm.cpp.o ./Release/TransformerForm.cpp.o ./Release/LoadForm.cpp.o ./Release/ReactiveShuntElementForm.cpp.o ./Release/IndMotorForm.cpp.o ./Release/SyncMachineForm.cpp.o ./Release/TextForm.cpp.o ./Release/TransferFunction.cpp.o
+./Release/main.cpp.o ./Release/win_resources.rc.o ./Release/ElementDataObject.cpp.o ./Release/Element.cpp.o ./Release/ArtMetro.cpp.o ./Release/wxGLString.cpp.o ./Release/MainFrame.cpp.o ./Release/Workspace.cpp.o ./Release/FileHanding.cpp.o ./Release/ControlEditor.cpp.o ./Release/Camera.cpp.o ./Release/MainFrameBitmaps.cpp.o ./Release/WorkspaceBitmaps.cpp.o ./Release/BusFormBitmaps.cpp.o ./Release/ElementFormBitmaps.cpp.o ./Release/ControlEditorBitmaps.cpp.o ./Release/MainFrameBase.cpp.o ./Release/WorkspaceBase.cpp.o ./Release/ElementForm.cpp.o ./Release/ControlEditorBase.cpp.o ./Release/Bus.cpp.o ./Release/Line.cpp.o ./Release/Transformer.cpp.o ./Release/Machines.cpp.o ./Release/SyncGenerator.cpp.o ./Release/IndMotor.cpp.o ./Release/Branch.cpp.o ./Release/SyncMotor.cpp.o ./Release/Shunt.cpp.o ./Release/Load.cpp.o ./Release/Inductor.cpp.o ./Release/Capacitor.cpp.o ./Release/PowerElement.cpp.o ./Release/ElectricCalculation.cpp.o ./Release/PowerFlow.cpp.o ./Release/Fault.cpp.o ./Release/Text.cpp.o ./Release/GraphicalElement.cpp.o ./Release/ControlElement.cpp.o ./Release/TransferFunction.cpp.o ./Release/BusForm.cpp.o ./Release/GeneratorStabForm.cpp.o ./Release/LineForm.cpp.o ./Release/SwitchingForm.cpp.o ./Release/TransformerForm.cpp.o ./Release/LoadForm.cpp.o ./Release/ReactiveShuntElementForm.cpp.o ./Release/IndMotorForm.cpp.o ./Release/SyncMachineForm.cpp.o ./Release/TextForm.cpp.o
diff --git a/Project/Text.cpp b/Project/Text.cpp
index 588e9a1..060e666 100644
--- a/Project/Text.cpp
+++ b/Project/Text.cpp
@@ -84,7 +84,7 @@ void Text::SetText(wxString text)
{
glEnable(GL_TEXTURE_2D);
m_text = text;
- wxFont font(m_fontSize, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
+ wxFont font(m_fontSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
wxScreenDC dc;
if(m_glString) {
diff --git a/Project/TransferFunction.cpp b/Project/TransferFunction.cpp
index 514ca9c..6bb03ae 100644
--- a/Project/TransferFunction.cpp
+++ b/Project/TransferFunction.cpp
@@ -2,9 +2,60 @@
TransferFunction::TransferFunction()
{
+ // Superscript unicode numbers
+ m_supNumber[0] = L'\u2070';
+ m_supNumber[1] = L'\u00B9';
+ m_supNumber[2] = L'\u00B2';
+ m_supNumber[3] = L'\u00B3';
+ m_supNumber[4] = L'\u2074';
+ m_supNumber[5] = L'\u2075';
+ m_supNumber[6] = L'\u2076';
+ m_supNumber[7] = L'\u2077';
+ m_supNumber[8] = L'\u2078';
+ m_supNumber[9] = L'\u2079';
+
+ wxString str = "";
+ for(int i = 0; i < 10; i++) {
+ str += "0,1s" + wxString(m_supNumber[i]) + " ";
+ }
+ SetText(str, "");
+
+ m_width = 100;
+ m_height = 50;
+ SetPosition(m_position); // Update rect;
}
-TransferFunction::~TransferFunction()
+TransferFunction::~TransferFunction() {}
+
+void TransferFunction::Draw(wxPoint2DDouble translation, double scale) const
{
+ if(m_selected) {
+ glColor4dv(m_selectionColour.GetRGBA());
+ double borderSize = (m_borderSize * 2.0 + 1.0) / scale;
+ DrawRectangle(m_position, m_width + borderSize, m_height + borderSize);
+ }
+ glColor4d(1.0, 1.0, 1.0, 1.0);
+ DrawRectangle(m_position, m_width, m_height);
+ glColor4d(0.0, 0.0, 0.0, 1.0);
+ DrawRectangle(m_position, m_width, m_height, GL_LINE_LOOP);
+
+ glEnable(GL_TEXTURE_2D);
+ glColor4d(0.0, 0.0, 0.0, 1.0);
+ m_glStringNum->bind();
+ m_glStringNum->render(m_position.m_x, m_position.m_y);
+ glDisable(GL_TEXTURE_2D);
}
+void TransferFunction::SetText(wxString numerator, wxString denominator)
+{
+ wxFont font(m_fontSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
+ wxScreenDC dc;
+
+ if(m_glStringNum) {
+ delete m_glStringNum;
+ m_glStringNum = NULL;
+ }
+ m_glStringNum = new wxGLString(numerator);
+ m_glStringNum->setFont(font);
+ m_glStringNum->consolidate(&dc);
+}
diff --git a/Project/TransferFunction.h b/Project/TransferFunction.h
index 2a5acbb..fa48354 100644
--- a/Project/TransferFunction.h
+++ b/Project/TransferFunction.h
@@ -3,12 +3,27 @@
#include "ControlElement.h"
+#include <wx/dcscreen.h>
+#include "wxGLString.h"
+
class TransferFunction : public ControlElement
{
public:
TransferFunction();
~TransferFunction();
+ virtual void Draw(wxPoint2DDouble translation, double scale) const;
+ virtual bool Contains(wxPoint2DDouble position) const { return m_rect.Contains(position); }
+ virtual bool Intersects(wxRect2DDouble rect) const { return m_rect.Intersects(rect); }
+ virtual bool AddParent(Element* parent, wxPoint2DDouble position) { return false; }
+ virtual void SetText(wxString numerator, wxString denominator);
+
+protected:
+ wchar_t m_supNumber[10];
+
+ wxGLString* m_glStringNum = NULL;
+ wxGLString* m_glStringDen = NULL;
+ int m_fontSize = 10;
};
#endif // TRANSFERFUNCTION_H
diff --git a/Project/Workspace.cpp b/Project/Workspace.cpp
index c53bd60..893f69c 100644
--- a/Project/Workspace.cpp
+++ b/Project/Workspace.cpp
@@ -584,16 +584,6 @@ void Workspace::OnMiddleDown(wxMouseEvent& event)
m_mode = MODE_DRAG;
} break;
}
- /*if(m_mode != MODE_INSERT && m_mode != MODE_INSERT_TEXT && m_mode == MODE_PASTE && m_mode != MODE_DRAG_INSERT &&
- m_mode != MODE_DRAG_INSERT_TEXT && m_mode != MODE_DRAG_PASTE) {
- m_mode = MODE_DRAG;
- } else if(m_mode == MODE_INSERT_TEXT) {
- m_mode = MODE_DRAG_INSERT_TEXT;
- }else if(m_mode == MODE_PASTE) {
- m_mode = MODE_DRAG_PASTE;
- } else {
- m_mode = MODE_DRAG_INSERT;
- }*/
m_camera->StartTranslation(m_camera->ScreenToWorld(event.GetPosition()));
UpdateStatusBar();
}