Blame src/lib/Dash.cpp

rpm-build 9243a4
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
rpm-build 9243a4
/*
rpm-build 9243a4
 * This file is part of the libmspub project.
rpm-build 9243a4
 *
rpm-build 9243a4
 * This Source Code Form is subject to the terms of the Mozilla Public
rpm-build 9243a4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
rpm-build 9243a4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
rpm-build 9243a4
 */
rpm-build 9243a4
rpm-build 9243a4
#include "Dash.h"
rpm-build 9243a4
rpm-build 9243a4
#include "MSPUBConstants.h"
rpm-build 9243a4
#include "libmspub_utils.h"
rpm-build 9243a4
rpm-build 9243a4
namespace libmspub
rpm-build 9243a4
{
rpm-build 9243a4
rpm-build 9243a4
bool operator==(const Dot &lhs, const Dot &rhs)
rpm-build 9243a4
{
rpm-build 9243a4
  return lhs.m_length == rhs.m_length && lhs.m_count == rhs.m_count;
rpm-build 9243a4
}
rpm-build 9243a4
rpm-build 9243a4
bool operator!=(const Dot &lhs, const Dot &rhs)
rpm-build 9243a4
{
rpm-build 9243a4
  return !operator==(lhs, rhs);
rpm-build 9243a4
}
rpm-build 9243a4
rpm-build 9243a4
bool operator==(const Dash &lhs, const Dash &rhs)
rpm-build 9243a4
{
rpm-build 9243a4
  if (!(lhs.m_distance == rhs.m_distance &&
rpm-build 9243a4
        lhs.m_dotStyle == rhs.m_dotStyle && lhs.m_dots.size() == rhs.m_dots.size()))
rpm-build 9243a4
  {
rpm-build 9243a4
    return false;
rpm-build 9243a4
  }
rpm-build 9243a4
  for (unsigned i = 0; i < lhs.m_dots.size(); ++i)
rpm-build 9243a4
  {
rpm-build 9243a4
    if (lhs.m_dots[i] != rhs.m_dots[i])
rpm-build 9243a4
    {
rpm-build 9243a4
      return false;
rpm-build 9243a4
    }
rpm-build 9243a4
  }
rpm-build 9243a4
  return true;
rpm-build 9243a4
}
rpm-build 9243a4
rpm-build 9243a4
Dash getDash(MSPUBDashStyle style, unsigned shapeLineWidthEmu,
rpm-build 9243a4
             DotStyle dotStyle)
rpm-build 9243a4
{
rpm-build 9243a4
  double shapeLineWidth = static_cast<double>(shapeLineWidthEmu) /
rpm-build 9243a4
                          EMUS_IN_INCH;
rpm-build 9243a4
  switch (style)
rpm-build 9243a4
  {
rpm-build 9243a4
  default:
rpm-build 9243a4
    MSPUB_DEBUG_MSG(("Couldn't match dash style, using solid line.\n"));
rpm-build 9243a4
    MSPUB_FALLTHROUGH;
rpm-build 9243a4
  case MSPUB_DS_SOLID:
rpm-build 9243a4
    return Dash(0, RECT_DOT);
rpm-build 9243a4
  case DASH_SYS:
rpm-build 9243a4
  {
rpm-build 9243a4
    Dash ret(shapeLineWidth, dotStyle);
rpm-build 9243a4
    ret.m_dots.push_back(Dot(1, 3 * shapeLineWidth));
rpm-build 9243a4
    return ret;
rpm-build 9243a4
  }
rpm-build 9243a4
  case DOT_SYS:
rpm-build 9243a4
  {
rpm-build 9243a4
    Dash ret(shapeLineWidth, dotStyle);
rpm-build 9243a4
    ret.m_dots.push_back(Dot(1));
rpm-build 9243a4
    return ret;
rpm-build 9243a4
  }
rpm-build 9243a4
  case DASH_DOT_SYS:
rpm-build 9243a4
  {
rpm-build 9243a4
    Dash ret(shapeLineWidth, dotStyle);
rpm-build 9243a4
    ret.m_dots.push_back(Dot(1, 3 * shapeLineWidth));
rpm-build 9243a4
    ret.m_dots.push_back(Dot(1));
rpm-build 9243a4
    return ret;
rpm-build 9243a4
  }
rpm-build 9243a4
  case DASH_DOT_DOT_SYS:
rpm-build 9243a4
  {
rpm-build 9243a4
    Dash ret(shapeLineWidth, dotStyle);
rpm-build 9243a4
    ret.m_dots.push_back(Dot(1, 3 * shapeLineWidth));
rpm-build 9243a4
    ret.m_dots.push_back(Dot(2));
rpm-build 9243a4
    return ret;
rpm-build 9243a4
  }
rpm-build 9243a4
  case DOT_GEL:
rpm-build 9243a4
  {
rpm-build 9243a4
    Dash ret(3 * shapeLineWidth, dotStyle);
rpm-build 9243a4
    ret.m_dots.push_back(Dot(1));
rpm-build 9243a4
    return ret;
rpm-build 9243a4
  }
rpm-build 9243a4
  case DASH_GEL:
rpm-build 9243a4
  {
rpm-build 9243a4
    Dash ret(3 * shapeLineWidth, dotStyle);
rpm-build 9243a4
    ret.m_dots.push_back(Dot(1, 4 * shapeLineWidth));
rpm-build 9243a4
    return ret;
rpm-build 9243a4
  }
rpm-build 9243a4
  case LONG_DASH_GEL:
rpm-build 9243a4
  {
rpm-build 9243a4
    Dash ret(3 * shapeLineWidth, dotStyle);
rpm-build 9243a4
    ret.m_dots.push_back(Dot(1, 8 * shapeLineWidth));
rpm-build 9243a4
    return ret;
rpm-build 9243a4
  }
rpm-build 9243a4
  case DASH_DOT_GEL:
rpm-build 9243a4
  {
rpm-build 9243a4
    Dash ret(3 * shapeLineWidth, dotStyle);
rpm-build 9243a4
    ret.m_dots.push_back(Dot(1, 4 * shapeLineWidth));
rpm-build 9243a4
    ret.m_dots.push_back(Dot(1));
rpm-build 9243a4
    return ret;
rpm-build 9243a4
  }
rpm-build 9243a4
  case LONG_DASH_DOT_GEL:
rpm-build 9243a4
  {
rpm-build 9243a4
    Dash ret(3 * shapeLineWidth, dotStyle);
rpm-build 9243a4
    ret.m_dots.push_back(Dot(1, 8 * shapeLineWidth));
rpm-build 9243a4
    ret.m_dots.push_back(Dot(1));
rpm-build 9243a4
    return ret;
rpm-build 9243a4
  }
rpm-build 9243a4
  case LONG_DASH_DOT_DOT_GEL:
rpm-build 9243a4
  {
rpm-build 9243a4
    Dash ret(3 * shapeLineWidth, dotStyle);
rpm-build 9243a4
    ret.m_dots.push_back(Dot(1, 8 * shapeLineWidth));
rpm-build 9243a4
    ret.m_dots.push_back(Dot(2));
rpm-build 9243a4
    return ret;
rpm-build 9243a4
  }
rpm-build 9243a4
  }
rpm-build 9243a4
}
rpm-build 9243a4
rpm-build 9243a4
}
rpm-build 9243a4
rpm-build 9243a4
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */