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

kig

  • sources
  • kde-4.12
  • kdeedu
  • kig
  • misc
special_constructors.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 "special_constructors.h"
19 
20 #include <math.h>
21 
22 #include "calcpaths.h"
23 #include "common.h"
24 #include "conic-common.h"
25 #include "guiaction.h"
26 #include "kigpainter.h"
27 
28 #include "../kig/kig_part.h"
29 #include "../kig/kig_document.h"
30 #include "../modes/construct_mode.h"
31 #include "../objects/special_imptypes.h"
32 #include "../objects/bogus_imp.h"
33 #include "../objects/centerofcurvature_type.h"
34 #include "../objects/circle_imp.h"
35 #include "../objects/conic_imp.h"
36 #include "../objects/conic_types.h"
37 #include "../objects/cubic_imp.h"
38 #include "../objects/intersection_types.h"
39 #include "../objects/inversion_type.h"
40 #include "../objects/line_imp.h"
41 #include "../objects/line_type.h"
42 #include "../objects/locus_imp.h"
43 #include "../objects/object_calcer.h"
44 #include "../objects/object_drawer.h"
45 #include "../objects/object_factory.h"
46 #include "../objects/object_holder.h"
47 #include "../objects/object_imp.h"
48 #include "../objects/object_type.h"
49 #include "../objects/other_imp.h"
50 #include "../objects/other_type.h"
51 #include "../objects/point_imp.h"
52 #include "../objects/point_type.h"
53 #include "../objects/polygon_imp.h"
54 #include "../objects/polygon_type.h"
55 #include "../objects/bezier_imp.h"
56 #include "../objects/bezier_type.h"
57 #include "../objects/tangent_type.h"
58 #include "../objects/text_imp.h"
59 #include "../objects/transform_types.h"
60 
61 #include <qpen.h>
62 
63 #include <klocale.h>
64 
65 #include <algorithm>
66 #include <functional>
67 #include <iterator>
68 
69 /*
70  * conic-line and circle-circle intersection (with search for already computed
71  * intersections)
72  * the previous "ConicLineIntersectionConstructor" is now
73  * dead code, which could be remove in the future
74  */
75 
76 TwoOrOneIntersectionConstructor::TwoOrOneIntersectionConstructor(
77  const ArgsParserObjectType* t_std,
78  const ArgsParserObjectType* t_special,
79  const char* iconfile,
80  const struct ArgsParser::spec argsspecv[] )
81  : StandardConstructorBase( "SHOULD NOT BE SEEN", "SHOULD NOT BE SEEN",
82  iconfile, margsparser ),
83  mtype_std( t_std ),
84  mtype_special( t_special ),
85  margsparser( argsspecv, 2 )
86 {
87 }
88 
89 TwoOrOneIntersectionConstructor::~TwoOrOneIntersectionConstructor()
90 {
91 }
92 
93 void TwoOrOneIntersectionConstructor::drawprelim(
94  const ObjectDrawer& drawer,
95  KigPainter& p,
96  const std::vector<ObjectCalcer*>& parents,
97  const KigDocument& doc ) const
98 {
99  Args args;
100  if ( parents.size() != 2 ) return;
101  transform( parents.begin(), parents.end(),
102  back_inserter( args ), std::mem_fun( &ObjectCalcer::imp ) );
103 
104  for ( int i = -1; i <= 1; i += 2 )
105  {
106  IntImp param( i );
107  args.push_back( &param );
108  ObjectImp* data = mtype_std->calc( args, doc );
109  drawer.draw( *data, p, true );
110  delete data;
111  args.pop_back();
112  }
113 }
114 
115 std::vector<ObjectCalcer*> removeDuplicatedPoints( std::vector<ObjectCalcer*> points )
116 {
117  std::vector<ObjectCalcer*> ret;
118 
119  for ( std::vector<ObjectCalcer*>::iterator i = points.begin();
120  i != points.end(); ++i )
121  {
122  for ( std::vector<ObjectCalcer*>::iterator j = ret.begin();
123  j != ret.end(); ++j )
124  {
125  if ( coincidentPoints( (*i)->imp(), (*j)->imp() ) ) break;
126  }
127  ret.push_back( *i );
128  }
129  return ret;
130 }
131 
132 bool coincidentPoints( const ObjectImp* p1, const ObjectImp* p2 )
133 {
134  const PointImp* pt1 = dynamic_cast<const PointImp*>( p1 );
135  if ( !pt1 ) return false;
136  const PointImp* pt2 = dynamic_cast<const PointImp*>( p2 );
137  if ( !pt2 ) return false;
138 
139  Coordinate diff = pt1->coordinate() - pt2->coordinate();
140  if ( diff.squareLength() < 1e-12 ) return true;
141  return false;
142 }
143 
144 std::vector<ObjectHolder*> TwoOrOneIntersectionConstructor::build(
145  const std::vector<ObjectCalcer*>& parents,
146  KigDocument& doc,
147  KigWidget& ) const
148 {
149  std::vector<ObjectHolder*> ret;
150  assert( parents.size() == 2 );
151 
152  std::vector<ObjectCalcer*> points = doc.findIntersectionPoints( parents[0], parents[1] );
153  std::vector<ObjectCalcer*> uniquepoints = removeDuplicatedPoints( points );
154 
155  if ( uniquepoints.size() == 1 )
156  {
157  std::vector<ObjectCalcer*> args( parents );
158  args.push_back( uniquepoints[0] );
159  ret.push_back( new ObjectHolder( new ObjectTypeCalcer(
160  mtype_special, args
161  ) ) );
162  return ret;
163  }
164  for ( int i = -1; i <= 1; i += 2 )
165  {
166  ObjectConstCalcer* d = new ObjectConstCalcer( new IntImp( i ) );
167  std::vector<ObjectCalcer*> args( parents );
168  args.push_back( d );
169 
170  ret.push_back( new ObjectHolder( new ObjectTypeCalcer(
171  mtype_std, args
172  ) ) );
173  }
174  return ret;
175 }
176 
177 void TwoOrOneIntersectionConstructor::plug( KigPart*, KigGUIAction* )
178 {
179 }
180 
181 bool TwoOrOneIntersectionConstructor::isTransform() const
182 {
183  return false;
184 }
185 
186 ThreeTwoOneIntersectionConstructor::ThreeTwoOneIntersectionConstructor(
187  const ArgsParserObjectType* t_std,
188  const ArgsParserObjectType* t_special,
189  const ArgsParserObjectType* t_special2,
190  const char* iconfile,
191  const struct ArgsParser::spec argsspecv[] )
192  : StandardConstructorBase( "SHOULD NOT BE SEEN", "SHOULD NOT BE SEEN",
193  iconfile, margsparser ),
194  mtype_std( t_std ),
195  mtype_special( t_special ),
196  mtype_special2( t_special2 ),
197  margsparser( argsspecv, 2 )
198 {
199 }
200 
201 ThreeTwoOneIntersectionConstructor::~ThreeTwoOneIntersectionConstructor()
202 {
203 }
204 
205 void ThreeTwoOneIntersectionConstructor::drawprelim(
206  const ObjectDrawer& drawer,
207  KigPainter& p,
208  const std::vector<ObjectCalcer*>& parents,
209  const KigDocument& doc ) const
210 {
211  Args args;
212  if ( parents.size() != 2 ) return;
213  transform( parents.begin(), parents.end(),
214  back_inserter( args ), std::mem_fun( &ObjectCalcer::imp ) );
215 
216  for ( int i = 1; i <= 3; i += 1 )
217  {
218  IntImp param( i );
219  args.push_back( &param );
220  ObjectImp* data = mtype_std->calc( args, doc );
221  drawer.draw( *data, p, true );
222  delete data;
223  args.pop_back();
224  }
225 }
226 
227 std::vector<ObjectHolder*> ThreeTwoOneIntersectionConstructor::build(
228  const std::vector<ObjectCalcer*>& parents,
229  KigDocument& doc,
230  KigWidget& ) const
231 {
232  std::vector<ObjectHolder*> ret;
233  assert( parents.size() == 2 );
234 
235  std::vector<ObjectCalcer*> points = doc.findIntersectionPoints( parents[0], parents[1] );
236  std::vector<ObjectCalcer*> uniquepoints = removeDuplicatedPoints( points );
237 
238  if ( uniquepoints.size() == 2 )
239  {
240  std::vector<ObjectCalcer*> args( parents );
241  args.push_back( uniquepoints[0] );
242  args.push_back( uniquepoints[1] );
243  ret.push_back( new ObjectHolder( new ObjectTypeCalcer(
244  mtype_special, args
245  ) ) );
246  return ret;
247  }
248  if ( uniquepoints.size() == 1 )
249  {
250  for ( int i = -1; i <= 1; i += 2 )
251  {
252  std::vector<ObjectCalcer*> args( parents );
253  args.push_back( uniquepoints[0] );
254  ObjectConstCalcer* d = new ObjectConstCalcer( new IntImp( i ) );
255  args.push_back( d );
256 
257  ret.push_back( new ObjectHolder( new ObjectTypeCalcer(
258  CubicLineTwoIntersectionType::instance(), args
259  ) ) );
260  args.clear();
261  }
262  return ret;
263  }
264  for ( int i = 1; i <= 3; i += 1 )
265  {
266  ObjectConstCalcer* d = new ObjectConstCalcer( new IntImp( i ) );
267  std::vector<ObjectCalcer*> args( parents );
268  args.push_back( d );
269 
270  ret.push_back( new ObjectHolder( new ObjectTypeCalcer(
271  mtype_std, args
272  ) ) );
273  }
274  return ret;
275 }
276 
277 void ThreeTwoOneIntersectionConstructor::plug( KigPart*, KigGUIAction* )
278 {
279 }
280 
281 bool ThreeTwoOneIntersectionConstructor::isTransform() const
282 {
283  return false;
284 }
285 
286 /*
287  * conic-conic intersection
288  */
289 
290 class ConicConicIntersectionConstructor
291  : public StandardConstructorBase
292 {
293 protected:
294  ArgsParser mparser;
295 public:
296  ConicConicIntersectionConstructor();
297  ~ConicConicIntersectionConstructor();
298 
299  void drawprelim( const ObjectDrawer& drawer, KigPainter& p, const std::vector<ObjectCalcer*>& parents,
300  const KigDocument& ) const;
301  std::vector<ObjectHolder*> build( const std::vector<ObjectCalcer*>& os, KigDocument& d, KigWidget& w ) const;
302  void plug( KigPart* doc, KigGUIAction* kact );
303 
304  bool isTransform() const;
305 };
306 
307 class ConicLineIntersectionConstructor
308  : public MultiObjectTypeConstructor
309 {
310 public:
311  ConicLineIntersectionConstructor();
312  ~ConicLineIntersectionConstructor();
313 };
314 
315 class ArcLineIntersectionConstructor
316  : public MultiObjectTypeConstructor
317 {
318 public:
319  ArcLineIntersectionConstructor();
320  ~ArcLineIntersectionConstructor();
321 };
322 
323 ConicRadicalConstructor::ConicRadicalConstructor()
324  : StandardConstructorBase(
325  I18N_NOOP( "Radical Lines for Conics" ),
326  I18N_NOOP( "The lines constructed through the intersections "
327  "of two conics. This is also defined for "
328  "non-intersecting conics." ),
329  "conicsradicalline", mparser ),
330  mtype( ConicRadicalType::instance() ),
331  mparser( mtype->argsParser().without( IntImp::stype() ) )
332 {
333 }
334 
335 ConicRadicalConstructor::~ConicRadicalConstructor()
336 {
337 }
338 
339 void ConicRadicalConstructor::drawprelim(
340  const ObjectDrawer& drawer, KigPainter& p, const std::vector<ObjectCalcer*>& parents, const KigDocument& doc ) const
341 {
342  if ( parents.size() == 2 && parents[0]->imp()->inherits( ConicImp::stype() ) &&
343  parents[1]->imp()->inherits( ConicImp::stype() ) )
344  {
345  Args args;
346  std::transform( parents.begin(), parents.end(),
347  std::back_inserter( args ), std::mem_fun( &ObjectCalcer::imp ) );
348  for ( int i = -1; i < 2; i += 2 )
349  {
350  IntImp root( i );
351  IntImp zeroindex( 1 );
352  args.push_back( &root );
353  args.push_back( &zeroindex );
354  ObjectImp* data = mtype->calc( args, doc );
355  drawer.draw( *data, p, true );
356  delete data; data = 0;
357  args.pop_back();
358  args.pop_back();
359  };
360  };
361 }
362 
363 std::vector<ObjectHolder*> ConicRadicalConstructor::build( const std::vector<ObjectCalcer*>& os, KigDocument&, KigWidget& ) const
364 {
365  using namespace std;
366  std::vector<ObjectHolder*> ret;
367  ObjectCalcer* zeroindexcalcer = new ObjectConstCalcer( new IntImp( 1 ) );
368  for ( int i = -1; i < 2; i += 2 )
369  {
370  std::vector<ObjectCalcer*> args;
371  std::copy( os.begin(), os.end(), back_inserter( args ) );
372  args.push_back( new ObjectConstCalcer( new IntImp( i ) ) );
373  // we use only one zeroindex dataobject, so that if you switch one
374  // radical line around, then the other switches along..
375  args.push_back( zeroindexcalcer );
376  ret.push_back(
377  new ObjectHolder( new ObjectTypeCalcer( mtype, args ) ) );
378  };
379  return ret;
380 }
381 
382 static const struct ArgsParser::spec argsspecpp[] =
383 {
384  { PointImp::stype(), I18N_NOOP( "Moving Point" ),
385  I18N_NOOP( "Select the moving point, which will be moved around while drawing the locus..." ), false },
386  { PointImp::stype(), I18N_NOOP( "Following Point" ),
387  I18N_NOOP( "Select the following point, whose locations the locus will be drawn through..." ), true }
388 };
389 
390 LocusConstructor::LocusConstructor()
391  : StandardConstructorBase( I18N_NOOP( "Locus" ), I18N_NOOP( "A locus" ),
392  "locus", margsparser ),
393  margsparser( argsspecpp, 2 )
394 {
395 }
396 
397 LocusConstructor::~LocusConstructor()
398 {
399 }
400 
401 void LocusConstructor::drawprelim( const ObjectDrawer& drawer, KigPainter& p, const std::vector<ObjectCalcer*>& parents,
402  const KigDocument& ) const
403 {
404  // this function is rather ugly, but it is necessary to do it this
405  // way in order to play nice with Kig's design..
406 
407  if ( parents.size() != 2 ) return;
408  const ObjectTypeCalcer* constrained = dynamic_cast<ObjectTypeCalcer*>( parents.front() );
409  const ObjectCalcer* moving = parents.back();
410  if ( ! constrained || ! constrained->type()->inherits( ObjectType::ID_ConstrainedPointType ) )
411  {
412  // moving is in fact the constrained point.. swap them..
413  moving = parents.front();
414  constrained = dynamic_cast<const ObjectTypeCalcer*>( parents.back() );
415  assert( constrained );
416  };
417  assert( constrained->type()->inherits( ObjectType::ID_ConstrainedPointType ) );
418 
419  const ObjectImp* oimp = constrained->parents().back()->imp();
420  if( !oimp->inherits( CurveImp::stype() ) )
421  oimp = constrained->parents().front()->imp();
422  assert( oimp->inherits( CurveImp::stype() ) );
423  const CurveImp* cimp = static_cast<const CurveImp*>( oimp );
424 
425  ObjectHierarchy hier( constrained, moving );
426 
427  LocusImp limp( cimp->copy(), hier );
428  drawer.draw( limp, p, true );
429 }
430 
431 int LocusConstructor::wantArgs(
432  const std::vector<ObjectCalcer*>& os, const KigDocument&, const KigWidget&
433  ) const
434 {
435  int ret = margsparser.check( os );
436  if ( ret == ArgsParser::Invalid ) return ret;
437  else if ( os.size() != 2 ) return ret;
438  if ( dynamic_cast<ObjectTypeCalcer*>( os.front() ) &&
439  static_cast<ObjectTypeCalcer*>( os.front() )->type()->inherits( ObjectType::ID_ConstrainedPointType ) )
440  {
441  std::set<ObjectCalcer*> children = getAllChildren( os.front() );
442  return children.find( os.back() ) != children.end() ? ret : ArgsParser::Invalid;
443  }
444  if ( dynamic_cast<ObjectTypeCalcer*>( os.back() ) &&
445  static_cast<ObjectTypeCalcer*>( os.back() )->type()->inherits( ObjectType::ID_ConstrainedPointType ) )
446  {
447  std::set<ObjectCalcer*> children = getAllChildren( os.back() );
448  return children.find( os.front() ) != children.end() ? ret : ArgsParser::Invalid;
449  }
450  return ArgsParser::Invalid;
451 }
452 
453 std::vector<ObjectHolder*> LocusConstructor::build( const std::vector<ObjectCalcer*>& parents, KigDocument&, KigWidget& ) const
454 {
455  std::vector<ObjectHolder*> ret;
456  assert( parents.size() == 2 );
457 
458  ObjectTypeCalcer* constrained = dynamic_cast<ObjectTypeCalcer*>( parents.front() );
459  ObjectCalcer* moving = parents.back();
460  if ( ! constrained || ! constrained->type()->inherits( ObjectType::ID_ConstrainedPointType ) )
461  {
462  // moving is in fact the constrained point.. swap them..
463  moving = parents.front();
464  constrained = dynamic_cast<ObjectTypeCalcer*>( parents.back() );
465  assert( constrained );
466  };
467  assert( constrained->type()->inherits( ObjectType::ID_ConstrainedPointType ) );
468 
469  ret.push_back( ObjectFactory::instance()->locus( constrained, moving ) );
470  return ret;
471 }
472 
473 QString LocusConstructor::useText( const ObjectCalcer& o, const std::vector<ObjectCalcer*>& os,
474  const KigDocument&, const KigWidget& ) const
475 {
476  if ( dynamic_cast<const ObjectTypeCalcer*>( &o ) &&
477  static_cast<const ObjectTypeCalcer&>( o ).type()->inherits( ObjectType::ID_ConstrainedPointType ) &&
478  ( os.empty() || !dynamic_cast<ObjectTypeCalcer*>( os[0] ) ||
479  !static_cast<const ObjectTypeCalcer*>( os[0] )->type()->inherits( ObjectType::ID_ConstrainedPointType ) )
480  ) return i18n( "Moving Point" );
481  else return i18n( "Dependent Point" );
482 }
483 
484 void ConicRadicalConstructor::plug( KigPart*, KigGUIAction* )
485 {
486 }
487 
488 void LocusConstructor::plug( KigPart*, KigGUIAction* )
489 {
490 }
491 
492 bool ConicRadicalConstructor::isTransform() const
493 {
494  return mtype->isTransform();
495 }
496 
497 bool LocusConstructor::isTransform() const
498 {
499  return false;
500 }
501 
502 /*
503  * generic sequence of points constructor
504  */
505 
506 PointSequenceConstructor::PointSequenceConstructor(
507  const char* descname,
508  const char* desc,
509  const char* iconfile,
510  const ObjectType* type )
511  : mdescname( descname ),
512  mdesc( desc ),
513  miconfile( iconfile ),
514  mtype( type )
515 {
516 }
517 
518 const QString PointSequenceConstructor::descriptiveName() const
519 {
520  return i18n( mdescname );
521 }
522 
523 const QString PointSequenceConstructor::description() const
524 {
525  return i18n( mdesc );
526 }
527 
528 const QByteArray PointSequenceConstructor::iconFileName( const bool ) const
529 {
530  return miconfile;
531 }
532 
533 void PointSequenceConstructor::handleArgs(
534  const std::vector<ObjectCalcer*>& os, KigPart& d,
535  KigWidget& v ) const
536 {
537  std::vector<ObjectHolder*> bos = build( os, d.document(), v );
538  for ( std::vector<ObjectHolder*>::iterator i = bos.begin();
539  i != bos.end(); ++i )
540  {
541  (*i)->calc( d.document() );
542  }
543 
544  d.addObjects( bos );
545 }
546 
547 void PointSequenceConstructor::handlePrelim(
548  KigPainter& p, const std::vector<ObjectCalcer*>& os,
549  const KigDocument& d, const KigWidget&
550  ) const
551 {
552  uint count = os.size();
553  if ( count < 2 ) return;
554 
555  for ( uint i = 0; i < count; i++ )
556  {
557  assert ( os[i]->imp()->inherits( PointImp::stype() ) );
558  }
559 
560  std::vector<ObjectCalcer*> args = os;
561  p.setBrushStyle( Qt::NoBrush );
562  p.setBrushColor( Qt::red );
563  p.setPen( QPen ( Qt::red, 1) );
564  p.setWidth( -1 ); // -1 means the default width for the object being
565  // drawn..
566 
567  ObjectDrawer drawer( Qt::red );
568  drawprelim( drawer, p, args, d );
569 }
570 
571 std::vector<ObjectHolder*> PointSequenceConstructor::build( const std::vector<ObjectCalcer*>& parents, KigDocument&, KigWidget& ) const
572 {
573  uint count = parents.size() - 1;
574  assert ( count >= 3 );
575  std::vector<ObjectCalcer*> args;
576  for ( uint i = 0; i < count; ++i ) args.push_back( parents[i] );
577  ObjectTypeCalcer* calcer = new ObjectTypeCalcer( mtype, args );
578  ObjectHolder* h = new ObjectHolder( calcer );
579  std::vector<ObjectHolder*> ret;
580  ret.push_back( h );
581  return ret;
582 }
583 
584 void PointSequenceConstructor::plug( KigPart*, KigGUIAction* )
585 {
586 }
587 
588 bool PointSequenceConstructor::isTransform() const
589 {
590  return false;
591 }
592 
593 /*
594  * generic polygon constructor
595  */
596 
597 PolygonBNPTypeConstructor::PolygonBNPTypeConstructor()
598  : PointSequenceConstructor(
599  I18N_NOOP( "Polygon by Its Vertices" ),
600  I18N_NOOP( "Construct a polygon by giving its vertices" ),
601  "kig_polygon",
602  PolygonBNPType::instance() )
603 {
604 }
605 
606 PolygonBNPTypeConstructor::~PolygonBNPTypeConstructor()
607 {
608 }
609 
610 bool PolygonBNPTypeConstructor::isAlreadySelectedOK(
611  const std::vector<ObjectCalcer*>& os, const uint& pos ) const
612 {
613  if ( pos == 0 && os.size() >= 3 ) return true;
614  return false;
615 }
616 
617 int PolygonBNPTypeConstructor::wantArgs( const std::vector<ObjectCalcer*>& os,
618  const KigDocument&,
619  const KigWidget& ) const
620 {
621  int count=os.size() - 1;
622 
623  for ( int i = 0; i <= count; i++ )
624  {
625  if ( ! ( os[i]->imp()->inherits( PointImp::stype() ) ) ) return ArgsParser::Invalid;
626  }
627  if ( count < 3 ) return ArgsParser::Valid;
628  if ( os[0] == os[count] ) return ArgsParser::Complete;
629  return ArgsParser::Valid;
630 }
631 
632 QString PolygonBNPTypeConstructor::useText( const ObjectCalcer&, const std::vector<ObjectCalcer*>& os,
633  const KigDocument&, const KigWidget& ) const
634 {
635  if ( os.size() > 3 )
636  return i18n("... with this vertex (click on the first vertex to terminate construction)");
637  else return i18n("Construct a polygon with this vertex");
638 }
639 
640 QString PolygonBNPTypeConstructor::selectStatement(
641  const std::vector<ObjectCalcer*>&, const KigDocument&,
642  const KigWidget& ) const
643 {
644  return i18n("Select a point to be a vertex of the new polygon...");
645 }
646 
647 void PolygonBNPTypeConstructor::drawprelim( const ObjectDrawer& drawer, KigPainter& p, const std::vector<ObjectCalcer*>& parents,
648  const KigDocument& ) const
649 {
650  if ( parents.size() < 2 ) return;
651 
652  std::vector<Coordinate> points;
653 
654  for ( uint i = 0; i < parents.size(); ++i )
655  {
656  const Coordinate vertex =
657  static_cast<const PointImp*>( parents[i]->imp() )->coordinate();
658  points.push_back( vertex );
659  }
660 
661  if ( parents.size() == 2 )
662  {
663  SegmentImp segment = SegmentImp( points[0], points[1] );
664  drawer.draw( segment, p, true );
665  } else {
666  FilledPolygonImp polygon = FilledPolygonImp( points );
667  drawer.draw( polygon, p, true );
668  }
669 }
670 
671 
672 /*
673  * open polygon (polyline) constructor
674  */
675 
676 OpenPolygonTypeConstructor::OpenPolygonTypeConstructor()
677  : PointSequenceConstructor(
678  I18N_NOOP( "Open Polygon (Polygonal Line)" ),
679  I18N_NOOP( "Construct an open polygon" ),
680  "openpolygon",
681  OpenPolygonType::instance() )
682 {
683 }
684 
685 OpenPolygonTypeConstructor::~OpenPolygonTypeConstructor()
686 {
687 }
688 
689 bool OpenPolygonTypeConstructor::isAlreadySelectedOK(
690  const std::vector<ObjectCalcer*>& os, const uint& pos ) const
691 {
692  if ( pos == os.size() - 1 && os.size() >= 2 ) return true;
693  return false;
694 }
695 
696 int OpenPolygonTypeConstructor::wantArgs( const std::vector<ObjectCalcer*>& os,
697  const KigDocument&,
698  const KigWidget& ) const
699 {
700  int count=os.size() - 1;
701 
702  for ( int i = 0; i <= count; i++ )
703  {
704  if ( ! ( os[i]->imp()->inherits( PointImp::stype() ) ) ) return ArgsParser::Invalid;
705  }
706  if ( count < 2 ) return ArgsParser::Valid;
707  if ( os[count] == os[count - 1] ) return ArgsParser::Complete;
708  return ArgsParser::Valid;
709 }
710 
711 QString OpenPolygonTypeConstructor::useText( const ObjectCalcer&, const std::vector<ObjectCalcer*>& os,
712  const KigDocument&, const KigWidget& ) const
713 {
714  if ( os.size() > 2 )
715  return i18n("... with this vertex (click again on the last vertex to terminate construction)");
716  else return i18n("Construct a polygonal line with this vertex");
717 }
718 
719 QString OpenPolygonTypeConstructor::selectStatement(
720  const std::vector<ObjectCalcer*>&, const KigDocument&,
721  const KigWidget& ) const
722 {
723  return i18n("Select a point to be a vertex of the new polygonal line...");
724 }
725 
726 void OpenPolygonTypeConstructor::drawprelim( const ObjectDrawer& drawer, KigPainter& p, const std::vector<ObjectCalcer*>& parents,
727  const KigDocument& ) const
728 {
729  if ( parents.size() < 2 ) return;
730 
731  std::vector<Coordinate> points;
732 
733  for ( uint i = 0; i < parents.size(); ++i )
734  {
735  const Coordinate vertex =
736  static_cast<const PointImp*>( parents[i]->imp() )->coordinate();
737  points.push_back( vertex );
738  }
739 
740  if ( parents.size() == 2 )
741  {
742  SegmentImp segment = SegmentImp( points[0], points[1] );
743  drawer.draw( segment, p, true );
744  } else {
745  OpenPolygonalImp polygon = OpenPolygonalImp( points );
746  drawer.draw( polygon, p, true );
747  }
748 }
749 
750 /*
751  * construction of polygon vertices
752  */
753 
754 static const struct ArgsParser::spec argsspecpv[] =
755 {
756  { FilledPolygonImp::stype(), I18N_NOOP( "Polygon" ),
757  I18N_NOOP( "Construct the vertices of this polygon..." ), true }
758 };
759 
760 PolygonVertexTypeConstructor::PolygonVertexTypeConstructor()
761  : StandardConstructorBase( I18N_NOOP( "Vertices of a Polygon" ),
762  I18N_NOOP( "The vertices of a polygon." ),
763  "polygonvertices", margsparser ),
764  mtype( PolygonVertexType::instance() ),
765  margsparser( argsspecpv, 1 )
766 {
767 }
768 
769 PolygonVertexTypeConstructor::~PolygonVertexTypeConstructor()
770 {
771 }
772 
773 void PolygonVertexTypeConstructor::drawprelim( const ObjectDrawer& drawer, KigPainter& p, const std::vector<ObjectCalcer*>& parents,
774  const KigDocument& ) const
775 {
776  if ( parents.size() != 1 ) return;
777 
778  const FilledPolygonImp* polygon = dynamic_cast<const FilledPolygonImp*>( parents.front()->imp() );
779  const std::vector<Coordinate> points = polygon->points();
780 
781  int sides = points.size();
782  for ( int i = 0; i < sides; ++i )
783  {
784  PointImp point = PointImp( points[i] );
785  drawer.draw( point, p, true );
786  }
787 }
788 
789 std::vector<ObjectHolder*> PolygonVertexTypeConstructor::build( const std::vector<ObjectCalcer*>& parents, KigDocument&, KigWidget& ) const
790 {
791  std::vector<ObjectHolder*> ret;
792  assert( parents.size() == 1 );
793  const FilledPolygonImp* polygon = dynamic_cast<const FilledPolygonImp*>( parents.front()->imp() );
794  const std::vector<Coordinate> points = polygon->points();
795 
796  int sides = points.size();
797 
798  for ( int i = 0; i < sides; ++i )
799  {
800  ObjectConstCalcer* d = new ObjectConstCalcer( new IntImp( i ) );
801  std::vector<ObjectCalcer*> args( parents );
802  args.push_back( d );
803  ret.push_back( new ObjectHolder( new ObjectTypeCalcer( mtype, args ) ) );
804  }
805  return ret;
806 }
807 
808 void PolygonVertexTypeConstructor::plug( KigPart*, KigGUIAction* )
809 {
810 }
811 
812 bool PolygonVertexTypeConstructor::isTransform() const
813 {
814  return false;
815 }
816 
817 /*
818  * construction of polygon sides
819  */
820 
821 static const struct ArgsParser::spec argsspecps[] =
822 {
823  { FilledPolygonImp::stype(), I18N_NOOP( "Polygon" ),
824  I18N_NOOP( "Construct the sides of this polygon..." ), false }
825 };
826 
827 PolygonSideTypeConstructor::PolygonSideTypeConstructor()
828  : StandardConstructorBase( I18N_NOOP( "Sides of a Polygon" ),
829  I18N_NOOP( "The sides of a polygon." ),
830  "polygonsides", margsparser ),
831  mtype( PolygonSideType::instance() ),
832  margsparser( argsspecps, 1 )
833 {
834 }
835 
836 PolygonSideTypeConstructor::~PolygonSideTypeConstructor()
837 {
838 }
839 
840 void PolygonSideTypeConstructor::drawprelim( const ObjectDrawer& drawer, KigPainter& p, const std::vector<ObjectCalcer*>& parents,
841  const KigDocument& ) const
842 {
843  if ( parents.size() != 1 ) return;
844 
845  const FilledPolygonImp* polygon = dynamic_cast<const FilledPolygonImp*>( parents.front()->imp() );
846  const std::vector<Coordinate> points = polygon->points();
847 
848  uint sides = points.size();
849  for ( uint i = 0; i < sides; ++i )
850  {
851  uint nexti = ( i + 1 < sides )?(i + 1):0;
852  SegmentImp segment = SegmentImp( points[i], points[nexti] );
853  drawer.draw( segment, p, true );
854  }
855 }
856 
857 std::vector<ObjectHolder*> PolygonSideTypeConstructor::build( const std::vector<ObjectCalcer*>& parents, KigDocument&, KigWidget& ) const
858 {
859  std::vector<ObjectHolder*> ret;
860  assert( parents.size() == 1 );
861  const FilledPolygonImp* polygon = dynamic_cast<const FilledPolygonImp*>( parents.front()->imp() );
862  const std::vector<Coordinate> points = polygon->points();
863 
864  uint sides = points.size();
865 
866  for ( uint i = 0; i < sides; ++i )
867  {
868  ObjectConstCalcer* d = new ObjectConstCalcer( new IntImp( i ) );
869  std::vector<ObjectCalcer*> args( parents );
870  args.push_back( d );
871  ret.push_back( new ObjectHolder( new ObjectTypeCalcer( mtype, args ) ) );
872  }
873  return ret;
874 }
875 
876 void PolygonSideTypeConstructor::plug( KigPart*, KigGUIAction* )
877 {
878 }
879 
880 bool PolygonSideTypeConstructor::isTransform() const
881 {
882  return false;
883 }
884 
885 /*
886  * polygon by center and vertex
887  */
888 
889 PolygonBCVConstructor::PolygonBCVConstructor()
890  : mtype( PolygonBCVType::instance() )
891 {
892 }
893 
894 PolygonBCVConstructor::~PolygonBCVConstructor()
895 {
896 }
897 
898 const QString PolygonBCVConstructor::descriptiveName() const
899 {
900  return i18n("Regular Polygon with Given Center");
901 }
902 
903 const QString PolygonBCVConstructor::description() const
904 {
905  return i18n("Construct a regular polygon with a given center and vertex");
906 }
907 
908 const QByteArray PolygonBCVConstructor::iconFileName( const bool ) const
909 {
910  return "hexagonbcv";
911 }
912 
913 bool PolygonBCVConstructor::isAlreadySelectedOK(
914  const std::vector<ObjectCalcer*>&, const uint& ) const
915 {
916  return false;
917 }
918 
919 int PolygonBCVConstructor::wantArgs( const std::vector<ObjectCalcer*>& os,
920  const KigDocument&,
921  const KigWidget& ) const
922 {
923  if ( os.size() > 3 ) return ArgsParser::Invalid;
924 
925  uint imax = ( os.size() <= 2) ? os.size() : 2;
926  for ( uint i = 0; i < imax; ++i )
927  if ( ! ( os[i]->imp()->inherits( PointImp::stype() ) ) ) return ArgsParser::Invalid;
928 
929  if ( os.size() < 3 ) return ArgsParser::Valid;
930 
931  if ( ! ( os[2]->imp()->inherits( BogusPointImp::stype() ) ) )
932  return ArgsParser::Invalid;
933 
934  return ArgsParser::Complete;
935 }
936 
937 void PolygonBCVConstructor::handleArgs(
938  const std::vector<ObjectCalcer*>& os, KigPart& d,
939  KigWidget& v ) const
940 {
941  std::vector<ObjectHolder*> bos = build( os, d.document(), v );
942  for ( std::vector<ObjectHolder*>::iterator i = bos.begin();
943  i != bos.end(); ++i )
944  {
945  (*i)->calc( d.document() );
946  }
947 
948  d.addObjects( bos );
949 }
950 
951 void PolygonBCVConstructor::handlePrelim(
952  KigPainter& p, const std::vector<ObjectCalcer*>& os,
953  const KigDocument& d, const KigWidget&
954  ) const
955 {
956  if ( os.size() < 2 ) return;
957 
958  for ( uint i = 0; i < 2; i++ )
959  {
960  assert ( os[i]->imp()->inherits( PointImp::stype() ) );
961  }
962 
963  Coordinate c = static_cast<const PointImp*>( os[0]->imp() )->coordinate();
964  Coordinate v = static_cast<const PointImp*>( os[1]->imp() )->coordinate();
965 
966  int nsides = 6;
967  bool moreinfo = false;
968  int winding = 0; // 0 means allow winding > 1
969  if ( os.size() == 3 )
970  {
971  assert ( os[2]->imp()->inherits( BogusPointImp::stype() ) );
972  Coordinate cntrl = static_cast<const PointImp*>( os[2]->imp() )->coordinate();
973  nsides = computeNsides( c, v, cntrl, winding );
974  moreinfo = true;
975  }
976 
977  std::vector<ObjectCalcer*> args;
978  args.push_back( os[0] );
979  args.push_back( os[1] );
980  ObjectConstCalcer* ns = new ObjectConstCalcer( new IntImp( nsides ) );
981  args.push_back( ns );
982  if ( winding > 1 )
983  {
984  ns = new ObjectConstCalcer( new IntImp( winding ) );
985  args.push_back( ns );
986  }
987 
988  p.setBrushStyle( Qt::NoBrush );
989  p.setBrushColor( Qt::red );
990  p.setPen( QPen ( Qt::red, 1) );
991  p.setWidth( -1 ); // -1 means the default width for the object being
992  // drawn..
993 
994  ObjectDrawer drawer( Qt::red );
995  drawprelim( drawer, p, args, d );
996  if ( moreinfo )
997  {
998  p.setPointStyle( 1 );
999  p.setWidth( 6 );
1000  double ro = 1.0/(2.5);
1001  Coordinate where = getRotatedCoord( c, (1-ro)*c+ro*v, 4*M_PI/5.0 );
1002  PointImp ptn = PointImp( where );
1003  TextImp text = TextImp( "(5,2)", where, false );
1004  ptn.draw( p );
1005  text.draw( p );
1006  for ( int i = 3; i < 9; ++i )
1007  {
1008  where = getRotatedCoord( c, v, 2.0*M_PI/i );
1009  ptn = PointImp( where );
1010  ptn.draw( p );
1011  if ( i > 5 ) continue;
1012  text = TextImp( QString( "(%1)" ).arg(i), where, false );
1013  text.draw( p );
1014  }
1015  p.setStyle( Qt::DotLine );
1016  p.setWidth( 1 );
1017  double radius = ( v - c ).length();
1018  CircleImp circle = CircleImp( c, radius );
1019  circle.draw( p );
1020  for ( int i = 2; i < 5; i++ )
1021  {
1022  ro = 1.0/(i+0.5);
1023  CircleImp circle = CircleImp( c, ro*radius );
1024  circle.draw( p );
1025  }
1026  }
1027  delete_all( args.begin() + 2, args.end() );
1028 }
1029 
1030 std::vector<ObjectHolder*> PolygonBCVConstructor::build( const std::vector<ObjectCalcer*>& parents, KigDocument&, KigWidget& ) const
1031 {
1032  assert ( parents.size() == 3 );
1033  std::vector<ObjectCalcer*> args;
1034 
1035  Coordinate c = static_cast<const PointImp*>( parents[0]->imp() )->coordinate();
1036  Coordinate v = static_cast<const PointImp*>( parents[1]->imp() )->coordinate();
1037  Coordinate cntrl = static_cast<const PointImp*>( parents[2]->imp() )->coordinate();
1038 
1039  args.push_back( parents[0] );
1040  args.push_back( parents[1] );
1041  int winding = 0;
1042  int nsides = computeNsides( c, v, cntrl, winding );
1043  ObjectConstCalcer* d = new ObjectConstCalcer( new IntImp( nsides ) );
1044  args.push_back( d );
1045  if ( winding > 1 )
1046  {
1047  d = new ObjectConstCalcer( new IntImp( winding ) );
1048  args.push_back( d );
1049  }
1050 
1051  ObjectTypeCalcer* calcer = new ObjectTypeCalcer( mtype, args );
1052  ObjectHolder* h = new ObjectHolder( calcer );
1053  std::vector<ObjectHolder*> ret;
1054  ret.push_back( h );
1055  return ret;
1056 }
1057 
1058 QString PolygonBCVConstructor::useText( const ObjectCalcer&, const std::vector<ObjectCalcer*>& os,
1059  const KigDocument&, const KigWidget& ) const
1060 {
1061  switch ( os.size() )
1062  {
1063  case 1:
1064  return i18n( "Construct a regular polygon with this center" );
1065  break;
1066 
1067  case 2:
1068  return i18n( "Construct a regular polygon with this vertex" );
1069  break;
1070 
1071  case 3:
1072  Coordinate c = static_cast<const PointImp*>( os[0]->imp() )->coordinate();
1073  Coordinate v = static_cast<const PointImp*>( os[1]->imp() )->coordinate();
1074  Coordinate cntrl = static_cast<const PointImp*>( os[2]->imp() )->coordinate();
1075  int winding = 0;
1076  int nsides = computeNsides( c, v, cntrl, winding );
1077 
1078  if ( winding > 1 )
1079  {
1080  QString result = i18n( "Adjust the number of sides (%1/%2)", nsides, winding );
1081  return result;
1082  } else
1083  {
1084  QString result = i18n( "Adjust the number of sides (%1)", nsides );
1085  return result;
1086  }
1087  break;
1088  }
1089 
1090  return "";
1091 }
1092 
1093 QString PolygonBCVConstructor::selectStatement(
1094  const std::vector<ObjectCalcer*>& os, const KigDocument&,
1095  const KigWidget& ) const
1096 {
1097  switch ( os.size() )
1098  {
1099  case 1:
1100  return i18n( "Select the center of the new polygon..." );
1101  break;
1102 
1103  case 2:
1104  return i18n( "Select a vertex for the new polygon..." );
1105  break;
1106 
1107  case 3:
1108  return i18n( "Move the cursor to get the desired number of sides..." );
1109  break;
1110  }
1111 
1112  return "";
1113 }
1114 
1115 void PolygonBCVConstructor::drawprelim( const ObjectDrawer& drawer, KigPainter& p, const std::vector<ObjectCalcer*>& parents,
1116  const KigDocument& doc ) const
1117 {
1118  if ( parents.size() < 3 || parents.size() > 4 ) return;
1119 
1120  assert ( parents[0]->imp()->inherits( PointImp::stype() ) &&
1121  parents[1]->imp()->inherits( PointImp::stype() ) &&
1122  parents[2]->imp()->inherits( IntImp::stype() ) );
1123 
1124  if ( parents.size() == 4 )
1125  assert ( parents[3]->imp()->inherits( IntImp::stype() ) );
1126 
1127  Args args;
1128  std::transform( parents.begin(), parents.end(),
1129  std::back_inserter( args ), std::mem_fun( &ObjectCalcer::imp ) );
1130 
1131  ObjectImp* data = mtype->calc( args, doc );
1132  drawer.draw( *data, p, true );
1133  delete data;
1134  data = 0;
1135 }
1136 
1137 void PolygonBCVConstructor::plug( KigPart*, KigGUIAction* )
1138 {
1139 }
1140 
1141 bool PolygonBCVConstructor::isTransform() const
1142 {
1143  return false;
1144 }
1145 
1146 Coordinate PolygonBCVConstructor::getRotatedCoord( const Coordinate& c,
1147  const Coordinate& v, double alpha ) const
1148 {
1149  double cosalpha = cos(alpha);
1150  double sinalpha = sin(alpha);
1151  double dx = v.x - c.x;
1152  double dy = v.y - c.y;
1153  return c + Coordinate( cosalpha*dx - sinalpha*dy, sinalpha*dx + cosalpha*dy );
1154 }
1155 
1156 int PolygonBCVConstructor::computeNsides ( const Coordinate& c,
1157  const Coordinate& v, const Coordinate& cntrl, int& winding ) const
1158 {
1159  Coordinate lvect = v - c;
1160  Coordinate rvect = cntrl - c;
1161 
1162  double angle = atan2( rvect.y, rvect.x ) - atan2( lvect.y, lvect.x );
1163  angle = fabs( angle/(2*M_PI) );
1164  while ( angle > 1 ) angle -= 1;
1165  if ( angle > 0.5 ) angle = 1 - angle;
1166 
1167  double realsides = 1.0/angle; // this is bigger that 2
1168  if ( angle == 0. ) realsides = 3;
1169  if ( winding <= 0 ) // free to compute winding
1170  {
1171  winding = 1;
1172  double ratio = lvect.length()/rvect.length();
1173  winding = int ( ratio );
1174  if ( winding < 1 ) winding = 1;
1175  if ( winding > 50 ) winding = 50;
1176  }
1177  int nsides = int( winding*realsides + 0.5 ); // nsides/winding should be reduced!
1178  if ( nsides > 100 ) nsides = 100; // well, 100 seems large enough!
1179  if ( nsides < 3 ) nsides = 3;
1180  while ( !relativePrimes ( nsides, winding ) ) ++nsides;
1181  return nsides;
1182 }
1183 
1184 /*
1185  * generic Bézier curve constructor
1186  */
1187 
1188 BezierCurveTypeConstructor::BezierCurveTypeConstructor()
1189  : PointSequenceConstructor(
1190  I18N_NOOP( "Bézier Curve by its Control Points" ),
1191  I18N_NOOP( "Construct a Bézier curve by giving its control points" ),
1192  "bezierN",
1193  BezierCurveType::instance() )
1194 {
1195 }
1196 
1197 BezierCurveTypeConstructor::~BezierCurveTypeConstructor()
1198 {
1199 }
1200 
1201 bool BezierCurveTypeConstructor::isAlreadySelectedOK(
1202  const std::vector<ObjectCalcer*>& os, const uint& pos ) const
1203 {
1204  if ( pos == os.size() - 1 && os.size() >= 3 ) return true;
1205  return false;
1206 }
1207 
1208 int BezierCurveTypeConstructor::wantArgs( const std::vector<ObjectCalcer*>& os,
1209  const KigDocument&,
1210  const KigWidget& ) const
1211 {
1212  int count=os.size() - 1;
1213 
1214  for ( int i = 0; i <= count; i++ )
1215  {
1216  if ( ! ( os[i]->imp()->inherits( PointImp::stype() ) ) ) return ArgsParser::Invalid;
1217  }
1218  if ( count < 3 ) return ArgsParser::Valid;
1219  if ( os[count] == os[count - 1] ) return ArgsParser::Complete;
1220  return ArgsParser::Valid;
1221 }
1222 
1223 QString BezierCurveTypeConstructor::useText( const ObjectCalcer&, const std::vector<ObjectCalcer*>& os,
1224  const KigDocument&, const KigWidget& ) const
1225 {
1226  if ( os.size() > 3 )
1227  return i18n("... with this control point (click again on the last control point to terminate construction)");
1228  else return i18n("Construct a Bézier curve with this control point");
1229 }
1230 
1231 QString BezierCurveTypeConstructor::selectStatement(
1232  const std::vector<ObjectCalcer*>&, const KigDocument&,
1233  const KigWidget& ) const
1234 {
1235  return i18n("Select a point to be a control point of the new Bézier curve...");
1236 }
1237 
1238 void BezierCurveTypeConstructor::drawprelim( const ObjectDrawer& ,
1239  KigPainter& p,
1240  const std::vector<ObjectCalcer*>& parents,
1241  const KigDocument& ) const
1242 {
1243  if ( parents.size() < 2 ) return;
1244 
1245  std::vector<Coordinate> points;
1246 
1247  for ( uint i = 0; i < parents.size(); ++i )
1248  {
1249  const Coordinate vertex =
1250  static_cast<const PointImp*>( parents[i]->imp() )->coordinate();
1251  points.push_back( vertex );
1252  }
1253 
1254  BezierImp B = BezierImp( points );
1255  B.draw( p );
1256 }
1257 
1258 /*
1259  * generic rational Bézier curve constructor
1260  */
1261 
1262 RationalBezierCurveTypeConstructor::RationalBezierCurveTypeConstructor()
1263 {
1264 }
1265 
1266 RationalBezierCurveTypeConstructor::~RationalBezierCurveTypeConstructor()
1267 {
1268 }
1269 
1270 const QString RationalBezierCurveTypeConstructor::descriptiveName() const
1271 {
1272  return i18n( "Rational Bézier Curve by its Control Points" );
1273 }
1274 
1275 const QString RationalBezierCurveTypeConstructor::description() const
1276 {
1277  return i18n( "Construct a Bézier curve by giving its control points and positive weights" );
1278 }
1279 
1280 const QByteArray RationalBezierCurveTypeConstructor::iconFileName( const bool ) const
1281 {
1282  return "rbezierN";
1283 }
1284 
1285 bool RationalBezierCurveTypeConstructor::isAlreadySelectedOK(
1286  const std::vector<ObjectCalcer*>& os, const uint& pos ) const
1287 {
1288  if ( pos % 2 == 1 ) return true;
1289  if ( pos == os.size() - 2 && os.size() >= 3 ) return true;
1290  return false;
1291 }
1292 
1293 int RationalBezierCurveTypeConstructor::wantArgs( const std::vector<ObjectCalcer*>& os,
1294  const KigDocument&,
1295  const KigWidget& ) const
1296 {
1297  int count=os.size() - 1;
1298 
1299  for ( int i = 0; i <= count; i++ )
1300  {
1301  if ( ! ( os[i]->imp()->inherits( i % 2 == 0 ? PointImp::stype() : &weightimptypeinstance ) ) )
1302  return ArgsParser::Invalid;
1303  }
1304  if ( count < 6 ) return ArgsParser::Valid;
1305  if ( count % 2 == 0 && ( os[count] == os[count - 2] ) ) return ArgsParser::Complete;
1306  return ArgsParser::Valid;
1307 }
1308 
1309 std::vector<ObjectHolder*> RationalBezierCurveTypeConstructor::build( const std::vector<ObjectCalcer*>& parents, KigDocument&, KigWidget& ) const
1310 {
1311  uint count = parents.size() - 1;
1312  assert ( count >= 3 );
1313  std::vector<ObjectCalcer*> args;
1314  for ( uint i = 0; i < count; ++i ) args.push_back( parents[i] );
1315  ObjectTypeCalcer* calcer = new ObjectTypeCalcer( RationalBezierCurveType::instance(), args );
1316  ObjectHolder* h = new ObjectHolder( calcer );
1317  std::vector<ObjectHolder*> ret;
1318  ret.push_back( h );
1319  return ret;
1320 }
1321 
1322 void RationalBezierCurveTypeConstructor::handleArgs( const std::vector<ObjectCalcer*>& os,
1323  KigPart& d,
1324  KigWidget& v ) const
1325 {
1326  std::vector<ObjectHolder*> bos = build( os, d.document(), v );
1327  for ( std::vector<ObjectHolder*>::iterator i = bos.begin();
1328  i != bos.end(); ++i )
1329  {
1330  (*i)->calc( d.document() );
1331  }
1332 
1333  d.addObjects( bos );
1334 }
1335 
1336 QString RationalBezierCurveTypeConstructor::useText( const ObjectCalcer&,
1337  const std::vector<ObjectCalcer*>& os,
1338  const KigDocument&,
1339  const KigWidget& ) const
1340 {
1341  if ( os.size() % 2 == 0 )
1342  return i18n("... assign this weight to last selected control point");
1343 
1344  if ( os.size() > 6 )
1345  return i18n("... with this control point (click again on the last control point or weight to terminate construction)");
1346  else return i18n("Construct a rational Bézier curve with this control point");
1347 }
1348 
1349 QString RationalBezierCurveTypeConstructor::selectStatement(
1350  const std::vector<ObjectCalcer*>& os, const KigDocument&,
1351  const KigWidget& ) const
1352 {
1353  if ( os.size() % 2 == 0 )
1354  return i18n("Select a point to be a control point of the new rational Bézier curve...");
1355  else
1356  return i18n("Select a numeric label to be a weight of last selected point...");
1357 }
1358 
1359 void RationalBezierCurveTypeConstructor::drawprelim( const ObjectDrawer& ,
1360  KigPainter& p,
1361  const std::vector<ObjectCalcer*>& parents,
1362  const KigDocument& ) const
1363 {
1364  if ( parents.size() < 5 ) return;
1365 
1366  std::vector<Coordinate> points;
1367  std::vector<double> weights;
1368 
1369  uint count = parents.size();
1370  for ( uint i = 0; i < count; i += 2 )
1371  {
1372  bool valid;
1373  assert ( parents[i]->imp()->inherits( PointImp::stype() ) );
1374  const Coordinate vertex =
1375  static_cast<const PointImp*>( parents[i]->imp() )->coordinate();
1376  points.push_back( vertex );
1377  if ( i+1 >= count ) break;
1378  assert ( parents[i+1]->imp()->inherits( &weightimptypeinstance ) );
1379  const double weight =
1380  getDoubleFromImp( parents[i+1]->imp(), valid );
1381  assert ( valid );
1382  weights.push_back( weight );
1383  }
1384 
1385  if ( count % 2 == 1 )
1386  {
1387  // point was selected, we
1388  weights.push_back( 1 ); // don't have its weight so far
1389  }
1390 
1391  assert ( points.size() == weights.size() );
1392 
1393  RationalBezierImp rB = RationalBezierImp( points, weights );
1394  rB.draw( p );
1395 }
1396 
1397 void RationalBezierCurveTypeConstructor::handlePrelim(
1398  KigPainter& p, const std::vector<ObjectCalcer*>& os,
1399  const KigDocument& d, const KigWidget&
1400  ) const
1401 {
1402  uint count = os.size();
1403  if ( count < 5 ) return;
1404 
1405  for ( uint i = 0; i < count; i += 2 )
1406  {
1407  assert ( os[i]->imp()->inherits( PointImp::stype() ) );
1408  if ( i+1 >= count ) break;
1409  assert ( os[i+1]->imp()->inherits( &weightimptypeinstance ) );
1410  }
1411 
1412  std::vector<ObjectCalcer*> args = os;
1413  p.setBrushStyle( Qt::NoBrush );
1414  p.setBrushColor( Qt::red );
1415  p.setPen( QPen ( Qt::red, 1) );
1416  p.setWidth( -1 ); // -1 means the default width for the object being
1417  // drawn..
1418 
1419  ObjectDrawer drawer( Qt::red );
1420  drawprelim( drawer, p, args, d );
1421 }
1422 
1423 void RationalBezierCurveTypeConstructor::plug( KigPart*, KigGUIAction* )
1424 {
1425 }
1426 
1427 bool RationalBezierCurveTypeConstructor::isTransform() const
1428 {
1429  return false;
1430 }
1431 
1432 
1433 /*
1434  * ConicConic intersection...
1435  */
1436 
1437 static const ArgsParser::spec argsspectc[] = {
1438  { ConicImp::stype(), "SHOULD NOT BE SEEN", "SHOULD NOT BE SEEN", true },
1439  { ConicImp::stype(), "SHOULD NOT BE SEEN", "SHOULD NOT BE SEEN", true }
1440 };
1441 
1442 ConicConicIntersectionConstructor::ConicConicIntersectionConstructor()
1443  : StandardConstructorBase( "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
1444  "curvelineintersection", mparser ),
1445  mparser( argsspectc, 2 )
1446 {
1447 }
1448 
1449 ConicConicIntersectionConstructor::~ConicConicIntersectionConstructor()
1450 {
1451 }
1452 
1453 void ConicConicIntersectionConstructor::drawprelim( const ObjectDrawer& drawer, KigPainter& p, const std::vector<ObjectCalcer*>& parents,
1454  const KigDocument& ) const
1455 {
1456  if ( parents.size() != 2 ) return;
1457  assert ( parents[0]->imp()->inherits( ConicImp::stype() ) &&
1458  parents[1]->imp()->inherits( ConicImp::stype() ) );
1459  const ConicCartesianData conica =
1460  static_cast<const ConicImp*>( parents[0]->imp() )->cartesianData();
1461  const ConicCartesianData conicb =
1462  static_cast<const ConicImp*>( parents[1]->imp() )->cartesianData();
1463  bool ok = true;
1464  for ( int wr = -1; wr < 2; wr += 2 )
1465  {
1466  LineData radical = calcConicRadical( conica, conicb, wr, 1, ok );
1467  if ( ok )
1468  {
1469  for ( int wi = -1; wi < 2; wi += 2 )
1470  {
1471  Coordinate c = calcConicLineIntersect( conica, radical, 0.0, wi );
1472  if ( c.valid() ) {
1473  PointImp pi( c );
1474  drawer.draw( pi, p, true );
1475  }
1476  };
1477  };
1478  };
1479 }
1480 
1481 std::vector<ObjectHolder*> ConicConicIntersectionConstructor::build(
1482  const std::vector<ObjectCalcer*>& os, KigDocument& doc, KigWidget& ) const
1483 {
1484  assert( os.size() == 2 );
1485  std::vector<ObjectHolder*> ret;
1486  ObjectCalcer* conica = os[0];
1487  ObjectConstCalcer* zeroindexdo = new ObjectConstCalcer( new IntImp( 1 ) );
1488 
1489  for ( int wr = -1; wr < 2; wr += 2 )
1490  {
1491  std::vector<ObjectCalcer*> args = os;
1492  args.push_back( new ObjectConstCalcer( new IntImp( wr ) ) );
1493  args.push_back( zeroindexdo );
1494  ObjectTypeCalcer* radical =
1495  new ObjectTypeCalcer( ConicRadicalType::instance(), args );
1496  radical->calc( doc );
1497  for ( int wi = -1; wi < 2; wi += 2 )
1498  {
1499  args.clear();
1500  args.push_back( conica );
1501  args.push_back( radical );
1502  args.push_back( new ObjectConstCalcer( new IntImp( wi ) ) );
1503  ret.push_back(
1504  new ObjectHolder(
1505  new ObjectTypeCalcer(
1506  ConicLineIntersectionType::instance(), args ) ) );
1507  };
1508  };
1509  return ret;
1510 }
1511 
1512 void ConicConicIntersectionConstructor::plug( KigPart*, KigGUIAction* )
1513 {
1514 }
1515 
1516 bool ConicConicIntersectionConstructor::isTransform() const
1517 {
1518  return false;
1519 }
1520 
1521 ConicLineIntersectionConstructor::ConicLineIntersectionConstructor()
1522  : MultiObjectTypeConstructor(
1523  ConicLineIntersectionType::instance(),
1524  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
1525  "curvelineintersection", -1, 1 )
1526 {
1527 }
1528 
1529 ConicLineIntersectionConstructor::~ConicLineIntersectionConstructor()
1530 {
1531 }
1532 
1533 ArcLineIntersectionConstructor::ArcLineIntersectionConstructor()
1534  : MultiObjectTypeConstructor(
1535  ArcLineIntersectionType::instance(),
1536  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
1537  "curvelineintersection", -1, 1 )
1538 {
1539 }
1540 
1541 ArcLineIntersectionConstructor::~ArcLineIntersectionConstructor()
1542 {
1543 }
1544 
1545 QString ConicRadicalConstructor::useText( const ObjectCalcer& o, const std::vector<ObjectCalcer*>&,
1546  const KigDocument&, const KigWidget& ) const
1547 {
1548  if ( o.imp()->inherits( CircleImp::stype() ) )
1549  return i18n( "Construct the Radical Lines of This Circle" );
1550  else
1551  return i18n( "Construct the Radical Lines of This Conic" );
1552 }
1553 
1554 /*
1555  * generic affinity and generic projectivity. A unique affinity can be
1556  * obtained by specifying the image of three points (four for projectivity)
1557  * in the end we need, besides the object to be transformed, a total of
1558  * six point or (alternatively) two triangles; our affinity will map the
1559  * first triangle onto the second with corresponding ordering of their
1560  * vertices. Since we allow for two different ways of specifying the six
1561  * points we shall use a Generic constructor, like that for intersections.
1562  */
1563 
1564 GenericAffinityConstructor::GenericAffinityConstructor()
1565  : MergeObjectConstructor(
1566  I18N_NOOP( "Generic Affinity" ),
1567  I18N_NOOP( "The unique affinity that maps three points (or a triangle) onto three other points (or a triangle)" ),
1568  "genericaffinity" )
1569 {
1570  SimpleObjectTypeConstructor* b2tr =
1571  new SimpleObjectTypeConstructor(
1572  AffinityB2TrType::instance(),
1573  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
1574  "genericaffinity" );
1575 
1576  SimpleObjectTypeConstructor* gi3p =
1577  new SimpleObjectTypeConstructor(
1578  AffinityGI3PType::instance(),
1579  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
1580  "genericaffinity" );
1581 
1582  merge( b2tr );
1583  merge( gi3p );
1584 }
1585 
1586 GenericAffinityConstructor::~GenericAffinityConstructor() {}
1587 
1588 bool GenericAffinityConstructor::isAlreadySelectedOK(const std::vector< ObjectCalcer* >& , const uint& ) const
1589 {
1590  return true;
1591 }
1592 
1593 GenericProjectivityConstructor::GenericProjectivityConstructor()
1594  : MergeObjectConstructor(
1595  I18N_NOOP( "Generic Projective Transformation" ),
1596  I18N_NOOP( "The unique projective transformation that maps four points (or a quadrilateral) onto four other points (or a quadrilateral)" ),
1597  "genericprojectivity" )
1598 {
1599  SimpleObjectTypeConstructor* b2qu =
1600  new SimpleObjectTypeConstructor(
1601  ProjectivityB2QuType::instance(),
1602  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
1603  "genericprojectivity" );
1604 
1605  SimpleObjectTypeConstructor* gi4p =
1606  new SimpleObjectTypeConstructor(
1607  ProjectivityGI4PType::instance(),
1608  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
1609  "genericprojectivity" );
1610 
1611  merge( b2qu );
1612  merge( gi4p );
1613 }
1614 
1615 GenericProjectivityConstructor::~GenericProjectivityConstructor() {}
1616 
1617 bool GenericProjectivityConstructor::isAlreadySelectedOK(const std::vector< ObjectCalcer* >& , const uint& ) const
1618 {
1619  return true;
1620 }
1621 
1622 /*
1623  * inversion of points, lines with respect to a circle
1624  */
1625 
1626 InversionConstructor::InversionConstructor()
1627  : MergeObjectConstructor(
1628  I18N_NOOP( "Inversion of Point, Line or Circle" ),
1629  I18N_NOOP( "The inversion of a point, line or circle with respect to a circle" ),
1630  "inversion" )
1631 {
1632  SimpleObjectTypeConstructor* pointobj =
1633  new SimpleObjectTypeConstructor(
1634  InvertPointType::instance(),
1635  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
1636  "inversion" );
1637 
1638  SimpleObjectTypeConstructor* curveobj =
1639  new SimpleObjectTypeConstructor(
1640  CircularInversionType::instance(),
1641  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
1642  "inversion" );
1643 
1644 // SimpleObjectTypeConstructor* lineobj =
1645 // new SimpleObjectTypeConstructor(
1646 // InvertLineType::instance(),
1647 // "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
1648 // "inversion" );
1649 //
1650 // SimpleObjectTypeConstructor* segmentobj =
1651 // new SimpleObjectTypeConstructor(
1652 // InvertSegmentType::instance(),
1653 // "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
1654 // "inversion" );
1655 //
1656 // SimpleObjectTypeConstructor* circleobj =
1657 // new SimpleObjectTypeConstructor(
1658 // InvertCircleType::instance(),
1659 // "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
1660 // "inversion" );
1661 //
1662 // SimpleObjectTypeConstructor* arcobj =
1663 // new SimpleObjectTypeConstructor(
1664 // InvertArcType::instance(),
1665 // "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
1666 // "inversion" );
1667 
1668 // merge( arcobj );
1669 // merge( circleobj );
1670  merge( curveobj );
1671  merge( pointobj );
1672 // merge( segmentobj );
1673 // merge( lineobj );
1674 }
1675 
1676 InversionConstructor::~InversionConstructor() {}
1677 
1678 /*
1679  * Transport of Measure
1680  */
1681 
1682 MeasureTransportConstructor::MeasureTransportConstructor()
1683  : mtype( MeasureTransportType::instance() )
1684 {
1685 }
1686 
1687 MeasureTransportConstructor::~MeasureTransportConstructor()
1688 {
1689 }
1690 
1691 const QString MeasureTransportConstructor::descriptiveName() const
1692 {
1693  return i18n("Measure Transport");
1694 }
1695 
1696 const QString MeasureTransportConstructor::description() const
1697 {
1698  return i18n("Transport the measure of a segment or arc over a line or circle.");
1699 }
1700 
1701 const QByteArray MeasureTransportConstructor::iconFileName( const bool ) const
1702 {
1703  return "measuretransport";
1704 }
1705 
1706 bool MeasureTransportConstructor::isAlreadySelectedOK(
1707  const std::vector<ObjectCalcer*>&, const uint& ) const
1708 {
1709  return false;
1710 }
1711 
1712 /*
1713  * we want the arguments in the exact order, this makes
1714  * the code simpler, but I guess it is also less confusing
1715  * to the user
1716  */
1717 
1718 int MeasureTransportConstructor::wantArgs(
1719  const std::vector<ObjectCalcer*>& os,
1720  const KigDocument& doc,
1721  const KigWidget& ) const
1722 {
1723  if ( os.size() == 0 ) return ArgsParser::Valid;
1724 
1725  if ( ! os[0]->imp()->inherits( &lengthimptypeinstance ) )
1726  return ArgsParser::Invalid;
1727 
1728  if ( os.size() == 1 ) return ArgsParser::Valid;
1729 
1730  if ( ! os[1]->imp()->inherits( LineImp::stype() ) &&
1731  ! os[1]->imp()->inherits( CircleImp::stype() ) )
1732  return ArgsParser::Invalid;
1733  const CurveImp* c = static_cast<const CurveImp*>( os[1]->imp() );
1734 
1735  if ( os.size() == 2 ) return ArgsParser::Valid;
1736 
1737  if ( ! os[2]->imp()->inherits( PointImp::stype() ) )
1738  return ArgsParser::Invalid;
1739  const PointImp* p = static_cast<const PointImp*>( os[2]->imp() );
1740 
1741  // we have two choices:
1742  // - using "isPointOnCurve" produces a "by construction" incidence
1743  // test. This would be fine, but doesn't always work; e.g. if we
1744  // have two points A, B, the segment s = AB and we construct the
1745  // support line of the segment (property of segments), then kig
1746  // is not able to understand that A is "by construction" on the
1747  // constructed line.
1748  // Moreover there are problems when hovering the cursor over points
1749  // that are on both a segment and its support line.
1750  // if ( ! isPointOnCurve( os[2], os[1] ) )
1751  // - using "containsPoint", which is actually the test performed
1752  // when calc-ing the TransportOfMeasure; the risk here is to
1753  // be able to select points that are only coincidentally on the line.
1754 
1755  if ( ! c->containsPoint( p->coordinate(), doc ) )
1756  return ArgsParser::Invalid;
1757 
1758  if ( os.size() == 3 ) return ArgsParser::Complete;
1759 
1760  return ArgsParser::Invalid;
1761 }
1762 
1763 void MeasureTransportConstructor::handleArgs(
1764  const std::vector<ObjectCalcer*>& os, KigPart& d,
1765  KigWidget& v ) const
1766 {
1767  std::vector<ObjectHolder*> bos = build( os, d.document(), v );
1768  for ( std::vector<ObjectHolder*>::iterator i = bos.begin();
1769  i != bos.end(); ++i )
1770  {
1771  (*i)->calc( d.document() );
1772  }
1773 
1774  d.addObjects( bos );
1775 }
1776 
1777 void MeasureTransportConstructor::handlePrelim(
1778  KigPainter& p, const std::vector<ObjectCalcer*>& os,
1779  const KigDocument& d, const KigWidget&
1780  ) const
1781 {
1782  p.setBrushStyle( Qt::NoBrush );
1783  p.setBrushColor( Qt::red );
1784  p.setPen( QPen ( Qt::red, 1) );
1785  p.setWidth( -1 ); // -1 means the default width for the object being
1786  // drawn..
1787 
1788  ObjectDrawer drawer( Qt::red );
1789  drawprelim( drawer, p, os, d );
1790 }
1791 
1792 void MeasureTransportConstructor::drawprelim( const ObjectDrawer& drawer,
1793  KigPainter& p,
1794  const std::vector<ObjectCalcer*>& parents,
1795  const KigDocument& doc ) const
1796 {
1797  Args args;
1798  using namespace std;
1799  transform( parents.begin(), parents.end(),
1800  back_inserter( args ), mem_fun( &ObjectCalcer::imp ) );
1801  ObjectImp* data = mtype->calc( args, doc );
1802  drawer.draw( *data, p, true );
1803  delete data;
1804 }
1805 
1806 QString MeasureTransportConstructor::useText( const ObjectCalcer& o,
1807  const std::vector<ObjectCalcer*>& os,
1808  const KigDocument&, const KigWidget& ) const
1809 {
1810  if ( o.imp()->inherits( SegmentImp::stype() ) )
1811  return i18n("Segment to transport");
1812  if ( o.imp()->inherits( ArcImp::stype() ) )
1813  return i18n("Arc to transport");
1814  if ( o.imp()->inherits( NumericTextImp::stype() ) )
1815  return i18n("Value to transport");
1816  if ( o.imp()->inherits( LineImp::stype() ) )
1817  return i18n("Transport a measure on this line");
1818  if ( o.imp()->inherits( CircleImp::stype() ) )
1819  return i18n("Transport a measure on this circle");
1820  if ( o.imp()->inherits( PointImp::stype() ) )
1821  {
1822  if ( os[1]->imp()->inherits( CircleImp::stype() ) )
1823  return i18n("Start transport from this point of the circle");
1824  if ( os[1]->imp()->inherits( LineImp::stype() ) )
1825  return i18n("Start transport from this point of the line");
1826  else
1827  return i18n("Start transport from this point of the curve");
1828  // well, this isn't impemented yet, should never get here
1829  }
1830  return "";
1831 }
1832 
1833 QString MeasureTransportConstructor::selectStatement(
1834  const std::vector<ObjectCalcer*>& os, const KigDocument&,
1835  const KigWidget& ) const
1836 {
1837  switch ( os.size() )
1838  {
1839  case 0:
1840  return i18n( "Select a segment, arc or numeric label to be transported..." );
1841  break;
1842 
1843  case 1:
1844  return i18n( "Select a destination line or circle..." );
1845  break;
1846 
1847  case 2:
1848  return i18n( "Choose a starting point on the line/circle..." );
1849  break;
1850  }
1851 
1852  return "";
1853 }
1854 
1855 std::vector<ObjectHolder*> MeasureTransportConstructor::build(
1856  const std::vector<ObjectCalcer*>& parents,
1857  KigDocument&, KigWidget& ) const
1858 {
1859  assert ( parents.size() == 3 );
1860 // std::vector<ObjectCalcer*> args;
1861 // for ( uint i = 0; i < count; ++i ) args.push_back( parents[i] );
1862  ObjectTypeCalcer* calcer = new ObjectTypeCalcer( mtype, parents );
1863  ObjectHolder* h = new ObjectHolder( calcer );
1864  std::vector<ObjectHolder*> ret;
1865  ret.push_back( h );
1866  return ret;
1867 }
1868 
1869 void MeasureTransportConstructor::plug( KigPart*, KigGUIAction* )
1870 {
1871 }
1872 
1873 bool MeasureTransportConstructor::isTransform() const
1874 {
1875  return false;
1876 }
1877 
1878 /*
1879  * Generic intersection
1880  */
1881 
1882 /*
1883  * these two argsparser spec vectors are used for the special
1884  * construction of conic-line and circle-circle constructions
1885  */
1886 
1887 static const struct ArgsParser::spec argsspeccli[] =
1888 {
1889  { ConicImp::stype(), I18N_NOOP( "Intersect with this conic" ),
1890  "SHOULD NOT BE SEEN", true },
1891  { AbstractLineImp::stype(), I18N_NOOP( "Intersect with this line" ),
1892  "SHOULD NOT BE SEEN", true }
1893 };
1894 
1895 
1896 static const struct ArgsParser::spec argsspeccbli[] =
1897 {
1898  { CubicImp::stype(), I18N_NOOP( "Intersect with this cubic" ),
1899  "SHOULD NOT BE SEEN", true },
1900  { AbstractLineImp::stype(), I18N_NOOP( "Intersect with this line" ),
1901  "SHOULD NOT BE SEEN", true }
1902 };
1903 
1904 
1905 static const struct ArgsParser::spec argsspeccci[] =
1906 {
1907  { CircleImp::stype(), I18N_NOOP( "Intersect with this circle" ),
1908  "SHOULD NOT BE SEEN", true },
1909  { CircleImp::stype(), I18N_NOOP( "Intersect with this circle" ),
1910  "SHOULD NOT BE SEEN", true }
1911 };
1912 
1913 GenericIntersectionConstructor::GenericIntersectionConstructor()
1914  : MergeObjectConstructor(
1915  I18N_NOOP( "Intersect" ),
1916  I18N_NOOP( "The intersection of two objects" ),
1917  "curvelineintersection" )
1918 {
1919  // intersection type..
1920  // There is one "toplevel" object_constructor, that is composed
1921  // of multiple subconstructors.. First we build the
1922  // subconstructors:
1923  SimpleObjectTypeConstructor* lineline =
1924  new SimpleObjectTypeConstructor(
1925  LineLineIntersectionType::instance(),
1926  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
1927  "curvelineintersection" );
1928 
1929  ObjectConstructor* lineconic =
1930 // new ConicLineIntersectionConstructor();
1931  new TwoOrOneIntersectionConstructor(
1932  ConicLineIntersectionType::instance(),
1933  ConicLineOtherIntersectionType::instance(),
1934  "curvelineintersection",
1935  argsspeccli);
1936 
1937  ObjectConstructor* arcline =
1938  new ArcLineIntersectionConstructor();
1939 
1940  ObjectConstructor* linecubic =
1941  new ThreeTwoOneIntersectionConstructor(
1942  LineCubicIntersectionType::instance(),
1943  CubicLineOtherIntersectionType::instance(),
1944  CubicLineTwoIntersectionType::instance(),
1945  "curvelineintersection",
1946  argsspeccbli);
1947 
1948  ObjectConstructor* conicconic =
1949  new ConicConicIntersectionConstructor();
1950 
1951 // MultiObjectTypeConstructor* circlecircle =
1952 // new MultiObjectTypeConstructor(
1953 // CircleCircleIntersectionType::instance(),
1954 // "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
1955 // "circlecircleintersection", -1, 1 );
1956  ObjectConstructor* circlecircle =
1957  new TwoOrOneIntersectionConstructor(
1958  CircleCircleIntersectionType::instance(),
1959  CircleCircleOtherIntersectionType::instance(),
1960  "circlecircleintersection",
1961  argsspeccci);
1962 
1963  SimpleObjectTypeConstructor* polygonline =
1964  new SimpleObjectTypeConstructor(
1965  PolygonLineIntersectionType::instance(),
1966  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
1967  "curvelineintersection" );
1968 
1969  SimpleObjectTypeConstructor* polygonpolygon =
1970  new SimpleObjectTypeConstructor(
1971  PolygonPolygonIntersectionType::instance(),
1972  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
1973  "curvelineintersection" );
1974 
1975  MultiObjectTypeConstructor* opolygonalline =
1976  new MultiObjectTypeConstructor(
1977  OPolygonalLineIntersectionType::instance(),
1978  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
1979  "curvelineintersection", -1, 1 );
1980 
1981  MultiObjectTypeConstructor* cpolygonalline =
1982  new MultiObjectTypeConstructor(
1983  CPolygonalLineIntersectionType::instance(),
1984  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
1985  "curvelineintersection", -1, 1 );
1986 
1987  merge( lineline );
1988  merge( circlecircle );
1989  merge( lineconic );
1990  merge( linecubic );
1991  merge( conicconic );
1992  merge( arcline );
1993  merge( polygonline );
1994  merge( opolygonalline );
1995  merge( cpolygonalline );
1996  merge( polygonpolygon );
1997 }
1998 
1999 GenericIntersectionConstructor::~GenericIntersectionConstructor()
2000 {
2001 }
2002 
2003 bool GenericIntersectionConstructor::isIntersection() const
2004 {
2005  return true;
2006 }
2007 
2008 QString GenericIntersectionConstructor::useText(
2009  const ObjectCalcer& o, const std::vector<ObjectCalcer*>& os,
2010  const KigDocument&, const KigWidget& ) const
2011 {
2012  QString preamble;
2013  switch (os.size())
2014  {
2015  case 1:
2016  if ( o.imp()->inherits( CircleImp::stype() ) )
2017  return i18n( "Intersect this Circle" );
2018  else if ( o.imp()->inherits( ConicImp::stype() ) )
2019  return i18n( "Intersect this Conic" );
2020  else if ( o.imp()->inherits( SegmentImp::stype() ) )
2021  return i18n( "Intersect this Segment" );
2022  else if ( o.imp()->inherits( RayImp::stype() ) )
2023  return i18n( "Intersect this Half-line" );
2024  else if ( o.imp()->inherits( LineImp::stype() ) )
2025  return i18n( "Intersect this Line" );
2026  else if ( o.imp()->inherits( CubicImp::stype() ) )
2027  return i18n( "Intersect this Cubic Curve" );
2028  else if ( o.imp()->inherits( ArcImp::stype() ) )
2029  return i18n( "Intersect this Arc" );
2030  else if ( o.imp()->inherits( FilledPolygonImp::stype() ) )
2031  return i18n( "Intersect this Polygon" );
2032  else if ( o.imp()->inherits( AbstractPolygonImp::stype() ) )
2033  return i18n( "Intersect this Polygonal" );
2034  else assert( false );
2035  break;
2036  case 2:
2037  if ( o.imp()->inherits( CircleImp::stype() ) )
2038  return i18n( "with this Circle" );
2039  else if ( o.imp()->inherits( ConicImp::stype() ) )
2040  return i18n( "with this Conic" );
2041  else if ( o.imp()->inherits( SegmentImp::stype() ) )
2042  return i18n( "with this Segment" );
2043  else if ( o.imp()->inherits( RayImp::stype() ) )
2044  return i18n( "with this Half-line" );
2045  else if ( o.imp()->inherits( LineImp::stype() ) )
2046  return i18n( "with this Line" );
2047  else if ( o.imp()->inherits( CubicImp::stype() ) )
2048  return i18n( "with this Cubic Curve" );
2049  else if ( o.imp()->inherits( ArcImp::stype() ) )
2050  return i18n( "with this Arc" );
2051  else if ( o.imp()->inherits( FilledPolygonImp::stype() ) )
2052  return i18n( "with this Polygon" );
2053  else if ( o.imp()->inherits( AbstractPolygonImp::stype() ) )
2054  return i18n( "with this Polygonal" );
2055  else assert( false );
2056  break;
2057  }
2058 
2059  return QString();
2060 }
2061 
2062 static const ArgsParser::spec argsspecMidPointOfTwoPoints[] =
2063 {
2064  { PointImp::stype(), I18N_NOOP( "Construct Midpoint of This Point and Another One" ),
2065  I18N_NOOP( "Select the first of the points of which you want to construct the midpoint..." ), false },
2066  { PointImp::stype(), I18N_NOOP( "Construct the midpoint of this point and another one" ),
2067  I18N_NOOP( "Select the other of the points of which to construct the midpoint..." ), false }
2068 };
2069 
2070 MidPointOfTwoPointsConstructor::MidPointOfTwoPointsConstructor()
2071  : StandardConstructorBase( "Mid Point",
2072  "Construct the midpoint of two points",
2073  "bisection", mparser ),
2074  mparser( argsspecMidPointOfTwoPoints, 2 )
2075 {
2076 }
2077 
2078 MidPointOfTwoPointsConstructor::~MidPointOfTwoPointsConstructor()
2079 {
2080 }
2081 
2082 void MidPointOfTwoPointsConstructor::drawprelim(
2083  const ObjectDrawer& drawer, KigPainter& p, const std::vector<ObjectCalcer*>& parents,
2084  const KigDocument& ) const
2085 {
2086  if ( parents.size() != 2 ) return;
2087  assert( parents[0]->imp()->inherits( PointImp::stype() ) );
2088  assert( parents[1]->imp()->inherits( PointImp::stype() ) );
2089  const Coordinate m =
2090  ( static_cast<const PointImp*>( parents[0]->imp() )->coordinate() +
2091  static_cast<const PointImp*>( parents[1]->imp() )->coordinate() ) / 2;
2092  drawer.draw( PointImp( m ), p, true );
2093 }
2094 
2095 std::vector<ObjectHolder*> MidPointOfTwoPointsConstructor::build(
2096  const std::vector<ObjectCalcer*>& os, KigDocument& d, KigWidget& ) const
2097 {
2098  ObjectTypeCalcer* seg = new ObjectTypeCalcer( SegmentABType::instance(), os );
2099  seg->calc( d );
2100 // int index = seg->imp()->propertiesInternalNames().indexOf( "mid-point" );
2101 // assert( index != -1 );
2102  ObjectPropertyCalcer* prop = new ObjectPropertyCalcer( seg, "mid-point" );
2103  prop->calc( d );
2104  std::vector<ObjectHolder*> ret;
2105  ret.push_back( new ObjectHolder( prop ) );
2106  return ret;
2107 }
2108 
2109 void MidPointOfTwoPointsConstructor::plug( KigPart*, KigGUIAction* )
2110 {
2111 }
2112 
2113 bool MidPointOfTwoPointsConstructor::isTransform() const
2114 {
2115  return false;
2116 }
2117 
2118 TestConstructor::TestConstructor( const ArgsParserObjectType* type, const char* descname,
2119  const char* desc, const char* iconfile )
2120  : StandardConstructorBase( descname, desc, iconfile, type->argsParser() ),
2121  mtype( type )
2122 {
2123 }
2124 
2125 TestConstructor::~TestConstructor()
2126 {
2127 }
2128 
2129 void TestConstructor::drawprelim( const ObjectDrawer&, KigPainter&, const std::vector<ObjectCalcer*>&,
2130  const KigDocument& ) const
2131 {
2132  // not used, only here because of the wrong
2133  // ObjectConstructor-GUIAction design. See the TODO
2134 }
2135 
2136 std::vector<ObjectHolder*> TestConstructor::build( const std::vector<ObjectCalcer*>&, KigDocument&,
2137  KigWidget& ) const
2138 {
2139  // not used, only here because of the wrong
2140  // ObjectConstructor-GUIAction design. See the TODO
2141  std::vector<ObjectHolder*> ret;
2142  return ret;
2143 }
2144 
2145 void TestConstructor::plug( KigPart*, KigGUIAction* )
2146 {
2147 }
2148 
2149 bool TestConstructor::isTransform() const
2150 {
2151  return false;
2152 }
2153 
2154 bool TestConstructor::isTest() const
2155 {
2156  return true;
2157 }
2158 
2159 BaseConstructMode* TestConstructor::constructMode( KigPart& doc )
2160 {
2161  return new TestConstructMode( doc, mtype );
2162 }
2163 
2164 int TestConstructor::wantArgs( const std::vector<ObjectCalcer*>& os,
2165  const KigDocument& d, const KigWidget& v ) const
2166 {
2167  int ret = StandardConstructorBase::wantArgs( os, d, v );
2168  if ( ret == ArgsParser::Complete ) ret = ArgsParser::Valid;
2169  return ret;
2170 }
2171 
2172 QString GenericIntersectionConstructor::selectStatement(
2173  const std::vector<ObjectCalcer*>& sel, const KigDocument&,
2174  const KigWidget& ) const
2175 {
2176  if ( sel.size() == 0 )
2177  return i18n( "Select the first object to intersect..." );
2178  else
2179  return i18n( "Select the second object to intersect..." );
2180 }
2181 
2182 TangentConstructor::TangentConstructor()
2183  : MergeObjectConstructor(
2184  I18N_NOOP( "Tangent" ),
2185  I18N_NOOP( "The line tangent to a curve" ),
2186  "tangent" )
2187 {
2188  SimpleObjectTypeConstructor* conic =
2189  new SimpleObjectTypeConstructor(
2190  TangentConicType::instance(),
2191  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
2192  "tangentconic" );
2193 
2194  SimpleObjectTypeConstructor* arc =
2195  new SimpleObjectTypeConstructor(
2196  TangentArcType::instance(),
2197  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
2198  "tangentarc" );
2199 
2200  SimpleObjectTypeConstructor* cubic =
2201  new SimpleObjectTypeConstructor(
2202  TangentCubicType::instance(),
2203  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
2204  "tangentcubic" );
2205 
2206  SimpleObjectTypeConstructor* curve =
2207  new SimpleObjectTypeConstructor(
2208  TangentCurveType::instance(),
2209  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
2210  "tangentcurve" );
2211 
2212  merge( conic );
2213  merge( arc );
2214  merge( cubic );
2215  merge( curve );
2216 }
2217 
2218 TangentConstructor::~TangentConstructor()
2219 {
2220 }
2221 
2222 QString TangentConstructor::useText(
2223  const ObjectCalcer& o, const std::vector<ObjectCalcer*>&,
2224  const KigDocument&, const KigWidget& ) const
2225 {
2226  if ( o.imp()->inherits( CircleImp::stype() ) )
2227  return i18n( "Tangent to This Circle" );
2228  else if ( o.imp()->inherits( ConicImp::stype() ) )
2229  return i18n( "Tangent to This Conic" );
2230  else if ( o.imp()->inherits( ArcImp::stype() ) )
2231  return i18n( "Tangent to This Arc" );
2232  else if ( o.imp()->inherits( CubicImp::stype() ) )
2233  return i18n( "Tangent to This Cubic Curve" );
2234  else if ( o.imp()->inherits( CurveImp::stype() ) )
2235  return i18n( "Tangent to This Curve" );
2236  else if ( o.imp()->inherits( PointImp::stype() ) )
2237  return i18n( "Tangent at This Point" );
2238 // else assert( false );
2239  return QString();
2240 }
2241 
2242 //QString TangentConstructor::selectStatement(
2243 // const std::vector<ObjectCalcer*>& sel, const KigDocument&,
2244 // const KigWidget& ) const
2245 //{
2246 // if ( sel.size() == 0 )
2247 // return i18n( "Select the object..." );
2248 // else
2249 // return i18n( "Select the point for the tangent to go through..." );
2250 //}
2251 
2252 /*
2253  * center of curvature of a curve
2254  */
2255 
2256 CocConstructor::CocConstructor()
2257  : MergeObjectConstructor(
2258  I18N_NOOP( "Center Of Curvature" ),
2259  I18N_NOOP( "The center of the osculating circle to a curve" ),
2260  "centerofcurvature" )
2261 {
2262  SimpleObjectTypeConstructor* conic =
2263  new SimpleObjectTypeConstructor(
2264  CocConicType::instance(),
2265  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
2266  "cocconic" );
2267 
2268  SimpleObjectTypeConstructor* cubic =
2269  new SimpleObjectTypeConstructor(
2270  CocCubicType::instance(),
2271  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
2272  "coccubic" );
2273 
2274  SimpleObjectTypeConstructor* curve =
2275  new SimpleObjectTypeConstructor(
2276  CocCurveType::instance(),
2277  "SHOULDNOTBESEEN", "SHOULDNOTBESEEN",
2278  "coccurve" );
2279 
2280  merge( conic );
2281  merge( cubic );
2282  merge( curve );
2283 }
2284 
2285 CocConstructor::~CocConstructor()
2286 {
2287 }
2288 
2289 QString CocConstructor::useText(
2290  const ObjectCalcer& o, const std::vector<ObjectCalcer*>&,
2291  const KigDocument&, const KigWidget& ) const
2292 {
2293  if ( o.imp()->inherits( ConicImp::stype() ) )
2294  return i18n( "Center of Curvature of This Conic" );
2295  else if ( o.imp()->inherits( CubicImp::stype() ) )
2296  return i18n( "Center of Curvature of This Cubic Curve" );
2297  else if ( o.imp()->inherits( CurveImp::stype() ) )
2298  return i18n( "Center of Curvature of This Curve" );
2299  else if ( o.imp()->inherits( PointImp::stype() ) )
2300  return i18n( "Center of Curvature at This Point" );
2301  return QString();
2302 }
2303 
2304 bool relativePrimes( int n, int p )
2305 {
2306  if ( p > n ) return relativePrimes( p, n );
2307  assert ( p >= 0 );
2308  if ( p == 0 ) return false;
2309  if ( p == 1 ) return true;
2310  int d = int( n/p );
2311  return relativePrimes( p, n-d*p );
2312 }
2313 
2314 //QString CocConstructor::selectStatement(
2315 // const std::vector<ObjectCalcer*>& sel, const KigDocument&,
2316 // const KigWidget& ) const
2317 //{
2318 // if ( sel.size() == 0 )
2319 // return i18n( "Select the object..." );
2320 // else
2321 // return i18n( "Select the point where to compute the center of curvature..." );
2322 //}
RationalBezierCurveTypeConstructor::iconFileName
const QByteArray iconFileName(const bool canBeNull=false) const
Definition: special_constructors.cc:1280
LocusConstructor::build
std::vector< ObjectHolder * > build(const std::vector< ObjectCalcer * > &os, KigDocument &d, KigWidget &w) const
Definition: special_constructors.cc:453
CPolygonalLineIntersectionType::instance
static const CPolygonalLineIntersectionType * instance()
Definition: polygon_type.cc:677
coincidentPoints
bool coincidentPoints(const ObjectImp *p1, const ObjectImp *p2)
Definition: special_constructors.cc:132
BezierImp
An ObjectImp representing polynomial Bézier Curve.
Definition: bezier_imp.h:31
MeasureTransportConstructor::handleArgs
void handleArgs(const std::vector< ObjectCalcer * > &os, KigPart &d, KigWidget &v) const
do something fun with os .
Definition: special_constructors.cc:1763
PointSequenceConstructor::handlePrelim
void handlePrelim(KigPainter &p, const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &v) const
show a preliminary version of what you would do when handleArgs would be called.
Definition: special_constructors.cc:547
ObjectFactory::instance
static const ObjectFactory * instance()
Definition: object_factory.cc:90
MergeObjectConstructor
This class is a collection of some other ObjectConstructors, that makes them appear to the user as a ...
Definition: object_constructor.h:285
ObjectConstructor::plug
virtual void plug(KigPart *doc, KigGUIAction *kact)=0
KigPainter::setPointStyle
void setPointStyle(int p)
Definition: kigpainter.cpp:239
BezierImp::draw
void draw(KigPainter &p) const
Definition: bezier_imp.cc:87
LocusImp
LocusImp is an imp that consists of a copy of the curveimp that the moving point moves over...
Definition: locus_imp.h:57
PolygonBNPTypeConstructor::isAlreadySelectedOK
bool isAlreadySelectedOK(const std::vector< ObjectCalcer * > &os, const uint &) const
the following function is called in case of duplication of arguments and returns true if this is acce...
Definition: special_constructors.cc:610
MeasureTransportConstructor::plug
void plug(KigPart *doc, KigGUIAction *kact)
Definition: special_constructors.cc:1869
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
BezierCurveTypeConstructor::drawprelim
void drawprelim(const ObjectDrawer &drawer, KigPainter &p, const std::vector< ObjectCalcer * > &parents, const KigDocument &) const
Definition: special_constructors.cc:1238
PointSequenceConstructor::build
std::vector< ObjectHolder * > build(const std::vector< ObjectCalcer * > &os, KigDocument &d, KigWidget &w) const
Definition: special_constructors.cc:571
TestConstructor::isTransform
bool isTransform() const
Definition: special_constructors.cc:2149
RationalBezierCurveType::instance
static const RationalBezierCurveType * instance()
Definition: bezier_type.cc:600
GenericAffinityConstructor::isAlreadySelectedOK
virtual bool isAlreadySelectedOK(const std::vector< ObjectCalcer * > &os, const uint &) const
the following function is called in case of duplication of arguments and returns true if this is acce...
Definition: special_constructors.cc:1588
StandardConstructorBase::wantArgs
virtual int wantArgs(const std::vector< ObjectCalcer * > &os, const KigDocument &d, const KigWidget &v) const
can this constructor do something useful with os ? return ArgsParser::Complete, Valid or NotGood ...
Definition: object_constructor.cc:77
GenericIntersectionConstructor::useText
QString useText(const ObjectCalcer &o, const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &v) const
return a string describing what you would use o for if it were selected...
Definition: special_constructors.cc:2008
MeasureTransportConstructor::wantArgs
int wantArgs(const std::vector< ObjectCalcer * > &os, const KigDocument &d, const KigWidget &v) const
can this constructor do something useful with os ? return ArgsParser::Complete, Valid or NotGood ...
Definition: special_constructors.cc:1718
ObjectHierarchy
Definition: object_hierarchy.h:30
PolygonSideTypeConstructor::drawprelim
void drawprelim(const ObjectDrawer &drawer, KigPainter &p, const std::vector< ObjectCalcer * > &parents, const KigDocument &) const
Definition: special_constructors.cc:840
PolygonBNPTypeConstructor::wantArgs
int wantArgs(const std::vector< ObjectCalcer * > &os, const KigDocument &d, const KigWidget &v) const
can this constructor do something useful with os ? return ArgsParser::Complete, Valid or NotGood ...
Definition: special_constructors.cc:617
BaseConstructMode
Definition: construct_mode.h:58
PolygonVertexTypeConstructor::build
std::vector< ObjectHolder * > build(const std::vector< ObjectCalcer * > &os, KigDocument &d, KigWidget &w) const
Definition: special_constructors.cc:789
MeasureTransportConstructor::handlePrelim
void handlePrelim(KigPainter &p, const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &v) const
show a preliminary version of what you would do when handleArgs would be called.
Definition: special_constructors.cc:1777
PolygonBCVConstructor::drawprelim
void drawprelim(const ObjectDrawer &drawer, KigPainter &p, const std::vector< ObjectCalcer * > &parents, const KigDocument &) const
Definition: special_constructors.cc:1115
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
SimpleObjectTypeConstructor
A standard implementation of StandardConstructorBase for simple types.
Definition: object_constructor.h:188
PolygonBCVConstructor::iconFileName
const QByteArray iconFileName(const bool canBeNull=false) const
Definition: special_constructors.cc:908
KigPainter::setBrushColor
void setBrushColor(const QColor &c)
Definition: kigpainter.cpp:265
PolygonVertexTypeConstructor::drawprelim
void drawprelim(const ObjectDrawer &drawer, KigPainter &p, const std::vector< ObjectCalcer * > &parents, const KigDocument &) const
Definition: special_constructors.cc:773
TestConstructMode
This class constructs a test object.
Definition: construct_mode.h:141
GenericIntersectionConstructor::GenericIntersectionConstructor
GenericIntersectionConstructor()
Definition: special_constructors.cc:1913
TestConstructor::drawprelim
void drawprelim(const ObjectDrawer &drawer, KigPainter &p, const std::vector< ObjectCalcer * > &parents, const KigDocument &) const
Definition: special_constructors.cc:2129
ObjectType::inherits
virtual bool inherits(int type) const
Definition: object_type.cc:64
RationalBezierCurveTypeConstructor::RationalBezierCurveTypeConstructor
RationalBezierCurveTypeConstructor()
Definition: special_constructors.cc:1262
OpenPolygonalImp
An ObjectImp representing an open polygonal.
Definition: polygon_imp.h:157
removeDuplicatedPoints
std::vector< ObjectCalcer * > removeDuplicatedPoints(std::vector< ObjectCalcer * > points)
Definition: special_constructors.cc:115
LineData
Simple class representing a line.
Definition: misc/common.h:49
TestConstructor::wantArgs
int wantArgs(const std::vector< ObjectCalcer * > &os, const KigDocument &d, const KigWidget &v) const
can this constructor do something useful with os ? return ArgsParser::Complete, Valid or NotGood ...
Definition: special_constructors.cc:2164
GenericProjectivityConstructor::~GenericProjectivityConstructor
~GenericProjectivityConstructor()
Definition: special_constructors.cc:1615
ObjectConstCalcer
This is an ObjectCalcer that keeps an ObjectImp, and never calculates a new one.
Definition: object_calcer.h:232
PointSequenceConstructor::handleArgs
void handleArgs(const std::vector< ObjectCalcer * > &os, KigPart &d, KigWidget &v) const
do something fun with os .
Definition: special_constructors.cc:533
CircleCircleOtherIntersectionType::instance
static const CircleCircleOtherIntersectionType * instance()
Definition: intersection_types.cc:323
PolygonSideTypeConstructor::PolygonSideTypeConstructor
PolygonSideTypeConstructor()
Definition: special_constructors.cc:827
argsspeccci
static const struct ArgsParser::spec argsspeccci[]
Definition: special_constructors.cc:1905
BezierCurveTypeConstructor::~BezierCurveTypeConstructor
~BezierCurveTypeConstructor()
Definition: special_constructors.cc:1197
ConicRadicalConstructor::ConicRadicalConstructor
ConicRadicalConstructor()
Definition: special_constructors.cc:323
LocusConstructor::useText
QString useText(const ObjectCalcer &o, const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &v) const
return a string describing what you would use o for if it were selected...
Definition: special_constructors.cc:473
ThreeTwoOneIntersectionConstructor::plug
void plug(KigPart *doc, KigGUIAction *kact)
Definition: special_constructors.cc:277
calcpaths.h
BogusPointImp::stype
static const ObjectImpType * stype()
Definition: point_imp.cc:203
CircleImp
An ObjectImp representing a circle.
Definition: circle_imp.h:27
PolygonSideTypeConstructor::plug
void plug(KigPart *doc, KigGUIAction *kact)
Definition: special_constructors.cc:876
argsspecpv
static const struct ArgsParser::spec argsspecpv[]
Definition: special_constructors.cc:754
TextImp
Definition: text_imp.h:26
MeasureTransportConstructor::selectStatement
QString selectStatement(const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &w) const
return a string describing what argument you want next, if the given selection of objects were select...
Definition: special_constructors.cc:1833
CubicLineOtherIntersectionType::instance
static const CubicLineOtherIntersectionType * instance()
Definition: intersection_types.cc:173
KigPart::document
const KigDocument & document() const
Definition: kig_part.cpp:989
MidPointOfTwoPointsConstructor::isTransform
bool isTransform() const
Definition: special_constructors.cc:2113
ConicCartesianData
Cartesian Conic Data.
Definition: conic-common.h:37
PolygonSideType
Definition: polygon_type.h:190
argsspecMidPointOfTwoPoints
static const ArgsParser::spec argsspecMidPointOfTwoPoints[]
Definition: special_constructors.cc:2062
GenericProjectivityConstructor::isAlreadySelectedOK
virtual bool isAlreadySelectedOK(const std::vector< ObjectCalcer * > &os, const uint &) const
the following function is called in case of duplication of arguments and returns true if this is acce...
Definition: special_constructors.cc:1617
RationalBezierImp
An ObjectImp representing a rational Bézier curve.
Definition: bezier_imp.h:100
PolygonBCVConstructor::description
const QString description() const
Definition: special_constructors.cc:903
MeasureTransportConstructor::isAlreadySelectedOK
bool isAlreadySelectedOK(const std::vector< ObjectCalcer * > &os, const uint &) const
the following function is called in case of duplication of arguments and returns true if this is acce...
Definition: special_constructors.cc:1706
ThreeTwoOneIntersectionConstructor::build
std::vector< ObjectHolder * > build(const std::vector< ObjectCalcer * > &os, KigDocument &d, KigWidget &w) const
Definition: special_constructors.cc:227
ObjectImpType::inherits
bool inherits(const ObjectImpType *t) const
Does the ObjectImp type represented by this instance inherit the ObjectImp type represented by t ...
Definition: object_imp.cc:224
CircleCircleIntersectionType::instance
static const CircleCircleIntersectionType * instance()
Definition: intersection_types.cc:490
TwoOrOneIntersectionConstructor::drawprelim
void drawprelim(const ObjectDrawer &drawer, KigPainter &p, const std::vector< ObjectCalcer * > &parents, const KigDocument &) const
Definition: special_constructors.cc:93
PolygonBNPTypeConstructor::useText
QString useText(const ObjectCalcer &o, const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &v) const
return a string describing what you would use o for if it were selected...
Definition: special_constructors.cc:632
RayImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the RayImp type.
Definition: line_imp.cc:562
StandardConstructorBase::build
virtual std::vector< ObjectHolder * > build(const std::vector< ObjectCalcer * > &os, KigDocument &d, KigWidget &w) const =0
kigpainter.h
MidPointOfTwoPointsConstructor::plug
void plug(KigPart *doc, KigGUIAction *kact)
Definition: special_constructors.cc:2109
ObjectDrawer::draw
void draw(const ObjectImp &imp, KigPainter &p, bool selected) const
Draw the object imp on kigpainter p .
Definition: object_drawer.cc:29
ArgsParser::Complete
Definition: argsparser.h:112
TestConstructor::build
std::vector< ObjectHolder * > build(const std::vector< ObjectCalcer * > &os, KigDocument &d, KigWidget &w) const
Definition: special_constructors.cc:2136
PointImp::coordinate
const Coordinate & coordinate() const
Get the coordinate of this PointImp.
Definition: point_imp.h:50
TangentConstructor::useText
QString useText(const ObjectCalcer &o, const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &v) const
return a string describing what you would use o for if it were selected...
Definition: special_constructors.cc:2222
GenericAffinityConstructor::~GenericAffinityConstructor
~GenericAffinityConstructor()
Definition: special_constructors.cc:1586
ArgsParser::spec::type
const ObjectImpType * type
Definition: argsparser.h:113
argsspecps
static const struct ArgsParser::spec argsspecps[]
Definition: special_constructors.cc:821
IntImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the IntImp type.
Definition: bogus_imp.cc:278
MeasureTransportConstructor::isTransform
bool isTransform() const
Definition: special_constructors.cc:1873
ArcLineIntersectionType
arc line intersection.
Definition: intersection_types.h:140
ObjectTypeCalcer
This is an ObjectCalcer that uses one of the various ObjectType's to calculate its ObjectImp...
Definition: object_calcer.h:183
AbstractPolygonImp::points
const std::vector< Coordinate > points() const
Returns the vector with polygon points.
Definition: polygon_imp.cc:571
LineImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the LineImp type.
Definition: line_imp.cc:528
lengthimptypeinstance
LengthImpType lengthimptypeinstance
TwoOrOneIntersectionConstructor::~TwoOrOneIntersectionConstructor
~TwoOrOneIntersectionConstructor()
Definition: special_constructors.cc:89
IntImp
This ObjectImp is a BogusImp containing only an int value.
Definition: bogus_imp.h:128
LocusConstructor::LocusConstructor
LocusConstructor()
Definition: special_constructors.cc:390
CocConstructor::~CocConstructor
~CocConstructor()
Definition: special_constructors.cc:2285
ObjectConstructor::isTransform
virtual bool isTransform() const =0
ThreeTwoOneIntersectionConstructor
Definition: special_constructors.h:42
PolygonBCVConstructor::isAlreadySelectedOK
bool isAlreadySelectedOK(const std::vector< ObjectCalcer * > &os, const uint &) const
the following function is called in case of duplication of arguments and returns true if this is acce...
Definition: special_constructors.cc:913
ObjectType::calc
virtual ObjectImp * calc(const Args &parents, const KigDocument &d) const =0
CocConstructor::CocConstructor
CocConstructor()
Definition: special_constructors.cc:2256
OpenPolygonType
Open Polygon (Polyline, Polygonal Line)
Definition: polygon_type.h:73
RationalBezierCurveTypeConstructor::wantArgs
int wantArgs(const std::vector< ObjectCalcer * > &os, const KigDocument &d, const KigWidget &v) const
can this constructor do something useful with os ? return ArgsParser::Complete, Valid or NotGood ...
Definition: special_constructors.cc:1293
StandardConstructorBase::drawprelim
virtual void drawprelim(const ObjectDrawer &drawer, KigPainter &p, const std::vector< ObjectCalcer * > &parents, const KigDocument &) const =0
PolygonBCVConstructor::PolygonBCVConstructor
PolygonBCVConstructor()
Definition: special_constructors.cc:889
InversionConstructor::~InversionConstructor
~InversionConstructor()
Definition: special_constructors.cc:1676
Coordinate
The Coordinate class is the basic class representing a 2D location by its x and y components...
Definition: coordinate.h:33
MeasureTransportConstructor::description
const QString description() const
Definition: special_constructors.cc:1696
TangentCurveType::instance
static const TangentCurveType * instance()
Definition: tangent_type.cc:233
KigGUIAction
Definition: guiaction.h:34
Coordinate::length
double length() const
Length.
Definition: coordinate.cpp:144
PolygonBNPTypeConstructor::drawprelim
void drawprelim(const ObjectDrawer &drawer, KigPainter &p, const std::vector< ObjectCalcer * > &parents, const KigDocument &) const
Definition: special_constructors.cc:647
CocConstructor::useText
QString useText(const ObjectCalcer &o, const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &v) const
return a string describing what you would use o for if it were selected...
Definition: special_constructors.cc:2289
ProjectivityB2QuType::instance
static const ProjectivityB2QuType * instance()
Definition: transform_types.cc:547
ObjectConstructor
This class represents a way to construct a set of objects from a set of other objects.
Definition: object_constructor.h:44
PolygonBCVConstructor::isTransform
bool isTransform() const
Definition: special_constructors.cc:1141
MeasureTransportConstructor::iconFileName
const QByteArray iconFileName(const bool canBeNull=false) const
Definition: special_constructors.cc:1701
MidPointOfTwoPointsConstructor::MidPointOfTwoPointsConstructor
MidPointOfTwoPointsConstructor()
Definition: special_constructors.cc:2070
ObjectType::isTransform
virtual bool isTransform() const
is this object type a transformation type.
Definition: object_type.cc:86
ObjectPropertyCalcer::calc
void calc(const KigDocument &doc)
Makes the ObjectCalcer recalculate its ObjectImp from its parents.
Definition: object_calcer.cc:183
PolygonBNPTypeConstructor::~PolygonBNPTypeConstructor
~PolygonBNPTypeConstructor()
Definition: special_constructors.cc:606
PolygonPolygonIntersectionType::instance
static const PolygonPolygonIntersectionType * instance()
Definition: polygon_type.cc:845
delete_all
void delete_all(T begin, T end)
Definition: objects/common.h:53
BezierCurveTypeConstructor::selectStatement
QString selectStatement(const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &w) const
return a string describing what argument you want next, if the given selection of objects were select...
Definition: special_constructors.cc:1231
RationalBezierCurveTypeConstructor::descriptiveName
const QString descriptiveName() const
Definition: special_constructors.cc:1270
calcConicLineIntersect
const Coordinate calcConicLineIntersect(const ConicCartesianData &c, const LineData &l, double knownparam, int which)
This function calculates the intersection of a given line ( l ) and a given conic ( c )...
Definition: conic-common.cpp:367
RationalBezierCurveTypeConstructor::handlePrelim
void handlePrelim(KigPainter &p, const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &v) const
show a preliminary version of what you would do when handleArgs would be called.
Definition: special_constructors.cc:1397
CircularInversionType::instance
static const CircularInversionType * instance()
Definition: inversion_type.cc:56
InversionConstructor::InversionConstructor
InversionConstructor()
Definition: special_constructors.cc:1626
TextImp::draw
void draw(KigPainter &p) const
Definition: text_imp.cc:48
PolygonSideTypeConstructor::~PolygonSideTypeConstructor
~PolygonSideTypeConstructor()
Definition: special_constructors.cc:836
PolygonBCVConstructor::descriptiveName
const QString descriptiveName() const
Definition: special_constructors.cc:898
LineLineIntersectionType::instance
static const LineLineIntersectionType * instance()
Definition: intersection_types.cc:374
PolygonVertexTypeConstructor::isTransform
bool isTransform() const
Definition: special_constructors.cc:812
KigPainter
KigPainter is an extended QPainter.
Definition: kigpainter.h:51
RationalBezierCurveTypeConstructor::isAlreadySelectedOK
bool isAlreadySelectedOK(const std::vector< ObjectCalcer * > &os, const uint &) const
the following function is called in case of duplication of arguments and returns true if this is acce...
Definition: special_constructors.cc:1285
conic-common.h
ThreeTwoOneIntersectionConstructor::isTransform
bool isTransform() const
Definition: special_constructors.cc:281
RationalBezierCurveTypeConstructor::~RationalBezierCurveTypeConstructor
~RationalBezierCurveTypeConstructor()
Definition: special_constructors.cc:1266
KigPainter::setWidth
void setWidth(int c)
setting this to -1 means to use the default width for the object being drawn.
Definition: kigpainter.cpp:232
TwoOrOneIntersectionConstructor::plug
void plug(KigPart *doc, KigGUIAction *kact)
Definition: special_constructors.cc:177
ObjectHolder
An ObjectHolder represents an object as it is known to the document.
Definition: object_holder.h:40
MidPointOfTwoPointsConstructor::drawprelim
void drawprelim(const ObjectDrawer &drawer, KigPainter &p, const std::vector< ObjectCalcer * > &parents, const KigDocument &) const
Definition: special_constructors.cc:2082
PointImp
An ObjectImp representing a point.
Definition: point_imp.h:27
ObjectCalcer
An ObjectCalcer is an object that represents an algorithm for calculating an ObjectImp from other Obj...
Definition: object_calcer.h:66
Args
std::vector< const ObjectImp * > Args
Definition: objects/common.h:47
AbstractPolygonImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the PolygonImp type.
Definition: polygon_imp.cc:651
PolygonLineIntersectionType::instance
static const PolygonLineIntersectionType * instance()
Definition: polygon_type.cc:532
PolygonSideTypeConstructor::isTransform
bool isTransform() const
Definition: special_constructors.cc:880
StandardConstructorBase
This class provides wraps ObjectConstructor in a more simple interface for the most common object typ...
Definition: object_constructor.h:133
PolygonVertexTypeConstructor::plug
void plug(KigPart *doc, KigGUIAction *kact)
Definition: special_constructors.cc:808
ConicRadicalConstructor::isTransform
bool isTransform() const
Definition: special_constructors.cc:492
InvertPointType::instance
static const InvertPointType * instance()
Definition: inversion_type.cc:308
PointSequenceConstructor::description
const QString description() const
Definition: special_constructors.cc:523
PointSequenceConstructor::drawprelim
virtual void drawprelim(const ObjectDrawer &drawer, KigPainter &p, const std::vector< ObjectCalcer * > &parents, const KigDocument &) const =0
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
PolygonSideTypeConstructor::build
std::vector< ObjectHolder * > build(const std::vector< ObjectCalcer * > &os, KigDocument &d, KigWidget &w) const
Definition: special_constructors.cc:857
MeasureTransportConstructor::descriptiveName
const QString descriptiveName() const
Definition: special_constructors.cc:1691
MeasureTransportConstructor::useText
QString useText(const ObjectCalcer &o, const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &v) const
return a string describing what you would use o for if it were selected...
Definition: special_constructors.cc:1806
PolygonBCVConstructor::computeNsides
int computeNsides(const Coordinate &c, const Coordinate &v, const Coordinate &cntrl, int &winding) const
Definition: special_constructors.cc:1156
KigPainter::setBrushStyle
void setBrushStyle(Qt::BrushStyle c)
Definition: kigpainter.cpp:259
OPolygonalLineIntersectionType::instance
static const OPolygonalLineIntersectionType * instance()
Definition: polygon_type.cc:645
MidPointOfTwoPointsConstructor::build
std::vector< ObjectHolder * > build(const std::vector< ObjectCalcer * > &os, KigDocument &d, KigWidget &w) const
Definition: special_constructors.cc:2095
ArgsParser::Invalid
Definition: argsparser.h:112
TwoOrOneIntersectionConstructor::build
std::vector< ObjectHolder * > build(const std::vector< ObjectCalcer * > &os, KigDocument &d, KigWidget &w) const
Definition: special_constructors.cc:144
KigWidget
This class is the real widget showing the document.
Definition: kig_view.h:50
FilledPolygonImp::stype
static const ObjectImpType * stype()
Definition: polygon_imp.cc:660
ConicLineIntersectionType
conic line intersection.
Definition: intersection_types.h:32
SegmentImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the SegmentImp type.
Definition: line_imp.cc:545
PolygonBNPTypeConstructor::selectStatement
QString selectStatement(const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &w) const
return a string describing what argument you want next, if the given selection of objects were select...
Definition: special_constructors.cc:640
CocCurveType::instance
static const CocCurveType * instance()
Definition: centerofcurvature_type.cc:223
LineCubicIntersectionType::instance
static const LineCubicIntersectionType * instance()
Definition: intersection_types.cc:414
ObjectPropertyCalcer
This is an ObjectCalcer that has a single parent, and gets a certain property from it in its calc() m...
Definition: object_calcer.h:276
PolygonBCVConstructor::selectStatement
QString selectStatement(const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &w) const
return a string describing what argument you want next, if the given selection of objects were select...
Definition: special_constructors.cc:1093
ArgsParser::spec
Definition: argsparser.h:113
ArcImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the ArcImp type.
Definition: other_imp.cc:629
ArgsParser
This class is meant to take care of checking the types of the parents to ObjectCalcer's, and to put them in the correct order.
Definition: argsparser.h:106
ConicImp
An ObjectImp representing a conic.
Definition: conic_imp.h:39
ThreeTwoOneIntersectionConstructor::~ThreeTwoOneIntersectionConstructor
~ThreeTwoOneIntersectionConstructor()
Definition: special_constructors.cc:201
RationalBezierCurveTypeConstructor::plug
void plug(KigPart *doc, KigGUIAction *kact)
Definition: special_constructors.cc:1423
RationalBezierCurveTypeConstructor::isTransform
bool isTransform() const
Definition: special_constructors.cc:1427
MeasureTransportConstructor::MeasureTransportConstructor
MeasureTransportConstructor()
Definition: special_constructors.cc:1682
CircleImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the CircleImp type.
Definition: circle_imp.cc:342
MidPointOfTwoPointsConstructor::~MidPointOfTwoPointsConstructor
~MidPointOfTwoPointsConstructor()
Definition: special_constructors.cc:2078
RationalBezierCurveTypeConstructor::selectStatement
QString selectStatement(const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &w) const
return a string describing what argument you want next, if the given selection of objects were select...
Definition: special_constructors.cc:1349
ObjectType
The ObjectType class is a thing that represents the "behaviour" for a certain type.
Definition: object_type.h:32
PolygonVertexType
Definition: polygon_type.h:179
TangentCubicType::instance
static const TangentCubicType * instance()
Definition: tangent_type.cc:162
TestConstructor::plug
void plug(KigPart *doc, KigGUIAction *kact)
Definition: special_constructors.cc:2145
Coordinate::squareLength
double squareLength() const
Square length.
Definition: coordinate.h:163
GenericIntersectionConstructor::selectStatement
QString selectStatement(const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &w) const
return a string describing what argument you want next, if the given selection of objects were select...
Definition: special_constructors.cc:2172
RationalBezierCurveTypeConstructor::useText
QString useText(const ObjectCalcer &o, const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &v) const
return a string describing what you would use o for if it were selected...
Definition: special_constructors.cc:1336
PolygonVertexTypeConstructor::~PolygonVertexTypeConstructor
~PolygonVertexTypeConstructor()
Definition: special_constructors.cc:769
PolygonBNPTypeConstructor::PolygonBNPTypeConstructor
PolygonBNPTypeConstructor()
Definition: special_constructors.cc:597
ObjectTypeCalcer::type
const ObjectType * type() const
Definition: object_calcer.cc:132
ConicRadicalConstructor::useText
QString useText(const ObjectCalcer &o, const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &v) const
return a string describing what you would use o for if it were selected...
Definition: special_constructors.cc:1545
OpenPolygonTypeConstructor::selectStatement
QString selectStatement(const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &w) const
return a string describing what argument you want next, if the given selection of objects were select...
Definition: special_constructors.cc:719
argsspecpp
static const struct ArgsParser::spec argsspecpp[]
Definition: special_constructors.cc:382
OpenPolygonTypeConstructor::~OpenPolygonTypeConstructor
~OpenPolygonTypeConstructor()
Definition: special_constructors.cc:685
common.h
OpenPolygonTypeConstructor::wantArgs
int wantArgs(const std::vector< ObjectCalcer * > &os, const KigDocument &d, const KigWidget &v) const
can this constructor do something useful with os ? return ArgsParser::Complete, Valid or NotGood ...
Definition: special_constructors.cc:696
ConicRadicalType
Definition: conic_types.h:170
ConicRadicalConstructor::build
std::vector< ObjectHolder * > build(const std::vector< ObjectCalcer * > &os, KigDocument &d, KigWidget &w) const
Definition: special_constructors.cc:363
BezierCurveType
Bézier curve of degree n.
Definition: bezier_type.h:68
ObjectDrawer
A class holding some information about how a certain object is drawn on the window.
Definition: object_drawer.h:47
LocusConstructor::plug
void plug(KigPart *doc, KigGUIAction *kact)
Definition: special_constructors.cc:488
LocusConstructor::isTransform
bool isTransform() const
Definition: special_constructors.cc:497
ConicRadicalConstructor::plug
void plug(KigPart *doc, KigGUIAction *kact)
Definition: special_constructors.cc:484
weightimptypeinstance
WeightImpType weightimptypeinstance
KigPainter::setStyle
void setStyle(Qt::PenStyle c)
Definition: kigpainter.cpp:226
ThreeTwoOneIntersectionConstructor::drawprelim
void drawprelim(const ObjectDrawer &drawer, KigPainter &p, const std::vector< ObjectCalcer * > &parents, const KigDocument &) const
Definition: special_constructors.cc:205
argsspeccli
static const struct ArgsParser::spec argsspeccli[]
Definition: special_constructors.cc:1887
ObjectType::ID_ConstrainedPointType
Definition: object_type.h:41
PointSequenceConstructor::isTransform
bool isTransform() const
Definition: special_constructors.cc:588
PolygonBCVConstructor::handleArgs
void handleArgs(const std::vector< ObjectCalcer * > &os, KigPart &d, KigWidget &v) const
do something fun with os .
Definition: special_constructors.cc:937
AffinityB2TrType::instance
static const AffinityB2TrType * instance()
Definition: transform_types.cc:448
PolygonBCVType
Polygon by center and vertex.
Definition: polygon_type.h:99
CocCubicType::instance
static const CocCubicType * instance()
Definition: centerofcurvature_type.cc:141
PolygonBCVConstructor::build
std::vector< ObjectHolder * > build(const std::vector< ObjectCalcer * > &os, KigDocument &d, KigWidget &w) const
Definition: special_constructors.cc:1030
ThreeTwoOneIntersectionConstructor::ThreeTwoOneIntersectionConstructor
ThreeTwoOneIntersectionConstructor(const ArgsParserObjectType *t_std, const ArgsParserObjectType *t_special, const ArgsParserObjectType *t_special2, const char *iconfile, const struct ArgsParser::spec argsspecv[])
Definition: special_constructors.cc:186
PointImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing PointImp's.
Definition: point_imp.cc:159
argsspectc
static const ArgsParser::spec argsspectc[]
Definition: special_constructors.cc:1437
AffinityGI3PType::instance
static const AffinityGI3PType * instance()
Definition: transform_types.cc:498
PointSequenceConstructor::descriptiveName
const QString descriptiveName() const
Definition: special_constructors.cc:518
KigPainter::setPen
void setPen(const QPen &p)
Definition: kigpainter.cpp:244
KigDocument::findIntersectionPoints
std::vector< ObjectCalcer * > findIntersectionPoints(const ObjectCalcer *c1, const ObjectCalcer *c2) const
Return all the points that belong (by construction) on both the given curves.
Definition: kig_document.cc:248
ConicRadicalType::instance
static const ConicRadicalType * instance()
Definition: conic_types.cc:562
CurveImp::containsPoint
virtual bool containsPoint(const Coordinate &p, const KigDocument &) const =0
Return whether this Curve contains the given point.
MultiObjectTypeConstructor
This class is the equivalent of SimpleObjectTypeConstructor for object types that are constructed in ...
Definition: object_constructor.h:251
TwoOrOneIntersectionConstructor::TwoOrOneIntersectionConstructor
TwoOrOneIntersectionConstructor(const ArgsParserObjectType *t_std, const ArgsParserObjectType *t_special, const char *iconfile, const struct ArgsParser::spec argsspecv[])
Definition: special_constructors.cc:76
PolygonBCVConstructor::plug
void plug(KigPart *doc, KigGUIAction *kact)
Definition: special_constructors.cc:1137
CurveImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the CurveImp type.
Definition: curve_imp.cc:27
ConicImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the ConicImp type.
Definition: conic_imp.cc:380
PointImp::draw
void draw(KigPainter &p) const
Definition: point_imp.cc:40
OpenPolygonTypeConstructor::drawprelim
void drawprelim(const ObjectDrawer &drawer, KigPainter &p, const std::vector< ObjectCalcer * > &parents, const KigDocument &) const
Definition: special_constructors.cc:726
KigDocument
KigDocument is the class holding the real data in a Kig document.
Definition: kig_document.h:36
PointSequenceConstructor::iconFileName
const QByteArray iconFileName(const bool canBeNull=false) const
Definition: special_constructors.cc:528
AbstractLineImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the AbstractLineImp type.
Definition: line_imp.cc:520
NumericTextImp::stype
static const ObjectImpType * stype()
Definition: text_imp.cc:189
CocConicType::instance
static const CocConicType * instance()
Definition: centerofcurvature_type.cc:55
ConicLineIntersectionType::instance
static const ConicLineIntersectionType * instance()
Definition: intersection_types.cc:54
LocusConstructor::~LocusConstructor
~LocusConstructor()
Definition: special_constructors.cc:397
LocusConstructor::wantArgs
int wantArgs(const std::vector< ObjectCalcer * > &os, const KigDocument &d, const KigWidget &v) const
we override the wantArgs() function, since we need to see something about the objects that an ArgsPar...
Definition: special_constructors.cc:431
BezierCurveTypeConstructor::isAlreadySelectedOK
bool isAlreadySelectedOK(const std::vector< ObjectCalcer * > &os, const uint &) const
the following function is called in case of duplication of arguments and returns true if this is acce...
Definition: special_constructors.cc:1201
ObjectCalcer::imp
virtual const ObjectImp * imp() const =0
Returns the ObjectImp of this ObjectCalcer.
PointSequenceConstructor::plug
void plug(KigPart *doc, KigGUIAction *kact)
Definition: special_constructors.cc:584
CubicLineTwoIntersectionType::instance
static const CubicLineTwoIntersectionType * instance()
Definition: intersection_types.cc:241
GenericAffinityConstructor::GenericAffinityConstructor
GenericAffinityConstructor()
Definition: special_constructors.cc:1564
ObjectTypeCalcer::parents
std::vector< ObjectCalcer * > parents() const
Returns the parent ObjectCalcer's of this ObjectCalcer.
Definition: object_calcer.cc:105
argsspeccbli
static const struct ArgsParser::spec argsspeccbli[]
Definition: special_constructors.cc:1896
OpenPolygonTypeConstructor::useText
QString useText(const ObjectCalcer &o, const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &v) const
return a string describing what you would use o for if it were selected...
Definition: special_constructors.cc:711
Coordinate::x
double x
X Component.
Definition: coordinate.h:126
PolygonBCVConstructor::wantArgs
int wantArgs(const std::vector< ObjectCalcer * > &os, const KigDocument &d, const KigWidget &v) const
can this constructor do something useful with os ? return ArgsParser::Complete, Valid or NotGood ...
Definition: special_constructors.cc:919
ConicRadicalConstructor::drawprelim
void drawprelim(const ObjectDrawer &drawer, KigPainter &p, const std::vector< ObjectCalcer * > &parents, const KigDocument &) const
Definition: special_constructors.cc:339
guiaction.h
PolygonBCVConstructor::~PolygonBCVConstructor
~PolygonBCVConstructor()
Definition: special_constructors.cc:894
TestConstructor::isTest
bool isTest() const
Definition: special_constructors.cc:2154
getDoubleFromImp
double getDoubleFromImp(const ObjectImp *obj, bool &valid)
Definition: special_imptypes.cc:27
PolygonBNPType
Polygon by its vertices.
Definition: polygon_type.h:47
ObjectTypeCalcer::calc
void calc(const KigDocument &doc)
Makes the ObjectCalcer recalculate its ObjectImp from its parents.
Definition: object_calcer.cc:32
ArgsParser::check
int check(const Args &os) const
Definition: argsparser.cpp:99
TangentConstructor::~TangentConstructor
~TangentConstructor()
Definition: special_constructors.cc:2218
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
RationalBezierCurveTypeConstructor::build
std::vector< ObjectHolder * > build(const std::vector< ObjectCalcer * > &os, KigDocument &d, KigWidget &w) const
Definition: special_constructors.cc:1309
TwoOrOneIntersectionConstructor
Definition: special_constructors.h:23
RationalBezierCurveTypeConstructor::drawprelim
void drawprelim(const ObjectDrawer &drawer, KigPainter &p, const std::vector< ObjectCalcer * > &parents, const KigDocument &d) const
Definition: special_constructors.cc:1359
BezierCurveTypeConstructor::wantArgs
int wantArgs(const std::vector< ObjectCalcer * > &os, const KigDocument &d, const KigWidget &v) const
can this constructor do something useful with os ? return ArgsParser::Complete, Valid or NotGood ...
Definition: special_constructors.cc:1208
ConicRadicalConstructor::~ConicRadicalConstructor
~ConicRadicalConstructor()
Definition: special_constructors.cc:335
PolygonVertexTypeConstructor::PolygonVertexTypeConstructor
PolygonVertexTypeConstructor()
Definition: special_constructors.cc:760
BezierCurveTypeConstructor::useText
QString useText(const ObjectCalcer &o, const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &v) const
return a string describing what you would use o for if it were selected...
Definition: special_constructors.cc:1223
TangentConicType::instance
static const TangentConicType * instance()
Definition: tangent_type.cc:57
KigPart::addObjects
void addObjects(const std::vector< ObjectHolder * > &os)
Definition: kig_part.cpp:503
CircleImp::draw
void draw(KigPainter &p) const
Definition: circle_imp.cc:62
MeasureTransportType
Definition: point_type.h:152
SegmentABType::instance
static const SegmentABType * instance()
Definition: line_type.cc:55
RationalBezierCurveTypeConstructor::handleArgs
void handleArgs(const std::vector< ObjectCalcer * > &os, KigPart &d, KigWidget &v) const
do something fun with os .
Definition: special_constructors.cc:1322
TestConstructor::constructMode
BaseConstructMode * constructMode(KigPart &doc)
Which construct mode should be used for this ObjectConstructor.
Definition: special_constructors.cc:2159
FilledPolygonImp
An ObjectImp representing a filled polygon.
Definition: polygon_imp.h:101
ArgsParser::Valid
Definition: argsparser.h:112
TestConstructor::TestConstructor
TestConstructor(const ArgsParserObjectType *type, const char *descname, const char *desc, const char *iconfile)
Definition: special_constructors.cc:2118
GenericIntersectionConstructor::~GenericIntersectionConstructor
~GenericIntersectionConstructor()
Definition: special_constructors.cc:1999
PolygonBCVConstructor::useText
QString useText(const ObjectCalcer &o, const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &v) const
return a string describing what you would use o for if it were selected...
Definition: special_constructors.cc:1058
getAllChildren
std::set< ObjectCalcer * > getAllChildren(ObjectCalcer *obj)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: calcpaths.cc:281
CubicImp::stype
static const ObjectImpType * stype()
Definition: cubic_imp.cc:352
TestConstructor::~TestConstructor
~TestConstructor()
Definition: special_constructors.cc:2125
TangentArcType::instance
static const TangentArcType * instance()
Definition: tangent_type.cc:107
PointSequenceConstructor
Definition: special_constructors.h:97
TwoOrOneIntersectionConstructor::isTransform
bool isTransform() const
Definition: special_constructors.cc:181
BezierCurveTypeConstructor::BezierCurveTypeConstructor
BezierCurveTypeConstructor()
Definition: special_constructors.cc:1188
ConicLineOtherIntersectionType::instance
static const ConicLineOtherIntersectionType * instance()
Definition: intersection_types.cc:118
MeasureTransportConstructor::build
std::vector< ObjectHolder * > build(const std::vector< ObjectCalcer * > &os, KigDocument &d, KigWidget &w) const
Definition: special_constructors.cc:1855
RationalBezierCurveTypeConstructor::description
const QString description() const
Definition: special_constructors.cc:1275
special_constructors.h
GenericProjectivityConstructor::GenericProjectivityConstructor
GenericProjectivityConstructor()
Definition: special_constructors.cc:1593
uint
unsigned int uint
Definition: object_imp.h:87
PointSequenceConstructor::PointSequenceConstructor
PointSequenceConstructor(const char *descname, const char *desc, const char *iconfile, const ObjectType *type)
Definition: special_constructors.cc:506
ProjectivityGI4PType::instance
static const ProjectivityGI4PType * instance()
Definition: transform_types.cc:601
TangentConstructor::TangentConstructor
TangentConstructor()
Definition: special_constructors.cc:2182
Coordinate::valid
bool valid() const
Return whether this is a valid Coordinate.
Definition: coordinate.cpp:176
relativePrimes
bool relativePrimes(int n, int p)
Definition: special_constructors.cc:2304
PolygonBCVConstructor::getRotatedCoord
Coordinate getRotatedCoord(const Coordinate &c1, const Coordinate &c2, double alpha) const
Definition: special_constructors.cc:1146
MergeObjectConstructor::merge
void merge(ObjectConstructor *e)
Definition: object_constructor.cc:235
LocusConstructor::drawprelim
void drawprelim(const ObjectDrawer &drawer, KigPainter &p, const std::vector< ObjectCalcer * > &parents, const KigDocument &) const
Definition: special_constructors.cc:401
OpenPolygonTypeConstructor::OpenPolygonTypeConstructor
OpenPolygonTypeConstructor()
Definition: special_constructors.cc:676
MeasureTransportConstructor::drawprelim
void drawprelim(const ObjectDrawer &drawer, KigPainter &p, const std::vector< ObjectCalcer * > &parents, const KigDocument &) const
Definition: special_constructors.cc:1792
GenericIntersectionConstructor::isIntersection
bool isIntersection() const
Definition: special_constructors.cc:2003
MeasureTransportConstructor::~MeasureTransportConstructor
~MeasureTransportConstructor()
Definition: special_constructors.cc:1687
PolygonBCVConstructor::handlePrelim
void handlePrelim(KigPainter &p, const std::vector< ObjectCalcer * > &sel, const KigDocument &d, const KigWidget &v) const
show a preliminary version of what you would do when handleArgs would be called.
Definition: special_constructors.cc:951
OpenPolygonTypeConstructor::isAlreadySelectedOK
bool isAlreadySelectedOK(const std::vector< ObjectCalcer * > &os, const uint &) const
the following function is called in case of duplication of arguments and returns true if this is acce...
Definition: special_constructors.cc:689
CurveImp
This class represents a curve: something which is composed of points, like a line, a circle, a locus.
Definition: curve_imp.h:27
SegmentImp
An ObjectImp representing a segment.
Definition: line_imp.h:81
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:40 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
  • kstars
  • libkdeedu
  •   keduvocdocument
  • 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