// $Header: https://oberon.oapd.inaf.it/shins/trunk/shins/src/track_ctrl/drot/Interface/Sharknir/Qt/Drot/SharknirDrotServiceWidget.h 2976 2020-05-14 15:38:34Z depa $

// #ifndef     SharknirDrotServiceWidget_H_
// #define     SharknirDrotServiceWidget_H_
#pragma once

#include <Nice/Qt/BridgeItem.h>
#include <Nice/Map/Point.h>
#include <Basda/Mocca/Constant.h>
#include <Sharknir/Drot/SharknirDrotServiceWorkerInterface.h>
#include <QtDesigner/QDesignerExportWidget>

namespace Ui
{
    class SharknirDrotServiceWidgetUI;
}


/**
 * @brief This class is the implementation of the GUI SharknirDrotServiceWidgetUI
 */
class QDESIGNER_WIDGET_EXPORT SharknirDrotServiceWidget : public QWidget,
        public Nice::BridgeItem
{
    private:
    Q_OBJECT

        /**
         * @brief Connect the Qt Designer Property propertyNode with the methods
         *        getPropertyNode and setPropertyNode.
         */
        Q_PROPERTY(QString PropertyNode READ getPropertyNode WRITE setPropertyNode)

        /**
         * @brief Connect the Qt Designer Property AutoSynch with the methods
         *        getSynchStatus and setSynchStatus.
         */
        Q_PROPERTY(bool AutoSynch READ getSynchStatus WRITE setSynchStatus)

        void addPositionItemLabel(std::string _name);

        void updateDoubleSpinBoxRel();

        void updateDoubleSpinBoxAbs();

        Ui::SharknirDrotServiceWidgetUI* m_drotView;

        /**
         * @brief member for the command interface
         */
        Sharknir::DrotServiceWorkerInterfacePtr m_cmd;

        /**
         * @brief member for the current used named position.
         */
        int m_namedPos;

        std::string m_notDefined;

        std::string m_unit;

        std::map<std::string, int> m_unitPrec;

        /**
         * @brief member to store the named relative position
         */
        std::vector<double> m_namedPosRel;

        /**
         * @brief member to store the named absolute position
         */
        std::vector<double> m_namedPosAbs;

        Nice::Mutex m_mutex;

        std::string m_namedPositionNotDefined;

    public:
        //------------------------------------------------------------
        /**
         * @brief Constructor
         * @param parent the parent widget
         * @param _connect ??
         */
        SharknirDrotServiceWidget(QWidget * parent = 0, bool _connect =
                false);

        //------------------------------------------------------------
        /**
         * @brief Initiate the attributes. The command attributes like the named
         *        position and the different units are added.
         *
         * One drop down button will be filled with the labels of the named ]
         * position. A second drop down button will be filled with the labels
         * of the units.
         */
        virtual void initAttributes();

        /**
         * @brief This method can be used to connect different properties with
         *        method, which will be executed every time when a property changed.
         */
        virtual void initSlots();

    public slots:
        void slotNice_setNamedPositionAbs(std::vector<double> _p);

        void slotNice_setNamedPositionRel(std::vector<double> _p);

    protected slots:
        /**
         * @brief This method will be called whenever the relative position
         *        will change in the GUI.
         */
        virtual void slotQt_valueRelChanged(double);

        /**
         * @brief This method will be called whenever the absolute position
         *        will change in the GUI.
         */
        virtual void slotQt_valueAbsChanged(double);

        /**
         * @brief This method will be called whenever the sign button of the
         *        relative position is pressed.
         */
        virtual void slotQt_signRelChanged();

        /**
         * @brief This method will be called whenever the sign button of the
         *        absolute position is pressed.
         */
        virtual void slotQt_signAbsChanged();

        /**
         * @brief This method will be called whenever the named position will
         *        change in the GUI
         */
        virtual void slotQt_valueNamedPositionChanged(int);

        /**
         * @brief This method will be called whenever the unit will change in
         *        the GUI.
         */
        virtual void slotQt_valueUnitChanged(QString);

        /**
         * @brief This is the implementation of the stop button.
         */
        virtual void slotQt_stop();

        /**
         * @brief This is the implementation of the abort button.
         */
        virtual void slotQt_abort();

        /**
         * @brief This is the implementation of the move relative button.
         */
        virtual void slotQt_moveRelative();

        /**
         * @brief This is the implementation of the move absolute button.
         */
        virtual void slotQt_moveAbsolute();

        /**
         * @brief This is the implementation of the move home button.
         */
        virtual void slotQt_moveToHome();

        /*
         * @brief This is the implementation of the start derotation button.
         */
        virtual void slotQt_startDerotation();

        /*
         * @brief This is the implementation of the change derotation button.
         */
        virtual void slotQt_changeDerotationWithAbsoluteOffset();

        /*
         * @brief This is the implementation of the change derotation button.
         */
        virtual void slotQt_changeDerotationWithRelativeOffset();
};

// #endif
