00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MACHINE_H
00020 #define MACHINE_H
00021
00022 #include <math.h>
00023 #include <qlist.h>
00024 #include <qobject.h>
00025 #include <qstringlist.h>
00026
00027 #include "GState.h"
00028 #include "GITransition.h"
00029 #include "Project.h"
00030
00031 class GTransition;
00032 class ICheck;
00033
00038 enum ObjectType {NoT, StateT, TransitionT, ITransitionT};
00039
00040
00045 class Machine : public QObject
00046 {
00047 Q_OBJECT
00048 public:
00049 Machine(QObject* parent=NULL, const char* name=0);
00050 Machine(QObject* name, const QString, QString, int type, int, QString, int, QString, int,
00051 QString, QFont, QFont, int);
00052 ~Machine();
00053
00055 GState* getInitialState() { return initial_state; };
00057 void setInitialState(GState* s) { initial_state = s; };
00059 GITransition* getInitialTransition() { return initial_transition; };
00061 void setInitialTransition(GITransition* t) { initial_transition = t; };
00063 void attachInitialTransition();
00064
00070 GState* getPhantomState() { return phantom_state; };
00072 void setPhantomState(GState* s) { phantom_state = s; };
00074 QList<GState>& getSList() { return state_list; };
00076 QString getName() { return name; };
00078 void setName(const QString n) { name = n; };
00080 QString getVersion() { return version; };
00082 void setVersion( QString v) { version = v; };
00084 int getType() { return type; };
00086 void setType(int t) { type = t; };
00088 int getNumBits() { return num_bits; };
00090 void setNumBits(int);
00092 int getNumInputs() { return num_input; };
00094 void setNumInputs(int );
00096 int getNumOutputs() { return num_output; };
00098 void setNumOutputs(int );
00100 QFont& getSFont() { return state_font; };
00102 void setSFont(const QFont& f) { state_font = f; };
00104 QFont& getTFont() { return transition_font; };
00106 void setTFont(const QFont& f) { transition_font = f; };
00108 int getArrowType() { return arrow_type; };
00110 void setArrowType(int t) { arrow_type=t; };
00112 void setProject(Project* p) { project = p; };
00114 Project* getProject() { return project; };
00115 int countStates();
00116 int getNewCode();
00117
00118 bool addState(const QString , QString, int , double , double , int , double, QPen,
00119 bool endstate, bool withundo=TRUE);
00120 bool addState(GState* , bool withundo=TRUE);
00121 GState* getState(QPoint , double );
00122 GObject* getObject(QPoint p, double scale, int& type);
00123 void removeState(GState* );
00124 GState* getState(int );
00125 QList<GState> getEndStates();
00126
00128 void getCanvasSize(int& w, int& h) { w=canvas_size.width();
00129 h=canvas_size.height(); };
00130 void setCanvasSize(int, int);
00131 void calcCanvasSize();
00132 int getNumStates();
00133
00134 void setMooreOutputNames(int, QString );
00135 QString getMooreOutputNames(QString separator=", ");
00136 void setMealyInputNames(int, QString );
00137 QString getMealyInputNames(QString separator=", ");
00138 void setMealyOutputNames(int, QString );
00139 QString getMealyOutputNames(QString separator=", ");
00140
00142 QStringList getMooreOutputList() { return output_names_moore; };
00144 void setMooreOutputList(QStringList l) { output_names_moore = l; };
00146 QStringList getInputNameList() { return input_names; };
00148 void setInputNameList(QStringList l) { input_names = l; };
00150 QStringList getOutputNameList() { return output_names; };
00152 void setOutputNameList(QStringList l) { output_names = l; };
00153 static void replaceChar(QString& s, QChar c1, QChar c2);
00154
00155 void checkIntegrity(ICheck* );
00156
00157 void getEventList(QList<IOInfo>*);
00158
00159 private:
00161 Project* project;
00163 QString name;
00165 QString version;
00167 int type;
00169 int num_bits;
00171 int num_input;
00173 int num_output;
00175 QStringList input_names;
00177 QStringList output_names;
00179 QStringList output_names_moore;
00181 QFont state_font;
00183 QFont transition_font;
00185 int arrow_type;
00187 QList<GState> state_list;
00189 GState* initial_state;
00191 GState* phantom_state;
00193 GITransition* initial_transition;
00195 QSize canvas_size;
00196
00197 signals:
00199 void newCanvasSize(int, int);
00200
00201 public slots:
00202 void updateCanvasSize(int, int, double);
00203 void updateCanvasSize(int, int);
00204 };
00205
00206
00207
00208
00209 #endif