00001 #ifndef _TRANSITIONMANAGER_H_12353466884_
00002 #define _TRANSITIONMANAGER_H_12353466884_
00003
00004 class Editor;
00005 class Transition;
00006 class OneStateTransition;
00007 class TwoStatesTransition;
00008 class State;
00009 class TransitionDialog;
00010 class TransitionLoopSEDialog;
00011
00012 #include <QList>
00013 #include <QMap>
00014 #include <QtDebug>
00015
00016
00017
00018
00019 struct OneStateTransitionProperties
00020 {
00021 OneStateTransitionProperties(bool label = false, bool labelPos = false,
00022 float labelPosVal = .0f)
00023 : hasLabel(label), hasLabelPos(labelPos),
00024 defLabelPos(labelPosVal)
00025 {}
00026
00027 bool hasLabel;
00028 bool hasLabelPos;
00029 float defLabelPos;
00030 };
00031
00032 struct TwoStatesTransitionProperties
00033 {
00034 TwoStatesTransitionProperties
00035 (bool label = false, bool labelPos = false,
00036 bool arcAngleA = false, bool nCurve = false,
00037 bool arcAngleB = false, float labelPosVal = .0f,
00038 float arcAngleAVal = .0f, float nCurveVal = .0f,
00039 float arcAngleBVal = .0f)
00040 : hasLabel(label), hasLabelPos(labelPos),
00041 hasArcAngleA(arcAngleA), hasNCurve(nCurve),
00042 hasArcAngleB(arcAngleB), defLabelPos(labelPosVal), defArcAngleA(arcAngleAVal),
00043 defNCurve(nCurveVal), defArcAngleB(arcAngleBVal)
00044 {}
00045
00046 bool hasLabel;
00047 bool hasLabelPos;
00048 bool hasArcAngleA;
00049 bool hasNCurve;
00050 bool hasArcAngleB;
00051
00052 float defLabelPos;
00053 float defArcAngleA;
00054 float defNCurve;
00055 float defArcAngleB;
00056 };
00057
00058
00059
00060
00061
00062 class TransitionManager
00063 {
00064 private:
00065 static bool instantiated;
00066 static TransitionManager *manager;
00067 TransitionManager();
00068
00069 public:
00070
00071 static TransitionManager* getInstance();
00072
00073 ~TransitionManager()
00074 {
00075 instantiated = false;
00076 }
00077
00078
00079 const QList<QString> &getOneStateTransitionTypeNameList() const;
00080 const QList<QString> &getTwoStatesTransitionTypeNameList() const;
00081
00082
00083 int getTypeNameId(const QString &typeName) const;
00084
00085
00086 const OneStateTransitionProperties& getOneStateTransitionProperties(int typeId) const;
00087 const TwoStatesTransitionProperties& getTwoStatesTransitionProperties(int typeId) const;
00088
00089 OneStateTransition* createOneStateTransition
00090 (Editor *editor, State *state, const TransitionLoopSEDialog& td);
00091 OneStateTransition* createOneStateTransition
00092 (const QString& typeName, Editor *editor, State *state,
00093 const QString& label, int direction, bool dimmed);
00094
00095 TwoStatesTransition* createTwoStatesTransition
00096 (Editor *editor, State *s1, State *s2, const TransitionDialog& td);
00097 TwoStatesTransition* createTwoStatesTransition
00098 (const QString& typeName, Editor *editor, State* s1, State* s2,
00099 const QString& label, bool leftOriented, bool dimmed);
00100
00101 protected:
00102
00103
00104 OneStateTransition* createTransitionInitial
00105 (Editor *editor, State *state, const QString &, int direction, bool dimmed);
00106 OneStateTransition* createTransitionFinal
00107 (Editor *editor, State *state, const QString &, int direction, bool dimmed);
00108 OneStateTransition* createTransitionLoop
00109 (Editor *editor, State *state, const QString &label, int direction, bool dimmed);
00110 OneStateTransition* createTransitionCLoop
00111 (Editor *editor, State *state, const QString &label, int direction, bool dimmed);
00112 OneStateTransition* createTransitionLoopVar
00113 (Editor *editor, State *state, const QString &label, int direction, bool dimmed);
00114
00115
00116 TwoStatesTransition* createTransitionLine
00117 (Editor *editor, State *s1, State *s2, const QString &label, bool leftOriented, bool dimmed);
00118 TwoStatesTransition* createTransitionArc
00119 (Editor *editor, State *s1, State *s2, const QString &label, bool leftOriented, bool dimmed);
00120 TwoStatesTransition* createTransitionLArc
00121 (Editor *editor, State *s1, State *s2, const QString &label, bool leftOriented, bool dimmed);
00122 TwoStatesTransition* createTransitionVArc
00123 (Editor *editor, State *s1, State *s2, const QString &label, bool leftOriented, bool dimmed);
00124 TwoStatesTransition* createTransitionVCurve
00125 (Editor *editor, State *s1, State *s2, const QString &label, bool leftOriented, bool dimmed);
00126
00127
00128 QList<QString> oneStateTransitionTypeList;
00129 QList<QString> twoStatesTransitionTypeList;
00130
00131
00132 typedef OneStateTransition* (TransitionManager::*OneStateTransitionConstructor)
00133 (Editor* , State* , const QString& ,
00134 int , bool );
00135 typedef QMap<QString, OneStateTransitionConstructor> TypeNameToOneStateInstanceMap;
00136
00137 typedef QMap<QString, OneStateTransitionProperties> TypeNameToOneStatePropsMap;
00138 typedef QMap<QString, TwoStatesTransitionProperties> TypeNameToTwoStatesPropsMap;
00139
00140
00141 TypeNameToOneStateInstanceMap typeNameToOneStateInstanceMap;
00142
00143 TypeNameToOneStatePropsMap typeNameToOneStatePropsMap;
00144 TypeNameToTwoStatesPropsMap typeNameToTwoStatesPropsMap;
00145
00146 typedef TwoStatesTransition* (TransitionManager::*TwoStatesTransitionConstructor)
00147 (Editor* , State* , State* , const QString& ,
00148 bool , bool );
00149 typedef QMap<QString, TwoStatesTransitionConstructor> TypeNameToTwoStatesInstanceMap;
00150
00151 TypeNameToTwoStatesInstanceMap typeNameToTwoStatesInstanceMap;
00152 };
00153
00154 #endif //_TRANSITIONMANAGER_H_12353466884_