00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00030 #ifndef LAYOUTMANAGER_HPP_
00031 #define LAYOUTMANAGER_HPP_
00032
00033 #include "layoutView.hpp"
00034 #include "layoutConfig.hpp"
00035 #include "truthTableManager.hpp"
00036 #include "ruleManager.hpp"
00037 #include "forbiddenPatternManager.hpp"
00038 #include "layoutDiskManager.hpp"
00039 #include "mainController.hpp"
00040 #include <map>
00041 #include <list>
00042 #include <wx/wx.h>
00043
00044 class LayoutView;
00045 class LayoutConfig;
00046 class LayoutDiskManager;
00047
00048 using namespace std;
00049
00050 class LayoutManager
00051 {
00052 public:
00053 LayoutManager(MainController *controller, TruthTableManager *tableManager, ForbiddenPatternManager *FPManager, RuleManager *ruleManager);
00054 virtual ~LayoutManager();
00055 void setView(LayoutView *view);
00056 void newLayout(int width, int height, int inputs, int outputs);
00057 void newLayout(LayoutConfig *layoutConfig);
00058 void tableSelected(wxString tableId);
00059 void inputSelected(int input);
00060 void outputSelected(int output);
00061 bool tableChecked(wxString tableId, bool checked);
00062 bool ruleChecked(unsigned int rule, bool checked);
00063 bool FPChecked(unsigned int FP, bool checked);
00064 void cellChanged(int x, int y);
00065 void tablesChanged();
00066 void rulesChanged();
00067 void FPsChanged();
00068 LayoutConfig* getLayout();
00069 bool saveFile();
00070 bool saveFileAs();
00071 void openFile();
00072 bool openPFile(wxString file);
00073 bool saveFilename(wxString file);
00074 void assignInput();
00075 void assignOutput();
00076 void escapePressed();
00077 bool isLayoutModified();
00078 bool setInput(wxString table, int input, int x, int y);
00079 bool setOutput(wxString table, int output, int x, int y);
00080 wxString getFileName();
00081 map< wxString, vector<coordinate> > getTableInputs();
00082 map< wxString, vector<coordinate> > getTableOutputs();
00083 vector<coordinate> getTableInput(wxString table);
00084 vector<coordinate> getTableOutput(wxString table);
00085 map< wxString, bool> getTableEnabled();
00086 map<unsigned int, bool> getRuleEnabled();
00087 map<unsigned int, bool> getFPEnabled();
00088 int getTables();
00089 int getRules();
00090 int getFPs();
00091 void clean();
00092 void prepareSimulation();
00093 void startSimulation();
00094 list <ForbiddenPattern> getListFPEnabled();
00095 list <Rule> getListRuleEnabled();
00096 void elementChanged();
00097 TruthTable *getTableSelected();
00098 bool checkLayout();
00099 void enableSimulation();
00100
00101 private:
00103 LayoutView *view;
00105 TruthTableManager *tableManager;
00107 ForbiddenPatternManager *FPManager;
00109 RuleManager *ruleManager;
00111 LayoutConfig* configuration;
00113 FileManagerView fileView;
00115 LayoutDiskManager *diskManager;
00117 MainController *controller;
00119 wxString layoutFileName;
00121 bool layoutModified;
00123 bool layoutNeedNewFile;
00125 map< wxString, vector<coordinate> > tableInputs;
00127 map< wxString, vector<coordinate> > tableOutputs;
00129 map< wxString, bool> tableEnabled;
00131 map<unsigned int, bool> ruleEnabled;
00133 map<unsigned int, bool> FPEnabled;
00135 wxString currentTable;
00137 int currentInput;
00139 int currentOutput;
00141 bool assigningInput;
00143 bool assigningOutput;
00144 void updateGrids(bool changed);
00145 void updateTTList(wxArrayString tables);
00146 void updateFPList(wxArrayString FPs);
00147 void updateRuleList(wxArrayString rules);
00148 void updateTable();
00149 void updateIOList();
00150 bool findString(wxArrayString list, wxString item);
00151 bool inputAssigned(int x,int y);
00152 bool outputAssigned(int x,int y);
00153 bool findInputAssignment(vector<coordinate> list, int x, int y);
00154 bool findOutputAssignment(vector<coordinate> list, int x, int y);
00155 void resetIO();
00156 };
00157
00158 #endif