#include "MaskPageForecast.h"

#include "pv/PvChart.h"

static int CreatePanel(PARAM* p, int parentId, int x, int y, int w, int h, std::string title)
{
    int id = PvApp::label(p, parentId, x, y, w, h, "", QSS::LABEL_BKG_2);
    PvApp::label(p, id, 10, 10, w, 20, title, QSS::STYLE_TITLE_ICON);
    PvApp::label(p, id, 20, 30, w, 2, "", QSS::QSS_UNDERLINE);
    return id;
}

MaskPageForecast::MaskPageForecast(PARAM* p) : PvMask(p) 
{
}

int MaskPageForecast::initUI(EPvCode pvcode)
{
    int x = 10, y = 100, w = 1900, h = 420;
    int delta = 40;
    {
        int panel  = CreatePanel(p, 0, x, y, w, h, "储能充放电预测");
        chart1_ = std::make_shared<PvChartCurve>(p, panel, 0, delta, w, h-delta);
        chart1_->setBackground(p, 8, 54, 91);
        chart1_->setLabelYLeft("电量(kWh)", 0, 10, 2);
        chart1_->insertItem(0, "充电电量", 120, 10, 80);
        chart1_->insertItem(0, "放电电量", 200, 10, 80);
    }
    {
        int panel = CreatePanel(p, 0, x, y+=(h+10), w = 945, h, "光伏发电预测");
        chart2_ = std::make_shared<PvChartCurve>(p, panel, 0, delta, w, h-delta);
        chart2_->setBackground(p, 8, 54, 91);
        chart2_->setLabelYLeft("电量(kWh)", 0, 10, 2);
        chart2_->insertItem(0, "发电电量", 120, 10, 80);
    }
    {
        int panel = CreatePanel(p, 0, x+=(w+10), y, w, h, "充电负荷预测");
        chart3_ = std::make_shared<PvChartCurve>(p, panel, 0, delta, w, h-delta);
        chart3_->setBackground(p, 8, 54, 91);
        chart3_->setLabelYLeft("电量(kWh)", 0, 10, 2);
        chart3_->insertItem(0, "充电电量", 120, 10, 80);
    }
    return 0;
}