• 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
conic_types.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 "conic_types.h"
19 
20 #include "bogus_imp.h"
21 #include "conic_imp.h"
22 #include "point_imp.h"
23 #include "circle_imp.h"
24 #include "line_imp.h"
25 #include "object_calcer.h"
26 #include "../misc/conic-common.h"
27 #include "../misc/common.h"
28 #include "../kig/kig_commands.h"
29 #include "../kig/kig_part.h"
30 
31 #include <klocale.h>
32 
33 static const char conic_constructstatement[] = I18N_NOOP( "Construct a conic through this point" );
34 
35 static const struct ArgsParser::spec argsspecConicB5P[] =
36 {
37  { PointImp::stype(), conic_constructstatement,
38  I18N_NOOP( "Select a point for the new conic to go through..." ), true },
39  { PointImp::stype(), conic_constructstatement,
40  I18N_NOOP( "Select a point for the new conic to go through..." ), true },
41  { PointImp::stype(), conic_constructstatement,
42  I18N_NOOP( "Select a point for the new conic to go through..." ), true },
43  { PointImp::stype(), conic_constructstatement,
44  I18N_NOOP( "Select a point for the new conic to go through..." ), true },
45  { PointImp::stype(), conic_constructstatement,
46  I18N_NOOP( "Select a point for the new conic to go through..." ),true }
47 };
48 
49 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ConicB5PType )
50 
51 ConicB5PType::ConicB5PType()
52  : ArgsParserObjectType( "ConicB5P", argsspecConicB5P, 5 )
53 {
54 }
55 
56 ConicB5PType::~ConicB5PType()
57 {
58 }
59 
60 ObjectImp* ConicB5PType::calc( const Args& parents, const KigDocument& ) const
61 {
62  if ( ! margsparser.checkArgs( parents, 1 ) ) return new InvalidImp;
63  std::vector<Coordinate> points;
64 
65  for ( Args::const_iterator i = parents.begin(); i != parents.end(); ++i )
66  points.push_back( static_cast<const PointImp*>( *i )->coordinate() );
67 
68  ConicCartesianData d =
69  calcConicThroughPoints( points, zerotilt, parabolaifzt, ysymmetry );
70  if ( d.valid() )
71  return new ConicImpCart( d );
72  else return new InvalidImp;
73 }
74 
75 const ConicB5PType* ConicB5PType::instance()
76 {
77  static const ConicB5PType t;
78  return &t;
79 }
80 
81 static const ArgsParser::spec argsspecConicBAAP[] =
82 {
83  { AbstractLineImp::stype(), I18N_NOOP( "Construct a conic with this asymptote" ),
84  I18N_NOOP( "Select the first asymptote of the new conic..." ), false },
85  { AbstractLineImp::stype(), I18N_NOOP( "Construct a conic with this asymptote" ),
86  I18N_NOOP( "Select the second asymptote of the new conic..." ), false },
87  { PointImp::stype(), I18N_NOOP( "Construct a conic through this point" ),
88  I18N_NOOP( "Select a point for the new conic to go through..." ), true }
89 };
90 
91 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ConicBAAPType )
92 
93 ConicBAAPType::ConicBAAPType()
94  : ArgsParserObjectType( "ConicBAAP", argsspecConicBAAP, 3 )
95 {
96 }
97 
98 ConicBAAPType::~ConicBAAPType()
99 {
100 }
101 
102 const ConicBAAPType* ConicBAAPType::instance()
103 {
104  static const ConicBAAPType t;
105  return &t;
106 }
107 
108 ObjectImp* ConicBAAPType::calc( const Args& parents, const KigDocument& ) const
109 {
110  if ( ! margsparser.checkArgs( parents ) )
111  return new InvalidImp;
112  const LineData la = static_cast<const AbstractLineImp*>( parents[0] )->data();
113  const LineData lb = static_cast<const AbstractLineImp*>( parents[1] )->data();
114  const Coordinate c = static_cast<const PointImp*>( parents[2] )->coordinate();
115 
116  return new ConicImpCart( calcConicByAsymptotes( la, lb, c ) );
117 }
118 
119 ObjectImp* ConicBFFPType::calc( const Args& parents, const KigDocument& ) const
120 {
121  if ( ! margsparser.checkArgs( parents, 2 ) ) return new InvalidImp;
122  std::vector<Coordinate> cs;
123 
124  for ( Args::const_iterator i = parents.begin(); i != parents.end(); ++i )
125  cs.push_back( static_cast<const PointImp*>( *i )->coordinate() );
126 
127  return new ConicImpPolar( calcConicBFFP( cs, type() ) );
128 }
129 
130 ConicBFFPType::ConicBFFPType( const char* fullname, const ArgsParser::spec* spec, int n )
131  : ArgsParserObjectType( fullname, spec, n )
132 {
133 }
134 
135 ConicBFFPType::~ConicBFFPType()
136 {
137 }
138 
139 static const char constructellipsewithfocusstat[] =
140  I18N_NOOP( "Construct an ellipse with this focus" );
141 
142 static const ArgsParser::spec argsspecEllipseBFFP[] =
143 {
144  { PointImp::stype(), constructellipsewithfocusstat,
145  I18N_NOOP( "Select the first focus of the new ellipse..." ), false },
146  { PointImp::stype(), constructellipsewithfocusstat,
147  I18N_NOOP( "Select the second focus of the new ellipse..." ), false },
148  { PointImp::stype(), I18N_NOOP( "Construct an ellipse through this point" ),
149  I18N_NOOP( "Select a point for the new ellipse to go through..." ), true }
150 };
151 
152 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( EllipseBFFPType )
153 
154 EllipseBFFPType::EllipseBFFPType()
155  : ConicBFFPType( "EllipseBFFP", argsspecEllipseBFFP, 3 )
156 {
157 }
158 
159 EllipseBFFPType::~EllipseBFFPType()
160 {
161 }
162 
163 int EllipseBFFPType::type() const
164 {
165  return 1;
166 }
167 
168 const EllipseBFFPType* EllipseBFFPType::instance()
169 {
170  static const EllipseBFFPType t;
171  return &t;
172 }
173 
174 static const char constructhyperbolawithfocusstat[] =
175  I18N_NOOP( "Construct a hyperbola with this focus" );
176 
177 static const ArgsParser::spec argsspecHyperbolaBFFP[] =
178 {
179  { PointImp::stype(), constructhyperbolawithfocusstat,
180  I18N_NOOP( "Select the first focus of the new hyperbola..." ), false },
181  { PointImp::stype(), constructhyperbolawithfocusstat,
182  I18N_NOOP( "Select the second focus of the new hyperbola..." ), false },
183  { PointImp::stype(), I18N_NOOP( "Construct a hyperbola through this point" ),
184  I18N_NOOP( "Select a point for the new hyperbola to go through..." ), true }
185 };
186 
187 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( HyperbolaBFFPType )
188 
189 HyperbolaBFFPType::HyperbolaBFFPType()
190  : ConicBFFPType( "HyperbolaBFFP", argsspecHyperbolaBFFP, 3 )
191 {
192 }
193 
194 HyperbolaBFFPType::~HyperbolaBFFPType()
195 {
196 }
197 
198 const HyperbolaBFFPType* HyperbolaBFFPType::instance()
199 {
200  static const HyperbolaBFFPType t;
201  return &t;
202 }
203 
204 int HyperbolaBFFPType::type() const
205 {
206  return -1;
207 }
208 
209 const ConicBDFPType* ConicBDFPType::instance()
210 {
211  static const ConicBDFPType t;
212  return &t;
213 }
214 
215 static const struct ArgsParser::spec argsspecConicBDFP[] =
216 {
217  { AbstractLineImp::stype(), I18N_NOOP( "Construct a conic with this line as directrix" ),
218  I18N_NOOP( "Select the directrix of the new conic..." ), false },
219  { PointImp::stype(), I18N_NOOP( "Construct a conic with this point as focus" ),
220  I18N_NOOP( "Select the focus of the new conic..." ), false },
221  { PointImp::stype(), I18N_NOOP( "Construct a conic through this point" ),
222  I18N_NOOP( "Select a point for the new conic to go through..." ), true }
223 };
224 
225 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ConicBDFPType )
226 
227 ConicBDFPType::ConicBDFPType()
228  : ArgsParserObjectType( "ConicBDFP", argsspecConicBDFP, 3 )
229 {
230 }
231 
232 ConicBDFPType::~ConicBDFPType()
233 {
234 }
235 
236 ObjectImp* ConicBDFPType::calc( const Args& parents, const KigDocument& ) const
237 {
238  if ( ! margsparser.checkArgs( parents, 2 ) ) return new InvalidImp;
239 
240  const LineData line = static_cast<const AbstractLineImp*>( parents[0] )->data();
241  const Coordinate focus =
242  static_cast<const PointImp*>( parents[1] )->coordinate();
243 
244  Coordinate point;
245  if ( parents.size() == 3 )
246  point = static_cast<const PointImp*>( parents[2] )->coordinate();
247  else
248  {
249  /* !!!! costruisci point come punto medio dell'altezza tra fuoco e d. */
250  Coordinate ba = line.dir();
251  Coordinate fa = focus - line.b;
252  double balsq = ba.x*ba.x + ba.y*ba.y;
253  double scal = (fa.x*ba.x + fa.y*ba.y)/balsq;
254  point = 0.5*(line.a + focus + scal*ba);
255  };
256  return new ConicImpPolar( calcConicBDFP( line, focus, point ) );
257 }
258 
259 static const char constructparabolathroughpointstat[] =
260  I18N_NOOP( "Construct a parabola through this point" );
261 
262 static const ArgsParser::spec argsspecParabolaBTP[] =
263 {
264  { PointImp::stype(), constructparabolathroughpointstat,
265  I18N_NOOP( "Select a point for the new parabola to go through..." ), true },
266  { PointImp::stype(), constructparabolathroughpointstat,
267  I18N_NOOP( "Select a point for the new parabola to go through..." ), true },
268  { PointImp::stype(), constructparabolathroughpointstat,
269  I18N_NOOP( "Select a point for the new parabola to go through..." ), true }
270 };
271 
272 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ParabolaBTPType )
273 
274 ParabolaBTPType::ParabolaBTPType()
275  : ArgsParserObjectType( "ParabolaBTP", argsspecParabolaBTP, 3 )
276 {
277 }
278 
279 ParabolaBTPType::~ParabolaBTPType()
280 {
281 }
282 
283 const ParabolaBTPType* ParabolaBTPType::instance()
284 {
285  static const ParabolaBTPType t;
286  return &t;
287 }
288 
289 ObjectImp* ParabolaBTPType::calc( const Args& parents, const KigDocument& ) const
290 {
291  if ( ! margsparser.checkArgs( parents, 2 ) ) return new InvalidImp;
292 
293  std::vector<Coordinate> points;
294  for ( Args::const_iterator i = parents.begin(); i != parents.end(); ++i )
295  points.push_back( static_cast<const PointImp*>( *i )->coordinate() );
296 
297  ConicCartesianData d =
298  calcConicThroughPoints( points, zerotilt, parabolaifzt, ysymmetry );
299  if ( d.valid() )
300  return new ConicImpCart( d );
301  else
302  return new InvalidImp;
303 }
304 
305 static const ArgsParser::spec argsspecConicPolarPoint[] =
306 {
307  { ConicImp::stype(), I18N_NOOP( "Construct a polar point wrt. this conic" ),
308  I18N_NOOP( "Select the conic wrt. which you want to construct a polar point..." ), false },
309  { AbstractLineImp::stype(), I18N_NOOP( "Construct the polar point of this line" ),
310  I18N_NOOP( "Select the line of which you want to construct the polar point..." ), false }
311 };
312 
313 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ConicPolarPointType )
314 
315 ConicPolarPointType::ConicPolarPointType()
316  : ArgsParserObjectType( "ConicPolarPoint", argsspecConicPolarPoint, 2 )
317 {
318 }
319 
320 ConicPolarPointType::~ConicPolarPointType()
321 {
322 }
323 
324 const ConicPolarPointType* ConicPolarPointType::instance()
325 {
326  static const ConicPolarPointType t;
327  return &t;
328 }
329 
330 ObjectImp* ConicPolarPointType::calc( const Args& parents, const KigDocument& ) const
331 {
332  if ( ! margsparser.checkArgs( parents ) ) return new InvalidImp;
333 
334  const ConicCartesianData c = static_cast<const ConicImp*>( parents[0] )->cartesianData();
335  const LineData l = static_cast<const AbstractLineImp*>( parents[1] )->data();
336  const Coordinate p = calcConicPolarPoint( c, l );
337  if ( p.valid() ) return new PointImp( p );
338  else return new InvalidImp;
339 }
340 
341 static const ArgsParser::spec argsspecConicPolarLine[] =
342 {
343  { ConicImp::stype(), I18N_NOOP( "Construct a polar line wrt. this conic" ),
344  I18N_NOOP( "Select the conic wrt. which you want to construct a polar point..." ), false },
345  { PointImp::stype(), I18N_NOOP( "Construct the polar line of this point" ),
346  I18N_NOOP( "Select the line of which you want to construct the polar point..." ), false }
347 };
348 
349 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ConicPolarLineType )
350 
351 ConicPolarLineType::ConicPolarLineType()
352  : ArgsParserObjectType( "ConicPolarLine", argsspecConicPolarLine, 2 )
353 {
354 }
355 
356 ConicPolarLineType::~ConicPolarLineType()
357 {
358 }
359 
360 const ConicPolarLineType* ConicPolarLineType::instance()
361 {
362  static const ConicPolarLineType t;
363  return &t;
364 }
365 
366 ObjectImp* ConicPolarLineType::calc( const Args& parents, const KigDocument& ) const
367 {
368  if ( ! margsparser.checkArgs( parents ) ) return new InvalidImp;
369 
370  const ConicCartesianData c = static_cast<const ConicImp*>( parents[0] )->cartesianData();
371  const Coordinate p = static_cast<const PointImp*>( parents[1] )->coordinate();
372  bool valid = true;
373  const LineData l = calcConicPolarLine( c, p, valid );
374  if ( valid ) return new LineImp( l );
375  else return new InvalidImp;
376 }
377 
378 static const ArgsParser::spec argsspecConicDirectrix[] =
379 {
380  { ConicImp::stype(), I18N_NOOP( "Construct the directrix of this conic" ),
381  I18N_NOOP( "Select the conic of which you want to construct the directrix..." ), false }
382 };
383 
384 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ConicDirectrixType )
385 
386 ConicDirectrixType::ConicDirectrixType()
387  : ArgsParserObjectType( "ConicDirectrix", argsspecConicDirectrix, 1 )
388 {
389 }
390 
391 ConicDirectrixType::~ConicDirectrixType()
392 {
393 }
394 
395 const ConicDirectrixType* ConicDirectrixType::instance()
396 {
397  static const ConicDirectrixType t;
398  return &t;
399 }
400 
401 ObjectImp* ConicDirectrixType::calc( const Args& parents, const KigDocument& ) const
402 {
403  if ( ! margsparser.checkArgs( parents ) ) return new InvalidImp;
404 
405  const ConicPolarData data =
406  static_cast<const ConicImp*>( parents[0] )->polarData();
407 
408  double ec = data.ecostheta0;
409  double es = data.esintheta0;
410  double eccsq = ec*ec + es*es;
411 
412  Coordinate a = data.focus1 - data.pdimen/eccsq*Coordinate(ec,es);
413  Coordinate b = a + Coordinate(-es,ec);
414  return new LineImp( a, b );
415 }
416 
417 static const char hyperbolatpstatement[] = I18N_NOOP( "Construct a hyperbola through this point" );
418 
419 static const ArgsParser::spec argsspecHyperbolaB4P[] =
420 {
421  { PointImp::stype(), hyperbolatpstatement,
422  I18N_NOOP( "Select a point for the new hyperbola to go through..." ), true },
423  { PointImp::stype(), hyperbolatpstatement,
424  I18N_NOOP( "Select a point for the new hyperbola to go through..." ), true },
425  { PointImp::stype(), hyperbolatpstatement,
426  I18N_NOOP( "Select a point for the new hyperbola to go through..." ), true },
427  { PointImp::stype(), hyperbolatpstatement,
428  I18N_NOOP( "Select a point for the new hyperbola to go through..." ), true }
429 };
430 
431 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( EquilateralHyperbolaB4PType )
432 
433 EquilateralHyperbolaB4PType::EquilateralHyperbolaB4PType()
434  : ArgsParserObjectType( "EquilateralHyperbolaB4P", argsspecHyperbolaB4P, 4 )
435 {
436 }
437 
438 EquilateralHyperbolaB4PType::~EquilateralHyperbolaB4PType()
439 {
440 }
441 
442 const EquilateralHyperbolaB4PType* EquilateralHyperbolaB4PType::instance()
443 {
444  static const EquilateralHyperbolaB4PType t;
445  return &t;
446 }
447 
448 ObjectImp* EquilateralHyperbolaB4PType::calc( const Args& parents, const KigDocument& ) const
449 {
450  if ( ! margsparser.checkArgs( parents, 1 ) ) return new InvalidImp;
451 
452  std::vector<Coordinate> pts;
453  for ( Args::const_iterator i = parents.begin(); i != parents.end(); ++i )
454  pts.push_back( static_cast<const PointImp*>( *i )->coordinate() );
455 
456  ConicCartesianData d = calcConicThroughPoints( pts, equilateral );
457  if ( d.valid() )
458  return new ConicImpCart( d );
459  else
460  return new InvalidImp;
461 }
462 
463 static const ArgsParser::spec argsspecParabolaBDP[] =
464 {
465  { AbstractLineImp::stype(), I18N_NOOP( "Construct a parabola with this directrix" ),
466  I18N_NOOP( "Select the directrix of the new parabola..." ), false },
467  { PointImp::stype(), I18N_NOOP( "Construct a parabola with this focus" ),
468  I18N_NOOP( "Select the focus of the new parabola..." ), false }
469 };
470 
471 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ParabolaBDPType )
472 
473 ParabolaBDPType::ParabolaBDPType()
474  : ObjectLPType( "ParabolaBDP", argsspecParabolaBDP, 2 )
475 {
476 }
477 
478 ParabolaBDPType::~ParabolaBDPType()
479 {
480 }
481 
482 const ParabolaBDPType* ParabolaBDPType::instance()
483 {
484  static const ParabolaBDPType t;
485  return &t;
486 }
487 
488 ObjectImp* ParabolaBDPType::calc( const LineData& l, const Coordinate& c ) const
489 {
490  ConicPolarData ret;
491  Coordinate ldir = l.dir();
492  ldir = ldir.normalize();
493  ret.focus1 = c;
494  ret.ecostheta0 = - ldir.y;
495  ret.esintheta0 = ldir.x;
496  Coordinate fa = c - l.a;
497  ret.pdimen = fa.y*ldir.x - fa.x*ldir.y;
498  ConicImpPolar* r = new ConicImpPolar( ret );
499  kDebug() << r->conicTypeString();
500  return r;
501 }
502 
503 static const ArgsParser::spec argsspecConicAsymptote[] =
504 {
505  { ConicImp::stype(), I18N_NOOP( "Construct the asymptotes of this conic" ),
506  I18N_NOOP( "Select the conic of which you want to construct the asymptotes..." ), false },
507  { IntImp::stype(), "param", "SHOULD NOT BE SEEN", false }
508 };
509 
510 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ConicAsymptoteType )
511 
512 ConicAsymptoteType::ConicAsymptoteType()
513  : ArgsParserObjectType( "ConicAsymptote", argsspecConicAsymptote, 2 )
514 {
515 }
516 
517 ConicAsymptoteType::~ConicAsymptoteType()
518 {
519 }
520 
521 const ConicAsymptoteType* ConicAsymptoteType::instance()
522 {
523  static const ConicAsymptoteType t;
524  return &t;
525 }
526 
527 ObjectImp* ConicAsymptoteType::calc( const Args& parents, const KigDocument& ) const
528 {
529  if ( ! margsparser.checkArgs( parents ) ) return new InvalidImp;
530 
531  bool valid = true;
532  const LineData ret = calcConicAsymptote(
533  static_cast<const ConicImp*>( parents[0] )->cartesianData(),
534  static_cast<const IntImp*>( parents[1] )->data(),
535  valid );
536 
537  if ( valid )
538  return new LineImp( ret );
539  else
540  return new InvalidImp;
541 }
542 
543 static const char radicallinesstatement[] = I18N_NOOP( "Construct the radical lines of this conic" );
544 
545 static const ArgsParser::spec argsspecConicRadical[] =
546 {
547  { ConicImp::stype(), radicallinesstatement,
548  I18N_NOOP( "Select the first of the two conics of which you want to construct the radical line..." ), false },
549  { ConicImp::stype(), radicallinesstatement,
550  I18N_NOOP( "Select the other of the two conic of which you want to construct the radical line..." ), false },
551  { IntImp::stype(), "param", "SHOULD NOT BE SEEN", false },
552  { IntImp::stype(), "param", "SHOULD NOT BE SEEN", false }
553 };
554 
555 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ConicRadicalType )
556 
557 ConicRadicalType::ConicRadicalType()
558  : ArgsParserObjectType( "ConicRadical", argsspecConicRadical, 4 )
559 {
560 }
561 
562 const ConicRadicalType* ConicRadicalType::instance()
563 {
564  static const ConicRadicalType t;
565  return &t;
566 }
567 
568 ObjectImp* ConicRadicalType::calc( const Args& parents, const KigDocument& ) const
569 {
570  if ( ! margsparser.checkArgs( parents ) ) return new InvalidImp;
571  if ( parents[0]->inherits( CircleImp::stype() ) &&
572  parents[1]->inherits( CircleImp::stype() ) )
573  {
574  if( static_cast<const IntImp*>( parents[2] )->data() != 1 )
575  return new InvalidImp;
576  else
577  {
578  const CircleImp* c1 = static_cast<const CircleImp*>( parents[0] );
579  const CircleImp* c2 = static_cast<const CircleImp*>( parents[1] );
580  const Coordinate a = calcCircleRadicalStartPoint(
581  c1->center(), c2->center(), c1->squareRadius(), c2->squareRadius()
582  );
583  return new LineImp( a, calcPointOnPerpend(
584  LineData( c1->center(), c2->center() ), a ) );
585  };
586  }
587  else
588  {
589  bool valid = true;
590  const LineData l = calcConicRadical(
591  static_cast<const ConicImp*>( parents[0] )->cartesianData(),
592  static_cast<const ConicImp*>( parents[1] )->cartesianData(),
593  static_cast<const IntImp*>( parents[2] )->data(),
594  static_cast<const IntImp*>( parents[3] )->data(), valid );
595  if ( valid )
596  return new LineImp( l );
597  else
598  return new InvalidImp;
599  };
600 }
601 
602 ConicRadicalType::~ConicRadicalType()
603 {
604 }
605 
606 const ObjectImpType* ConicB5PType::resultId() const
607 {
608  return ConicImp::stype();
609 }
610 
611 const ObjectImpType* ConicBAAPType::resultId() const
612 {
613  return ConicImp::stype();
614 }
615 
616 const ObjectImpType* ConicBFFPType::resultId() const
617 {
618  return ConicImp::stype();
619 }
620 
621 const ObjectImpType* ConicBDFPType::resultId() const
622 {
623  return ConicImp::stype();
624 }
625 
626 const ObjectImpType* ParabolaBTPType::resultId() const
627 {
628  return ConicImp::stype();
629 }
630 
631 const ObjectImpType* EquilateralHyperbolaB4PType::resultId() const
632 {
633  return ConicImp::stype();
634 }
635 
636 const ObjectImpType* ConicPolarPointType::resultId() const
637 {
638  return PointImp::stype();
639 }
640 
641 const ObjectImpType* ConicPolarLineType::resultId() const
642 {
643  return LineImp::stype();
644 }
645 
646 const ObjectImpType* ConicDirectrixType::resultId() const
647 {
648  return LineImp::stype();
649 }
650 
651 const ObjectImpType* ParabolaBDPType::resultId() const
652 {
653  return ConicImp::stype();
654 }
655 
656 const ObjectImpType* ConicAsymptoteType::resultId() const
657 {
658  return LineImp::stype();
659 }
660 
661 const ObjectImpType* ConicRadicalType::resultId() const
662 {
663  return LineImp::stype();
664 }
665 
666 QStringList ConicRadicalType::specialActions() const
667 {
668  QStringList ret;
669  ret << i18n( "Switch Radical Lines" );
670  return ret;
671 }
672 
673 void ConicRadicalType::executeAction( int i, ObjectHolder&, ObjectTypeCalcer& t,
674  KigPart& d, KigWidget&, NormalMode& ) const
675 {
676  assert( i == 0 );
677  std::vector<ObjectCalcer*> parents = t.parents();
678  assert( dynamic_cast<ObjectConstCalcer*>( parents[3] ) );
679  ObjectConstCalcer* zeroindexo = static_cast<ObjectConstCalcer*>( parents[3] );
680  MonitorDataObjects mon( zeroindexo );
681  assert( zeroindexo->imp()->inherits( IntImp::stype() ) );
682  int oldzeroindex = static_cast<const IntImp*>( zeroindexo->imp() )->data();
683  int newzeroindex = oldzeroindex % 3 + 1;
684  zeroindexo->setImp( new IntImp( newzeroindex ) );
685  KigCommand* kc = new KigCommand( d, i18n( "Switch Conic Radical Lines" ) );
686  mon.finish( kc );
687  d.history()->push( kc );
688 }
689 
EllipseBFFPType
Definition: conic_types.h:61
argsspecConicDirectrix
static const ArgsParser::spec argsspecConicDirectrix[]
Definition: conic_types.cc:378
calcConicPolarLine
const LineData calcConicPolarLine(const ConicCartesianData &data, const Coordinate &cpole, bool &valid)
This function calculates the polar line of the point cpole with respect to the given conic data...
Definition: conic-common.cpp:293
ObjectImpType
Instances of this class represent a certain ObjectImp type.
Definition: object_imp.h:95
HyperbolaBFFPType
Definition: conic_types.h:71
ObjectImp::inherits
bool inherits(const ObjectImpType *t) const
Returns true if this ObjectImp inherits the ObjectImp type represented by t.
Definition: object_imp.cc:279
ObjectConstCalcer::imp
const ObjectImp * imp() const
Returns the ObjectImp of this ObjectCalcer.
Definition: object_calcer.cc:65
ObjectConstCalcer::setImp
void setImp(ObjectImp *newimp)
Set the ObjectImp of this ObjectConstCalcer to the given newimp.
Definition: object_calcer.cc:241
argsspecEllipseBFFP
static const ArgsParser::spec argsspecEllipseBFFP[]
Definition: conic_types.cc:142
ConicB5PType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: conic_types.cc:60
ConicPolarData::esintheta0
double esintheta0
The esintheta0 value from the polar equation.
Definition: conic-common.h:118
ConicPolarLineType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: conic_types.cc:366
ConicImp::conicTypeString
virtual QString conicTypeString() const
A string containing "Hyperbola", "Parabola" or "Ellipse".
Definition: conic_imp.cc:205
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE(SegmentAxisType)
ConicDirectrixType::instance
static const ConicDirectrixType * instance()
Definition: conic_types.cc:395
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
ConicPolarLineType
Definition: conic_types.h:125
ConicRadicalType::specialActions
QStringList specialActions() const
return i18n'd names for the special actions.
Definition: conic_types.cc:666
KigCommand
a KigCommand represents almost every action performed in Kig.
Definition: kig_commands.h:44
ObjectType::inherits
virtual bool inherits(int type) const
Definition: object_type.cc:64
AbstractLineImp
An ObjectImp class that is the base of the line-like ObjectImp's: SegmentImp, LineImp and RayImp...
Definition: line_imp.h:31
LineData
Simple class representing a line.
Definition: misc/common.h:49
ObjectConstCalcer
This is an ObjectCalcer that keeps an ObjectImp, and never calculates a new one.
Definition: object_calcer.h:232
LineData::dir
const Coordinate dir() const
The direction of the line.
Definition: misc/common.h:72
ParabolaBDPType::instance
static const ParabolaBDPType * instance()
Definition: conic_types.cc:482
LineData::b
Coordinate b
Another point on the line.
Definition: misc/common.h:68
ConicDirectrixType
Definition: conic_types.h:136
CircleImp
An ObjectImp representing a circle.
Definition: circle_imp.h:27
ConicBFFPType::~ConicBFFPType
~ConicBFFPType()
Definition: conic_types.cc:135
calcConicAsymptote
const LineData calcConicAsymptote(const ConicCartesianData data, int which, bool &valid)
This function calculates the asymptote of the given conic ( data ).
Definition: conic-common.cpp:467
ConicCartesianData
Cartesian Conic Data.
Definition: conic-common.h:37
HyperbolaBFFPType::type
int type() const
-1 for hyperbola, 1 for ellipse.
Definition: conic_types.cc:204
CircleImp::center
const Coordinate center() const
Return the center of this circle.
Definition: circle_imp.cc:210
ConicB5PType
Definition: conic_types.h:23
KigPart::history
QUndoStack * history()
Definition: kig_part.cpp:630
ConicBAAPType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: conic_types.cc:108
hyperbolatpstatement
static const char hyperbolatpstatement[]
Definition: conic_types.cc:417
calcConicThroughPoints
const ConicCartesianData calcConicThroughPoints(const std::vector< Coordinate > &points, const LinearConstraints c1, const LinearConstraints c2, const LinearConstraints c3, const LinearConstraints c4, const LinearConstraints c5)
Calculate a conic through a given set of points.
Definition: conic-common.cpp:169
ConicDirectrixType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: conic_types.cc:401
ConicBAAPType::instance
static const ConicBAAPType * instance()
Definition: conic_types.cc:102
circle_imp.h
ObjectLPType
Definition: base_type.h:46
EllipseBFFPType::type
int type() const
-1 for hyperbola, 1 for ellipse.
Definition: conic_types.cc:163
ConicPolarPointType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: conic_types.cc:636
calcConicPolarPoint
const Coordinate calcConicPolarPoint(const ConicCartesianData &data, const LineData &polar)
This function calculates the polar point of the line polar with respect to the given conic data...
Definition: conic-common.cpp:325
ConicBDFPType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: conic_types.cc:621
radicallinesstatement
static const char radicallinesstatement[]
Definition: conic_types.cc:543
IntImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the IntImp type.
Definition: bogus_imp.cc:278
ObjectTypeCalcer
This is an ObjectCalcer that uses one of the various ObjectType's to calculate its ObjectImp...
Definition: object_calcer.h:183
LineImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the LineImp type.
Definition: line_imp.cc:528
ConicAsymptoteType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: conic_types.cc:527
calcPointOnPerpend
Coordinate calcPointOnPerpend(const LineData &l, const Coordinate &t)
This file is part of Kig, a KDE program for Interactive Geometry...
Definition: common.cpp:37
IntImp
This ObjectImp is a BogusImp containing only an int value.
Definition: bogus_imp.h:128
parabolaifzt
Definition: conic-common.h:138
Coordinate
The Coordinate class is the basic class representing a 2D location by its x and y components...
Definition: coordinate.h:33
constructellipsewithfocusstat
static const char constructellipsewithfocusstat[]
Definition: conic_types.cc:139
ConicBDFPType
Definition: conic_types.h:81
ConicBDFPType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: conic_types.cc:236
ConicImpPolar
An implementation of ConicImp to be used when only the polar equation of the conic is known...
Definition: conic_imp.h:157
conic_constructstatement
static const char conic_constructstatement[]
Definition: conic_types.cc:33
equilateral
Definition: conic-common.h:139
calcConicBDFP
const ConicPolarData calcConicBDFP(const LineData &directrix, const Coordinate &cfocus, const Coordinate &cpoint)
function used by ConicBDFP.
Definition: conic-common.cpp:433
ArgsParserObjectType::margsparser
const ArgsParser margsparser
Definition: object_type.h:117
EllipseBFFPType::instance
static const EllipseBFFPType * instance()
Definition: conic_types.cc:168
ConicPolarPointType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: conic_types.cc:330
ParabolaBDPType::calc
ObjectImp * calc(const LineData &l, const Coordinate &c) const
Definition: conic_types.cc:488
EquilateralHyperbolaB4PType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: conic_types.cc:448
constructhyperbolawithfocusstat
static const char constructhyperbolawithfocusstat[]
Definition: conic_types.cc:174
argsspecConicB5P
static const struct ArgsParser::spec argsspecConicB5P[]
Definition: conic_types.cc:35
Coordinate::normalize
const Coordinate normalize(double length=1) const
Normalize.
Definition: coordinate.cpp:154
argsspecConicAsymptote
static const ArgsParser::spec argsspecConicAsymptote[]
Definition: conic_types.cc:503
ConicImpCart
An implementation of ConicImp to be used when only the cartesian equation of the conic is known...
Definition: conic_imp.h:138
EquilateralHyperbolaB4PType
Definition: conic_types.h:103
argsspecConicBAAP
static const ArgsParser::spec argsspecConicBAAP[]
Definition: conic_types.cc:81
calcCircleRadicalStartPoint
Coordinate calcCircleRadicalStartPoint(const Coordinate &ca, const Coordinate &cb, double sqra, double sqrb)
Definition: common.cpp:335
ObjectHolder
An ObjectHolder represents an object as it is known to the document.
Definition: object_holder.h:40
bogus_imp.h
PointImp
An ObjectImp representing a point.
Definition: point_imp.h:27
ConicBFFPType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: conic_types.cc:119
Args
std::vector< const ObjectImp * > Args
Definition: objects/common.h:47
ConicAsymptoteType::instance
static const ConicAsymptoteType * instance()
Definition: conic_types.cc:521
ConicBFFPType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: conic_types.cc:616
ConicRadicalType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: conic_types.cc:568
ParabolaBTPType
Definition: conic_types.h:92
ConicPolarData::focus1
Coordinate focus1
The first focus of this conic.
Definition: conic-common.h:106
MonitorDataObjects
this class monitors a set of DataObjects for changes and returns an appropriate ChangeObjectImpsComma...
Definition: kig_commands.h:153
ConicPolarLineType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: conic_types.cc:641
ConicDirectrixType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: conic_types.cc:646
calcConicRadical
const LineData calcConicRadical(const ConicCartesianData &cequation1, const ConicCartesianData &cequation2, int which, int zeroindex, bool &valid)
This function calculates the radical line of two conics.
Definition: conic-common.cpp:544
ParabolaBTPType::calc
ObjectImp * calc(const Args &parents, const KigDocument &) const
Definition: conic_types.cc:289
ConicPolarLineType::instance
static const ConicPolarLineType * instance()
Definition: conic_types.cc:360
LineData::a
Coordinate a
One point on the line.
Definition: misc/common.h:64
ConicPolarData::pdimen
double pdimen
The pdimen value from the polar equation.
Definition: conic-common.h:110
KigWidget
This class is the real widget showing the document.
Definition: kig_view.h:50
ArgsParser::checkArgs
bool checkArgs(const std::vector< ObjectCalcer * > &os) const
Definition: argsparser.cpp:222
argsspecParabolaBTP
static const ArgsParser::spec argsspecParabolaBTP[]
Definition: conic_types.cc:262
ConicBDFPType::instance
static const ConicBDFPType * instance()
Definition: conic_types.cc:209
ConicPolarData::ecostheta0
double ecostheta0
The ecostheta0 value from the polar equation.
Definition: conic-common.h:114
QStringList
ConicAsymptoteType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: conic_types.cc:656
ArgsParser::spec
Definition: argsparser.h:113
ConicImp
An ObjectImp representing a conic.
Definition: conic_imp.h:39
ConicAsymptoteType
Definition: conic_types.h:159
MonitorDataObjects::finish
void finish(KigCommand *comm)
add the generated KigCommandTasks to the command comm .
Definition: kig_commands.cpp:227
object_calcer.h
ysymmetry
Definition: conic-common.h:139
CircleImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the CircleImp type.
Definition: circle_imp.cc:342
ConicRadicalType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: conic_types.cc:661
ConicPolarPointType::instance
static const ConicPolarPointType * instance()
Definition: conic_types.cc:324
argsspecParabolaBDP
static const ArgsParser::spec argsspecParabolaBDP[]
Definition: conic_types.cc:463
ParabolaBTPType::instance
static const ParabolaBTPType * instance()
Definition: conic_types.cc:283
ConicRadicalType
Definition: conic_types.h:170
constructparabolathroughpointstat
static const char constructparabolathroughpointstat[]
Definition: conic_types.cc:259
ConicBFFPType::type
virtual int type() const =0
-1 for hyperbola, 1 for ellipse.
ConicRadicalType::executeAction
void executeAction(int i, ObjectHolder &o, ObjectTypeCalcer &t, KigPart &d, KigWidget &w, NormalMode &m) const
execute the i 'th action from the specialActions above.
Definition: conic_types.cc:673
calcConicBFFP
const ConicPolarData calcConicBFFP(const std::vector< Coordinate > &args, int type)
This function is used by ConicBFFP.
Definition: conic-common.cpp:251
ParabolaBDPType
Definition: conic_types.h:147
ConicPolarPointType
Definition: conic_types.h:114
PointImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing PointImp's.
Definition: point_imp.cc:159
argsspecConicRadical
static const ArgsParser::spec argsspecConicRadical[]
Definition: conic_types.cc:545
line_imp.h
conic_types.h
ParabolaBTPType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: conic_types.cc:626
ConicB5PType::instance
static const ConicB5PType * instance()
Definition: conic_types.cc:75
ConicRadicalType::instance
static const ConicRadicalType * instance()
Definition: conic_types.cc:562
argsspecConicPolarLine
static const ArgsParser::spec argsspecConicPolarLine[]
Definition: conic_types.cc:341
ConicImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the ConicImp type.
Definition: conic_imp.cc:380
KigDocument
KigDocument is the class holding the real data in a Kig document.
Definition: kig_document.h:36
ConicBFFPType
Definition: conic_types.h:45
calcConicByAsymptotes
const ConicCartesianData calcConicByAsymptotes(const LineData &line1, const LineData &line2, const Coordinate &p)
This calcs the hyperbola defined by its two asymptotes line1 and line2, and a point p on the edge...
Definition: conic-common.cpp:511
AbstractLineImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the AbstractLineImp type.
Definition: line_imp.cc:520
ConicCartesianData::valid
bool valid() const
Test validity.
Definition: conic-common.cpp:890
LineImp
An ObjectImp representing a line.
Definition: line_imp.h:184
argsspecHyperbolaBFFP
static const ArgsParser::spec argsspecHyperbolaBFFP[]
Definition: conic_types.cc:177
ObjectTypeCalcer::parents
std::vector< ObjectCalcer * > parents() const
Returns the parent ObjectCalcer's of this ObjectCalcer.
Definition: object_calcer.cc:105
ConicBFFPType::ConicBFFPType
ConicBFFPType(const char *fullname, const ArgsParser::spec *, int n)
Definition: conic_types.cc:130
Coordinate::x
double x
X Component.
Definition: coordinate.h:126
argsspecConicBDFP
static const struct ArgsParser::spec argsspecConicBDFP[]
Definition: conic_types.cc:215
argsspecConicPolarPoint
static const ArgsParser::spec argsspecConicPolarPoint[]
Definition: conic_types.cc:305
zerotilt
Definition: conic-common.h:138
Coordinate::y
double y
Y Component.
Definition: coordinate.h:129
ObjectImp
The ObjectImp class represents the behaviour of an object after it is calculated. ...
Definition: object_imp.h:226
KigPart
This is a "Part".
Definition: kig_part.h:68
EquilateralHyperbolaB4PType::instance
static const EquilateralHyperbolaB4PType * instance()
Definition: conic_types.cc:442
ConicB5PType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: conic_types.cc:606
ConicBAAPType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: conic_types.cc:611
argsspecHyperbolaB4P
static const ArgsParser::spec argsspecHyperbolaB4P[]
Definition: conic_types.cc:419
ParabolaBDPType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: conic_types.cc:651
CircleImp::squareRadius
double squareRadius() const
Return the square radius of this circle.
Definition: circle_imp.cc:225
EquilateralHyperbolaB4PType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: conic_types.cc:631
conic_imp.h
ConicBAAPType
Definition: conic_types.h:34
NormalMode
Definition: normal.h:26
Coordinate::valid
bool valid() const
Return whether this is a valid Coordinate.
Definition: coordinate.cpp:176
QUndoStack::push
void push(QUndoCommand *cmd)
InvalidImp
This ObjectImp represents an invalid object.
Definition: bogus_imp.h:61
HyperbolaBFFPType::instance
static const HyperbolaBFFPType * instance()
Definition: conic_types.cc:198
ConicPolarData
This class represents an equation of a conic in the form .
Definition: conic-common.h:85
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