PositionChangeOfStabilityPanel.h

#pragma once


namespace Core
{
    ref class Motion;
    ref class SupportPolygon;


    /// <summary>
    /// 安定性の位置変化パネル
    /// </summary>
    public ref class PositionChangeOfStabilityPanel : public System::Windows::Forms::UserControl
    {
    // Construction --------------------------------------------------------
    public:
        PositionChangeOfStabilityPanel( void );

    protected:
        ~PositionChangeOfStabilityPanel();


    // Operation -----------------------------------------------------------
    public:
        void Initialize( Motion^ motion );

    protected:
        virtual void OnResize( System::EventArgs^ e ) override;

    private:
        void InitializeComponent( void );

        void SetCoordinate( System::Drawing::Graphics^ graphics );
        void DrawBackground( System::Drawing::Graphics^ graphics );

        void DrawCenterOfGravityProjection( System::Drawing::Graphics^ graphics, System::Drawing::PointF point );
        void DrawLocusOfCenterOfGravityProjection( System::Drawing::Graphics^ graphics );

        void DrawSupportPolygon( System::Drawing::Graphics^ graphics, SupportPolygon^ supportPolygon, System::Drawing::Color color );
        void DrawLocusSupportPolygon( System::Drawing::Graphics^ graphics );

        void DrawStabilityMargin( System::Drawing::Graphics^ graphics, System::Drawing::PointF point, double stabilityMargin );

        void FillPie( System::Drawing::Graphics^ graphics, System::Drawing::Brush^ brush, System::Drawing::RectangleF rectangle, float startAngle, float sweepAngle );


    // Event Handler -------------------------------------------------------
    private:
        System::Void PanelPaint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e);

        void MotionChanged( System::Object^ sender, System::EventArgs^ e );


       /// @todo
       /// サイズ変更のイベントで再描画する。


    // Event ---------------------------------------------------------------
    public:
        event System::EventHandler^ Fall;    ///< 転倒イベント


    // Attribute ===========================================================
    private:
        int m_currentPoseIndex;         ///< 現在のポーズのインデックス
        double m_stabilityMargin;       ///< 安定余裕[ m ]

        array< System::Drawing::PointF >^ m_centerOfGravity;  ///< 重心[ m ]
        array< SupportPolygon^ >^ m_supportPolygon;           ///< 支持多角形[ m ]


        //
        // 以降は デザイナによって自動生成されたコード
        //


    private: System::ComponentModel::Container ^components;
    private: System::Windows::Forms::Panel^ m_panel;

    };
}