Go to the documentation of this file.00001 #ifndef _DRAWALGORITHM_H_7435185424786_
00002 #define _DRAWALGORITHM_H_7435185424786_
00003
00004 #include "idrawalgorithm.h"
00005 #include "igraphviz.h"
00006
00007
00008
00009
00010
00011
00012 class BaseDrawAlgorithm : public IDrawAlgorithm
00013 {
00014 public:
00015 typedef QMap<QString, unsigned int> TDistanceMap;
00016 typedef QMap<QString, QString> TPredecessorMap;
00017
00018 protected:
00019 IState::TIStateList getBFSSortedStates(const QSharedPointer<IAutomaton> &automaton) const;
00020
00021 void fillDijkstraShortestPaths(const QSharedPointer<IAutomaton> &automaton,
00022 const QString &fromStateName,
00023 TDistanceMap &distances, TPredecessorMap &predecessors) const;
00024
00025 void relax (const QString &u, const QString &v,
00026 TDistanceMap &distances, TPredecessorMap &predecessors) const;
00027
00028 void initPaths(const IState::TIStateList &states, const QString& fromStateName,
00029 TDistanceMap &distances, TPredecessorMap &predecessors) const;
00030
00031 IState::TIStateNameSet getStatesInDistance(unsigned int distance,
00032 const TDistanceMap &distances) const;
00033
00034 unsigned int getMaxDistance(const TDistanceMap &distances) const;
00035
00036 void drawTransitions(Editor *editor,
00037 const Editor::TStateMap &states,
00038 const QSharedPointer<IAutomaton> &automaton,
00039 const ITransition::TITransitionList &transitions,
00040 const QPoint &startPos) const;
00041
00042 QString charactersToLabel(const QSharedPointer<IAutomaton> &automaton,
00043 const QSharedPointer<ITransition> &transition) const;
00044
00045 #ifdef USE_TRANSITION_GROUPING_IN_DRAWING_ALGORITHM
00046 ITransition::TITransitionList getGroupedTransitions(const QSharedPointer<IAutomaton> &automaton) const;
00047 #endif
00048
00049 static const int X_STEP;
00050 static const int Y_STEP;
00051 };
00052
00053
00054
00055
00056
00057
00058
00059 class NaiveDrawAlgorithm : public BaseDrawAlgorithm
00060 {
00061 public:
00062 QList<State*> drawAutomaton(Editor *editor, const QSharedPointer<IAutomaton> &automaton);
00063
00064 QString getName() const { return "Naive drawing algorithm"; }
00065 };
00066
00067
00068
00069
00070
00071
00072
00073
00074 class FarthestFinalDrawAlgorithm : public BaseDrawAlgorithm
00075 {
00076 public:
00077 QList<State*> drawAutomaton(Editor *editor, const QSharedPointer<IAutomaton> &automaton);
00078
00079 QString getName() const { return "Farthest final state drawing algorithm"; }
00080 };
00081
00082
00083
00084
00085
00086
00087
00088 class GraphVizDrawAlgorithm : public BaseDrawAlgorithm
00089 {
00090 public:
00091 GraphVizDrawAlgorithm(IGraphViz *graphVizWrapper);
00092
00093 QList<State*> drawAutomaton(Editor *editor, const QSharedPointer<IAutomaton> &automaton);
00094
00095 QString getName() const { return "GraphViz drawing algorithm"; }
00096
00097 protected:
00098 enum ETransitionType {eLine, eLoop, eCurve};
00099
00100 void drawTransitionsAccordingToGV(Editor *editor,
00101 const Editor::TStateMap &states,
00102 const QSharedPointer<IAutomaton> &automaton,
00103 const QSharedPointer<IGVGraph> &graph) const;
00104
00105 IGVEdge::TCPList convertCPToBezierCP(const QSharedPointer<IGVEdge> &edge) const;
00106 ETransitionType getTransitionType(const QSharedPointer<IGVEdge> &edge, const IGVEdge::TCPList &bezierCP) const;
00107
00108 private:
00109 IGraphViz *m_graphVizWrapper;
00110 };
00111
00112 #endif //_DRAWALGORITHM_H_7435185424786_