• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kig

  • sources
  • kde-4.14
  • kdeedu
  • kig
  • objects
cubic_type.cc
Go to the documentation of this file.
1 // Copyright (C) 2003 Dominique Devriese <devriese@kde.org>
2 
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.
7 
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.
12 
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., 51 Franklin Street, Fifth Floor, Boston, MA
16 // 02110-1301, USA.
17 
18 #include "cubic_type.h"
19 
20 #include "cubic_imp.h"
21 #include "point_imp.h"
22 #include "bogus_imp.h"
23 
24 #include <klocale.h>
25 
26 static const char cubictpstatement[] = I18N_NOOP( "Construct a cubic curve through this point" );
27 static const char cubicselectstatement[] = I18N_NOOP( "Select a point for the new cubic to go through..." );
28 
29 static const struct ArgsParser::spec argsspecCubicB9P[] =
30 {
31  { PointImp::stype(), cubictpstatement, cubicselectstatement, true },
32  { PointImp::stype(), cubictpstatement, cubicselectstatement, true },
33  { PointImp::stype(), cubictpstatement, cubicselectstatement, true },
34  { PointImp::stype(), cubictpstatement, cubicselectstatement, true },
35  { PointImp::stype(), cubictpstatement, cubicselectstatement, true },
36  { PointImp::stype(), cubictpstatement, cubicselectstatement, true },
37  { PointImp::stype(), cubictpstatement, cubicselectstatement, true },
38  { PointImp::stype(), cubictpstatement, cubicselectstatement, true },
39  { PointImp::stype(), cubictpstatement, cubicselectstatement, true }
40 };
41 
42 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( CubicB9PType )
43 
44 CubicB9PType::CubicB9PType()
45  : ArgsParserObjectType( "CubicB9P", argsspecCubicB9P, 9 )
46 {
47 }
48 
49 CubicB9PType::~CubicB9PType()
50 {
51 }
52 
53 const CubicB9PType* CubicB9PType::instance()
54 {
55  static const CubicB9PType t;
56  return &t;
57 }
58 
59 ObjectImp* CubicB9PType::calc( const Args& os, const KigDocument& ) const
60 {
61  if ( ! margsparser.checkArgs( os, 2 ) ) return new InvalidImp;
62 
63  std::vector<Coordinate> points;
64  for ( uint i = 0; i < os.size(); ++i )
65  points.push_back( static_cast<const PointImp*>( os[i] )->coordinate() );
66 
67  CubicCartesianData d = calcCubicThroughPoints( points );
68  if ( d.valid() )
69  return new CubicImp( d );
70  else
71  return new InvalidImp;
72 }
73 
74 static const ArgsParser::spec argsspecCubicNodeB6P[] =
75 {
76  { PointImp::stype(), cubictpstatement, cubicselectstatement, true },
77  { PointImp::stype(), cubictpstatement, cubicselectstatement, true },
78  { PointImp::stype(), cubictpstatement, cubicselectstatement, true },
79  { PointImp::stype(), cubictpstatement, cubicselectstatement, true },
80  { PointImp::stype(), cubictpstatement, cubicselectstatement, true },
81  { PointImp::stype(), cubictpstatement, cubicselectstatement, true }
82 };
83 
84 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( CubicNodeB6PType )
85 
86 CubicNodeB6PType::CubicNodeB6PType()
87  : ArgsParserObjectType( "CubicNodeB6P", argsspecCubicNodeB6P, 6 )
88 {
89 }
90 
91 CubicNodeB6PType::~CubicNodeB6PType()
92 {
93 }
94 
95 const CubicNodeB6PType* CubicNodeB6PType::instance()
96 {
97  static const CubicNodeB6PType t;
98  return &t;
99 }
100 
101 ObjectImp* CubicNodeB6PType::calc( const Args& parents, const KigDocument& ) const
102 {
103  if ( ! margsparser.checkArgs( parents, 2 ) ) return new InvalidImp;
104 
105  std::vector<Coordinate> points;
106  for ( Args::const_iterator i = parents.begin(); i != parents.end(); ++i )
107  points.push_back( static_cast<const PointImp*>( *i )->coordinate() );
108 
109  CubicCartesianData d = calcCubicNodeThroughPoints( points );
110  if ( d.valid() )
111  return new CubicImp( d );
112  else
113  return new InvalidImp;
114 }
115 
116 static const ArgsParser::spec argsspecCubicCuspB4P[] =
117 {
118  { PointImp::stype(), cubictpstatement, cubicselectstatement, true },
119  { PointImp::stype(), cubictpstatement, cubicselectstatement, true },
120  { PointImp::stype(), cubictpstatement, cubicselectstatement, true },
121  { PointImp::stype(), cubictpstatement, cubicselectstatement, true }
122 };
123 
124 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( CubicCuspB4PType )
125 
126 CubicCuspB4PType::CubicCuspB4PType()
127  : ArgsParserObjectType( "CubicCuspB4P", argsspecCubicCuspB4P, 4 )
128 {
129 }
130 
131 CubicCuspB4PType::~CubicCuspB4PType()
132 {
133 }
134 
135 const CubicCuspB4PType* CubicCuspB4PType::instance()
136 {
137  static const CubicCuspB4PType t;
138  return &t;
139 }
140 
141 ObjectImp* CubicCuspB4PType::calc( const Args& parents, const KigDocument& ) const
142 {
143  if ( ! margsparser.checkArgs( parents, 2 ) ) return new InvalidImp;
144 
145  std::vector<Coordinate> points;
146  for ( Args::const_iterator i = parents.begin(); i != parents.end(); ++i )
147  points.push_back( static_cast<const PointImp*>( *i )->coordinate() );
148 
149  CubicCartesianData d = calcCubicCuspThroughPoints( points );
150  if ( d.valid() ) return new CubicImp( d );
151  else return new InvalidImp;
152 }
153 
154 static const ArgsParser::spec argsspecVerticalCubicB4P[] =
155 {
156  { PointImp::stype(), cubictpstatement, cubicselectstatement, true },
157  { PointImp::stype(), cubictpstatement, cubicselectstatement, true },
158  { PointImp::stype(), cubictpstatement, cubicselectstatement, true },
159  { PointImp::stype(), cubictpstatement, cubicselectstatement, true }
160 };
161 
162 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( VerticalCubicB4PType )
163 
164 VerticalCubicB4PType::VerticalCubicB4PType()
165  : ArgsParserObjectType( "VerticalCubicB4P", argsspecVerticalCubicB4P, 4 )
166 {
167 }
168 
169 VerticalCubicB4PType::~VerticalCubicB4PType()
170 {
171 }
172 
173 const VerticalCubicB4PType* VerticalCubicB4PType::instance()
174 {
175  static const VerticalCubicB4PType t;
176  return &t;
177 }
178 
179 ObjectImp* VerticalCubicB4PType::calc( const Args& parents, const KigDocument& ) const
180 {
181  if ( ! margsparser.checkArgs( parents, 2 ) ) return new InvalidImp;
182 
183  std::vector<Coordinate> points;
184  for ( Args::const_iterator i = parents.begin(); i != parents.end(); ++i )
185  points.push_back( static_cast<const PointImp*>( *i )->coordinate() );
186 
187  CubicCartesianData d = calcCubicThroughPoints( points );
188  if ( d.valid() ) return new CubicImp( d );
189  else return new InvalidImp;
190 }
191 
192 const ObjectImpType* CubicB9PType::resultId() const
193 {
194  return CubicImp::stype();
195 }
196 
197 const ObjectImpType* CubicNodeB6PType::resultId() const
198 {
199  return CubicImp::stype();
200 }
201 
202 const ObjectImpType* CubicCuspB4PType::resultId() const
203 {
204  return CubicImp::stype();
205 }
206 
207 const ObjectImpType* VerticalCubicB4PType::resultId() const
208 {
209  return CubicImp::stype();
210 }
CubicImp
An ObjectImp representing a cubic.
Definition: cubic_imp.h:29
ObjectImpType
Instances of this class represent a certain ObjectImp type.
Definition: object_imp.h:95
CubicCuspB4PType
Definition: cubic_type.h:45
CubicCuspB4PType::instance
static const CubicCuspB4PType * instance()
Definition: cubic_type.cc:135
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE(SegmentAxisType)
point_imp.h
ArgsParserObjectType
This is a convenience subclass of ObjectType that a type should inherit from if its parents can be sp...
Definition: object_type.h:113
calcCubicCuspThroughPoints
const CubicCartesianData calcCubicCuspThroughPoints(const std::vector< Coordinate > &points)
Definition: cubic-common.cc:153
CubicCuspB4PType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: cubic_type.cc:141
CubicB9PType::instance
static const CubicB9PType * instance()
Definition: cubic_type.cc:53
VerticalCubicB4PType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: cubic_type.cc:207
VerticalCubicB4PType::instance
static const VerticalCubicB4PType * instance()
Definition: cubic_type.cc:173
cubic_type.h
CubicCuspB4PType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: cubic_type.cc:202
ArgsParserObjectType::margsparser
const ArgsParser margsparser
Definition: object_type.h:117
bogus_imp.h
Args
std::vector< const ObjectImp * > Args
Definition: objects/common.h:47
CubicCartesianData::valid
bool valid() const
Return whether this is a valid CubicCartesianData.
Definition: cubic-common.cc:539
ArgsParser::checkArgs
bool checkArgs(const std::vector< ObjectCalcer * > &os) const
Definition: argsparser.cpp:222
CubicCartesianData
This class represents an equation of a cubic in the form (in homogeneous coordinates, ), .
Definition: cubic-common.h:31
argsspecVerticalCubicB4P
static const ArgsParser::spec argsspecVerticalCubicB4P[]
Definition: cubic_type.cc:154
ArgsParser::spec
Definition: argsparser.h:113
CubicNodeB6PType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: cubic_type.cc:101
CubicB9PType
Definition: cubic_type.h:23
argsspecCubicNodeB6P
static const ArgsParser::spec argsspecCubicNodeB6P[]
Definition: cubic_type.cc:74
PointImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing PointImp's.
Definition: point_imp.cc:159
CubicNodeB6PType::instance
static const CubicNodeB6PType * instance()
Definition: cubic_type.cc:95
argsspecCubicB9P
static const struct ArgsParser::spec argsspecCubicB9P[]
Definition: cubic_type.cc:29
CubicB9PType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: cubic_type.cc:192
calcCubicNodeThroughPoints
const CubicCartesianData calcCubicNodeThroughPoints(const std::vector< Coordinate > &points)
Definition: cubic-common.cc:247
cubic_imp.h
KigDocument
KigDocument is the class holding the real data in a Kig document.
Definition: kig_document.h:36
CubicNodeB6PType
Definition: cubic_type.h:34
CubicB9PType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: cubic_type.cc:59
VerticalCubicB4PType
Definition: cubic_type.h:56
cubicselectstatement
static const char cubicselectstatement[]
Definition: cubic_type.cc:27
ObjectImp
The ObjectImp class represents the behaviour of an object after it is calculated. ...
Definition: object_imp.h:226
cubictpstatement
static const char cubictpstatement[]
Definition: cubic_type.cc:26
CubicImp::stype
static const ObjectImpType * stype()
Definition: cubic_imp.cc:352
VerticalCubicB4PType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: cubic_type.cc:179
CubicNodeB6PType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: cubic_type.cc:197
argsspecCubicCuspB4P
static const ArgsParser::spec argsspecCubicCuspB4P[]
Definition: cubic_type.cc:116
calcCubicThroughPoints
const CubicCartesianData calcCubicThroughPoints(const std::vector< Coordinate > &points)
This function calcs a cartesian cubic equation such that the given points are on the cubic...
Definition: cubic-common.cc:58
uint
unsigned int uint
Definition: object_imp.h:87
InvalidImp
This ObjectImp represents an invalid object.
Definition: bogus_imp.h:61
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:12:05 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kig

Skip menu "kig"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal