Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* libmspub
3 : * Version: MPL 1.1 / GPLv2+ / LGPLv2+
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License or as specified alternatively below. You may obtain a copy of
8 : * the License at http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * Major Contributor(s):
16 : * Copyright (C) 2012 Brennan Vincent <brennanv@email.arizona.edu>
17 : *
18 : * All Rights Reserved.
19 : *
20 : * For minor contributions see the git repository.
21 : *
22 : * Alternatively, the contents of this file may be used under the terms of
23 : * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
24 : * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
25 : * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
26 : * instead of those above.
27 : */
28 :
29 : #include "Dash.h"
30 : #include "libmspub_utils.h"
31 :
32 0 : bool libmspub::operator==(const libmspub::Dot &lhs, const libmspub::Dot &rhs)
33 : {
34 0 : return lhs.m_length == rhs.m_length && lhs.m_count == rhs.m_count;
35 : }
36 :
37 0 : bool libmspub::operator!=(const libmspub::Dot &lhs, const libmspub::Dot &rhs)
38 : {
39 0 : return !operator==(lhs, rhs);
40 : }
41 :
42 0 : bool libmspub::operator==(const libmspub::Dash &lhs, const libmspub::Dash &rhs)
43 : {
44 0 : if (!(lhs.m_distance == rhs.m_distance &&
45 0 : lhs.m_dotStyle == rhs.m_dotStyle && lhs.m_dots.size() == rhs.m_dots.size()))
46 : {
47 0 : return false;
48 : }
49 0 : for (unsigned i = 0; i < lhs.m_dots.size(); ++i)
50 : {
51 0 : if (lhs.m_dots[i] != rhs.m_dots[i])
52 : {
53 0 : return false;
54 : }
55 : }
56 0 : return true;
57 : }
58 :
59 0 : libmspub::Dash libmspub::getDash(MSPUBDashStyle style, unsigned shapeLineWidthEmu,
60 : DotStyle dotStyle)
61 : {
62 : double shapeLineWidth = static_cast<double>(shapeLineWidthEmu) /
63 0 : EMUS_IN_INCH;
64 0 : switch (style)
65 : {
66 : default:
67 : MSPUB_DEBUG_MSG(("Couldn't match dash style, using solid line.\n"));
68 : case MSPUB_DS_SOLID:
69 0 : return Dash(0, RECT_DOT);
70 : case DASH_SYS:
71 : {
72 0 : Dash ret(shapeLineWidth, dotStyle);
73 0 : ret.m_dots.push_back(Dot(1, 3 * shapeLineWidth));
74 0 : return ret;
75 : }
76 : case DOT_SYS:
77 : {
78 0 : Dash ret(shapeLineWidth, dotStyle);
79 0 : ret.m_dots.push_back(Dot(1));
80 0 : return ret;
81 : }
82 : case DASH_DOT_SYS:
83 : {
84 0 : Dash ret(shapeLineWidth, dotStyle);
85 0 : ret.m_dots.push_back(Dot(1, 3 * shapeLineWidth));
86 0 : ret.m_dots.push_back(Dot(1));
87 0 : return ret;
88 : }
89 : case DASH_DOT_DOT_SYS:
90 : {
91 0 : Dash ret(shapeLineWidth, dotStyle);
92 0 : ret.m_dots.push_back(Dot(1, 3 * shapeLineWidth));
93 0 : ret.m_dots.push_back(Dot(2));
94 0 : return ret;
95 : }
96 : case DOT_GEL:
97 : {
98 0 : Dash ret(3 * shapeLineWidth, dotStyle);
99 0 : ret.m_dots.push_back(Dot(1));
100 0 : return ret;
101 : }
102 : case DASH_GEL:
103 : {
104 0 : Dash ret(3 * shapeLineWidth, dotStyle);
105 0 : ret.m_dots.push_back(Dot(1, 4 * shapeLineWidth));
106 0 : return ret;
107 : }
108 : case LONG_DASH_GEL:
109 : {
110 0 : Dash ret(3 * shapeLineWidth, dotStyle);
111 0 : ret.m_dots.push_back(Dot(1, 8 * shapeLineWidth));
112 0 : return ret;
113 : }
114 : case DASH_DOT_GEL:
115 : {
116 0 : Dash ret(3 * shapeLineWidth, dotStyle);
117 0 : ret.m_dots.push_back(Dot(1, 4 * shapeLineWidth));
118 0 : ret.m_dots.push_back(Dot(1));
119 0 : return ret;
120 : }
121 : case LONG_DASH_DOT_GEL:
122 : {
123 0 : Dash ret(3 * shapeLineWidth, dotStyle);
124 0 : ret.m_dots.push_back(Dot(1, 8 * shapeLineWidth));
125 0 : ret.m_dots.push_back(Dot(1));
126 0 : return ret;
127 : }
128 : case LONG_DASH_DOT_DOT_GEL:
129 : {
130 0 : Dash ret(3 * shapeLineWidth, dotStyle);
131 0 : ret.m_dots.push_back(Dot(1, 8 * shapeLineWidth));
132 0 : ret.m_dots.push_back(Dot(2));
133 0 : return ret;
134 : }
135 : }
136 : }
137 :
138 : /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
|