summaryrefslogtreecommitdiffstats
path: root/Project/Element.cpp
diff options
context:
space:
mode:
authorThales1330 <thaleslima.ufu@gmail.com>2016-09-08 18:54:52 -0300
committerThales1330 <thaleslima.ufu@gmail.com>2016-09-08 18:54:52 -0300
commit122d124108384bb4579b6d96956b931d7221d3c1 (patch)
tree72a94cb2d317d37665dac1905d3d3660c48100fb /Project/Element.cpp
parentfb8a409d7e35735afc9d28bfc0d7b49974f0d3a2 (diff)
downloadPSP.git-122d124108384bb4579b6d96956b931d7221d3c1.tar.gz
PSP.git-122d124108384bb4579b6d96956b931d7221d3c1.tar.xz
PSP.git-122d124108384bb4579b6d96956b931d7221d3c1.zip
Fit implemented
Diffstat (limited to 'Project/Element.cpp')
-rw-r--r--Project/Element.cpp49
1 files changed, 39 insertions, 10 deletions
diff --git a/Project/Element.cpp b/Project/Element.cpp
index bd04944..170be4a 100644
--- a/Project/Element.cpp
+++ b/Project/Element.cpp
@@ -295,15 +295,44 @@ void Element::SetOnline(bool online)
void Element::GeneralMenuItens(wxMenu& menu)
{
- wxMenuItem* clockItem = new wxMenuItem(&menu, ID_ROTATE_CLOCK, _("Rotate clockwise"));
- clockItem->SetBitmap(wxImage("data\\images\\menu\\rotateClock16.png"));
- menu.Append(clockItem);
-
- wxMenuItem* counterClockItem = new wxMenuItem(&menu, ID_ROTATE_COUNTERCLOCK, _("Rotate counter-clockwise"));
- counterClockItem->SetBitmap(wxImage("data\\images\\menu\\rotateCounterClock16.png"));
- menu.Append(counterClockItem);
-
+ wxMenuItem* clockItem = new wxMenuItem(&menu, ID_ROTATE_CLOCK, _("Rotate clockwise"));
+ clockItem->SetBitmap(wxImage("data\\images\\menu\\rotateClock16.png"));
+ menu.Append(clockItem);
+
+ wxMenuItem* counterClockItem = new wxMenuItem(&menu, ID_ROTATE_COUNTERCLOCK, _("Rotate counter-clockwise"));
+ counterClockItem->SetBitmap(wxImage("data\\images\\menu\\rotateCounterClock16.png"));
+ menu.Append(counterClockItem);
+
wxMenuItem* deleteItem = new wxMenuItem(&menu, ID_DELETE, _("Delete"));
- deleteItem->SetBitmap(wxImage("data\\images\\menu\\delete16.png"));
- menu.Append(deleteItem);
+ deleteItem->SetBitmap(wxImage("data\\images\\menu\\delete16.png"));
+ menu.Append(deleteItem);
+}
+
+void Element::CalculateBoundaries(wxPoint2DDouble& leftUp, wxPoint2DDouble& rightBottom) const
+{
+ // Check rect corners boundaries.
+
+ // Get rectangle corners
+ wxPoint2DDouble rectCorner[4] = {m_rect.GetLeftTop(), m_rect.GetLeftBottom(), m_rect.GetRightBottom(),
+ m_rect.GetRightTop()};
+ // Rotate corners.
+ for(int i = 0; i < 4; ++i) {
+ rectCorner[i] = RotateAtPosition(rectCorner[i], m_angle);
+ }
+ leftUp = rectCorner[0];
+ rightBottom = rectCorner[0];
+ for(int i = 1; i < 4; ++i) {
+ if(rectCorner[i].m_x < leftUp.m_x) leftUp.m_x = rectCorner[i].m_x;
+ if(rectCorner[i].m_y < leftUp.m_y) leftUp.m_y = rectCorner[i].m_y;
+ if(rectCorner[i].m_x > rightBottom.m_x) rightBottom.m_x = rectCorner[i].m_x;
+ if(rectCorner[i].m_y > rightBottom.m_y) rightBottom.m_y = rectCorner[i].m_y;
+ }
+
+ // Check points list boundaries.
+ for(int i = 0; i < (int)m_pointList.size(); i++) {
+ if(m_pointList[i].m_x < leftUp.m_x) leftUp.m_x = m_pointList[i].m_x;
+ if(m_pointList[i].m_y < leftUp.m_y) leftUp.m_y = m_pointList[i].m_y;
+ if(m_pointList[i].m_x > rightBottom.m_x) rightBottom.m_x = m_pointList[i].m_x;
+ if(m_pointList[i].m_y > rightBottom.m_y) rightBottom.m_y = m_pointList[i].m_y;
+ }
}