/*
 * File         : victimpanel.h
 * Author       : Timothy Wiley
 * Version      :
 * Created      : 09/02/2010
 * Description  : Victim Id Panel - based on existing SnapPanel
 * Copyright    :
 */

#ifndef VICTIMID_VICTIMPANEL_H_
#define VICTIMID_VICTIMPANEL_H_

#include "victim_id/class.hpp"

#include <crosbot_ui/panels/panel.hpp>
#include "victim_id/VictimIdDataMsg.h"
#include "victim_id/gui/QStatusCircle.hpp"

#include <QtGui/QDialog>
#include <QtGui/QGroupBox>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <QtGui/QRadioButton>
#include <QtCore/QTimer>
#include <QtGui/QTextEdit>
#include <QtGui/QTreeWidget>
#include <map>
#include <vector>

using namespace crosbot;
using namespace crosbot::gui;
using namespace casualty;

namespace casualty {
namespace gui {

class VictimIdViewWidget : public QWidget {
Q_OBJECT
public:
    VictimIdViewWidget();
    ~VictimIdViewWidget();

    void configure(ConfigElementPtr config);
    void start();
    void stop();

public Q_SLOTS:
    void updateFeedback();
    void callbackPausedBtn();
    void callbackOnlyDtBtn();
    void callbackRightWallBtn();
    void callbackLeftWallBtn();

Q_SIGNALS:
    void updateNeeded();

protected:
    // QT Entities
    QGroupBox autoVictimGB;

    // ROS elements
    ros::Subscriber vicDataSub;
    ros::Publisher vicControlPub;

    // Status feedback
    std::vector<QLabel* > statusLabels;
    std::vector<QStatusCircle* > statusCircles;
    QLabel victimLB;

    // Control buttons
    QPushButton pauseBtn;
    QPushButton onlyDtBtn;
    QPushButton leftWallBtn;
    QPushButton rightWallBtn;

    // Data collection - mapping required data elements to their values
    bool paused;
    std::map<int, std::string> data;
    std::map<int, QColor> colour;

    // Map of actypes to description strings
    std::map<std::string, std::string> stateDescStrings;

    // Map of DT running states
    std::map<int, std::string> runningStrings;

    // Do generation of values for redraw
    void callbackVicData(const victim_id::VictimIdDataMsgPtr msg);
    void generateFeedback(int type, std::string fieldStart);
};

class VictimIdViewPanel : public Panel {
Q_OBJECT
protected:
    VictimIdViewWidget widget;
public:
    VictimIdViewPanel(ConfigElementPtr config);
    ~VictimIdViewPanel();

    void configure(ConfigElementPtr config);
    QWidget *getWidget();

    void start();
    void stop();
};

} // namespace gui
} // namespace casualty

#endif /* VICTIMID_VICTIMPANEL_H_ */
