/*$Id$
 *
 * This source file is a part of the Fresco Project.
 * Copyright (C) 2003 Nick Lewycky <nicholas@fresco.org>
 * http://www.fresco.org
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
 * MA 02139, USA.
 */
#ifndef _Berlin_PathImpl_hh
#define _Berlin_PathImpl_hh

#include <Fresco/config.hh>
#include <Fresco/Path.hh>
#include <Fresco/Types.hh>
#include <Berlin/ServantBase.hh>
#include <Berlin/Vertex.hh>
#include <Berlin/Provider.hh>

using namespace Fresco;

class RegionImpl;

enum PathSegmentType { move, line, conic, cubic };
struct PathSegment
{
  Vertex to, cp1, cp2;
  PathSegmentType type;
};

class PathImpl : public virtual POA_Fresco::Path,
                 public virtual ServantBase
{
  friend class Provider<PathImpl>;
public:
  PathImpl() {}
  virtual ~PathImpl() {}
  virtual void move_to_point(const Vertex &);
  virtual void add_line_to_point(const Vertex &);
  virtual void add_lines(const Vertices &);
  virtual void add_curve_to_point(const Vertex &, const Vertex &,
                                  const Vertex &);
  virtual void add_quad_curve_to_point(const Vertex &, const Vertex &);
  virtual void add_rect(const Vertex &, const Vertex &);
  virtual void add_rects(const Vertices &, const Vertices &);
  virtual void add_arc(const Vertex &, CORBA::Float, CORBA::Float,
                       CORBA::Float, CORBA::Boolean);
  virtual void add_arc_to_point(const Vertex &, const Vertex &, CORBA::Float);

  virtual CORBA::Boolean is_path_empty();
  virtual Vertex get_current_point();
  virtual Region_ptr get_bounding_box();

  virtual CORBA::Boolean contains_point(const Vertex &);
  virtual CORBA::Boolean contains_rect(const Vertex &, const Vertex &);
  virtual CORBA::Boolean intersects_rect(const Vertex &, const Vertex &);
  virtual Vertices *get_subpath(CORBA::ULong);
  virtual CORBA::ULong length();
private:
  std::vector<PathSegment *> segments;
};

#endif
