diff options
Diffstat (limited to 'Project')
-rw-r--r-- | Project/Bus.cpp | 29 | ||||
-rw-r--r-- | Project/Line.cpp | 1 | ||||
-rw-r--r-- | Project/Project.mk | 7 | ||||
-rw-r--r-- | Project/Release/Bus.cpp.o | bin | 26831 -> 27137 bytes | |||
-rw-r--r-- | Project/Release/PSP-UFU.exe | bin | 3286235 -> 3286539 bytes | |||
-rw-r--r-- | Project/Release/Workspace.cpp.o | bin | 113659 -> 113675 bytes | |||
-rw-r--r-- | Project/Workspace.cpp | 6 |
7 files changed, 31 insertions, 12 deletions
diff --git a/Project/Bus.cpp b/Project/Bus.cpp index a578e1b..96bff55 100644 --- a/Project/Bus.cpp +++ b/Project/Bus.cpp @@ -9,7 +9,6 @@ Bus::Bus(wxPoint2DDouble position) : Element() } Bus::~Bus() {} - void Bus::Draw(wxPoint2DDouble translation, double scale) const { // Draw selection (layer 1) @@ -75,7 +74,27 @@ bool Bus::Contains(wxPoint2DDouble position) const return m_rect.Contains(ptR); } -bool Bus::Intersects(wxRect2DDouble rect) const { return rect.Intersects(m_rect); } +bool Bus::Intersects(wxRect2DDouble rect) const +{ + wxPoint2DDouble m_rectCorners[2] = {m_rect.GetLeftTop(), m_rect.GetRightBottom()}; + + wxPoint2DDouble rectCorners[2] = {rect.GetLeftTop(), rect.GetRightBottom()}; + + // Rotate the rect corners + for(int i = 0; i < 2; i++) { + rectCorners[i] = RotateAtPosition(rectCorners[i], -m_angle); + } + //[Ref] http://stackoverflow.com/questions/306316/determine-if-two-rectangles-overlap-each-other + //[Ref2] http://www.gamedev.net/page/resources/_/technical/game-programming/2d-rotated-rectangle-collision-r2604 + // if (RectA.X1 < RectB.X2 && RectA.X2 > RectB.X1 && RectA.Y1 < RectB.Y2 && RectA.Y2 > RectB.Y1) + + if(m_rectCorners[0].m_x < rectCorners[1].m_x && m_rectCorners[1].m_x > rectCorners[0].m_x && + m_rectCorners[0].m_y < rectCorners[1].m_y && m_rectCorners[1].m_y > rectCorners[0].m_y) + return true; + + return false; + // return rect.Intersects(m_rect); +} bool Bus::PickboxContains(wxPoint2DDouble position) { m_activePickboxID = ID_PB_NONE; @@ -153,7 +172,7 @@ void Bus::Rotate() bool Bus::GetContextMenu(wxMenu& menu) { - menu.Append(ID_EDIT_BUS, _("Edit bus")); - menu.Append(ID_ROTATE, _("Rotate")); - return true; + menu.Append(ID_EDIT_BUS, _("Edit bus")); + menu.Append(ID_ROTATE, _("Rotate")); + return true; } diff --git a/Project/Line.cpp b/Project/Line.cpp index 7f4605f..8b17ade 100644 --- a/Project/Line.cpp +++ b/Project/Line.cpp @@ -164,7 +164,6 @@ void Line::StartMove(wxPoint2DDouble position) void Line::MoveNode(Element* parent, wxPoint2DDouble position) { if(parent) { - //wxMessageBox("OK"); // First bus. if(parent == m_parentList[0]) { m_pointList[0] = m_movePts[0] + position - m_moveStartPt; diff --git a/Project/Project.mk b/Project/Project.mk index 09ecb89..2a6d78f 100644 --- a/Project/Project.mk +++ b/Project/Project.mk @@ -13,8 +13,8 @@ CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=Thales -Date :=21/08/2016 -CodeLitePath :="C:/Program Files (x86)/CodeLite" +Date :=23/08/2016 +CodeLitePath :="C:/Program Files/CodeLite" LinkerName :=C:/TDM-GCC-64/bin/g++.exe SharedObjectLinkerName :=C:/TDM-GCC-64/bin/g++.exe -shared -fPIC ObjectSuffix :=.o @@ -61,8 +61,7 @@ AS := C:/TDM-GCC-64/bin/as.exe ## ## User defined environment variables ## -CodeLiteDir:=C:\Program Files (x86)\CodeLite -UNIT_TEST_PP_SRC_DIR:=C:\UnitTest++-1.3 +CodeLiteDir:=C:\Program Files\CodeLite WXWIN:=C:\wxWidgets-3.1.0 WXCFG:=gcc_dll\mswu Objects0=$(IntermediateDirectory)/main.cpp$(ObjectSuffix) $(IntermediateDirectory)/win_resources.rc$(ObjectSuffix) $(IntermediateDirectory)/Element.cpp$(ObjectSuffix) $(IntermediateDirectory)/Bus.cpp$(ObjectSuffix) $(IntermediateDirectory)/Line.cpp$(ObjectSuffix) $(IntermediateDirectory)/ArtMetro.cpp$(ObjectSuffix) $(IntermediateDirectory)/MainFrame.cpp$(ObjectSuffix) $(IntermediateDirectory)/Workspace.cpp$(ObjectSuffix) $(IntermediateDirectory)/MainFrameBitmaps.cpp$(ObjectSuffix) $(IntermediateDirectory)/WorkspaceBitmaps.cpp$(ObjectSuffix) \ diff --git a/Project/Release/Bus.cpp.o b/Project/Release/Bus.cpp.o Binary files differindex 886f064..ca53709 100644 --- a/Project/Release/Bus.cpp.o +++ b/Project/Release/Bus.cpp.o diff --git a/Project/Release/PSP-UFU.exe b/Project/Release/PSP-UFU.exe Binary files differindex c436fd9..9af8de7 100644 --- a/Project/Release/PSP-UFU.exe +++ b/Project/Release/PSP-UFU.exe diff --git a/Project/Release/Workspace.cpp.o b/Project/Release/Workspace.cpp.o Binary files differindex 3c52ac0..99752d1 100644 --- a/Project/Release/Workspace.cpp.o +++ b/Project/Release/Workspace.cpp.o diff --git a/Project/Workspace.cpp b/Project/Workspace.cpp index d4b6fa6..68e8464 100644 --- a/Project/Workspace.cpp +++ b/Project/Workspace.cpp @@ -492,8 +492,10 @@ void Workspace::OnKeyDown(wxKeyEvent& event) // Parent's element rotating... for(int i = 0; i < (int)element->GetParentList().size(); i++) { Element* parent = element->GetParentList()[i]; - if(parent->IsSelected()) { - element->RotateNode(parent); + if(parent) { // Check if parent is not null + if(parent->IsSelected()) { + element->RotateNode(parent); + } } } if(element->IsSelected()) { |