// @(#)root/gpad:$Id$
// Author:  Sergey Linev  04/03/2026

/*************************************************************************
 * Copyright (C) 1995-2026, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TPadPainterPS
#define ROOT_TPadPainterPS

#include "TPadPainterBase.h"

/*
TPadPainterPS is an attempt to abstract
pad painting operation to the TVirtualPS interface.
So using same API as for normal object drawing on interactive canvas,
one also will be able to produce vector-based and binary images  */

class TVirtualPad;
class TVirtualPS;

class TPadPainterPS : public TPadPainterBase {
private:
   TVirtualPS    *fPS = nullptr;
   TVirtualPad   *fPad = nullptr;
public:
   TPadPainterPS(TVirtualPS *ps);

   void     SetOpacity(Int_t percent) override;

   //Overall attributes
   void      SetAttFill(const TAttFill &att) override;
   void      SetAttLine(const TAttLine &att) override;
   void      SetAttMarker(const TAttMarker &att) override;
   void      SetAttText(const TAttText &att) override;

   //Final overriders for TVirtualPadPainter pure virtual functions.
   //1. Part, which simply delegates to TVirtualX.

   //2. "Off-screen management" part.
   Int_t    CreateDrawable(UInt_t w, UInt_t h) override;
   void     ClearDrawable() override;
   void     CopyDrawable(Int_t device, Int_t px, Int_t py) override;
   void     DestroyDrawable(Int_t device) override;
   void     SelectDrawable(Int_t device) override;

   void     NewPage() override;

   //TASImage support (noop for a non-gl pad).
   void     DrawPixels(const unsigned char *pixelData, UInt_t width, UInt_t height,
                       Int_t dstX, Int_t dstY, Bool_t enableAlphaBlending) override;

   void     DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override;
   void     DrawLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2) override;

   void     DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, EBoxMode mode) override;

   //TPad needs double and float versions.
   void     DrawFillArea(Int_t n, const Double_t *x, const Double_t *y) override;
   void     DrawFillArea(Int_t n, const Float_t *x, const Float_t *y) override;

   //TPad needs both double and float versions of DrawPolyLine.
   void     DrawPolyLine(Int_t n, const Double_t *x, const Double_t *y) override;
   void     DrawPolyLine(Int_t n, const Float_t *x, const Float_t *y) override;
   void     DrawPolyLineNDC(Int_t n, const Double_t *u, const Double_t *v) override;

   void     DrawSegments(Int_t n, Double_t *x, Double_t *y) override;
   void     DrawSegmentsNDC(Int_t n, Double_t *u, Double_t *v) override;

   //TPad needs both versions.
   void     DrawPolyMarker(Int_t n, const Double_t *x, const Double_t *y) override;
   void     DrawPolyMarker(Int_t n, const Float_t *x, const Float_t *y) override;

   void     DrawText(Double_t x, Double_t y, const char *text, ETextMode mode) override;
   void     DrawText(Double_t x, Double_t y, const wchar_t *text, ETextMode mode) override;
   void     DrawTextNDC(Double_t u, Double_t v, const char *text, ETextMode mode) override;
   void     DrawTextNDC(Double_t u, Double_t v, const wchar_t *text, ETextMode mode) override;

   void     DrawTextUrl(Double_t x, Double_t y, const char *text, const char *url) override;

   //jpg, png, bmp, gif output.
   void     SaveImage(TVirtualPad *pad, const char *fileName, Int_t type) const override;

   void     OnPad(TVirtualPad *pad) override { fPad = pad; }

   TVirtualPS *GetPS() const override { return fPS; }


private:
   //Let's make this clear:
   TPadPainterPS(const TPadPainterPS &) = delete;
   TPadPainterPS(TPadPainterPS &&) = delete;
   TPadPainterPS &operator=(const TPadPainterPS &) = delete;
   TPadPainterPS &operator=(TPadPainterPS &&) = delete;

   ClassDefOverride(TPadPainterPS, 0) //TPad painting with TVirtualPS interface
};

#endif
