AnnotationObject.qt.H
00001 #ifndef ANNOTATIONOBJECT_QT_H
00002 #define ANNOTATIONOBJECT_QT_H
00003
00004 #include <QtGui/QtGui>
00005 #include "NeovisionII/NeoAnnotate/AnimationModel.qt.H"
00006 #include "NeovisionII/NeoAnnotate/ObjectAnimation.qt.H"
00007
00008
00009 class AnnotationObject;
00010 class FrameRange;
00011
00012
00013 class AnnotationObjectVertex : public QObject, public QGraphicsItem
00014 {
00015 Q_OBJECT
00016
00017 public:
00018
00019 AnnotationObjectVertex(AnnotationObject *parent, int frameNum, FrameRange frameRange, QPointF initialPos);
00020
00021
00022 QRectF boundingRect() const;
00023
00024
00025 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
00026
00027 ObjectAnimation * getAnimation() { return itsAnimation; }
00028
00029 ObjectAnimation::FrameState getFrameState(int fnum) { return itsAnimation->getFrameState(fnum); }
00030
00031
00032 void makeOpaque();
00033
00034
00035 void makeTransparent();
00036
00037
00038 void setKeyframe(int frameNum, QPointF pos, bool visible);
00039
00040
00041 void clearAnimation();
00042
00043 signals:
00044 void animationChanged();
00045
00046 public slots:
00047
00048 void frameChanged(int);
00049
00050 protected:
00051
00052 QVariant itemChange(GraphicsItemChange change, const QVariant &value);
00053
00054
00055 void hoverEnterEvent(QGraphicsSceneHoverEvent * event);
00056
00057
00058 void hoverLeaveEvent(QGraphicsSceneHoverEvent * event);
00059
00060
00061
00062 void mouseReleaseEvent(QGraphicsSceneMouseEvent * event);
00063
00064
00065 void mousePressEvent(QGraphicsSceneMouseEvent * event);
00066
00067 private:
00068 const QRectF getVertexRect(void) const;
00069
00070 const QRectF itsVertexSize;
00071
00072 AnnotationObject * itsParent;
00073
00074
00075 QPen itsPen;
00076
00077 QBrush itsBrush;
00078
00079 QColor itsColor;
00080
00081 ObjectAnimation * itsAnimation;
00082
00083 int itsCurrentFrame;
00084 };
00085
00086
00087 class AnnotationObject : public QObject, public QGraphicsItem
00088 {
00089 Q_OBJECT
00090
00091 public:
00092
00093 AnnotationObject(int frameNum, FrameRange frameRange, QPointF initialPos,
00094 QString description="None", int type=0,
00095 QGraphicsItem * parent = 0);
00096
00097
00098 ~AnnotationObject();
00099
00100
00101 void addVertex(int index, AnnotationObjectVertex * v);
00102
00103
00104
00105
00106 void insertVertexAtPoint(QPointF point);
00107
00108
00109 void removeVertex(QPointF point);
00110
00111
00112 void showSelected();
00113
00114
00115 void showDeselected();
00116
00117
00118 QRectF boundingRect() const;
00119
00120
00121
00122
00123
00124 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
00125
00126
00127
00128 int getId() const { return itsId; }
00129
00130
00131 QString getDescription() const { return itsDescription; }
00132
00133
00134 int getType() const { return itsType; }
00135
00136
00137 QColor getColor() const { return itsColor; }
00138
00139
00140 QPointF getCenter() const;
00141
00142
00143 void setDescription(QString description) { itsDescription = description; setToolTip(description); update(); }
00144
00145
00146 void setType(int type) { itsType = type; update(); }
00147
00148
00149 ObjectAnimation::FrameState getFrameState(int fnum) { return itsAnimation->getFrameState(fnum); }
00150
00151
00152 ObjectAnimation * getAnimation() { return itsAnimation; }
00153
00154
00155 QList<AnnotationObjectVertex*>* getVertices() { return &itsVertices; }
00156
00157
00158 AnimationModel* getAnimationModel();
00159
00160
00161 void constructAnimationContextMenu(QPoint globalPos, int row, int column);
00162
00163 int getCurrentFrameNum() { return itsCurrentFrame; }
00164
00165
00166
00167
00168 void selectVertex(AnnotationObjectVertex *vertex);
00169
00170
00171 QPainterPath shape() const;
00172
00173
00174
00175
00176
00177
00178 void pubPrepareGeometryChange() { this->prepareGeometryChange(); }
00179
00180
00181 void setLastClick(const QModelIndex & index) {itsAnimationModel.setLastClick(index);}
00182
00183
00184 void setOpacity(int opacity) { itsOpacity = opacity; update(); }
00185
00186
00187
00188
00189
00190
00191 QVector<QMap<int, QPointF > > renderAnimation();
00192
00193
00194 std::map<int, ObjectAnimation::FrameState> getVertexStates(int fnum);
00195
00196
00197 void setVertices(std::map<int, ObjectAnimation::FrameState> VertexFrames);
00198
00199
00200 void setKeyframe(int frameNum, QPointF pos, bool visible);
00201
00202
00203 void forceId(int id);
00204
00205
00206 AnnotationObjectVertex* getVertexById(int id) { return itsVertices[id]; }
00207
00208
00209 void clearAnimation();
00210 signals:
00211
00212 void objectSelected(int);
00213
00214
00215 void rowSelected(int);
00216
00217
00218 void animationChanged(int row, int frame);
00219
00220
00221 public slots:
00222
00223 void frameChanged(int);
00224
00225
00226 void updateAnimation();
00227
00228 protected:
00229
00230
00231 void mouseReleaseEvent(QGraphicsSceneMouseEvent * event);
00232
00233
00234 void mousePressEvent(QGraphicsSceneMouseEvent * event);
00235
00236 private:
00237
00238 void recalculatePoly();
00239
00240 static int theirIdCount;
00241
00242 int itsId;
00243
00244 QString itsDescription;
00245
00246 int itsType;
00247
00248 QPolygonF itsPoly;
00249
00250 QBrush itsBrush;
00251
00252 QPen itsPen;
00253
00254 QColor itsColor;
00255
00256 int itsCurrentFrame;
00257
00258 ObjectAnimation *itsAnimation;
00259
00260 int itsOpacity;
00261
00262 bool itsSelected;
00263
00264 AnimationModel itsAnimationModel;
00265
00266 QList<AnnotationObjectVertex*> itsVertices;
00267
00268
00269 };
00270
00271
00272
00273
00274
00275
00276 struct AnnotationObjectFrame
00277 {
00278 QString ObjectDescription;
00279 int ObjectType;
00280 int ObjectId;
00281 ObjectAnimation::FrameState ObjectFrameState;
00282 std::map<int, ObjectAnimation::FrameState> VertexFrames;
00283 };
00284
00285
00286 #endif //ANNOTATIONOBJECT_QT_H
00287
00288