/***************************************************************************
 * tabbeateffects.h: implementation of TabBeatEffects
 *
 * This file is part of KGuitar, a KDE tabulature editor
 *
 * copyright (C) 2003-2006 the KTabEdit development team <mrgwen@gmail.com>
 ***************************************************************************/

/***************************************************************************
 * 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 2 of the License, or
 * (at your option) any later version.
 *
 * See the file COPYING for more information.
 ***************************************************************************/
 
#include "tabbeateffects.h"
#include "util/assert.h"

TabTimeEffect::TabTimeEffect()
: mRasgueado(false),
  mPickStroke(NonePickStroke),
  mTremolo(0),
  mTapping(false),
  mPopping(false),
  mSlapping(false),
  mStroke(false),
  mUpStroke(0),
  mDownStroke(0), 
  mVibrato(false),
  mWideVibrato(false),
  mNaturalHarmonic(false),
  mArtificialHarmonic(false),
  mFadeIn(false),
  mBend(0x0)
{
	mBend = new TabBend;
}

TabTimeEffect::~TabTimeEffect()
{
	if (hasBend() == true)
		delete mBend;
}

void TabTimeEffect::clone(const TabTimeEffect* effect)
{
	if (hasBend() == true)
		delete bend();
	
	mRasgueado = effect->mRasgueado;
	mPickStroke = effect->mPickStroke;
	mTremolo = effect->mTremolo;
	mTapping = effect->mTapping;
	mPopping = effect->mPopping;
	mSlapping = effect->mSlapping;
	mStroke = effect->mStroke;
	mUpStroke = effect->mUpStroke;
	mDownStroke = effect->mDownStroke; 
	mVibrato = effect->mVibrato;
	mWideVibrato = effect->mWideVibrato;
	mNaturalHarmonic = effect->mNaturalHarmonic;
	mArtificialHarmonic = effect->mArtificialHarmonic;
	mFadeIn = effect->mFadeIn;
	
	mBend = new TabBend();
	if (effect->hasBend() == true)
		mBend->clone(effect->bend());
}

void TabTimeEffect::setRasgueado(bool b)
{
	mRasgueado = b;
}

bool TabTimeEffect::isRasgueado() const
{
	return mRasgueado;
}

bool TabTimeEffect::hasPickStroke() const
{
	return mPickStroke != NonePickStroke;
}

void TabTimeEffect::setPickStroke(PickStroke p)
{
	mPickStroke = p;
}

PickStroke TabTimeEffect::pickstroke() const
{
	return mPickStroke;
}

bool TabTimeEffect::hasTremolo() const
{
	return mTremolo != 0;
}

void TabTimeEffect::setTremolo(int i)
{
	mTremolo = i;
}

int TabTimeEffect::tremolo() const
{
	return mTremolo;
}

void TabTimeEffect::setTapping(bool b)
{
	mTapping = b;
}

bool TabTimeEffect::isTapping() const
{
	return mTapping;
}

void TabTimeEffect::setPopping(bool b)
{
	mPopping = b;
}

bool TabTimeEffect::isPopping() const
{
	return mPopping;
}

void TabTimeEffect::setSlapping(bool b)
{
	mSlapping = b;
}

bool TabTimeEffect::isSlapping() const
{
	return mSlapping;
}

void TabTimeEffect::setStroke(bool b)
{
	mStroke = b;
}

bool TabTimeEffect::isStroke() const
{
	return mStroke;
}

void TabTimeEffect::setUpStroke(int i)
{
	mUpStroke = i;
}

int TabTimeEffect::upStroke() const
{
	return mUpStroke;
}

void TabTimeEffect::setDownStroke(int i)
{
	mDownStroke = i;
}

int TabTimeEffect::downStroke() const
{
	return mDownStroke;
}

void TabTimeEffect::setVibrato(bool b)
{
	mVibrato = b;
}

bool TabTimeEffect::isVibrato() const
{
	return mVibrato;
}

void TabTimeEffect::setWideVibrato(bool b)
{
	mWideVibrato = b;
}

bool TabTimeEffect::isWideVibrato() const
{
	return mWideVibrato;
}

void TabTimeEffect::setNaturalHarmonic(bool b)
{
	mNaturalHarmonic = b;
}

bool TabTimeEffect::isNaturalHarmonic() const
{
	return mNaturalHarmonic;
}

void TabTimeEffect::setArtificialHarmonic(bool b)
{
	mArtificialHarmonic = b;
}

bool TabTimeEffect::isArtificialHarmonic() const
{
	return mArtificialHarmonic;
}

void TabTimeEffect::setFadeIn(bool b)
{
	mFadeIn = b;
}

bool TabTimeEffect::isFadeIn() const
{
	return mFadeIn;
}

void TabTimeEffect::setBend(TabBend* bend)
{
	PRECONDITION( bend != 0x0 );
	
	if (mBend != 0x0)
		delete mBend;
	
	mBend = bend;
}

TabBend* TabTimeEffect::bend() const
{
	return mBend;
}

bool TabTimeEffect::hasBend() const
{
	return (mBend != 0x0);
}

void TabTimeEffect::setBendType(TabBend::BendType b)
{
	bend()->setBendType(b);
}

TabBend::BendType TabTimeEffect::bendType() const
{
	return bend()->bendType();
}

void TabTimeEffect::setBendValue(int i)
{
	bend()->setBendValue(i);
}

int TabTimeEffect::bendValue() const
{
	return bend()->bendValue();
}

QString TabTimeEffect::bendValueToString() const
{
	return bend()->bendValueToString();
}

int TabTimeEffect::sizeOfBendPoints() const
{
	return bend()->sizeOfBendPoints();
}

void TabTimeEffect::addBendPoint(TabBendPoint* point)
{
	return bend()->addBendPoint(point);
}

void TabTimeEffect::setBendPoint(uint i, TabBendPoint* point)
{
	return bend()->setBendPoint(i, point);
}

void TabTimeEffect::removeBendPoint(uint i)
{
	bend()->removeBendPoint(i);
}

TabBendPoint* TabTimeEffect::bendPoint(uint i) const
{
	return bend()->bendPoint(i);
}

bool TabTimeEffect::operator==(const TabTimeEffect& effect) const
{
	bool result;
	
	if (mBend == effect.mBend)
		result = true;
	else if (mBend != 0x0 && effect.mBend != 0x0 && *mBend == *effect.mBend)
		result = true;
	else
		result = false;
	
	return (this->mRasgueado == effect.mRasgueado && this->mPickStroke == effect.mPickStroke
	&& this->mTremolo == effect.mTremolo && this->mTapping == effect.mTapping
	&& this->mPopping == effect.mPopping && this->mSlapping == effect.mSlapping
	&& this->mStroke == effect.mStroke && this->mUpStroke == effect.mUpStroke
	&& this->mDownStroke == effect.mDownStroke && this->mVibrato == effect.mVibrato
	&& this->mWideVibrato == effect.mWideVibrato && this->mNaturalHarmonic == effect.mNaturalHarmonic
	&& this->mArtificialHarmonic == effect.mArtificialHarmonic && this->mFadeIn == effect.mFadeIn
	&& result == true);
}

bool TabTimeEffect::operator!=(const TabTimeEffect& effect) const
{
	return !(*this == effect);
}
