forked from NadaAdelIsmailM/cie-202
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ActionAddConnec.cpp
77 lines (58 loc) · 1.86 KB
/
ActionAddConnec.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "ActionAddConnec.h"
#include "ApplicationManager.h"
#include "./Components/Connection.h"
#include <iostream>
ActionAddConnec::ActionAddConnec(ApplicationManager* pApp) :Action(pApp)
{
}
ActionAddConnec::~ActionAddConnec(void)
{
}
void ActionAddConnec::Execute()
{
Component* cmp1=nullptr;
Component* cmp2=nullptr;
UI* pUI = pManager->GetUI();
GraphicsInfo* pGInfo = new GraphicsInfo(2);
pUI->PrintMsg("Adding a new connection: Click on the first component");
pUI->GetPointClicked(x1, y1);
while (!pManager->ValidConnectionPoint(x1, y1,cmp1))
{
pUI->PrintMsg("Error!!! Invalid Connection point. Click agian to add first connection point.");
pUI->GetPointClicked(x1, y1);
};
pGInfo->PointsList[0].x = x1;
pGInfo->PointsList[0].y = y1;
pUI->PrintMsg("Adding a new connection: Click on the Second component");
pUI->GetPointClicked(x2,y2);
while (!pManager->ValidConnectionPoint(x2, y2, cmp2))
{
pUI->PrintMsg("Error!!! Invalid Connection point. Click agian to add second connection point.");
pUI->GetPointClicked(x2, y2);
};
pGInfo->PointsList[1].x = x2;
pGInfo->PointsList[1].y = y2;
/*if (x1 > x2) {
pGInfo->PointsList[0].x = cmp1->m_pGfxInfo->PointsList[1].x;
pGInfo->PointsList[1].x = cmp2->m_pGfxInfo->PointsList[0].x;
}
else if (x1<x2) {
pGInfo->PointsList[0].x = cmp1->m_pGfxInfo->PointsList[0].x;
pGInfo->PointsList[1].x = cmp2->m_pGfxInfo->PointsList[1].x;
}
if (y1 > y2) {
pGInfo->PointsList[0].y = cmp1->m_pGfxInfo->PointsList[1].y;
pGInfo->PointsList[1].y = cmp2->m_pGfxInfo->PointsList[0].y;
}
else if (x1 < x2) {
pGInfo->PointsList[0].y = cmp1->m_pGfxInfo->PointsList[0].y;
pGInfo->PointsList[1].y = cmp2->m_pGfxInfo->PointsList[1].y;
}*/
pUI->ClearStatusBar();
Connection* pR = new Connection(pGInfo,cmp1,cmp2);
pManager->AddConnection(pR);
}
void ActionAddConnec::Undo()
{}
void ActionAddConnec::Redo()
{}