1 // Copyright (C) 2003 Dominique Devriese <devriese@kde.org>
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 #include "cubic_type.h"
20 #include "cubic_imp.h"
21 #include "point_imp.h"
22 #include "bogus_imp.h"
26 static const char cubictpstatement
[] = I18N_NOOP( "Construct a cubic curve through this point" );
28 static const struct ArgsParser::spec argsspecCubicB9P
[] =
30 { PointImp::stype(), cubictpstatement
,
31 I18N_NOOP( "Select a point for the new cubic to go through..." ), true },
32 { PointImp::stype(), cubictpstatement
,
33 I18N_NOOP( "Select a point for the new cubic to go through..." ), true },
34 { PointImp::stype(), cubictpstatement
,
35 I18N_NOOP( "Select a point for the new cubic to go through..." ), true },
36 { PointImp::stype(), cubictpstatement
,
37 I18N_NOOP( "Select a point for the new cubic to go through..." ), true },
38 { PointImp::stype(), cubictpstatement
,
39 I18N_NOOP( "Select a point for the new cubic to go through..." ), true },
40 { PointImp::stype(), cubictpstatement
,
41 I18N_NOOP( "Select a point for the new cubic to go through..." ), true },
42 { PointImp::stype(), cubictpstatement
,
43 I18N_NOOP( "Select a point for the new cubic to go through..." ), true },
44 { PointImp::stype(), cubictpstatement
,
45 I18N_NOOP( "Select a point for the new cubic to go through..." ), true },
46 { PointImp::stype(), cubictpstatement
,
47 I18N_NOOP( "Select a point for the new cubic to go through..." ), true }
50 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( CubicB9PType
)
52 CubicB9PType::CubicB9PType()
53 : ArgsParserObjectType( "CubicB9P", argsspecCubicB9P
, 9 )
57 CubicB9PType::~CubicB9PType()
61 const CubicB9PType
* CubicB9PType::instance()
63 static const CubicB9PType t
;
67 ObjectImp
* CubicB9PType::calc( const Args
& os
, const KigDocument
& ) const
69 if ( ! margsparser
.checkArgs( os
, 2 ) ) return new InvalidImp
;
71 std::vector
<Coordinate
> points
;
72 for ( uint i
= 0; i
< os
.size(); ++i
)
73 points
.push_back( static_cast<const PointImp
*>( os
[i
] )->coordinate() );
75 CubicCartesianData d
= calcCubicThroughPoints( points
);
77 return new CubicImp( d
);
79 return new InvalidImp
;
82 static const ArgsParser::spec argsspecCubicNodeB6P
[] =
84 { PointImp::stype(), cubictpstatement
,
85 I18N_NOOP( "Select a point for the new cubic to go through..." ), true },
86 { PointImp::stype(), cubictpstatement
,
87 I18N_NOOP( "Select a point for the new cubic to go through..." ), true },
88 { PointImp::stype(), cubictpstatement
,
89 I18N_NOOP( "Select a point for the new cubic to go through..." ), true },
90 { PointImp::stype(), cubictpstatement
,
91 I18N_NOOP( "Select a point for the new cubic to go through..." ), true },
92 { PointImp::stype(), cubictpstatement
,
93 I18N_NOOP( "Select a point for the new cubic to go through..." ), true },
94 { PointImp::stype(), cubictpstatement
,
95 I18N_NOOP( "Select a point for the new cubic to go through..." ), true }
98 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( CubicNodeB6PType
)
100 CubicNodeB6PType::CubicNodeB6PType()
101 : ArgsParserObjectType( "CubicNodeB6P", argsspecCubicNodeB6P
, 6 )
105 CubicNodeB6PType::~CubicNodeB6PType()
109 const CubicNodeB6PType
* CubicNodeB6PType::instance()
111 static const CubicNodeB6PType t
;
115 ObjectImp
* CubicNodeB6PType::calc( const Args
& parents
, const KigDocument
& ) const
117 if ( ! margsparser
.checkArgs( parents
, 2 ) ) return new InvalidImp
;
119 std::vector
<Coordinate
> points
;
120 for ( Args::const_iterator i
= parents
.begin(); i
!= parents
.end(); ++i
)
121 points
.push_back( static_cast<const PointImp
*>( *i
)->coordinate() );
123 CubicCartesianData d
= calcCubicNodeThroughPoints( points
);
125 return new CubicImp( d
);
127 return new InvalidImp
;
130 static const ArgsParser::spec argsspecCubicCuspB4P
[] =
132 { PointImp::stype(), cubictpstatement
,
133 I18N_NOOP( "Select a point for the new cubic to go through..." ), true },
134 { PointImp::stype(), cubictpstatement
,
135 I18N_NOOP( "Select a point for the new cubic to go through..." ), true },
136 { PointImp::stype(), cubictpstatement
,
137 I18N_NOOP( "Select a point for the new cubic to go through..." ), true },
138 { PointImp::stype(), cubictpstatement
,
139 I18N_NOOP( "Select a point for the new cubic to go through..." ), true }
142 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( CubicCuspB4PType
)
144 CubicCuspB4PType::CubicCuspB4PType()
145 : ArgsParserObjectType( "CubicCuspB4P", argsspecCubicCuspB4P
, 4 )
149 CubicCuspB4PType::~CubicCuspB4PType()
153 const CubicCuspB4PType
* CubicCuspB4PType::instance()
155 static const CubicCuspB4PType t
;
159 ObjectImp
* CubicCuspB4PType::calc( const Args
& parents
, const KigDocument
& ) const
161 if ( ! margsparser
.checkArgs( parents
, 2 ) ) return new InvalidImp
;
163 std::vector
<Coordinate
> points
;
164 for ( Args::const_iterator i
= parents
.begin(); i
!= parents
.end(); ++i
)
165 points
.push_back( static_cast<const PointImp
*>( *i
)->coordinate() );
167 CubicCartesianData d
= calcCubicCuspThroughPoints( points
);
168 if ( d
.valid() ) return new CubicImp( d
);
169 else return new InvalidImp
;
172 const ObjectImpType
* CubicB9PType::resultId() const
174 return CubicImp::stype();
177 const ObjectImpType
* CubicNodeB6PType::resultId() const
179 return CubicImp::stype();
182 const ObjectImpType
* CubicCuspB4PType::resultId() const
184 return CubicImp::stype();