{-# LANGUAGE ForeignFunctionInterface, TypeFamilies, MultiParamTypeClasses, 
             FlexibleInstances, TypeSynonymInstances, 
             EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}

-- module HROOT.Class.Interface where

module HROOT.Class.TH2.Interface where


import Data.Word
import Foreign.ForeignPtr
import HROOT.TypeCast

import HROOT.Class.TH2.RawType
import HROOT.Class.TH1D.RawType
import HROOT.Class.TH1.Interface
import HROOT.Class.TF1.Interface
import HROOT.Class.TObjArray.Interface


class (ITH1 a) => ITH2 a where
    -- | 
    --   > Int_t    Fill(Double_t x, Double_t y);

    fill2 :: a -> Double -> Double -> IO Int 

    fill2w :: a -> Double -> Double -> Double -> IO Int 

    fillN2 :: a -> Int -> [Double] -> [Double] -> [Double] -> Int -> IO () 
    -- | 
    --   > void     FillRandom(TH1 *h, Int_t ntimes=5000);
    --   

    fillRandom2 :: (ITH1 c0, FPtr c0) => a -> c0 -> Int -> IO () 
    -- | 
    --   > Int_t    FindFirstBinAbove(Double_t threshold=0, Int_t axis=1) const;
    --   

    findFirstBinAbove2 :: a -> Double -> Int -> IO Int 
    -- | 
    --   > Int_t    FindLastBinAbove (Double_t threshold=0, Int_t axis=1) const;
    --   

    findLastBinAbove2 :: a -> Double -> Int -> IO Int 
    -- | 
    --   > void     FitSlicesX(TF1 *f1=0,Int_t firstybin=0, Int_t lastybin=-1, Int_t cut=0, Option_t *option="QNR", TObjArray* arr = 0); // *MENU*
    --   

    fitSlicesX :: (ITObjArray c1, FPtr c1, ITF1 c0, FPtr c0) => a -> c0 -> Int -> Int -> Int -> String -> c1 -> IO () 
    -- | 
    --   > void     FitSlicesY(TF1 *f1=0,Int_t firstxbin=0, Int_t lastxbin=-1, Int_t cut=0, Option_t *option="QNR", TObjArray* arr = 0); // *MENU*
    --   

    fitSlicesY :: (ITObjArray c1, FPtr c1, ITF1 c0, FPtr c0) => a -> c0 -> Int -> Int -> Int -> String -> c1 -> IO () 

    getCorrelationFactor2 :: a -> Int -> Int -> IO Double 

    getCovariance2 :: a -> Int -> Int -> IO Double 

    integral2 :: a -> Int -> Int -> Int -> Int -> String -> IO Double 

    rebinX2 :: a -> Int -> String -> IO TH2 

    rebinY2 :: a -> Int -> String -> IO TH2 
    -- | 
    --   > TH2     *Rebin2D(Int_t nxgroup=2, Int_t nygroup=2, const char *newname="");     
    --   

    rebin2D :: a -> Int -> Int -> String -> IO TH2 
    -- | 
    --   > void     SetShowProjectionX(Int_t nbins);  // *MENU*
    --   

    setShowProjectionX :: a -> Int -> IO () 
    -- | 
    --   > void     SetShowProjectionY(Int_t nbins);  // *MENU*
    --   

    setShowProjectionY :: a -> Int -> IO () 

instance Existable TH2 where
  data Exist TH2 = forall a. (FPtr a, ITH2 a) => ETH2 a

upcastTH2 :: (FPtr a, ITH2 a) => a -> TH2
upcastTH2 h = let fh = get_fptr h
                  fh2 :: ForeignPtr RawTH2 = castForeignPtr fh
              in cast_fptr_to_obj fh2