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

kig

conic_types.cc

Go to the documentation of this file.
00001 // Copyright (C)  2003  Dominique Devriese <devriese@kde.org>
00002 
00003 // This program is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU General Public License
00005 // as published by the Free Software Foundation; either version 2
00006 // of the License, or (at your option) any later version.
00007 
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software
00015 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00016 // 02110-1301, USA.
00017 
00018 #include "conic_types.h"
00019 
00020 #include "bogus_imp.h"
00021 #include "conic_imp.h"
00022 #include "point_imp.h"
00023 #include "circle_imp.h"
00024 #include "line_imp.h"
00025 #include "object_calcer.h"
00026 #include "../misc/conic-common.h"
00027 #include "../misc/common.h"
00028 #include "../kig/kig_commands.h"
00029 #include "../kig/kig_part.h"
00030 
00031 #include <klocale.h>
00032 
00033 static const char conic_constructstatement[] = I18N_NOOP( "Construct a conic through this point" );
00034 
00035 static const struct ArgsParser::spec argsspecConicB5P[] =
00036 {
00037   { PointImp::stype(), conic_constructstatement,
00038     I18N_NOOP( "Select a point for the new conic to go through..." ), true },
00039   { PointImp::stype(), conic_constructstatement,
00040     I18N_NOOP( "Select a point for the new conic to go through..." ), true },
00041   { PointImp::stype(), conic_constructstatement,
00042     I18N_NOOP( "Select a point for the new conic to go through..." ), true },
00043   { PointImp::stype(), conic_constructstatement,
00044     I18N_NOOP( "Select a point for the new conic to go through..." ), true },
00045   { PointImp::stype(), conic_constructstatement,
00046     I18N_NOOP( "Select a point for the new conic to go through..." ),true }
00047 };
00048 
00049 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ConicB5PType )
00050 
00051 ConicB5PType::ConicB5PType()
00052   : ArgsParserObjectType( "ConicB5P", argsspecConicB5P, 5 )
00053 {
00054 }
00055 
00056 ConicB5PType::~ConicB5PType()
00057 {
00058 }
00059 
00060 ObjectImp* ConicB5PType::calc( const Args& parents, const KigDocument& ) const
00061 {
00062   if ( ! margsparser.checkArgs( parents, 1 ) ) return new InvalidImp;
00063   std::vector<Coordinate> points;
00064 
00065   for ( Args::const_iterator i = parents.begin(); i != parents.end(); ++i )
00066     points.push_back( static_cast<const PointImp*>( *i )->coordinate() );
00067 
00068   ConicCartesianData d =
00069     calcConicThroughPoints( points, zerotilt, parabolaifzt, ysymmetry );
00070   if ( d.valid() )
00071     return new ConicImpCart( d );
00072   else return new InvalidImp;
00073 }
00074 
00075 const ConicB5PType* ConicB5PType::instance()
00076 {
00077   static const ConicB5PType t;
00078   return &t;
00079 }
00080 
00081 static const ArgsParser::spec argsspecConicBAAP[] =
00082 {
00083   { AbstractLineImp::stype(), I18N_NOOP( "Construct a conic with this asymptote" ),
00084     I18N_NOOP( "Select the first asymptote of the new conic..." ), false },
00085   { AbstractLineImp::stype(), I18N_NOOP( "Construct a conic with this asymptote" ),
00086     I18N_NOOP( "Select the second asymptote of the new conic..." ), false },
00087   { PointImp::stype(), I18N_NOOP( "Construct a conic through this point" ),
00088     I18N_NOOP( "Select a point for the new conic to go through..." ), true }
00089 };
00090 
00091 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ConicBAAPType )
00092 
00093 ConicBAAPType::ConicBAAPType()
00094   : ArgsParserObjectType( "ConicBAAP", argsspecConicBAAP, 3 )
00095 {
00096 }
00097 
00098 ConicBAAPType::~ConicBAAPType()
00099 {
00100 }
00101 
00102 const ConicBAAPType* ConicBAAPType::instance()
00103 {
00104   static const ConicBAAPType t;
00105   return &t;
00106 }
00107 
00108 ObjectImp* ConicBAAPType::calc( const Args& parents, const KigDocument& ) const
00109 {
00110   if ( ! margsparser.checkArgs( parents ) )
00111     return new InvalidImp;
00112   const LineData la = static_cast<const AbstractLineImp*>( parents[0] )->data();
00113   const LineData lb = static_cast<const AbstractLineImp*>( parents[1] )->data();
00114   const Coordinate c = static_cast<const PointImp*>( parents[2] )->coordinate();
00115 
00116   return new ConicImpCart( calcConicByAsymptotes( la, lb, c ) );
00117 }
00118 
00119 ObjectImp* ConicBFFPType::calc( const Args& parents, const KigDocument& ) const
00120 {
00121   if ( ! margsparser.checkArgs( parents, 2 ) ) return new InvalidImp;
00122   std::vector<Coordinate> cs;
00123 
00124   for ( Args::const_iterator i = parents.begin(); i != parents.end(); ++i )
00125     cs.push_back( static_cast<const PointImp*>( *i )->coordinate() );
00126 
00127   return new ConicImpPolar( calcConicBFFP( cs, type() ) );
00128 }
00129 
00130 ConicBFFPType::ConicBFFPType( const char* fullname, const ArgsParser::spec* spec, int n )
00131   : ArgsParserObjectType( fullname, spec, n )
00132 {
00133 }
00134 
00135 ConicBFFPType::~ConicBFFPType()
00136 {
00137 }
00138 
00139 static const char constructellipsewithfocusstat[] =
00140   I18N_NOOP( "Construct an ellipse with this focus" );
00141 
00142 static const ArgsParser::spec argsspecEllipseBFFP[] =
00143 {
00144   { PointImp::stype(), constructellipsewithfocusstat,
00145     I18N_NOOP( "Select the first focus of the new ellipse..." ), false },
00146   { PointImp::stype(), constructellipsewithfocusstat,
00147     I18N_NOOP( "Select the second focus of the new ellipse..." ), false },
00148   { PointImp::stype(), I18N_NOOP( "Construct an ellipse through this point" ),
00149     I18N_NOOP( "Select a point for the new ellipse to go through..." ), true }
00150 };
00151 
00152 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( EllipseBFFPType )
00153 
00154 EllipseBFFPType::EllipseBFFPType()
00155   : ConicBFFPType( "EllipseBFFP", argsspecEllipseBFFP, 3 )
00156 {
00157 }
00158 
00159 EllipseBFFPType::~EllipseBFFPType()
00160 {
00161 }
00162 
00163 int EllipseBFFPType::type() const
00164 {
00165   return 1;
00166 }
00167 
00168 const EllipseBFFPType* EllipseBFFPType::instance()
00169 {
00170   static const EllipseBFFPType t;
00171   return &t;
00172 }
00173 
00174 static const char constructhyperbolawithfocusstat[] =
00175   I18N_NOOP( "Construct a hyperbola with this focus" );
00176 
00177 static const ArgsParser::spec argsspecHyperbolaBFFP[] =
00178 {
00179   { PointImp::stype(), constructhyperbolawithfocusstat,
00180     I18N_NOOP( "Select the first focus of the new hyperbola..." ), false },
00181   { PointImp::stype(), constructhyperbolawithfocusstat,
00182     I18N_NOOP( "Select the second focus of the new hyperbola..." ), false },
00183   { PointImp::stype(), I18N_NOOP( "Construct a hyperbola through this point" ),
00184     I18N_NOOP( "Select a point for the new hyperbola to go through..." ), true }
00185 };
00186 
00187 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( HyperbolaBFFPType )
00188 
00189 HyperbolaBFFPType::HyperbolaBFFPType()
00190   : ConicBFFPType( "HyperbolaBFFP", argsspecHyperbolaBFFP, 3 )
00191 {
00192 }
00193 
00194 HyperbolaBFFPType::~HyperbolaBFFPType()
00195 {
00196 }
00197 
00198 const HyperbolaBFFPType* HyperbolaBFFPType::instance()
00199 {
00200   static const HyperbolaBFFPType t;
00201   return &t;
00202 }
00203 
00204 int HyperbolaBFFPType::type() const
00205 {
00206   return -1;
00207 }
00208 
00209 const ConicBDFPType* ConicBDFPType::instance()
00210 {
00211   static const ConicBDFPType t;
00212   return &t;
00213 }
00214 
00215 static const struct ArgsParser::spec argsspecConicBDFP[] =
00216 {
00217   { AbstractLineImp::stype(), I18N_NOOP( "Construct a conic with this line as directrix" ),
00218     I18N_NOOP( "Select the directrix of the new conic..." ), false },
00219   { PointImp::stype(), I18N_NOOP( "Construct a conic with this point as focus" ),
00220     I18N_NOOP( "Select the focus of the new conic..." ), false },
00221   { PointImp::stype(), I18N_NOOP( "Construct a conic through this point" ),
00222     I18N_NOOP( "Select a point for the new conic to go through..." ), true }
00223 };
00224 
00225 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ConicBDFPType )
00226 
00227 ConicBDFPType::ConicBDFPType()
00228   : ArgsParserObjectType( "ConicBDFP", argsspecConicBDFP, 3 )
00229 {
00230 }
00231 
00232 ConicBDFPType::~ConicBDFPType()
00233 {
00234 }
00235 
00236 ObjectImp* ConicBDFPType::calc( const Args& parents, const KigDocument& ) const
00237 {
00238   if ( ! margsparser.checkArgs( parents, 2 ) ) return new InvalidImp;
00239 
00240   const LineData line = static_cast<const AbstractLineImp*>( parents[0] )->data();
00241   const Coordinate focus =
00242     static_cast<const PointImp*>( parents[1] )->coordinate();
00243 
00244   Coordinate point;
00245   if ( parents.size() == 3 )
00246     point = static_cast<const PointImp*>( parents[2] )->coordinate();
00247   else
00248   {
00249     /* !!!! costruisci point come punto medio dell'altezza tra fuoco e d. */
00250     Coordinate ba = line.dir();
00251     Coordinate fa = focus - line.b;
00252     double balsq = ba.x*ba.x + ba.y*ba.y;
00253     double scal = (fa.x*ba.x + fa.y*ba.y)/balsq;
00254     point = 0.5*(line.a + focus + scal*ba);
00255   };
00256   return new ConicImpPolar( calcConicBDFP( line, focus, point ) );
00257 }
00258 
00259 static const char constructparabolathroughpointstat[] =
00260   I18N_NOOP( "Construct a parabola through this point" );
00261 
00262 static const ArgsParser::spec argsspecParabolaBTP[] =
00263 {
00264   { PointImp::stype(), constructparabolathroughpointstat,
00265     I18N_NOOP( "Select a point for the new parabola to go through..." ), true },
00266   { PointImp::stype(), constructparabolathroughpointstat,
00267     I18N_NOOP( "Select a point for the new parabola to go through..." ), true },
00268   { PointImp::stype(), constructparabolathroughpointstat,
00269     I18N_NOOP( "Select a point for the new parabola to go through..." ), true }
00270 };
00271 
00272 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ParabolaBTPType )
00273 
00274 ParabolaBTPType::ParabolaBTPType()
00275   : ArgsParserObjectType( "ParabolaBTP", argsspecParabolaBTP, 3 )
00276 {
00277 }
00278 
00279 ParabolaBTPType::~ParabolaBTPType()
00280 {
00281 }
00282 
00283 const ParabolaBTPType* ParabolaBTPType::instance()
00284 {
00285   static const ParabolaBTPType t;
00286   return &t;
00287 }
00288 
00289 ObjectImp* ParabolaBTPType::calc( const Args& parents, const KigDocument& ) const
00290 {
00291   if ( ! margsparser.checkArgs( parents, 2 ) ) return new InvalidImp;
00292 
00293   std::vector<Coordinate> points;
00294   for ( Args::const_iterator i = parents.begin(); i != parents.end(); ++i )
00295     points.push_back( static_cast<const PointImp*>( *i )->coordinate() );
00296 
00297   ConicCartesianData d =
00298     calcConicThroughPoints( points, zerotilt, parabolaifzt, ysymmetry );
00299   if ( d.valid() )
00300     return new ConicImpCart( d );
00301   else
00302     return new InvalidImp;
00303 }
00304 
00305 static const ArgsParser::spec argsspecConicPolarPoint[] =
00306 {
00307   { ConicImp::stype(), I18N_NOOP( "Construct a polar point wrt. this conic" ),
00308     I18N_NOOP( "Select the conic wrt. which you want to construct a polar point..." ), false },
00309   { AbstractLineImp::stype(), I18N_NOOP( "Construct the polar point of this line" ),
00310     I18N_NOOP( "Select the line of which you want to construct the polar point..." ), false }
00311 };
00312 
00313 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ConicPolarPointType )
00314 
00315 ConicPolarPointType::ConicPolarPointType()
00316   : ArgsParserObjectType( "ConicPolarPoint", argsspecConicPolarPoint, 2 )
00317 {
00318 }
00319 
00320 ConicPolarPointType::~ConicPolarPointType()
00321 {
00322 }
00323 
00324 const ConicPolarPointType* ConicPolarPointType::instance()
00325 {
00326   static const ConicPolarPointType t;
00327   return &t;
00328 }
00329 
00330 ObjectImp* ConicPolarPointType::calc( const Args& parents, const KigDocument& ) const
00331 {
00332   if ( ! margsparser.checkArgs( parents ) ) return new InvalidImp;
00333 
00334   const ConicCartesianData c = static_cast<const ConicImp*>( parents[0] )->cartesianData();
00335   const LineData l = static_cast<const AbstractLineImp*>( parents[1] )->data();
00336   const Coordinate p = calcConicPolarPoint( c, l );
00337   if ( p.valid() ) return new PointImp( p );
00338   else return new InvalidImp;
00339 }
00340 
00341 static const ArgsParser::spec argsspecConicPolarLine[] =
00342 {
00343   { ConicImp::stype(), I18N_NOOP( "Construct a polar line wrt. this conic" ),
00344     I18N_NOOP( "Select the conic wrt. which you want to construct a polar point..." ), false },
00345   { PointImp::stype(), I18N_NOOP( "Construct the polar line of this point" ),
00346     I18N_NOOP( "Select the line of which you want to construct the polar point..." ), false }
00347 };
00348 
00349 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ConicPolarLineType )
00350 
00351 ConicPolarLineType::ConicPolarLineType()
00352   : ArgsParserObjectType( "ConicPolarLine", argsspecConicPolarLine, 2 )
00353 {
00354 }
00355 
00356 ConicPolarLineType::~ConicPolarLineType()
00357 {
00358 }
00359 
00360 const ConicPolarLineType* ConicPolarLineType::instance()
00361 {
00362   static const ConicPolarLineType t;
00363   return &t;
00364 }
00365 
00366 ObjectImp* ConicPolarLineType::calc( const Args& parents, const KigDocument& ) const
00367 {
00368   if ( ! margsparser.checkArgs( parents ) ) return new InvalidImp;
00369 
00370   const ConicCartesianData c = static_cast<const ConicImp*>( parents[0] )->cartesianData();
00371   const Coordinate p = static_cast<const PointImp*>( parents[1] )->coordinate();
00372   bool valid = true;
00373   const LineData l = calcConicPolarLine( c, p, valid );
00374   if ( valid ) return new LineImp( l );
00375   else return new InvalidImp;
00376 }
00377 
00378 static const ArgsParser::spec argsspecConicDirectrix[] =
00379 {
00380   { ConicImp::stype(), I18N_NOOP( "Construct the directrix of this conic" ),
00381     I18N_NOOP( "Select the conic of which you want to construct the directrix..." ), false }
00382 };
00383 
00384 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ConicDirectrixType )
00385 
00386 ConicDirectrixType::ConicDirectrixType()
00387   : ArgsParserObjectType( "ConicDirectrix", argsspecConicDirectrix, 1 )
00388 {
00389 }
00390 
00391 ConicDirectrixType::~ConicDirectrixType()
00392 {
00393 }
00394 
00395 const ConicDirectrixType* ConicDirectrixType::instance()
00396 {
00397   static const ConicDirectrixType t;
00398   return &t;
00399 }
00400 
00401 ObjectImp* ConicDirectrixType::calc( const Args& parents, const KigDocument& ) const
00402 {
00403   if ( ! margsparser.checkArgs( parents ) ) return new InvalidImp;
00404 
00405   const ConicPolarData data =
00406     static_cast<const ConicImp*>( parents[0] )->polarData();
00407 
00408   double ec = data.ecostheta0;
00409   double es = data.esintheta0;
00410   double eccsq = ec*ec + es*es;
00411 
00412   Coordinate a = data.focus1 - data.pdimen/eccsq*Coordinate(ec,es);
00413   Coordinate b = a + Coordinate(-es,ec);
00414   return new LineImp( a, b );
00415 }
00416 
00417 static const char hyperbolatpstatement[] = I18N_NOOP( "Construct a hyperbola through this point" );
00418 
00419 static const ArgsParser::spec argsspecHyperbolaB4P[] =
00420 {
00421   { PointImp::stype(), hyperbolatpstatement,
00422     I18N_NOOP( "Select a point for the new hyperbola to go through..." ), true },
00423   { PointImp::stype(), hyperbolatpstatement,
00424     I18N_NOOP( "Select a point for the new hyperbola to go through..." ), true },
00425   { PointImp::stype(), hyperbolatpstatement,
00426     I18N_NOOP( "Select a point for the new hyperbola to go through..." ), true },
00427   { PointImp::stype(), hyperbolatpstatement,
00428     I18N_NOOP( "Select a point for the new hyperbola to go through..." ), true }
00429 };
00430 
00431 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( EquilateralHyperbolaB4PType )
00432 
00433 EquilateralHyperbolaB4PType::EquilateralHyperbolaB4PType()
00434   : ArgsParserObjectType( "EquilateralHyperbolaB4P", argsspecHyperbolaB4P, 4 )
00435 {
00436 }
00437 
00438 EquilateralHyperbolaB4PType::~EquilateralHyperbolaB4PType()
00439 {
00440 }
00441 
00442 const EquilateralHyperbolaB4PType* EquilateralHyperbolaB4PType::instance()
00443 {
00444   static const EquilateralHyperbolaB4PType t;
00445   return &t;
00446 }
00447 
00448 ObjectImp* EquilateralHyperbolaB4PType::calc( const Args& parents, const KigDocument& ) const
00449 {
00450   if ( ! margsparser.checkArgs( parents, 1 ) ) return new InvalidImp;
00451 
00452   std::vector<Coordinate> pts;
00453   for ( Args::const_iterator i = parents.begin(); i != parents.end(); ++i )
00454     pts.push_back( static_cast<const PointImp*>( *i )->coordinate() );
00455 
00456   ConicCartesianData d = calcConicThroughPoints( pts, equilateral );
00457   if ( d.valid() )
00458     return new ConicImpCart( d );
00459   else
00460     return new InvalidImp;
00461 }
00462 
00463 static const ArgsParser::spec argsspecParabolaBDP[] =
00464 {
00465   { AbstractLineImp::stype(), I18N_NOOP( "Construct a parabola with this directrix" ),
00466     I18N_NOOP( "Select the directrix of the new parabola..." ), false },
00467   { PointImp::stype(), I18N_NOOP( "Construct a parabola with this focus" ),
00468     I18N_NOOP( "Select the focus of the new parabola..." ), true }
00469 };
00470 
00471 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ParabolaBDPType )
00472 
00473 ParabolaBDPType::ParabolaBDPType()
00474   : ObjectLPType( "ParabolaBDP", argsspecParabolaBDP, 2 )
00475 {
00476 }
00477 
00478 ParabolaBDPType::~ParabolaBDPType()
00479 {
00480 }
00481 
00482 const ParabolaBDPType* ParabolaBDPType::instance()
00483 {
00484   static const ParabolaBDPType t;
00485   return &t;
00486 }
00487 
00488 ObjectImp* ParabolaBDPType::calc( const LineData& l, const Coordinate& c ) const
00489 {
00490   ConicPolarData ret;
00491   Coordinate ldir = l.dir();
00492   ldir = ldir.normalize();
00493   ret.focus1 = c;
00494   ret.ecostheta0 = - ldir.y;
00495   ret.esintheta0 = ldir.x;
00496   Coordinate fa = c - l.a;
00497   ret.pdimen = fa.y*ldir.x - fa.x*ldir.y;
00498   ConicImpPolar* r = new ConicImpPolar( ret );
00499   kDebug() << r->conicTypeString();
00500   return r;
00501 }
00502 
00503 static const ArgsParser::spec argsspecConicAsymptote[] =
00504 {
00505   { ConicImp::stype(), I18N_NOOP( "Construct the asymptotes of this conic" ),
00506     I18N_NOOP( "Select the conic of which you want to construct the asymptotes..." ), false },
00507   { IntImp::stype(), "param", "SHOULD NOT BE SEEN", false }
00508 };
00509 
00510 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ConicAsymptoteType )
00511 
00512 ConicAsymptoteType::ConicAsymptoteType()
00513   : ArgsParserObjectType( "ConicAsymptote", argsspecConicAsymptote, 2 )
00514 {
00515 }
00516 
00517 ConicAsymptoteType::~ConicAsymptoteType()
00518 {
00519 }
00520 
00521 const ConicAsymptoteType* ConicAsymptoteType::instance()
00522 {
00523   static const ConicAsymptoteType t;
00524   return &t;
00525 }
00526 
00527 ObjectImp* ConicAsymptoteType::calc( const Args& parents, const KigDocument& ) const
00528 {
00529   if ( ! margsparser.checkArgs( parents ) ) return new InvalidImp;
00530 
00531   bool valid = true;
00532   const LineData ret = calcConicAsymptote(
00533     static_cast<const ConicImp*>( parents[0] )->cartesianData(),
00534     static_cast<const IntImp*>( parents[1] )->data(),
00535     valid );
00536 
00537   if ( valid )
00538     return new LineImp( ret );
00539   else
00540     return new InvalidImp;
00541 }
00542 
00543 static const char radicallinesstatement[] = I18N_NOOP( "Construct the radical lines of this conic" );
00544 
00545 static const ArgsParser::spec argsspecConicRadical[] =
00546 {
00547   { ConicImp::stype(), radicallinesstatement,
00548     I18N_NOOP( "Select the first of the two conics of which you want to construct the radical line..." ), false },
00549   { ConicImp::stype(), radicallinesstatement,
00550     I18N_NOOP( "Select the other of the two conic of which you want to construct the radical line..." ), false },
00551   { IntImp::stype(), "param", "SHOULD NOT BE SEEN", false },
00552   { IntImp::stype(), "param", "SHOULD NOT BE SEEN", false }
00553 };
00554 
00555 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ConicRadicalType )
00556 
00557 ConicRadicalType::ConicRadicalType()
00558   : ArgsParserObjectType( "ConicRadical", argsspecConicRadical, 4 )
00559 {
00560 }
00561 
00562 const ConicRadicalType* ConicRadicalType::instance()
00563 {
00564   static const ConicRadicalType t;
00565   return &t;
00566 }
00567 
00568 ObjectImp* ConicRadicalType::calc( const Args& parents, const KigDocument& ) const
00569 {
00570   if ( ! margsparser.checkArgs( parents ) ) return new InvalidImp;
00571   if ( parents[0]->inherits( CircleImp::stype() ) &&
00572        parents[1]->inherits( CircleImp::stype() ) )
00573   {
00574     if( static_cast<const IntImp*>( parents[2] )->data() != 1 )
00575       return new InvalidImp;
00576     else
00577     {
00578       const CircleImp* c1 = static_cast<const CircleImp*>( parents[0] );
00579       const CircleImp* c2 = static_cast<const CircleImp*>( parents[1] );
00580       const Coordinate a = calcCircleRadicalStartPoint(
00581         c1->center(), c2->center(), c1->squareRadius(), c2->squareRadius()
00582         );
00583       return new LineImp( a, calcPointOnPerpend(
00584           LineData( c1->center(), c2->center() ), a ) );
00585     };
00586   }
00587   else
00588   {
00589     bool valid = true;
00590     const LineData l = calcConicRadical(
00591       static_cast<const ConicImp*>( parents[0] )->cartesianData(),
00592       static_cast<const ConicImp*>( parents[1] )->cartesianData(),
00593       static_cast<const IntImp*>( parents[2] )->data(),
00594       static_cast<const IntImp*>( parents[3] )->data(), valid );
00595     if ( valid )
00596       return new LineImp( l );
00597     else
00598       return new InvalidImp;
00599   };
00600 }
00601 
00602 ConicRadicalType::~ConicRadicalType()
00603 {
00604 }
00605 
00606 const ObjectImpType* ConicB5PType::resultId() const
00607 {
00608   return ConicImp::stype();
00609 }
00610 
00611 const ObjectImpType* ConicBAAPType::resultId() const
00612 {
00613   return ConicImp::stype();
00614 }
00615 
00616 const ObjectImpType* ConicBFFPType::resultId() const
00617 {
00618   return ConicImp::stype();
00619 }
00620 
00621 const ObjectImpType* ConicBDFPType::resultId() const
00622 {
00623   return ConicImp::stype();
00624 }
00625 
00626 const ObjectImpType* ParabolaBTPType::resultId() const
00627 {
00628   return ConicImp::stype();
00629 }
00630 
00631 const ObjectImpType* EquilateralHyperbolaB4PType::resultId() const
00632 {
00633   return ConicImp::stype();
00634 }
00635 
00636 const ObjectImpType* ConicPolarPointType::resultId() const
00637 {
00638   return PointImp::stype();
00639 }
00640 
00641 const ObjectImpType* ConicPolarLineType::resultId() const
00642 {
00643   return LineImp::stype();
00644 }
00645 
00646 const ObjectImpType* ConicDirectrixType::resultId() const
00647 {
00648   return LineImp::stype();
00649 }
00650 
00651 const ObjectImpType* ParabolaBDPType::resultId() const
00652 {
00653   return ConicImp::stype();
00654 }
00655 
00656 const ObjectImpType* ConicAsymptoteType::resultId() const
00657 {
00658   return LineImp::stype();
00659 }
00660 
00661 const ObjectImpType* ConicRadicalType::resultId() const
00662 {
00663   return LineImp::stype();
00664 }
00665 
00666 QStringList ConicRadicalType::specialActions() const
00667 {
00668   QStringList ret;
00669   ret << i18n( "Switch Radical Lines" );
00670   return ret;
00671 }
00672 
00673 void ConicRadicalType::executeAction( int i, ObjectHolder&, ObjectTypeCalcer& t,
00674                                       KigPart& d, KigWidget&, NormalMode& ) const
00675 {
00676   assert( i == 0 );
00677   std::vector<ObjectCalcer*> parents = t.parents();
00678   assert( dynamic_cast<ObjectConstCalcer*>( parents[3] ) );
00679   ObjectConstCalcer* zeroindexo = static_cast<ObjectConstCalcer*>( parents[3] );
00680   MonitorDataObjects mon( zeroindexo );
00681   assert( zeroindexo->imp()->inherits( IntImp::stype() ) );
00682   int oldzeroindex = static_cast<const IntImp*>( zeroindexo->imp() )->data();
00683   int newzeroindex = oldzeroindex % 3 + 1;
00684   zeroindexo->setImp( new IntImp( newzeroindex ) );
00685   KigCommand* kc = new KigCommand( d, "Switch Conic Radical Lines" );
00686   mon.finish( kc );
00687   d.history()->push( kc );
00688 }
00689 

kig

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