1 // GraphicView widget and supporting classes
2 // Copyright © 2009 The University of Chicago
8 class LabeledDataPoint
;
16 #include <Q3CanvasView>
17 #include <Q3CanvasRectangle>
18 #include <Q3CanvasLine>
23 #include "StringSurrogate.h"
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;
42 CParse m_DimensionLabels
;
43 VideoFrame (int dimensionality
);
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
*>
57 int m_NumberOfDataPoints
;
59 CParse m_DimensionLabels
;
60 // QPtrList<VideoFrame> m_VideoFrames;
63 Video (int dimensionality
);
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
80 int m_CurrentLocation
;
83 LabeledDataPoint ( QString label
, int dimensionality
);
85 bool operator<< (double);
93 class GraphicView
: public Q3CanvasView
97 Q3CanvasItem
* pendingItem
;
98 Q3CanvasItem
* activeItem
;
100 QAction
* PropertiesAct
;
101 QAction
* PlotStatesAct
;
103 QAction
* DisplayMeAct
;
106 Q3PtrList
<CEdge
>* m_MyRoots
;
110 QMap
<QString
, QString
>* m_filter
;
112 // HMM Display Related members
113 int m_numberOfDimension
;
114 double** m_multiDimensionDataPoints
;
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
; }
126 void PlotNVectors(int, int, double**, QMap
<int, QString
>);
127 void PlotNVectors2(VideoFrame
* data
);
128 void PlotVideo(Video
* pVideo
);
132 void contentsContextMenuEvent(QContextMenuEvent
* event
);
133 void contentsMousePressEvent(QMouseEvent
* event
);
134 void contentsMouseDoubleClickEvent(QMouseEvent
*event
);
136 void computeProjectedLocForOneDataPoint(LabeledDataPoint
* Data
,
137 double** anchors
, double& xcord
, double& ycoor
);
139 void computeProjectedLocForOneDataPoint(int num_states
,
140 double** anchor_coords
, double* highdim_data
,
141 double& xcoord
, double& ycoord
);
143 void createActions();
144 void setActiveItem(Q3CanvasItem
*item
);
145 void showNewItem(Q3CanvasItem
*item
);
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
158 enum { RTTI
= 1001 };
160 DiagramBox(Q3Canvas
*canvas
);
161 DiagramBox(Q3Canvas
*canvas
, int, int, CState
*);
164 void setText(const QString
&newText
);
165 QString
text() const { return str
; }
166 void drawShape(QPainter
&painter
);
167 int rtti() const { return RTTI
; }
177 class DiagramLine
: public Q3CanvasLine
180 enum { RTTI
= 1002 };
182 DiagramLine(Q3Canvas
*canvas
);
185 void drawShape(QPainter
&painter
);
186 int rtti() const { return RTTI
; }
189 int m_FromWhichState
;
191 StringToInt m_Morphemes
;
200 class ProbBox
: public Q3CanvasRectangle
203 enum { RTTI
= 1003 };
205 ProbBox(Q3Canvas
*canvas
);
206 ProbBox(Q3Canvas
*canvas
, int, int, bool, int);
209 void setText(const QString
&newText
);
210 QString
text() const { return str
; }
211 void drawShape(QPainter
&painter
);
212 int rtti() const { return RTTI
; }
220 class Anchor
: public Q3CanvasEllipse
223 enum { RTTI
= 1010 };
225 Anchor(Q3Canvas
*canvas
);
226 Anchor(Q3Canvas
*canvas
, int, int);
229 void setText(const QString
&newText
);
230 QString
text() const { return m_str
; }
231 void drawShape(QPainter
&painter
);
232 int rtti() const { return RTTI
; }
242 #endif // GRAPHICVIEW_H