CMiniLexicon::FindMajorSignatures(): use log file routines
[linguistica.git] / GraphicView.h
blob7034900443af9266c4928c63dd1c8dfd0e3b8c86
1 // GraphicView widget and supporting classes
2 // Copyright © 2009 The University of Chicago
3 #ifndef GRAPHICVIEW_H
4 #define GRAPHICVIEW_H
6 class VideoFrame;
7 class Video;
8 class LabeledDataPoint;
9 class GraphicView;
10 class DiagramBox;
11 class DiagramLine;
12 class ProbBox;
13 class Anchor;
15 #include <QList>
16 #include <Q3CanvasView>
17 #include <Q3CanvasRectangle>
18 #include <Q3CanvasLine>
20 #include <QPainter>
21 #include <QString>
22 #include <QMap>
23 #include "StringSurrogate.h"
24 #include "Edge.h"
26 class QAction;
27 class CState;
28 class CStem;
30 typedef QMap<QString,int> StringToInt;
31 typedef QMap<CState*,StringToInt*> StateToStringToInt;
32 typedef QMap<CState*,int> StateToInt;
33 typedef QMap<int,double> IntToDouble;
34 typedef QMap<int,QString> IntToString;
36 class VideoFrame : public QList< LabeledDataPoint*>
38 // QPtrList< LabeledDataPoint> m_Data;
40 public:
41 int m_Dimensionality;
42 CParse m_DimensionLabels;
43 VideoFrame (int dimensionality);
44 VideoFrame ( );
45 VideoFrame (VideoFrame& );
47 void operator<< ( LabeledDataPoint* );
48 void AddLabels ( CStringSurrogate );
49 void Incorporate ( VideoFrame* );
50 // QPtrList<LabeledDataPoint>* GetData ( ) {return &m_Data;}
53 class Video : public QList<VideoFrame*>
56 int m_Dimensionality;
57 int m_NumberOfDataPoints;
58 int m_NumberOfFrames;
59 CParse m_DimensionLabels;
60 // QPtrList<VideoFrame> m_VideoFrames;
62 public:
63 Video (int dimensionality );
64 ~Video ( );
65 void operator<< ( VideoFrame *);
66 void AddLabels ( CStringSurrogate );
67 int GetDimensionality () { return m_Dimensionality;}
68 int GetNumberOfDataPoints () { return m_NumberOfDataPoints; }
69 // int GetNumberOfFrames () { return m_NumberOfFrames; }
70 // QPtrList<VideoFrame>* GetVideoFrames () { return m_VideoFrames; }
74 class LabeledDataPoint
76 public:
77 QString m_Label;
78 int m_Dimensionality;
79 double* m_Values;
80 int m_CurrentLocation;
82 LabeledDataPoint ();
83 LabeledDataPoint ( QString label, int dimensionality);
84 ~LabeledDataPoint ();
85 bool operator<< (double);
93 class GraphicView : public Q3CanvasView
95 Q_OBJECT
97 Q3CanvasItem* pendingItem;
98 Q3CanvasItem* activeItem;
100 QAction* PropertiesAct;
101 QAction* PlotStatesAct;
102 QAction* RefreshAct;
103 QAction* DisplayMeAct;
105 CState* m_MyState;
106 Q3PtrList<CEdge>* m_MyRoots;
107 bool m_IsStateView;
108 CStem* m_MyStem;
110 QMap<QString, QString>* m_filter;
112 // HMM Display Related members
113 int m_numberOfDimension;
114 double** m_multiDimensionDataPoints;
115 public:
116 GraphicView();
117 GraphicView(Q3Canvas *canvas,
118 QMap<QString, QString>* filter = 0, QWidget* parent = 0);
119 virtual ~GraphicView();
121 void SetFilter(QMap<QString, QString>* filter) { m_filter = filter; }
122 public slots:
123 void Properties();
124 void PlotStates();
125 void PlotStems();
126 void PlotNVectors(int, int, double**, QMap<int, QString>);
127 void PlotNVectors2(VideoFrame* data);
128 void PlotVideo(Video* pVideo);
129 void Refresh();
130 void DisplayMe();
131 protected:
132 void contentsContextMenuEvent(QContextMenuEvent* event);
133 void contentsMousePressEvent(QMouseEvent* event);
134 void contentsMouseDoubleClickEvent(QMouseEvent *event);
135 protected:
136 void computeProjectedLocForOneDataPoint(LabeledDataPoint* Data,
137 double** anchors, double& xcord, double& ycoor);
138 /// deprecated
139 void computeProjectedLocForOneDataPoint(int num_states,
140 double** anchor_coords, double* highdim_data,
141 double& xcoord, double& ycoord);
142 private:
143 void createActions();
144 void setActiveItem(Q3CanvasItem *item);
145 void showNewItem(Q3CanvasItem *item);
146 public:
147 void SetMyState(CState* pState)
148 { m_MyState = pState; m_IsStateView = true; }
149 void SetMyStem(CStem* pStem)
150 { m_MyStem = pStem; m_IsStateView = false;};
151 void SetMyRoots(Q3PtrList<CEdge>* roots)
152 { m_MyRoots = roots; m_IsStateView = false;}
155 class DiagramBox : public Q3CanvasRectangle
157 public:
158 enum { RTTI = 1001 };
160 DiagramBox(Q3Canvas *canvas);
161 DiagramBox(Q3Canvas *canvas, int, int, CState*);
162 ~DiagramBox();
164 void setText(const QString &newText);
165 QString text() const { return str; }
166 void drawShape(QPainter &painter);
167 int rtti() const { return RTTI; }
170 private:
171 QString str;
172 public:
173 CState* m_MyState;
177 class DiagramLine : public Q3CanvasLine
179 public:
180 enum { RTTI = 1002 };
182 DiagramLine(Q3Canvas *canvas);
183 ~DiagramLine();
185 void drawShape(QPainter &painter);
186 int rtti() const { return RTTI; }
188 public:
189 int m_FromWhichState;
190 int m_ToWhichState;
191 StringToInt m_Morphemes;
200 class ProbBox : public Q3CanvasRectangle
202 public:
203 enum { RTTI = 1003 };
205 ProbBox(Q3Canvas *canvas);
206 ProbBox(Q3Canvas *canvas, int, int, bool, int);
207 ~ProbBox();
209 void setText(const QString &newText);
210 QString text() const { return str; }
211 void drawShape(QPainter &painter);
212 int rtti() const { return RTTI; }
215 private:
216 QString str;
220 class Anchor : public Q3CanvasEllipse
222 public:
223 enum { RTTI = 1010 };
225 Anchor(Q3Canvas *canvas);
226 Anchor(Q3Canvas *canvas, int, int);
227 ~Anchor();
229 void setText(const QString &newText);
230 QString text() const { return m_str; }
231 void drawShape(QPainter &painter);
232 int rtti() const { return RTTI; }
235 private:
236 QString m_str;
242 #endif // GRAPHICVIEW_H