-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77c4d65
commit 1202b74
Showing
279 changed files
with
26,421 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef _ACTION_H | ||
#define _ACTION_H | ||
|
||
class ApplicationManager; //forward class declaration | ||
|
||
|
||
//Base class for all possible actions (abstract class) | ||
class Action | ||
{ | ||
protected: | ||
ApplicationManager *pManager; //Actions needs AppMngr to do their job | ||
public: | ||
Action(ApplicationManager *pApp) { pManager = pApp; } //constructor | ||
|
||
//Reads parameters required for action to execute | ||
virtual void ReadActionParameters()=0; | ||
|
||
//Execute action (code depends on action type) | ||
virtual void Execute()=0; | ||
|
||
//To undo this action (code depends on action type) | ||
virtual void Undo()=0; | ||
|
||
//To redo this action (code depends on action type) | ||
virtual void Redo()=0; | ||
|
||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#include "../Actions/ActionLabel.h" | ||
#include "..\ApplicationManager.h" | ||
|
||
ActionLabel::ActionLabel(ApplicationManager* pApp) :Action(pApp) | ||
{ | ||
test = true; | ||
comp = NULL; | ||
} | ||
|
||
ActionLabel::~ActionLabel(void) | ||
{ | ||
|
||
} | ||
|
||
void ActionLabel::ReadActionParameters() | ||
{ | ||
//Get a Pointer to the Input / Output Interfaces | ||
Output* pOut = pManager->GetOutput(); | ||
Input* pIn = pManager->GetInput(); | ||
|
||
//Print Action Message | ||
pOut->PrintMsg("click on the item that you want to label (if wire click on its srcPin or DstPin)"); | ||
|
||
//Wait for User Input | ||
pIn->GetPointClicked(Cx, Cy); | ||
int i; | ||
if (pManager->isExist(Cx, Cy, i)) | ||
{ | ||
comp = pManager->getComponent(i); | ||
if (comp->isLabeld()) | ||
{ | ||
pOut->PrintMsg("This component has already been labeled (we suggest to click on edit from tool bar)"); | ||
test = false; | ||
} | ||
} | ||
else | ||
{ | ||
pOut->PrintMsg("Failed, It is not a component. try again accurately"); | ||
test = false; | ||
} | ||
} | ||
|
||
void ActionLabel::Execute() | ||
{ | ||
//Get Center point of the Gate | ||
ReadActionParameters(); | ||
|
||
if (test) | ||
{ | ||
Output* pOut = pManager->GetOutput(); | ||
Input* pIn = pManager->GetInput(); | ||
GraphicsInfo gfx; | ||
Gate* g; | ||
Connection* c; | ||
if (comp) | ||
{ | ||
g = dynamic_cast<Gate*>(comp); | ||
c = dynamic_cast<Connection*>(comp); | ||
string InputText = "empty"; | ||
if (g) | ||
{ | ||
gfx = comp->getGxfInfo(); | ||
InputText = pIn->GetSrting(pOut, "Write Here : ", gfx.x1, gfx.y1 - (0.5 * UI.AND2_Height + 5)); | ||
} | ||
else if (c) | ||
{ | ||
gfx = comp->getGxfInfo(); | ||
InputText = pIn->GetSrting(pOut, "Write Here : ", ((gfx.x1 + gfx.x2) / 2.0), gfx.y1 - (0.5 * UI.AND2_Height + 2)); | ||
} | ||
comp->setLabel(InputText); | ||
} | ||
} | ||
else | ||
{ | ||
return; | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
void ActionLabel::Undo() | ||
{} | ||
|
||
void ActionLabel::Redo() | ||
{} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef _ACTIONLABEL_H | ||
#define _ACTIONLABEL_H | ||
|
||
#include "action.h" | ||
#include "../Components/Component.h" | ||
class ActionLabel : public Action | ||
{ | ||
|
||
private: | ||
int Cx, Cy; //Two corners of the start and end of wire | ||
bool test; // to validate that ReadActionParameters has no problem | ||
Component* comp; | ||
public: | ||
ActionLabel(ApplicationManager* pApp); | ||
virtual ~ActionLabel(void); | ||
|
||
//Reads parameters required for action to execute | ||
virtual void ReadActionParameters(); | ||
//Execute action (code depends on action type) | ||
virtual void Execute(); | ||
|
||
virtual void Undo(); | ||
virtual void Redo(); | ||
|
||
|
||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include "AddANDgate2.h" | ||
#include "..\ApplicationManager.h" | ||
|
||
AddANDgate2::AddANDgate2(ApplicationManager* pApp, ActionType actType, Data* pLoadedData):Action(pApp) | ||
{ | ||
test = true; | ||
} | ||
|
||
AddANDgate2::~AddANDgate2(void) | ||
{ | ||
|
||
} | ||
|
||
void AddANDgate2::ReadActionParameters() | ||
{ | ||
//Get a Pointer to the Input / Output Interfaces | ||
Output* pOut = pManager->GetOutput(); | ||
Input* pIn = pManager->GetInput(); | ||
|
||
//Print Action Message | ||
pOut->PrintMsg("2-Input AND Gate: Click to add the gate"); | ||
|
||
int i; | ||
pIn->GetPointClicked(Cx, Cy); | ||
if (pOut->isValidArea(Cy) && !(pManager->isExist(Cx, Cy, i))) | ||
{ | ||
test = true; | ||
} | ||
else | ||
{ | ||
pOut->PrintMsg("Invalid position to draw, try again"); | ||
test = false; | ||
} | ||
} | ||
|
||
void AddANDgate2::Execute() | ||
{ | ||
//Get Center point of the Gate | ||
ReadActionParameters(); | ||
|
||
if (test) | ||
{ | ||
//Calculate the rectangle Corners | ||
int Len = UI.AND2_Width; | ||
int Wdth = UI.AND2_Height; | ||
|
||
GraphicsInfo GInfo; //Gfx info to be used to construct the AND2 gate | ||
|
||
GInfo.x1 = Cx - Len / 2; | ||
GInfo.x2 = Cx + Len / 2; | ||
GInfo.y1 = Cy - Wdth / 2; | ||
GInfo.y2 = Cy + Wdth / 2; | ||
AND2* pA = new AND2(GInfo, AND2_FANOUT); | ||
pManager->AddComponent(pA); | ||
} | ||
else | ||
{ | ||
return; | ||
} | ||
} | ||
|
||
void AddANDgate2::Undo() | ||
{} | ||
|
||
void AddANDgate2::Redo() | ||
{} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef _ADD_AND_GATE_H | ||
#define _ADD_AND_GATE_H | ||
|
||
#include "action.h" | ||
#include "..\Components\AND2.h" | ||
|
||
class AddANDgate2 : public Action | ||
{ | ||
private: | ||
//Parameters for rectangular area to be occupied by the gate | ||
int Cx, Cy; //Center point of the gate | ||
int x1, y1, x2, y2; //Two corners of the rectangluar area | ||
bool test; | ||
public: | ||
AddANDgate2(ApplicationManager* pAppMan, ActionType actType, Data* pLoadedData = NULL); | ||
virtual ~AddANDgate2(void); | ||
|
||
//Reads parameters required for action to execute | ||
virtual void ReadActionParameters(); | ||
//Execute action (code depends on action type) | ||
virtual void Execute(); | ||
|
||
virtual void Undo(); | ||
virtual void Redo(); | ||
|
||
|
||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include "AddANDgate3.h" | ||
#include "..\ApplicationManager.h" | ||
|
||
AddANDgate3::AddANDgate3(ApplicationManager* pApp, ActionType actType, Data* pLoadedData) :Action(pApp) | ||
{ | ||
test = true; | ||
} | ||
|
||
AddANDgate3::~AddANDgate3(void) | ||
{ | ||
|
||
} | ||
|
||
void AddANDgate3::ReadActionParameters() | ||
{ | ||
//Get a Pointer to the Input / Output Interfaces | ||
Output* pOut = pManager->GetOutput(); | ||
Input* pIn = pManager->GetInput(); | ||
|
||
//Print Action Message | ||
pOut->PrintMsg("3-Input AND Gate: Click to add the gate"); | ||
|
||
int i; | ||
pIn->GetPointClicked(Cx, Cy); | ||
if (pOut->isValidArea(Cy) && !(pManager->isExist(Cx, Cy, i))) | ||
{ | ||
test = true; | ||
} | ||
else | ||
{ | ||
pOut->PrintMsg("Invalid position to draw, try again"); | ||
test = false; | ||
} | ||
|
||
} | ||
|
||
void AddANDgate3::Execute() | ||
{ | ||
//Get Center point of the Gate | ||
ReadActionParameters(); | ||
|
||
if (test) | ||
{ | ||
//Calculate the rectangle Corners | ||
int Len = UI.AND3_Width; | ||
int Wdth = UI.AND3_Height; | ||
|
||
GraphicsInfo GInfo; //Gfx info to be used to construct the AND2 gate | ||
|
||
GInfo.x1 = Cx - Len / 2; | ||
GInfo.x2 = Cx + Len / 2; | ||
GInfo.y1 = Cy - Wdth / 2; | ||
GInfo.y2 = Cy + Wdth / 2; | ||
AND3* pA = new AND3(GInfo, AND2_FANOUT); | ||
pManager->AddComponent(pA); | ||
} | ||
else | ||
{ | ||
return;; | ||
} | ||
} | ||
|
||
void AddANDgate3::Undo() | ||
{} | ||
|
||
void AddANDgate3::Redo() | ||
{} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef _ADD_AND3_GATE_H | ||
#define _ADD_AND3_GATE_H | ||
|
||
#include "Action.h" | ||
#include "..\Components\AND3.h" | ||
|
||
class AddANDgate3 : public Action | ||
{ | ||
private: | ||
//Parameters for rectangular area to be occupied by the gate | ||
int Cx, Cy; //Center point of the gate | ||
int x1, y1, x2, y2; //Two corners of the rectangluar area | ||
bool test; | ||
public: | ||
AddANDgate3(ApplicationManager* pAppMan, ActionType actType, Data* pLoadedData = NULL); | ||
virtual ~AddANDgate3(void); | ||
|
||
//Reads parameters required for action to execute | ||
virtual void ReadActionParameters(); | ||
//Execute action (code depends on action type) | ||
virtual void Execute(); | ||
|
||
virtual void Undo(); | ||
virtual void Redo(); | ||
|
||
|
||
}; | ||
|
||
#endif#pragma once |
Oops, something went wrong.