1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_basegfx.hxx"
26 #include <basegfx/curve/b2dquadraticbezier.hxx>
27 #include <basegfx/numeric/ftools.hxx>
28 
29 //////////////////////////////////////////////////////////////////////////////
30 
31 namespace basegfx
32 {
B2DQuadraticBezier(const B2DQuadraticBezier & rBezier)33 	B2DQuadraticBezier::B2DQuadraticBezier(const B2DQuadraticBezier& rBezier)
34 	:	maStartPoint(rBezier.maStartPoint),
35 		maEndPoint(rBezier.maEndPoint),
36 		maControlPoint(rBezier.maControlPoint)
37 	{
38 	}
39 
B2DQuadraticBezier()40 	B2DQuadraticBezier::B2DQuadraticBezier()
41 	{
42 	}
43 
B2DQuadraticBezier(const::basegfx::B2DPoint & rStart,const::basegfx::B2DPoint & rEnd)44 	B2DQuadraticBezier::B2DQuadraticBezier(const ::basegfx::B2DPoint& rStart, const ::basegfx::B2DPoint& rEnd)
45 	:	maStartPoint(rStart),
46 		maEndPoint(rEnd)
47 	{
48 	}
49 
B2DQuadraticBezier(const::basegfx::B2DPoint & rStart,const::basegfx::B2DPoint & rControl,const::basegfx::B2DPoint & rEnd)50 	B2DQuadraticBezier::B2DQuadraticBezier(const ::basegfx::B2DPoint& rStart, const ::basegfx::B2DPoint& rControl, const ::basegfx::B2DPoint& rEnd)
51 	:	maStartPoint(rStart),
52 		maEndPoint(rEnd),
53 		maControlPoint(rControl)
54 	{
55 	}
56 
~B2DQuadraticBezier()57 	B2DQuadraticBezier::~B2DQuadraticBezier()
58 	{
59 	}
60 
61 	// assignment operator
operator =(const B2DQuadraticBezier & rBezier)62 	B2DQuadraticBezier& B2DQuadraticBezier::operator=(const B2DQuadraticBezier& rBezier)
63 	{
64 		maStartPoint = rBezier.maStartPoint;
65 		maEndPoint = rBezier.maEndPoint;
66 		maControlPoint = rBezier.maControlPoint;
67 
68 		return *this;
69 	}
70 
71 	// compare operators
operator ==(const B2DQuadraticBezier & rBezier) const72 	bool B2DQuadraticBezier::operator==(const B2DQuadraticBezier& rBezier) const
73 	{
74 		return (
75 			maStartPoint == rBezier.maStartPoint
76 			&& maEndPoint == rBezier.maEndPoint
77 			&& maControlPoint == rBezier.maControlPoint
78 		);
79 	}
80 
operator !=(const B2DQuadraticBezier & rBezier) const81 	bool B2DQuadraticBezier::operator!=(const B2DQuadraticBezier& rBezier) const
82 	{
83 		return (
84 			maStartPoint != rBezier.maStartPoint
85 			|| maEndPoint != rBezier.maEndPoint
86 			|| maControlPoint != rBezier.maControlPoint
87 		);
88 	}
89 
90 	// test if control vector is used
isBezier() const91 	bool B2DQuadraticBezier::isBezier() const
92 	{
93 		// if control vector is empty, bezier is not used
94 		if(maControlPoint == maStartPoint || maControlPoint == maEndPoint)
95 			return false;
96 
97 		return true;
98 	}
99 } // end of namespace basegfx
100 
101 // eof
102