/**
    05Robot - Computer Vision Module

    @author P.Kaczmarek,J.Tomczynski,T.Mankowski
    @version 1.0 2017
*/
#ifndef PROCESSORWINDOW_H
#define PROCESSORWINDOW_H

#include <QWidget>
#include <QAction>
#include <QDialog>
#include <QMenu>
#include "ProcessorObject.h"
#include "ProcessorThread.h"

#include "CameraPreview.h"

//#include "GLScene.h"

#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <QPropertyEditorWidget.h>

/** \addtogroup ComputerVisionModule
 *  @{
 */
/**
 @brief Generic camera processor window base class
 */
class ProcessorWindow : public QWidget
{
	Q_OBJECT

public:
    /**
     @brief Default constructor, initializes processor calibration window
     
     @param pt pointer to corresponding ProcessorThread
     @param parent pointer to parent widget
     @param flags window flags
     */
    ProcessorWindow(ProcessorThread*,QWidget *parent = 0, Qt::WindowFlags flags = 0);
    /**
     @brief Default destructor, cleans up
     */
	~ProcessorWindow();
    /**
     @brief Allows derived classes to update list of input cameras and processors, empty in base class
     
     @param cameraList list of pointers to input CameraPreview objects
     @param processorList list of pointers to input ProcessorWindow objects
     */
	virtual void updateLists(QList<CameraPreview*>, QList<ProcessorWindow*>){};
	
public slots:
    /**
     @brief Update displayed picture
     
     @param id Frame ID
     @param frame Pointer to picture
     */
	virtual void frameIn(int id, cv::Mat* frame);
    /**
     @brief Opens properties dialog
     */
	void Properties();
    /**
     @brief Opens context menu
     */
	virtual void contextMenuRequested(QPoint point);
    /**
     @brief Triggers context menu event
     */
	virtual void contextMenuEvent ( QContextMenuEvent * event );


signals:
    /**
     @brief Emitted on window close
     */
	void closing(ProcessorWindow*);
    /**
     @brief Updates connected devices list
     */
	void connectInputs(QList<CameraObject*>, QList<ProcessorObject*>);
    /**
     @brief For communication between ProcessorObject and ProcessorWindow
     */
	void signalSpecial(QString);
protected:
	QPropertyEditorWidget *prop;
public:
    /**
     @brief Pointer to corresponding ProcessorThread
     */
    ProcessorThread * pt;
private:
	void closeEvent(QCloseEvent * event);
    QDialog *dlg;
	QMenu*   contextMenu;	
	QAction* actionProperties;
	QAction* actionClose;
	
};
/** @}*/
#endif // PROCESSORWINDOW_H
