/***************************************************************************
 *   Copyright (C) 2004 by Hans Oischinger                                 *
 *   hans.oischinger@kdemail.net                                           *
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 *   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, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.             *
 ***************************************************************************/
#ifndef VCONSOLIDATETRANSFORM_H
#define VCONSOLIDATETRANSFORM_H

#include "visitor.h"

class Matrix;
class Transformable;
class Transform;
/**
@author Hans Oischinger
*/
class VConsolidateTransform : public Visitor
{
public:
  VConsolidateTransform();
  ~VConsolidateTransform();

  virtual bool visit( VectorElement& element );
  virtual bool visit( GroupElement& element );
  virtual bool visit( UseElement& element );
  virtual bool visit( DefsElement& element );

  /**
   * Retrieves the CTM from the element tree starting with element, ending with the DocumentRoot
   * @param element the element to begin with
   * @param processAnimvals whether to use animVals (the default) or basevals
   * @param discardOwn discard the element's transformations (off by default)
   * @return 
   */
  static Matrix* calcCTM( ElementNode& element, bool processAnimvals=true, bool discardOwn=false );

  Matrix& ctm() { return *m_matrix; }

protected:
  void setProcessAnimvals( bool b ) { m_processAnimvals = b; }
  bool getProcessAnimvals() { return m_processAnimvals; }
  void consolidateTransformable( Transformable& element );

private:
  Matrix* m_matrix;
  bool m_processAnimvals;
};

#endif
