00001 #ifndef MAINWINDOW_H 00002 #define MAINWINDOW_H 00003 00004 #include <Qt/qapplication.h> 00005 #include <QtGui/qgroupbox.h> 00006 #include <QtGui/qgraphicsscene.h> 00007 #include <QtGui/qgraphicsview.h> 00008 #include <QtGui/qtableview.h> 00009 #include <QtGui/qslider.h> 00010 #include <QtGui/qboxlayout.h> 00011 #include <QtGui/qmainwindow.h> 00012 #include <QtGui/qpushbutton.h> 00013 #include <QtGui/qmenubar.h> 00014 #include <QtGui/qmenu.h> 00015 #include <QtGui/qfiledialog.h> 00016 #include <QtGui/qmessagebox.h> 00017 #include <QtGui/qtoolbar.h> 00018 #include <QtCore/qtimeline.h> 00019 00020 00021 #include "Component/ModelManager.H" 00022 #include "Component/ModelComponent.H" 00023 #include "Media/FrameSeries.H" 00024 #include "Image/Image.H" 00025 #include "Image/PixelsTypes.H" 00026 #include "QtUtil/ImageConvert4.H" 00027 #include "Qt4/ImageGraphicsItem.qt.H" 00028 #include "NeovisionII/NeoAnnotate/CachedFrameLoader.H" 00029 #include "NeovisionII/NeoAnnotate/MainDisplay.qt.H" 00030 #include "NeovisionII/NeoAnnotate/AnnotationObjectManager.qt.H" 00031 #include "NeovisionII/NeoAnnotate/DBManager.qt.H" 00032 #include "NeovisionII/NeoAnnotate/PreferencesDialog.qt.H" 00033 00034 class MainWindow : public QMainWindow 00035 { 00036 Q_OBJECT 00037 00038 public: 00039 //! Create a new MainWindow 00040 MainWindow(); 00041 00042 //! Constructs the actual window 00043 /*! buildWindow() does all the work of actually instantiating all of the Qt 00044 * member objects and setting up the layouts, etc. Any changes to the 00045 * window building should go in here.*/ 00046 void buildWindow(); 00047 00048 bool eventFilter(QObject * watched, QEvent * event); 00049 00050 void setDBStatusLabel(QString text); 00051 void setAnnotatorLabel(QString text); 00052 FrameRange getFrameRange() { return itsCachedFrameLoader->getFrameRange(); } 00053 MainDisplay* getMainDisplay() { return itsMainDisplay; } 00054 QTimeLine* getTimeline() { return itsTimeline; } 00055 00056 public slots: 00057 //! Update a frame on a new timeline event 00058 void updateFrame(int frameNum); 00059 00060 //! Create a new Annotation Object, and pass it to our Main Display and Object Manager 00061 void addObject(); 00062 00063 void playPushed(); 00064 00065 void changeTime(int frameNum); 00066 00067 void animationViewPopup(const QPoint & pos); 00068 00069 void animationFrameSelected(const QModelIndex &); 00070 00071 //! Open a dialog to export the annotation data to xml 00072 //void saveAnnotation(); 00073 00074 //! Open a dialog to load the annotation data from xml 00075 //void loadAnnotation(); 00076 00077 //! Open a new video file 00078 void openVideo(); 00079 00080 void openVideo(QString fileName); 00081 00082 //! Mark whether the timeline was playing or not, and pause it 00083 void sliderPressed(); 00084 00085 //! Check whether the timeline was playing when the slider was pressed, and resume it if so 00086 void sliderReleased(); 00087 00088 void saveAnnotationToDB(); 00089 00090 void openAnnotationFromDB(); 00091 00092 void createDBEntry(); 00093 00094 QString getFileName() { return itsFileName; } 00095 00096 AnnotationObjectManager* getObjectManager() { return itsObjectManager; } 00097 00098 void openPrefsDialog(); 00099 00100 signals: 00101 //! Pause the current playback 00102 void pausePlayback(bool); 00103 00104 void frameIndexChanged(int); 00105 00106 private: 00107 /* 00108 //! Exports the current annotation to XML 00109 void saveAnnotationToXML(QString directoryName, std::map<int, std::map<int, AnnotationObjectFrame > > animation); 00110 00111 //! Loads an annotation state from XML 00112 void loadAnnotationFromXML(QString Directory); 00113 */ 00114 00115 //! Create the File/Edit/etc.. menu bar 00116 void createMenuBar(); 00117 00118 //! Create the timeline which will drive the movie and animations 00119 void createTimeline(); 00120 00121 //! Create the top toolbar 00122 /*! Initializes all of the tool buttons such as zoom, add vertex, etc. that 00123 * are applicable to the main display*/ 00124 void createToolbar(); 00125 00126 //! Creates the transport box and returns a pointer to the box widget containing it 00127 QGroupBox* createTransport(); 00128 00129 //! Create the object list view and return an overarching widget containing the associated bits 00130 QWidget* createObjectList(); 00131 00132 QTableView* createAnimationControls(); 00133 00134 //! An animation timeline to control the current frame 00135 QTimeLine *itsTimeline; 00136 00137 //! A progress bar showing/controlling the current frame 00138 QSlider *itsProgressBar; 00139 00140 //!A label to show the current frame 00141 QLabel *itsFrameLabel; 00142 00143 QPushButton *itsPlayButton; 00144 00145 QTableView *itsAnimationView; 00146 00147 //! The main image and object display 00148 MainDisplay *itsMainDisplay; 00149 00150 //! The repository for all of our annotation objects 00151 AnnotationObjectManager *itsObjectManager; 00152 00153 DBManager itsDBManager; 00154 00155 //! A wrapper around InputFrameSeries 00156 nub::ref<CachedFrameLoader> itsCachedFrameLoader; 00157 00158 //! The movie playback speed in frames / second 00159 float itsFramerate; 00160 00161 //! The current frame, set in updateFrame() 00162 int itsCurrentFrame; 00163 00164 bool timelineWasRunning; 00165 00166 QString itsFileName; 00167 00168 QLabel itsDBStatusLabel; 00169 QLabel itsAnnotatorLabel; 00170 00171 PreferencesDialog itsPrefsDialog; 00172 QSettings *itsSettings; 00173 }; 00174 00175 #endif //MAINWINDOW_H 00176