// Created with MonoDevelop
//
//    QuickStep: Acquire, view and identify spectra 
//    Copyright (C) 2024 Hiperscan GmbH Dresden, Germany
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.


using System;
using Hiperscan.ApoIdentCore.Reporting.ReportData;
using Hiperscan.PdfLib;

namespace Hiperscan.ApoIdentCore.Reporting.Protocol.Graphics
{
    public class CommonGraphics : IDraw
    {
        public bool Draw(PdfArgs args)
        {

            args.Layout.Feed(5);

            double padding = 1;
            int bitmap_save_width = (int)args.Layout.InnerPageWidth;
            int bitmap_save_height = (int)(0.8 * bitmap_save_width);
            double reference_width = args.Layout.InnerPageWidth / 2 - 2 * padding;

            ReportInfo.DetailPlot.Init(args.Info);

            PdfPoint point1 = new PdfPoint(padding, args.Layout.YPosition);
            System.Drawing.Bitmap bmp1 = ReportInfo.DetailPlot.GetAbsorbancePlot(bitmap_save_width, bitmap_save_height);
            if (args.Layout.AddBitmap(bmp1, point1, PdfBitmapScales.X, reference_width) == false)
                return false;

            PdfPoint point2 = new PdfPoint(args.Layout.InnerPageWidth / 2 + padding, args.Layout.YPosition);
            System.Drawing.Bitmap bmp2 = ReportInfo.DetailPlot.GetBackProjectionPlot(bitmap_save_width, bitmap_save_height);
            if (args.Layout.AddBitmap(bmp2, point2, PdfBitmapScales.X, reference_width) == false)
                return false;

            args.Layout.Feed(5 + args.Layout.ImageBoundingBox.Height);

            return true;
        }
    }
}
