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

kig

  • sources
  • kde-4.14
  • kdeedu
  • kig
  • objects
special_imptypes.cc
Go to the documentation of this file.
1 // Copyright (C) 2005 Maurizio Paolini <paolini@dmf.unicatt.it>
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_imptypes.h"
19 #include "line_imp.h"
20 #include "other_imp.h"
21 #include "bogus_imp.h"
22 #include "text_imp.h"
23 #include "circle_imp.h"
24 
25 static char snbs[] = "SHOULD NOT BE SEEN";
26 
27 double getDoubleFromImp( const ObjectImp* obj, bool& valid )
28 {
29  valid = true;
30 
31  if ( obj->inherits( SegmentImp::stype() ) )
32  return static_cast<const SegmentImp*>( obj )->length();
33 
34  if ( obj->inherits( ArcImp::stype() ) )
35  {
36  const ArcImp* arc = static_cast<const ArcImp*>( obj );
37  return arc->radius()*arc->angle();
38  }
39 
40  if ( obj->inherits( AngleImp::stype() ) )
41  return static_cast<const AngleImp*>( obj )->size();
42 
43  if ( obj->inherits( DoubleImp::stype() ) )
44  return static_cast<const DoubleImp*>( obj )->data();
45 
46  if ( obj->inherits( NumericTextImp::stype() ) )
47  return static_cast<const NumericTextImp*>( obj )->getValue();
48 
49  valid = false;
50  return 0;
51 }
52 
53 LengthImpType::LengthImpType( const ObjectImpType* parent,
54  const char* internalname )
55  : ObjectImpType( parent, internalname, snbs, snbs,
56  snbs, snbs, snbs, snbs, snbs, snbs, snbs )
57 {
58 }
59 
60 LengthImpType::~LengthImpType()
61 {
62 }
63 
64 bool LengthImpType::match( const ObjectImpType* t ) const
65 {
66  return t == this || t == SegmentImp::stype() || t == ArcImp::stype()
67  || t == NumericTextImp::stype() || t == DoubleImp::stype();
68 }
69 
70 LengthImpType lengthimptypeinstance(
71  ObjectImp::stype(), "length-object" );
72 
73 AngleImpType::AngleImpType( const ObjectImpType* parent,
74  const char* internalname )
75  : ObjectImpType( parent, internalname, snbs, snbs,
76  snbs, snbs, snbs, snbs, snbs, snbs, snbs )
77 {
78 }
79 
80 AngleImpType::~AngleImpType()
81 {
82 }
83 
84 bool AngleImpType::match( const ObjectImpType* t ) const
85 {
86  return t == this || t == AngleImp::stype() || t == NumericTextImp::stype();
87 }
88 
89 AngleImpType angleimptypeinstance(
90  ObjectImp::stype(), "angle-object" );
91 
92 WeightImpType::WeightImpType( const ObjectImpType* parent,
93  const char* internalname )
94  : ObjectImpType( parent, internalname, snbs, snbs,
95  snbs, snbs, snbs, snbs, snbs, snbs, snbs )
96 {
97 }
98 
99 WeightImpType::~WeightImpType()
100 {
101 }
102 
103 bool WeightImpType::match( const ObjectImpType* t ) const
104 {
105  return t == this || t == SegmentImp::stype() || t == ArcImp::stype()
106  || t == NumericTextImp::stype() || t == DoubleImp::stype();
107 }
108 
109 WeightImpType weightimptypeinstance(
110  ObjectImp::stype(), "weight-object" );
111 
112 InvertibleImpType::InvertibleImpType( const ObjectImpType* parent,
113  const char* internalname )
114  : ObjectImpType( parent, internalname, snbs, snbs,
115  snbs, snbs, snbs, snbs, snbs, snbs, snbs )
116 {
117 }
118 
119 InvertibleImpType::~InvertibleImpType()
120 {
121 }
122 
123 bool InvertibleImpType::match( const ObjectImpType* t ) const
124 {
125  return t == this || t == LineImp::stype() || t == RayImp::stype() ||
126  t == SegmentImp::stype() || t == CircleImp::stype() ||
127  t == ArcImp::stype();
128 }
129 
130 InvertibleImpType invertibleimptypeinstance(
131  ObjectImp::stype(), "invertible-object" );
AngleImpType::match
virtual bool match(const ObjectImpType *t) const
Definition: special_imptypes.cc:84
WeightImpType::WeightImpType
WeightImpType(const ObjectImpType *parent, const char *internalname)
Definition: special_imptypes.cc:92
ObjectImpType
Instances of this class represent a certain ObjectImp type.
Definition: object_imp.h:95
WeightImpType::match
virtual bool match(const ObjectImpType *t) const
Definition: special_imptypes.cc:103
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
angleimptypeinstance
AngleImpType angleimptypeinstance(ObjectImp::stype(),"angle-object")
lengthimptypeinstance
LengthImpType lengthimptypeinstance(ObjectImp::stype(),"length-object")
AngleImpType::AngleImpType
AngleImpType(const ObjectImpType *parent, const char *internalname)
Definition: special_imptypes.cc:73
invertibleimptypeinstance
InvertibleImpType invertibleimptypeinstance(ObjectImp::stype(),"invertible-object")
text_imp.h
DoubleImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the DoubleImp type.
Definition: bogus_imp.cc:270
LengthImpType::match
virtual bool match(const ObjectImpType *t) const
Definition: special_imptypes.cc:64
special_imptypes.h
RayImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the RayImp type.
Definition: line_imp.cc:562
InvertibleImpType::~InvertibleImpType
~InvertibleImpType()
Definition: special_imptypes.cc:119
circle_imp.h
InvertibleImpType::InvertibleImpType
InvertibleImpType(const ObjectImpType *parent, const char *internalname)
Definition: special_imptypes.cc:112
LengthImpType
Definition: special_imptypes.h:45
ObjectImp::stype
static const ObjectImpType * stype()
The ObjectImpType representing the base ObjectImp class.
Definition: object_imp.cc:284
LineImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the LineImp type.
Definition: line_imp.cc:528
ArcImp::radius
double radius() const
Return the radius of this arc.
Definition: other_imp.cc:537
InvertibleImpType::match
virtual bool match(const ObjectImpType *t) const
Definition: special_imptypes.cc:123
LengthImpType::~LengthImpType
~LengthImpType()
Definition: special_imptypes.cc:60
InvertibleImpType
Definition: special_imptypes.h:90
ArcImp::angle
double angle() const
Return the dimension in radians of this arc.
Definition: other_imp.cc:547
LengthImpType::LengthImpType
LengthImpType(const ObjectImpType *parent, const char *internalname)
Definition: special_imptypes.cc:53
bogus_imp.h
SegmentImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the SegmentImp type.
Definition: line_imp.cc:545
ArcImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the ArcImp type.
Definition: other_imp.cc:629
CircleImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the CircleImp type.
Definition: circle_imp.cc:342
AngleImpType::~AngleImpType
~AngleImpType()
Definition: special_imptypes.cc:80
line_imp.h
snbs
static char snbs[]
Definition: special_imptypes.cc:25
AngleImpType
Definition: special_imptypes.h:56
AngleImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the AngleImp type.
Definition: other_imp.cc:597
WeightImpType::~WeightImpType
~WeightImpType()
Definition: special_imptypes.cc:99
NumericTextImp::stype
static const ObjectImpType * stype()
Definition: text_imp.cc:189
ArcImp
An ObjectImp representing an arc.
Definition: other_imp.h:169
getDoubleFromImp
double getDoubleFromImp(const ObjectImp *obj, bool &valid)
Definition: special_imptypes.cc:27
ObjectImp
The ObjectImp class represents the behaviour of an object after it is calculated. ...
Definition: object_imp.h:226
WeightImpType
Definition: special_imptypes.h:67
weightimptypeinstance
WeightImpType weightimptypeinstance(ObjectImp::stype(),"weight-object")
other_imp.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:12:05 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kig

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

kdeedu API Reference

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

Search



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

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