Skip to content

Commit 990fbb7

Browse files
authored
Final Project
1 parent b11d8f5 commit 990fbb7

17 files changed

Lines changed: 2797 additions & 0 deletions

ApplicationManager.cpp

Lines changed: 497 additions & 0 deletions
Large diffs are not rendered by default.

ApplicationManager.h

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#ifndef APPLICATION_MANAGER_H
2+
#define APPLICATION_MANAGER_H
3+
4+
#include "DEFS.h"
5+
#include<map>
6+
7+
#include "Statements\Statement.h"
8+
#include"Statements\Conditional.h"
9+
#include"Statements\Start_End.h"
10+
#include"Statements\ReadWrite.h"
11+
#include"Statements\SingleOp.h"
12+
#include"Statements\SmplAssign.h"
13+
#include"Statements\Variable.h"
14+
15+
16+
class Input;
17+
class Output;
18+
19+
//Main class that manages everything in the application.
20+
class ApplicationManager
21+
{
22+
enum { MaxCount = 200 }; //Max no of statements/connectors in a single flowchart
23+
24+
private:
25+
int StatCount; //Actual number of statements
26+
int ConnCount; //Actual number of connectors
27+
Statement* StatList[MaxCount]; //List of all statements (Array of pointers)
28+
Connector* ConnList[MaxCount]; //List of all connectors (Array of pointers)
29+
30+
Statement *pSelectedStat; //a pointer to the last selected statement
31+
Connector *pSelectedConn; //a pointer to the last selected statement
32+
33+
//Pointers to Input and Output classes
34+
Input *pIn;
35+
Output *pOut;
36+
37+
bool IsPointBetween(Point, Point, Point) const; //To get Connector between two points
38+
39+
public:
40+
ApplicationManager();
41+
~ApplicationManager();
42+
43+
// -- Actions Related Functions
44+
//Reads the input command from the user and returns the corresponding action type
45+
ActionType GetUserAction() const;
46+
void ExecuteAction(ActionType); //Creates an action and executes it
47+
48+
Statement** Statementlist() { return StatList; }
49+
Connector** Connectorlist() { return ConnList;}
50+
int Statementcurrent() { return StatCount; }
51+
int Connectorcurrent() { return ConnCount; }
52+
53+
54+
// -- Statements/Connector Management Functions
55+
void AddStatement(Statement* pStat); //Adds a new Statement to the Flowchart
56+
Statement *GetStatement(Point P) const; //search for a statement where point P belongs
57+
58+
void AddConnector(Connector* pConn); //Adds a new Connector to the Flowchart
59+
Connector *GetConnector(Point P) const; //search for a Connector where point P belongs
60+
61+
62+
Statement *GetSelectedStatement() const; //Returns the selected Statement
63+
void SetSelectedStatement(Statement *pStat); //Set the Statement selected by the user
64+
65+
Connector *GetSelectedConnector() const; //Returns the selected Connector
66+
void SetSelectedConnector(Connector *pStat); //Set the Connector selected by the user
67+
68+
void DeleteConnector(Connector *);
69+
void DeleteStatement(Statement *);
70+
71+
72+
void ApplicationManager::Loading(ifstream &In);//Load Action
73+
74+
// -- Interface Management Functions
75+
Input *GetInput() const; //Return pointer to the input
76+
Output *GetOutput() const; //Return pointer to the output
77+
void UpdateInterface() const; //Redraws all the drawing window
78+
79+
};
80+
81+
#endif

DEFS.h

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#ifndef DEFS_H
2+
#define DEFS_H
3+
4+
//This file contais some global constants and definitions to be used in the project.
5+
6+
7+
enum ActionType //The actions supported (you can add more if needed)
8+
{
9+
ADD_SMPL_ASSIGN, //Add simple assignment statement
10+
//ADD_VAR_ASSIGN, //Add variable assignment statement ??
11+
ADD_CONDITION, //Add a conditional statement (for if and while-loop statements)
12+
13+
ADD_Single_OP,
14+
ADD_One_Variable,
15+
No_Action,
16+
17+
ADD_CONNECTOR, //Add a connector between two statements
18+
19+
EDIT_STAT, //Edit a statement
20+
EDIT_CONN,
21+
22+
SELECT, //Select a statement, a connector
23+
MULTI_SELECT,
24+
25+
DEL, //Delete a figure(s)
26+
MOVE, //Move a figure(s)
27+
28+
SAVE, //Save the whole graph to a file
29+
LOAD, //Load a graph from a file
30+
EXIT, //Exit the application
31+
STATUS, //A click on the status bar
32+
DSN_TOOL, //A click on an empty place in the design tool bar
33+
DSN_MODE, //Switch to Design mode
34+
SIM_TOOL, //A click on an empty place in the Simulation tool bar
35+
SIM_MODE, //Switch to simulatiom mode
36+
37+
ADD_ellipse_start,
38+
ADD_ellipse_END,
39+
40+
ADD_Read,
41+
ADD_Write,
42+
43+
COPY,
44+
CUT,
45+
46+
COMMENT,
47+
RUN,
48+
DEBUG,
49+
VALID,
50+
Generate,
51+
52+
ZoomIn,
53+
ZoomOut,
54+
55+
UNDO,
56+
REDO,
57+
};
58+
59+
enum MODE //Modes of operation
60+
{
61+
DESIGN,
62+
SIMULATION
63+
};
64+
65+
enum DsgnMenuItem //The items of the design menu (you should add more items)
66+
{
67+
//Note: Items are ordered here as they appear in menu
68+
//If you change the menu items order, change the order here too
69+
ITM_SMPL_ASSIGN,//simple assignment statement
70+
ITM_COND, //conditional statement
71+
72+
73+
ITM_EXIT, //Exit
74+
75+
//TODO: Add more items names here
76+
77+
ITM_DSN_CNT //no. of design menu items ==> This should be the last line in this enum
78+
79+
};
80+
81+
82+
enum SimMenuItem //The items of the simulation menu (you should add more items)
83+
{
84+
//Note: Items are ordered here as they appear in menu
85+
ITM_RUN, //Run
86+
ITM_STP, //Step by step
87+
88+
//TODO:Add more items names here
89+
90+
ITM_SIM_CNT //no. of simulation menu items ==> This should be the last line in this enum
91+
92+
};
93+
94+
95+
96+
97+
#ifndef NULL
98+
#define NULL 0
99+
#endif
100+
101+
#endif

Flow_Chart.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
6
2+
STRT 1 147 193 ""
3+
SmplAssign 2 75 280 x 3 ""
4+
SmplAssign 3 76 387 y 4 ""
5+
COND 4 503 149 x GRT y ""
6+
WRITE 5 655 315 x ""
7+
WRITE 6 403 324 y ""
8+
5
9+
1 2 0
10+
2 3 0
11+
3 4 0
12+
4 5 1
13+
4 6 2

Flow_Code.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <iostream>
2+
using namespace std;
3+
int main()
4+
{
5+
double x,y;
6+
x=3;
7+
y=4;
8+
if(x > y)
9+
{
10+
cout<<x;
11+
return 0;
12+
13+
}
14+
else
15+
{
16+
cout<<y;
17+
return 0;
18+
}
19+
}

PT Project.sln

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 11.00
3+
# Visual Studio 2010
4+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PT Project", "PT Project.vcxproj", "{1AC3DDD7-FDDE-487E-A2A4-52A8FCF7BDB9}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Win32 = Debug|Win32
9+
Release|Win32 = Release|Win32
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{1AC3DDD7-FDDE-487E-A2A4-52A8FCF7BDB9}.Debug|Win32.ActiveCfg = Debug|Win32
13+
{1AC3DDD7-FDDE-487E-A2A4-52A8FCF7BDB9}.Debug|Win32.Build.0 = Debug|Win32
14+
{1AC3DDD7-FDDE-487E-A2A4-52A8FCF7BDB9}.Release|Win32.ActiveCfg = Release|Win32
15+
{1AC3DDD7-FDDE-487E-A2A4-52A8FCF7BDB9}.Release|Win32.Build.0 = Release|Win32
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
EndGlobal

PT Project.suo

33.5 KB
Binary file not shown.

PT Project.v11.suo

136 KB
Binary file not shown.

PT Project.v12.suo

257 KB
Binary file not shown.

0 commit comments

Comments
 (0)