summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThales1330 <thaleslima.ufu@gmail.com>2016-11-24 17:01:04 -0200
committerThales1330 <thaleslima.ufu@gmail.com>2016-11-24 17:01:04 -0200
commit22f71caae9771b8279dcfdbd3842b45c4520b782 (patch)
tree51925aae4d9c1bad0cd60899e9139bdf089df0c0
parent8e79aff80e56adbdcfd6a9be5a873c6bb4b1020a (diff)
downloadPSP.git-22f71caae9771b8279dcfdbd3842b45c4520b782.tar.gz
PSP.git-22f71caae9771b8279dcfdbd3842b45c4520b782.tar.xz
PSP.git-22f71caae9771b8279dcfdbd3842b45c4520b782.zip
Text under implementation [2]
-rw-r--r--.codelite/.tern-port2
-rw-r--r--.codelite/PSP.session33
-rw-r--r--.codelite/PSP.tagsbin83467264 -> 83468288 bytes
-rw-r--r--.codelite/compilation.dbbin61440 -> 61440 bytes
-rw-r--r--.codelite/compile_commands.json8
-rw-r--r--.codelite/refactoring.dbbin2089984 -> 2089984 bytes
-rw-r--r--Project/Project.mk2
-rw-r--r--Project/Release/PSP-UFU.exebin4140418 -> 4143351 bytes
-rw-r--r--Project/Release/Text.cpp.obin38352 -> 40534 bytes
-rw-r--r--Project/Release/Workspace.cpp.obin205068 -> 206026 bytes
-rw-r--r--Project/Text.cpp69
-rw-r--r--Project/Text.h8
-rw-r--r--Project/Workspace.cpp59
13 files changed, 128 insertions, 53 deletions
diff --git a/.codelite/.tern-port b/.codelite/.tern-port
index 7f8f52f..a84847a 100644
--- a/.codelite/.tern-port
+++ b/.codelite/.tern-port
@@ -1 +1 @@
-56486 \ No newline at end of file
+58160 \ No newline at end of file
diff --git a/.codelite/PSP.session b/.codelite/PSP.session
index ae7ec32..00212d5 100644
--- a/.codelite/PSP.session
+++ b/.codelite/PSP.session
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<Session Name="C:\Users\Thales\Documents\GitHub\PSP\PSP.workspace">
- <int Value="10" Name="m_selectedTab"/>
+ <int Value="0" Name="m_selectedTab"/>
<wxString Value="C:\Users\Thales\Documents\GitHub\PSP\PSP.workspace" Name="m_workspaceName"/>
<TabInfoArray Name="TabInfoArray">
<TabInfo>
<wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Workspace.cpp" Name="FileName"/>
- <int Value="405" Name="FirstVisibleLine"/>
- <int Value="405" Name="CurrentLine"/>
+ <int Value="555" Name="FirstVisibleLine"/>
+ <int Value="575" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
<IntVector Name="CollapsedFolds"/>
</TabInfo>
@@ -39,50 +39,43 @@
<IntVector Name="CollapsedFolds"/>
</TabInfo>
<TabInfo>
- <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Element.h" Name="FileName"/>
- <int Value="105" Name="FirstVisibleLine"/>
- <int Value="130" Name="CurrentLine"/>
- <wxArrayString Name="Bookmarks"/>
- <IntVector Name="CollapsedFolds"/>
- </TabInfo>
- <TabInfo>
<wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Text.h" Name="FileName"/>
<int Value="8" Name="FirstVisibleLine"/>
- <int Value="26" Name="CurrentLine"/>
+ <int Value="28" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
<IntVector Name="CollapsedFolds"/>
</TabInfo>
<TabInfo>
<wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Text.cpp" Name="FileName"/>
- <int Value="29" Name="FirstVisibleLine"/>
- <int Value="35" Name="CurrentLine"/>
+ <int Value="44" Name="FirstVisibleLine"/>
+ <int Value="82" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
<IntVector Name="CollapsedFolds"/>
</TabInfo>
<TabInfo>
<wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Bus.h" Name="FileName"/>
- <int Value="21" Name="FirstVisibleLine"/>
- <int Value="39" Name="CurrentLine"/>
+ <int Value="33" Name="FirstVisibleLine"/>
+ <int Value="46" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
<IntVector Name="CollapsedFolds"/>
</TabInfo>
<TabInfo>
<wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Bus.cpp" Name="FileName"/>
- <int Value="42" Name="FirstVisibleLine"/>
- <int Value="49" Name="CurrentLine"/>
+ <int Value="143" Name="FirstVisibleLine"/>
+ <int Value="163" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
<IntVector Name="CollapsedFolds"/>
</TabInfo>
<TabInfo>
<wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\wxGLString.cpp" Name="FileName"/>
- <int Value="243" Name="FirstVisibleLine"/>
- <int Value="256" Name="CurrentLine"/>
+ <int Value="126" Name="FirstVisibleLine"/>
+ <int Value="156" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
<IntVector Name="CollapsedFolds"/>
</TabInfo>
<TabInfo>
<wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\wxGLString.h" Name="FileName"/>
- <int Value="79" Name="FirstVisibleLine"/>
+ <int Value="75" Name="FirstVisibleLine"/>
<int Value="76" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
<IntVector Name="CollapsedFolds"/>
diff --git a/.codelite/PSP.tags b/.codelite/PSP.tags
index f833400..71ab0db 100644
--- a/.codelite/PSP.tags
+++ b/.codelite/PSP.tags
Binary files differ
diff --git a/.codelite/compilation.db b/.codelite/compilation.db
index eba4d38..6cefeae 100644
--- a/.codelite/compilation.db
+++ b/.codelite/compilation.db
Binary files differ
diff --git a/.codelite/compile_commands.json b/.codelite/compile_commands.json
index 1fa0735..9d017f3 100644
--- a/.codelite/compile_commands.json
+++ b/.codelite/compile_commands.json
@@ -4,6 +4,14 @@
"file": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project\\Text.cpp"
}, {
"directory": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project",
+ "command": "C:/TDM-GCC-64/bin/g++.exe -O2 -Wall -mthreads -DHAVE_W32API_H -D__WXMSW__ -DNDEBUG -D_UNICODE -IC:/wxWidgets-3.1.0/lib/gcc_dll/mswu -IC:/wxWidgets-3.1.0/include -DWXUSINGDLL -Wno-ctor-dtor-privacy -pipe -fmessage-length=0 -fno-keep-inline-dllexport -std=c++11 -DNDEBUG -DUNICODE -I. -I. -MG -MP -MT./Release/Workspace.cpp.o -MF./Release/Workspace.cpp.o.d -MM Workspace.cpp",
+ "file": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project\\Workspace.cpp"
+ }, {
+ "directory": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project",
"command": "C:/TDM-GCC-64/bin/g++.exe -c C:/Users/Thales/Documents/GitHub/PSP/Project/Text.cpp -O2 -Wall -mthreads -DHAVE_W32API_H -D__WXMSW__ -DNDEBUG -D_UNICODE -IC:/wxWidgets-3.1.0/lib/gcc_dll/mswu -IC:/wxWidgets-3.1.0/include -DWXUSINGDLL -Wno-ctor-dtor-privacy -pipe -fmessage-length=0 -fno-keep-inline-dllexport -std=c++11 -DNDEBUG -DUNICODE -o ./Release/Text.cpp.o -I. -I.",
"file": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project\\Text.cpp"
+ }, {
+ "directory": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project",
+ "command": "C:/TDM-GCC-64/bin/g++.exe -c C:/Users/Thales/Documents/GitHub/PSP/Project/Workspace.cpp -O2 -Wall -mthreads -DHAVE_W32API_H -D__WXMSW__ -DNDEBUG -D_UNICODE -IC:/wxWidgets-3.1.0/lib/gcc_dll/mswu -IC:/wxWidgets-3.1.0/include -DWXUSINGDLL -Wno-ctor-dtor-privacy -pipe -fmessage-length=0 -fno-keep-inline-dllexport -std=c++11 -DNDEBUG -DUNICODE -o ./Release/Workspace.cpp.o -I. -I.",
+ "file": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project\\Workspace.cpp"
}] \ No newline at end of file
diff --git a/.codelite/refactoring.db b/.codelite/refactoring.db
index 935c527..29e83ff 100644
--- a/.codelite/refactoring.db
+++ b/.codelite/refactoring.db
Binary files differ
diff --git a/Project/Project.mk b/Project/Project.mk
index 350b273..dbbf71e 100644
--- a/Project/Project.mk
+++ b/Project/Project.mk
@@ -13,7 +13,7 @@ CurrentFileName :=
CurrentFilePath :=
CurrentFileFullPath :=
User :=Thales
-Date :=23/11/2016
+Date :=24/11/2016
CodeLitePath :="C:/Program Files/CodeLite"
LinkerName :=C:/TDM-GCC-64/bin/g++.exe
SharedObjectLinkerName :=C:/TDM-GCC-64/bin/g++.exe -shared -fPIC
diff --git a/Project/Release/PSP-UFU.exe b/Project/Release/PSP-UFU.exe
index 02fc6d6..5c69aba 100644
--- a/Project/Release/PSP-UFU.exe
+++ b/Project/Release/PSP-UFU.exe
Binary files differ
diff --git a/Project/Release/Text.cpp.o b/Project/Release/Text.cpp.o
index ae85016..98d69f5 100644
--- a/Project/Release/Text.cpp.o
+++ b/Project/Release/Text.cpp.o
Binary files differ
diff --git a/Project/Release/Workspace.cpp.o b/Project/Release/Workspace.cpp.o
index f384585..5b3493d 100644
--- a/Project/Release/Workspace.cpp.o
+++ b/Project/Release/Workspace.cpp.o
Binary files differ
diff --git a/Project/Text.cpp b/Project/Text.cpp
index 25c9b85..1a89d17 100644
--- a/Project/Text.cpp
+++ b/Project/Text.cpp
@@ -10,11 +10,7 @@
#include "Inductor.h"
#include "Capacitor.h"
-Text::Text() : Element()
-{
- SetText(m_text);
-}
-
+Text::Text() : Element() { SetText(m_text); }
Text::Text(wxPoint2DDouble position) : Element()
{
SetText(m_text);
@@ -22,32 +18,41 @@ Text::Text(wxPoint2DDouble position) : Element()
}
Text::~Text() {}
-
bool Text::Contains(wxPoint2DDouble position) const
{
wxPoint2DDouble ptR = RotateAtPosition(position, -m_angle);
return m_rect.Contains(ptR);
}
-void Text::Draw(wxPoint2DDouble translation, double scale, wxDC& dc)
+void Text::Draw(wxPoint2DDouble translation, double scale)
{
- if(consolidate) {
- glString.setFont(wxFont(10, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
- glString.consolidate(&dc);
- //glString.bind();
- consolidate = false;
- }
- /*if(m_selected) {
+ wxScreenDC dc;
+
+ // Draw selection rectangle
+
+ // Push the current matrix on stack.
+ glPushMatrix();
+ // Rotate the matrix around the object position.
+ glTranslated(m_position.m_x, m_position.m_y, 0.0);
+ glRotated(m_angle, 0.0, 0.0, 1.0);
+ glTranslated(-m_position.m_x, -m_position.m_y, 0.0);
+
+ if(m_selected) {
glColor4d(0.0, 0.5, 1.0, 0.5);
- wxGLString backSelection(m_text);
- backSelection.setFont(wxFont(10, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
- backSelection.consolidate(&dc);
- backSelection.bind();
- backSelection.render(m_position.m_x, m_position.m_y);
- }*/
+ DrawRectangle(m_position + wxPoint2DDouble(m_borderSize / 2.0, m_borderSize / 2.0), m_rect.m_width,
+ m_rect.m_height);
+ }
+ // Draw text (layer 2)
+
glColor4d(0.0, 0.0, 0.0, 1.0);
- //glString.render(m_position.m_x, m_position.m_y);
+ wxGLString glString(m_text);
+ glString.setFont(wxFont(m_fontSize, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
+ glString.consolidate(&dc);
+ glString.bind();
+ glString.render(m_position.m_x, m_position.m_y);
+
+ glPopMatrix();
}
bool Text::Intersects(wxRect2DDouble rect) const
@@ -59,7 +64,23 @@ bool Text::Intersects(wxRect2DDouble rect) const
void Text::SetText(wxString text)
{
m_text = text;
- glString = text;
-
- consolidate = true;
+
+ // Generate a glString to get the text size.
+ wxGLString glString(m_text);
+ glString.setFont(wxFont(m_fontSize, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
+ wxScreenDC dc;
+ glString.consolidate(&dc);
+ glString.bind();
+
+ m_width = glString.getWidth();
+ m_height = glString.getheight();
+}
+
+void Text::Rotate(bool clockwise)
+{
+ double rotAngle = m_rotationAngle;
+ if(!clockwise) rotAngle = -m_rotationAngle;
+
+ m_angle += rotAngle;
+ if(m_angle >= 360.0) m_angle = 0.0;
}
diff --git a/Project/Text.h b/Project/Text.h
index 0ff8d17..d54d927 100644
--- a/Project/Text.h
+++ b/Project/Text.h
@@ -24,16 +24,16 @@ class Text : public Element
virtual bool AddParent(Element* parent, wxPoint2DDouble position) { return true; };
virtual bool Contains(wxPoint2DDouble position) const;
- virtual void Draw(wxPoint2DDouble translation, double scale, wxDC& dc);
+ virtual void Draw(wxPoint2DDouble translation, double scale);
virtual bool Intersects(wxRect2DDouble rect) const;
+ virtual void Rotate(bool clockwise = true);
virtual wxString GetText() const { return m_text; }
virtual void SetText(wxString text);
protected:
- wxString m_text = _("Text");
- wxGLString glString;
- bool consolidate = true;
+ wxString m_text = _("Barra 1");
+ int m_fontSize = 10;
};
#endif // TEXT_H
diff --git a/Project/Workspace.cpp b/Project/Workspace.cpp
index 029737c..1a91bb0 100644
--- a/Project/Workspace.cpp
+++ b/Project/Workspace.cpp
@@ -101,7 +101,7 @@ void Workspace::OnPaint(wxPaintEvent& event)
// Texts
for(auto it = m_textList.begin(); it != m_textList.end(); ++it) {
Text* text = *it;
- text->Draw(m_camera->GetTranslation(), m_camera->GetScale(), dc);
+ text->Draw(m_camera->GetTranslation(), m_camera->GetScale());
}
// Selection rectangle
@@ -156,8 +156,7 @@ void Workspace::OnLeftClickDown(wxMouseEvent& event)
bool foundElement = false;
if(m_mode == MODE_INSERT_TEXT) {
m_mode = MODE_EDIT;
- }
- else if(m_mode == MODE_INSERT || m_mode == MODE_DRAG_INSERT) {
+ } else if(m_mode == MODE_INSERT || m_mode == MODE_DRAG_INSERT) {
// Get the last element inserted on the list.
Element* newElement = *(m_elementList.end() - 1);
for(auto it = m_elementList.begin(); it != m_elementList.end(); ++it) {
@@ -224,6 +223,21 @@ void Workspace::OnLeftClickDown(wxMouseEvent& event)
element->SetOnline(element->IsOnline() ? false : true);
}
}
+
+ // Text element
+ for(auto it = m_textList.begin(); it != m_textList.end(); it++) {
+ Text* text = *it;
+
+ text->StartMove(m_camera->ScreenToWorld(event.GetPosition()));
+
+ if(text->Contains(m_camera->ScreenToWorld(event.GetPosition()))) {
+ if(!foundElement) {
+ text->SetSelected();
+ m_mode = MODE_MOVE_ELEMENT;
+ foundElement = true;
+ }
+ }
+ }
}
if(!foundElement) {
@@ -391,6 +405,23 @@ void Workspace::OnLeftClickUp(wxMouseEvent& event)
}
}
}
+
+ // Text element
+ for(auto it = m_textList.begin(); it != m_textList.end(); it++) {
+ Text* text = *it;
+ if(m_mode == MODE_SELECTION_RECT) {
+ if(text->Intersects(m_selectionRect)) {
+ text->SetSelected();
+ } else {
+ text->SetSelected(false);
+ }
+ } else if(!event.ControlDown()) {
+ if(!text->Contains(m_camera->ScreenToWorld(event.GetPosition()))) {
+ text->SetSelected(false);
+ }
+ }
+ }
+
if(findNewParent) {
std::rotate(itnp, itnp + 1, m_elementList.end());
updateVoltages = true;
@@ -499,6 +530,14 @@ void Workspace::OnMouseMotion(wxMouseEvent& event)
redraw = true;
}
}
+ // Text element motion
+ for(auto it = m_textList.begin(); it != m_textList.end(); it++) {
+ Text* text = *it;
+ if(text->IsSelected()) {
+ text->Move(m_camera->ScreenToWorld(event.GetPosition()));
+ redraw = true;
+ }
+ }
} break;
case MODE_SELECTION_RECT: {
@@ -574,6 +613,11 @@ void Workspace::OnKeyDown(wxKeyEvent& event)
m_mode = MODE_EDIT;
Redraw();
}
+ else if(m_mode == MODE_INSERT_TEXT) {
+ m_textList.pop_back();
+ m_mode = MODE_EDIT;
+ Redraw();
+ }
} break;
case WXK_DELETE: // Delete selected elements
{
@@ -828,6 +872,15 @@ void Workspace::RotateSelectedElements(bool clockwise)
element->StartMove(m_camera->GetMousePosition());
}
}
+
+ //Rotate text element
+ for(auto it = m_textList.begin(); it != m_textList.end(); it++) {
+ Text* text = *it;
+ if(text->IsSelected()) {
+ text->Rotate(clockwise);
+ text->StartMove(m_camera->GetMousePosition());
+ }
+ }
Redraw();
}