• 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
  • objects
object_factory.cc
Go to the documentation of this file.
1 // Copyright (C) 2002 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 "object_factory.h"
19 
20 #include "bogus_imp.h"
21 #include "curve_imp.h"
22 #include "intersection_types.h"
23 #include "line_imp.h"
24 #include "object_drawer.h"
25 #include "object_holder.h"
26 #include "other_type.h"
27 #include "point_imp.h"
28 #include "point_type.h"
29 #include "text_type.h"
30 #include "conic_types.h"
31 
32 #include "../kig/kig_document.h"
33 #include "../kig/kig_view.h"
34 #include "../misc/calcpaths.h"
35 #include "../misc/coordinate.h"
36 #include "../misc/object_hierarchy.h"
37 #include "../misc/special_constructors.h"
38 
39 #include <algorithm>
40 #include <functional>
41 #include <limits>
42 #include <iterator>
43 
44 ObjectHolder* ObjectFactory::fixedPoint( const Coordinate& c ) const
45 {
46  ObjectHolder* o = new ObjectHolder( fixedPointCalcer( c ) );
47  return o;
48 }
49 
50 ObjectTypeCalcer* ObjectFactory::fixedPointCalcer( const Coordinate& c ) const
51 {
52  std::vector<ObjectCalcer*> args;
53  args.push_back( new ObjectConstCalcer( new DoubleImp( c.x ) ) );
54  args.push_back( new ObjectConstCalcer( new DoubleImp( c.y ) ) );
55  ObjectTypeCalcer* oc = new ObjectTypeCalcer( FixedPointType::instance(), args );
56  return oc;
57 }
58 
59 ObjectHolder* ObjectFactory::numericValue(
60  const double value, const Coordinate& loc, const KigDocument& doc ) const
61 {
62  return new ObjectHolder( numericValueCalcer( value, loc, doc ) );
63 }
64 
65 ObjectTypeCalcer* ObjectFactory::numericValueCalcer(
66  const double value, const Coordinate& loc, const KigDocument& doc ) const
67 {
68  std::vector<ObjectCalcer*> parents;
69  parents.reserve( 4 );
70  const bool needframe = false;
71  parents.push_back( new ObjectConstCalcer( new IntImp( needframe ? 1 : 0 ) ) );
72  parents.push_back( getAttachPoint( 0, loc, doc ) );
73  parents.push_back( new ObjectConstCalcer( new StringImp( "%1" ) ) );
74  parents.push_back( new ObjectConstCalcer( new DoubleImp( value ) ) );
75 
76  ObjectTypeCalcer* ret = new ObjectTypeCalcer( NumericTextType::instance(), parents );
77  ret->calc( doc );
78  return ret;
79 }
80 
81 ObjectTypeCalcer* ObjectFactory::cursorPointCalcer( const Coordinate& c ) const
82 {
83  std::vector<ObjectCalcer*> args;
84  args.push_back( new ObjectConstCalcer( new DoubleImp( c.x ) ) );
85  args.push_back( new ObjectConstCalcer( new DoubleImp( c.y ) ) );
86  ObjectTypeCalcer* oc = new ObjectTypeCalcer( CursorPointType::instance(), args );
87  return oc;
88 }
89 
90 const ObjectFactory* ObjectFactory::instance()
91 {
92  static ObjectFactory f;
93  return &f;
94 }
95 
96 ObjectTypeCalcer* ObjectFactory::sensiblePointCalcer(
97  const Coordinate& c, const KigDocument& d, const KigWidget& w ) const
98 {
99  std::vector<ObjectHolder*> os = d.whatAmIOn( c, w );
100  if ( os.size() == 2 )
101  {
102  // we can calc intersection point *only* between two objects...
103  std::vector<ObjectCalcer*> args;
104  int linecount = 0;
105  int coniccount = 0;
106  int circlecount = 0; // Note: a circle is a conic
107 // int cubiccount = 0; // not yet implemented
108  int lineid = -1;
109  int conicid = -1;
110 // int cubicid = -1;
111  for (int i = 0; i < 2; i++)
112  {
113  if ( os[i]->imp()->inherits( AbstractLineImp::stype() ) ) {linecount++; lineid = i;}
114  if ( os[i]->imp()->inherits( ConicImp::stype() ) ) {coniccount++; conicid = i;}
115  if ( os[i]->imp()->inherits( CircleImp::stype() ) ) circlecount++;
116 // if ( os[i]->imp()->inherits( CubicImp::stype() ) ) {cubiccount++; cubicid = i;}
117  }
118  if ( linecount == 2 )
119  {
120  // the simplest case: two lines...
121  args.push_back( os[0]->calcer() );
122  args.push_back( os[1]->calcer() );
123  return new ObjectTypeCalcer( LineLineIntersectionType::instance(), args );
124  }
125  if ( circlecount == 2 || ( coniccount == 1 && linecount == 1 ) )
126  {
127  // in this case there are generally two intersections, we need
128  // to check if one of these is already present, in which case
129  // we must use the "Other" variant of the intersection types
130  std::vector<ObjectCalcer*> points =
131  d.findIntersectionPoints( os[0]->calcer(), os[1]->calcer() );
132  std::vector<ObjectCalcer*> uniquepoints = removeDuplicatedPoints( points );
133  if ( uniquepoints.size() == 1 )
134  {
135  bool doother = true;
136  std::vector<ObjectCalcer*> parents = uniquepoints[0]->parents();
137  if ( parents.size() == 3 )
138  {
139  if ( ( parents[0] == os[0]->calcer() && parents[1] == os[1]->calcer() )
140  || ( parents[0] == os[1]->calcer() && parents[1] == os[0]->calcer() ) )
141  {
142  if ( parents[2]->imp()->inherits( IntImp::stype() ) )
143  doother = false; // we should test if the type is
144  // ConicLineIntersectionType or
145  // CircleCircleIntersectionType
146  }
147  }
148  if ( doother )
149  {
150  // in this case we construct an OtherIntersection
151 printf ("*** trovata altra intersezione!\n");
152  if ( circlecount == 2 )
153  {
154  args.push_back( os[0]->calcer() );
155  args.push_back( os[1]->calcer() );
156  args.push_back( uniquepoints[0] );
157  return new ObjectTypeCalcer(
158  CircleCircleOtherIntersectionType::instance(), args );
159  } else {
160  args.push_back( os[conicid]->calcer() );
161  args.push_back( os[lineid]->calcer() );
162  args.push_back( uniquepoints[0] );
163  return new ObjectTypeCalcer(
164  ConicLineOtherIntersectionType::instance(), args );
165  }
166  }
167  }
168  }
169  if ( coniccount == 1 && linecount == 1 )
170  {
171  // conic-line intersection...
172  const ConicImp* conic = static_cast<const ConicImp*>( os[conicid]->imp() );
173  const AbstractLineImp* line = static_cast<const AbstractLineImp*>( os[lineid]->imp() );
174 
175  // we have two intersections, select the nearest one
176  Coordinate p1, p2;
177  if ( circlecount ) // in this case we cannot use the ConicLine computation
178  { // because "which" behaves differently when "calc"-ing
179  const CircleImp* c = static_cast<const CircleImp*>( conic );
180  p1 = calcCircleLineIntersect(
181  c->center(), c->squareRadius(), line->data(), -1 );
182  p2 = calcCircleLineIntersect(
183  c->center(), c->squareRadius(), line->data(), 1 );
184  } else {
185  p1 = calcConicLineIntersect(
186  conic->cartesianData(), line->data(), 0.0, -1 );
187  p2 = calcConicLineIntersect(
188  conic->cartesianData(), line->data(), 0.0, 1 );
189  }
190  int which = -1;
191  if ( (p2-c).length() < (p1-c).length() ) which = 1;
192  args.push_back( os[conicid]->calcer() );
193  args.push_back( os[lineid]->calcer() );
194  args.push_back( new ObjectConstCalcer( new IntImp( which ) ) );
195  return new ObjectTypeCalcer( ConicLineIntersectionType::instance(), args );
196  }
197  if ( circlecount == 2 )
198  {
199  // circle-circle intersection...
200  const CircleImp* c1 = static_cast<const CircleImp*>( os[0]->imp() );
201  const CircleImp* c2 = static_cast<const CircleImp*>( os[1]->imp() );
202  const Coordinate o1 = c1->center();
203  const Coordinate o2 = c2->center();
204  const double r1sq = c1->squareRadius();
205  const Coordinate a = calcCircleRadicalStartPoint(
206  o1, o2, r1sq, c2->squareRadius()
207  );
208  const LineData lined = LineData (a, Coordinate ( a.x -o2.y + o1.y, a.y + o2.x - o1.x ));
209  Coordinate p1 = calcCircleLineIntersect( o1, r1sq, lined, -1 );
210  Coordinate p2 = calcCircleLineIntersect( o1, r1sq, lined, 1 );
211  int which = -1;
212  if ( (p2-c).length() < (p1-c).length() ) which = 1;
213  args.push_back( os[0]->calcer() );
214  args.push_back( os[1]->calcer() );
215  args.push_back( new ObjectConstCalcer( new IntImp( which ) ) );
216  return new ObjectTypeCalcer( CircleCircleIntersectionType::instance(), args );
217  }
218  if ( coniccount == 2 )
219  {
220  // conic-conic intersection...
221  const ConicImp* conic1 = static_cast<const ConicImp*>( os[0]->imp() );
222  const ConicImp* conic2 = static_cast<const ConicImp*>( os[1]->imp() );
223  bool valid;
224  double d1, d2, d3, d4;
225  Coordinate p1, p2, p3, p4;
226  d1 = d2 = d3 = d4 = std::numeric_limits<double>::max();
227  const LineData l1 = calcConicRadical(
228  static_cast<const ConicImp*>( conic1 )->cartesianData(),
229  static_cast<const ConicImp*>( conic2 )->cartesianData(),
230  -1, 1, valid);
231  if ( valid )
232  {
233  p1 = calcConicLineIntersect(
234  conic1->cartesianData(), l1, 0.0, -1 );
235  p2 = calcConicLineIntersect(
236  conic1->cartesianData(), l1, 0.0, 1 );
237  d1 = (p1-c).length();
238  d2 = (p2-c).length();
239  }
240  const LineData l2 = calcConicRadical(
241  static_cast<const ConicImp*>( conic1 )->cartesianData(),
242  static_cast<const ConicImp*>( conic2 )->cartesianData(),
243  1, 1, valid);
244  if ( valid )
245  {
246  p3 = calcConicLineIntersect(
247  conic1->cartesianData(), l2, 0.0, -1 );
248  p4 = calcConicLineIntersect(
249  conic1->cartesianData(), l2, 0.0, 1 );
250  d3 = (p3-c).length();
251  d4 = (p4-c).length();
252  }
253  double d12 = fmin( d1, d2 );
254  double d34 = fmin( d3, d4 );
255  // test which is the right point, by now just choose p1
256  int whichline = -1;
257  if ( d34 < d12 )
258  {
259  whichline = 1;
260  d1 = d3;
261  d2 = d4;
262  }
263  int whichpoint = -1;
264  if ( d2 < d1 ) whichpoint = 1;
265  args.push_back( os[0]->calcer() );
266  args.push_back( os[1]->calcer() );
267  args.push_back( new ObjectConstCalcer( new IntImp( whichline ) ) );
268  args.push_back( new ObjectConstCalcer( new IntImp( 1 ) ) );
269  ObjectTypeCalcer* radical =
270  new ObjectTypeCalcer( ConicRadicalType::instance(), args );
271  radical->calc( d );
272  args.clear();
273  args.push_back( os[0]->calcer() );
274  args.push_back( radical );
275  args.push_back( new ObjectConstCalcer( new IntImp( whichpoint ) ) );
276  return new ObjectTypeCalcer( ConicLineIntersectionType::instance(), args );
277  }
278  // other cases will follow...
279  }
280  for ( std::vector<ObjectHolder*>::iterator i = os.begin(); i != os.end(); ++i )
281  if ( (*i)->imp()->inherits( CurveImp::stype() ) )
282  return constrainedPointCalcer( (*i)->calcer(), c, d );
283  return fixedPointCalcer( c );
284 }
285 
286 ObjectHolder* ObjectFactory::sensiblePoint(
287  const Coordinate& c, const KigDocument& d, const KigWidget& w ) const
288 {
289  return new ObjectHolder( sensiblePointCalcer( c, d, w ) );
290 }
291 
292 ObjectTypeCalcer* ObjectFactory::relativePointCalcer(
293  ObjectCalcer* o, const Coordinate& loc ) const
294 {
295  Coordinate reference =
296  static_cast<const ObjectImp*>( o->imp() )->attachPoint();
297  assert( reference.valid() );
298 
299  double x = 0.0;
300  double y = 0.0;
301  if ( loc.valid() )
302  {
303  x = loc.x - reference.x;
304  y = loc.y - reference.y;
305  }
306  std::vector<ObjectCalcer*> parents;
307  parents.push_back( new ObjectConstCalcer( new DoubleImp( x ) ) );
308  parents.push_back( new ObjectConstCalcer( new DoubleImp( y ) ) );
309  parents.push_back( o );
310  return new ObjectTypeCalcer( RelativePointType::instance(), parents );
311 }
312 
313 ObjectTypeCalcer* ObjectFactory::constrainedPointCalcer(
314  ObjectCalcer* curve, double param ) const
315 {
316  assert( curve->imp()->inherits( CurveImp::stype() ) );
317  std::vector<ObjectCalcer*> parents;
318  parents.push_back( new ObjectConstCalcer( new DoubleImp( param ) ) );
319  parents.push_back( curve );
320  return new ObjectTypeCalcer( ConstrainedPointType::instance(), parents );
321 }
322 
323 ObjectHolder* ObjectFactory::constrainedPoint(
324  ObjectCalcer* curve, double param ) const
325 {
326  return new ObjectHolder( constrainedPointCalcer( curve, param ) );
327 }
328 
329 ObjectTypeCalcer* ObjectFactory::constrainedPointCalcer(
330  ObjectCalcer* curve, const Coordinate& c, const KigDocument& d ) const
331 {
332  assert( curve->imp()->inherits( CurveImp::stype() ) );
333  double param = static_cast<const CurveImp*>( curve->imp() )->getParam( c, d );
334  return constrainedPointCalcer( curve, param );
335 }
336 
337 ObjectHolder* ObjectFactory::constrainedPoint(
338  ObjectCalcer* curve, const Coordinate& c, const KigDocument& d ) const
339 {
340  return new ObjectHolder( constrainedPointCalcer( curve, c, d ) );
341 }
342 
343 ObjectTypeCalcer* ObjectFactory::constrainedRelativePointCalcer(
344  ObjectCalcer* curve, double param ) const
345 {
346  assert( curve->imp()->inherits( CurveImp::stype() ) );
347  std::vector<ObjectCalcer*> parents;
348  parents.push_back( new ObjectConstCalcer( new DoubleImp( 0.0 ) ) );
349  parents.push_back( new ObjectConstCalcer( new DoubleImp( 0.0 ) ) );
350  parents.push_back( new ObjectConstCalcer( new DoubleImp( param ) ) );
351  parents.push_back( curve );
352  return new ObjectTypeCalcer( ConstrainedRelativePointType::instance(), parents );
353 }
354 
355 ObjectTypeCalcer* ObjectFactory::locusCalcer(
356  ObjectCalcer* a, ObjectCalcer* b ) const
357 {
358  assert( dynamic_cast<const ObjectTypeCalcer*>( a ) );
359  ObjectTypeCalcer* constrained = static_cast<ObjectTypeCalcer*>( a );
360  assert( constrained->type()->inherits( ObjectType::ID_ConstrainedPointType ) );
361  assert( constrained->parents().size() == 2 );
362  ObjectCalcer* curve = a->parents().back();
363 
364  const ObjectCalcer* moving = b;
365 
366  std::vector<ObjectCalcer*> hierparents;
367  hierparents.push_back( constrained );
368  std::vector<ObjectCalcer*> sideOfTree = sideOfTreePath( hierparents, moving );
369  std::copy( sideOfTree.begin(), sideOfTree.end(), std::back_inserter( hierparents ) );
370 
371  ObjectHierarchy hier( hierparents, moving );
372 
373  std::vector<ObjectCalcer*> realparents( 2 + sideOfTree.size(), 0 );
374  realparents[0] = new ObjectConstCalcer( new HierarchyImp( hier ) );
375  realparents[1] = curve;
376  std::copy( sideOfTree.begin(), sideOfTree.end(), realparents.begin() + 2 );
377 
378  return new ObjectTypeCalcer( LocusType::instance(), realparents );
379 }
380 
381 ObjectHolder* ObjectFactory::locus( ObjectCalcer* a, ObjectCalcer* b ) const
382 {
383  return new ObjectHolder( locusCalcer( a, b ) );
384 }
385 
386 ObjectHolder* ObjectFactory::label(
387  const QString& s, const Coordinate& loc,
388  bool needframe, const std::vector<ObjectCalcer*>& parents,
389  const KigDocument& doc ) const
390 {
391  return new ObjectHolder( labelCalcer( s, loc, needframe, parents, doc ) );
392 }
393 
394 ObjectTypeCalcer* ObjectFactory::labelCalcer(
395  const QString& s, const Coordinate& loc,
396  bool needframe, const std::vector<ObjectCalcer*>& parents,
397  const KigDocument& doc ) const
398 {
399  return attachedLabelCalcer( s, 0, loc, needframe, parents, doc );
400 }
401 
402 ObjectTypeCalcer* ObjectFactory::attachedLabelCalcer(
403  const QString& s, ObjectCalcer* p,
404  const Coordinate& loc, bool needframe,
405  const std::vector<ObjectCalcer*>& nparents,
406  const KigDocument& doc ) const
407 {
408  std::vector<ObjectCalcer*> parents;
409  parents.reserve( nparents.size() + 3 );
410  parents.push_back( new ObjectConstCalcer( new IntImp( needframe ? 1 : 0 ) ) );
411 
412  parents.push_back( getAttachPoint( p, loc, doc ) );
413 
414  parents.push_back( new ObjectConstCalcer( new StringImp( s ) ) );
415  std::copy( nparents.begin(), nparents.end(), std::back_inserter( parents ) );
416  ObjectTypeCalcer* ret = new ObjectTypeCalcer( TextType::instance(), parents );
417  ret->calc( doc );
418  return ret;
419 }
420 
421 ObjectCalcer* ObjectFactory::getAttachPoint(
422  ObjectCalcer* p,
423  const Coordinate& loc,
424  const KigDocument& doc ) const
425 {
426 /*
427  * mp: (changes to add relative-attachment). Now an object is tested
428  * as follows:
429  * - if attachPoint() returns a valid coordinate, then we use the new method
430  * - if it is a point: 'old-style' treatment (we can change this shortly)
431  * - if it is a curve: use the new (nov 2009) ConstrainedRelativePoint
432  * similar to the RelativePoint
433  *
434  * the first condition that matches determines the behaviour.
435  * the new method works similarly to the curve case, but we generate a new
436  * RelativePointType instead of a ConstrainedPointType; this will in turn make use
437  * of the new attachPoint() method for objects.
438  *
439  * changed the preference order 2005/01/21 (now attachPoint has preference over points)
440  *
441  * NOTE: changes in the tests performed should be matched also in
442  * modes/popup.cc (addNameLabel) and in label.cc (TextLabelModeBase::mouseMoved)
443  */
444 
445  if ( p && p->imp()->attachPoint().valid() )
446  {
447  ObjectCalcer* o = relativePointCalcer( p, loc );
448  o->calc( doc );
449  return o;
450  }
451  else if ( p && p->imp()->inherits( PointImp::stype() ) )
452  {
453  return p;
454  }
455  else if ( p && p->imp()->inherits( CurveImp::stype() ) )
456  {
457  double param = 0.5;
458  if ( loc.valid() )
459  param = static_cast<const CurveImp*>( p->imp() )->getParam( loc, doc );
460 
461  ObjectCalcer* o = constrainedRelativePointCalcer( p, param );
462  o->calc( doc );
463  return o;
464  }
465  else
466  {
467  if ( loc.valid() )
468  return new ObjectConstCalcer( new PointImp( loc ) );
469  else
470  return new ObjectConstCalcer( new PointImp( Coordinate( 0, 0 ) ) );
471  }
472 }
473 
474 ObjectHolder* ObjectFactory::attachedLabel(
475  const QString& s, ObjectCalcer* locationparent,
476  const Coordinate& loc, bool needframe,
477  const std::vector<ObjectCalcer*>& parents,
478  const KigDocument& doc ) const
479 {
480  return new ObjectHolder( attachedLabelCalcer( s, locationparent, loc, needframe, parents, doc ) );
481 }
482 
483 ObjectPropertyCalcer* ObjectFactory::propertyObjectCalcer(
484  ObjectCalcer* o, const char* p ) const
485 {
486  int wp = o->imp()->propertiesInternalNames().indexOf( p );
487  if ( wp == -1 ) return 0;
488  return new ObjectPropertyCalcer( o, p );
489 }
490 
491 ObjectHolder* ObjectFactory::propertyObject(
492  ObjectCalcer* o, const char* p ) const
493 {
494  return new ObjectHolder( propertyObjectCalcer( o, p ) );
495 }
496 
497 void ObjectFactory::redefinePoint(
498  ObjectTypeCalcer* point, const Coordinate& c,
499  KigDocument& doc, const KigWidget& w ) const
500 {
501  std::vector<ObjectHolder*> hos = doc.whatAmIOn( c, w );
502  std::vector<ObjectCalcer*> os;
503  ObjectCalcer* (ObjectHolder::*calcmeth)() = &ObjectHolder::calcer;
504  std::transform( hos.begin(), hos.end(), std::back_inserter( os ),
505  std::mem_fun( calcmeth ) );
506  ObjectCalcer* v = 0;
507 
508  // we don't want one of our children as a parent...
509  std::set<ObjectCalcer*> children = getAllChildren( point );
510  for ( std::vector<ObjectCalcer*>::iterator i = os.begin();
511  i != os.end(); ++i )
512  if ( (*i)->imp()->inherits( CurveImp::stype() ) &&
513  children.find( *i ) == children.end() )
514  {
515  v = *i;
516  break;
517  };
518 
519  if ( v )
520  {
521  // we want a constrained point...
522  const CurveImp* curveimp = static_cast<const CurveImp*>( v->imp() );
523  double newparam = curveimp->getParam( c, doc );
524 
525  if ( point->type()->inherits( ObjectType::ID_ConstrainedPointType ) )
526  {
527  // point already was constrained -> simply update the param
528  // DataObject and make sure point is on the right curve...
529  ObjectCalcer* dataobj = 0;
530  std::vector<ObjectCalcer*> parents = point->parents();
531  assert( parents.size() == 2 );
532  assert ( parents[0]->imp()->inherits( DoubleImp::stype() ) );
533  dataobj = parents[0];
534 
535  parents.clear();
536  parents.push_back( dataobj );
537  parents.push_back( v );
538  point->setParents( parents );
539 
540  assert( dynamic_cast<ObjectConstCalcer*>( dataobj ) );
541  static_cast<ObjectConstCalcer*>( dataobj )->setImp(
542  new DoubleImp( newparam ) );
543  }
544  else
545  {
546  // point used to be fixed -> add a new DataObject etc.
547  std::vector<ObjectCalcer*> args;
548  args.push_back( new ObjectConstCalcer( new DoubleImp( newparam ) ) );
549  args.push_back( v );
550  point->setType( ConstrainedPointType::instance() );
551  point->setParents( args );
552  }
553  }
554  else
555  {
556  // a fixed point...
557  if ( point->type()->inherits( ObjectType::ID_ConstrainedPointType ) )
558  {
559  // point used to be constrained..
560  std::vector<ObjectCalcer*> a;
561  a.push_back( new ObjectConstCalcer( new DoubleImp( c.x ) ) );
562  a.push_back( new ObjectConstCalcer( new DoubleImp( c.y ) ) );
563 
564  point->setType( FixedPointType::instance() );
565  point->setParents( a );
566  }
567  else
568  {
569  // point used to be fixed -> simply update the DataObject's
570  // we can use the point's move function for that..
571  point->move( c, doc );
572  };
573  }
574 }
575 
object_factory.h
ObjectFactory::sensiblePoint
ObjectHolder * sensiblePoint(const Coordinate &c, const KigDocument &d, const KigWidget &w) const
Definition: object_factory.cc:286
ObjectFactory::instance
static const ObjectFactory * instance()
Definition: object_factory.cc:90
ObjectTypeCalcer::move
void move(const Coordinate &to, const KigDocument &doc)
This is the method that does the real moving work.
Definition: object_calcer.cc:296
AbstractLineImp::data
LineData data() const
Get the LineData for this AbstractLineImp.
Definition: line_imp.cc:359
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
ObjectHierarchy
Definition: object_hierarchy.h:30
point_imp.h
StringImp
This ObjectImp is a BogusImp containing only a string value.
Definition: bogus_imp.h:167
ObjectTypeCalcer::setParents
void setParents(const std::vector< ObjectCalcer * > np)
Set the parents of this ObjectTypeCalcer to np.
Definition: object_calcer.cc:246
ObjectType::inherits
virtual bool inherits(int type) const
Definition: object_type.cc:64
removeDuplicatedPoints
std::vector< ObjectCalcer * > removeDuplicatedPoints(std::vector< ObjectCalcer * > points)
Definition: special_constructors.cc:115
object_drawer.h
AbstractLineImp
An ObjectImp class that is the base of the line-like ObjectImp's: SegmentImp, LineImp and RayImp...
Definition: line_imp.h:31
LineData
Simple class representing a line.
Definition: misc/common.h:49
ObjectConstCalcer
This is an ObjectCalcer that keeps an ObjectImp, and never calculates a new one.
Definition: object_calcer.h:232
CircleCircleOtherIntersectionType::instance
static const CircleCircleOtherIntersectionType * instance()
Definition: intersection_types.cc:323
CircleImp
An ObjectImp representing a circle.
Definition: circle_imp.h:27
ObjectFactory::fixedPointCalcer
ObjectTypeCalcer * fixedPointCalcer(const Coordinate &c) const
Definition: object_factory.cc:50
DoubleImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the DoubleImp type.
Definition: bogus_imp.cc:270
CircleImp::center
const Coordinate center() const
Return the center of this circle.
Definition: circle_imp.cc:210
ObjectTypeCalcer::setType
void setType(const ObjectType *t)
Definition: object_calcer.cc:255
CircleCircleIntersectionType::instance
static const CircleCircleIntersectionType * instance()
Definition: intersection_types.cc:490
ObjectFactory::getAttachPoint
ObjectCalcer * getAttachPoint(ObjectCalcer *locationparent, const Coordinate &loc, const KigDocument &doc) const
this has been added because it comes handy when redefining a text label, we move here all the code fo...
Definition: object_factory.cc:421
ObjectFactory::locusCalcer
ObjectTypeCalcer * locusCalcer(ObjectCalcer *a, ObjectCalcer *b) const
return a locus, defined by the two points ( one constrained, and one following ) a and b ...
Definition: object_factory.cc:355
IntImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the IntImp type.
Definition: bogus_imp.cc:278
ObjectImp::propertiesInternalNames
virtual const QByteArrayList propertiesInternalNames() const
Definition: object_imp.cc:63
ObjectTypeCalcer
This is an ObjectCalcer that uses one of the various ObjectType's to calculate its ObjectImp...
Definition: object_calcer.h:183
FixedPointType::instance
static const FixedPointType * instance()
Definition: point_type.cc:309
IntImp
This ObjectImp is a BogusImp containing only an int value.
Definition: bogus_imp.h:128
RelativePointType::instance
static const RelativePointType * instance()
Definition: point_type.cc:320
point_type.h
Coordinate
The Coordinate class is the basic class representing a 2D location by its x and y components...
Definition: coordinate.h:33
ObjectFactory::propertyObject
ObjectHolder * propertyObject(ObjectCalcer *o, const char *p) const
Definition: object_factory.cc:491
ObjectFactory::labelCalcer
ObjectTypeCalcer * labelCalcer(const QString &s, const Coordinate &loc, bool needframe, const std::vector< ObjectCalcer * > &parents, const KigDocument &doc) const
Definition: object_factory.cc:394
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
ObjectFactory::label
ObjectHolder * label(const QString &s, const Coordinate &loc, bool needframe, const std::vector< ObjectCalcer * > &parents, const KigDocument &doc) const
returns a label with text s at point c .
Definition: object_factory.cc:386
LineLineIntersectionType::instance
static const LineLineIntersectionType * instance()
Definition: intersection_types.cc:374
ObjectFactory::redefinePoint
void redefinePoint(ObjectTypeCalcer *point, const Coordinate &c, KigDocument &d, const KigWidget &w) const
set point to what sensiblePoint would have returned.
Definition: object_factory.cc:497
calcCircleRadicalStartPoint
Coordinate calcCircleRadicalStartPoint(const Coordinate &ca, const Coordinate &cb, double sqra, double sqrb)
Definition: common.cpp:335
ObjectHolder
An ObjectHolder represents an object as it is known to the document.
Definition: object_holder.h:40
bogus_imp.h
ConstrainedRelativePointType::instance
static const ConstrainedRelativePointType * instance()
Definition: point_type.cc:566
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
ObjectFactory::attachedLabelCalcer
ObjectTypeCalcer * attachedLabelCalcer(const QString &s, ObjectCalcer *locationparent, const Coordinate &loc, bool needframe, const std::vector< ObjectCalcer * > &parents, const KigDocument &doc) const
this one does the same as the above, only that the new label is attached to locationparent if it is n...
Definition: object_factory.cc:402
ObjectFactory::fixedPoint
ObjectHolder * fixedPoint(const Coordinate &c) const
this returns a fixed point.
Definition: object_factory.cc:44
sideOfTreePath
std::vector< ObjectCalcer * > sideOfTreePath(const std::vector< ObjectCalcer * > &from, const ObjectCalcer *to)
This function returns all objects on the side of the path through the dependency tree from from down ...
Definition: calcpaths.cc:222
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
ObjectFactory::constrainedPointCalcer
ObjectTypeCalcer * constrainedPointCalcer(ObjectCalcer *curve, double param) const
Definition: object_factory.cc:313
ObjectFactory::constrainedPoint
ObjectHolder * constrainedPoint(ObjectCalcer *curve, double param) const
this returns a constrained point.
Definition: object_factory.cc:323
KigDocument::whatAmIOn
std::vector< ObjectHolder * > whatAmIOn(const Coordinate &p, const KigWidget &w) const
Return a vector of objects that contain the given point.
Definition: kig_document.cc:68
ObjectFactory::constrainedRelativePointCalcer
ObjectTypeCalcer * constrainedRelativePointCalcer(ObjectCalcer *curve, double param) const
Definition: object_factory.cc:343
ObjectCalcer::calc
virtual void calc(const KigDocument &)=0
Makes the ObjectCalcer recalculate its ObjectImp from its parents.
KigWidget
This class is the real widget showing the document.
Definition: kig_view.h:50
HierarchyImp
Definition: bogus_imp.h:203
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
other_type.h
ObjectFactory::propertyObjectCalcer
ObjectPropertyCalcer * propertyObjectCalcer(ObjectCalcer *o, const char *p) const
returns a property object for the property p of object o .
Definition: object_factory.cc:483
ObjectImp::attachPoint
virtual Coordinate attachPoint() const =0
Returns a reference point where to attach labels; when this returns an invalidCoord then the attachme...
ConicImp
An ObjectImp representing a conic.
Definition: conic_imp.h:39
ObjectFactory::cursorPointCalcer
ObjectTypeCalcer * cursorPointCalcer(const Coordinate &c) const
this returns a CursorPointType; this is used during special constructions (e.g.
Definition: object_factory.cc:81
CircleImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the CircleImp type.
Definition: circle_imp.cc:342
ObjectHolder::calcer
const ObjectCalcer * calcer() const
Definition: object_holder.cc:53
ObjectTypeCalcer::type
const ObjectType * type() const
Definition: object_calcer.cc:132
intersection_types.h
ObjectFactory::sensiblePointCalcer
ObjectTypeCalcer * sensiblePointCalcer(const Coordinate &c, const KigDocument &d, const KigWidget &w) const
this returns a "sensible point".
Definition: object_factory.cc:96
ObjectType::ID_ConstrainedPointType
Definition: object_type.h:41
PointImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing PointImp's.
Definition: point_imp.cc:159
LocusType::instance
static const LocusType * instance()
Definition: other_type.cc:148
line_imp.h
text_type.h
conic_types.h
ConicImp::cartesianData
virtual const ConicCartesianData cartesianData() const
Return the cartesian representation of this conic.
Definition: conic_imp.cc:285
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
ObjectFactory::attachedLabel
ObjectHolder * attachedLabel(const QString &s, ObjectCalcer *locationparent, const Coordinate &loc, bool needframe, const std::vector< ObjectCalcer * > &parents, const KigDocument &doc) const
Definition: object_factory.cc:474
ObjectFactory::numericValueCalcer
ObjectTypeCalcer * numericValueCalcer(const double value, const Coordinate &loc, const KigDocument &doc) const
Definition: object_factory.cc:65
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
DoubleImp
This ObjectImp is a BogusImp containing only a double value.
Definition: bogus_imp.h:89
KigDocument
KigDocument is the class holding the real data in a Kig document.
Definition: kig_document.h:36
AbstractLineImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the AbstractLineImp type.
Definition: line_imp.cc:520
ConicLineIntersectionType::instance
static const ConicLineIntersectionType * instance()
Definition: intersection_types.cc:54
ObjectCalcer::imp
virtual const ObjectImp * imp() const =0
Returns the ObjectImp of this ObjectCalcer.
ObjectTypeCalcer::parents
std::vector< ObjectCalcer * > parents() const
Returns the parent ObjectCalcer's of this ObjectCalcer.
Definition: object_calcer.cc:105
Coordinate::x
double x
X Component.
Definition: coordinate.h:126
ObjectTypeCalcer::calc
void calc(const KigDocument &doc)
Makes the ObjectCalcer recalculate its ObjectImp from its parents.
Definition: object_calcer.cc:32
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
ObjectFactory::relativePointCalcer
ObjectTypeCalcer * relativePointCalcer(ObjectCalcer *o, const Coordinate &loc) const
this returns a relative point (to an object).
Definition: object_factory.cc:292
object_holder.h
calcCircleLineIntersect
const Coordinate calcCircleLineIntersect(const Coordinate &c, const double sqr, const LineData &l, int side)
this calcs the intersection points of the circle with center c and radius sqrt( r )...
Definition: common.cpp:262
TextType::instance
static const TextType * instance()
Definition: text_type.cc:237
ObjectCalcer::parents
virtual std::vector< ObjectCalcer * > parents() const =0
Returns the parent ObjectCalcer's of this ObjectCalcer.
ConstrainedPointType::instance
static const ConstrainedPointType * instance()
Definition: point_type.cc:298
curve_imp.h
ObjectFactory::numericValue
ObjectHolder * numericValue(const double value, const Coordinate &loc, const KigDocument &doc) const
this returns a numeric label with the value value at the position loc .
Definition: object_factory.cc:59
CircleImp::squareRadius
double squareRadius() const
Return the square radius of this circle.
Definition: circle_imp.cc:225
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
NumericTextType::instance
static const NumericTextType * instance()
Definition: text_type.cc:288
ConicLineOtherIntersectionType::instance
static const ConicLineOtherIntersectionType * instance()
Definition: intersection_types.cc:118
CurveImp::getParam
virtual double getParam(const Coordinate &point, const KigDocument &) const
Definition: curve_imp.cc:149
ObjectFactory
Definition: object_factory.h:23
Coordinate::valid
bool valid() const
Return whether this is a valid Coordinate.
Definition: coordinate.cpp:176
CursorPointType::instance
static const CursorPointType * instance()
Definition: point_type.cc:109
CurveImp
This class represents a curve: something which is composed of points, like a line, a circle, a locus.
Definition: curve_imp.h:27
ObjectFactory::locus
ObjectHolder * locus(ObjectCalcer *a, ObjectCalcer *b) const
Definition: object_factory.cc:381
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:39 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