• 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_imp.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_imp.h"
19 
20 #include "bogus_imp.h"
21 
22 #include "../misc/coordinate.h"
23 
24 #include <klocale.h>
25 #include <map>
26 
27 class ObjectImpType::StaticPrivate
28 {
29 public:
30  std::map<QByteArray, const ObjectImpType*> namemap;
31 };
32 
33 ObjectImp::ObjectImp()
34 {
35 }
36 
37 ObjectImp::~ObjectImp()
38 {
39 }
40 
41 bool ObjectImp::valid() const
42 {
43  return ! type()->inherits( InvalidImp::stype() );
44 }
45 
46 void ObjectImp::fillInNextEscape( QString&, const KigDocument& ) const
47 {
48  assert( false );
49 }
50 
51 const QByteArrayList ObjectImp::properties() const
52 {
53  QByteArrayList ret;
54  ret << I18N_NOOP( "Object Type" );
55  return ret;
56 }
57 
58 int ObjectImp::numberOfProperties() const
59 {
60  return 1;
61 }
62 
63 const QByteArrayList ObjectImp::propertiesInternalNames() const
64 {
65  QByteArrayList ret;
66  ret << "base-object-type";
67  return ret;
68 }
69 
70 ObjectImp* ObjectImp::property( int i, const KigDocument& ) const
71 {
72  if ( i == 0 ) return new StringImp( type()->translatedName() );
73  return new InvalidImp;
74 }
75 
76 const ObjectImpType* ObjectImp::impRequirementForProperty( int ) const
77 {
78  return ObjectImp::stype();
79 }
80 
81 void ObjectImpVisitor::visit( const ObjectImp* imp )
82 {
83  imp->visit( this );
84 }
85 
86 void ObjectImpVisitor::visit( const IntImp* )
87 {
88 }
89 
90 void ObjectImpVisitor::visit( const DoubleImp* )
91 {
92 }
93 
94 void ObjectImpVisitor::visit( const StringImp* )
95 {
96 }
97 
98 void ObjectImpVisitor::visit( const InvalidImp* )
99 {
100 }
101 
102 void ObjectImpVisitor::visit( const HierarchyImp* )
103 {
104 }
105 
106 void ObjectImpVisitor::visit( const LineImp* )
107 {
108 }
109 
110 void ObjectImpVisitor::visit( const PointImp* )
111 {
112 }
113 
114 void ObjectImpVisitor::visit( const TextImp* )
115 {
116 }
117 
118 void ObjectImpVisitor::visit( const AngleImp* )
119 {
120 }
121 
122 void ObjectImpVisitor::visit( const VectorImp* )
123 {
124 }
125 
126 void ObjectImpVisitor::visit( const LocusImp* )
127 {
128 }
129 
130 void ObjectImpVisitor::visit( const CircleImp* )
131 {
132 }
133 
134 void ObjectImpVisitor::visit( const ConicImp* )
135 {
136 }
137 
138 void ObjectImpVisitor::visit( const CubicImp* )
139 {
140 }
141 
142 void ObjectImpVisitor::visit( const SegmentImp* )
143 {
144 }
145 
146 void ObjectImpVisitor::visit( const RayImp* )
147 {
148 }
149 
150 void ObjectImpVisitor::visit( const ArcImp* )
151 {
152 }
153 
154 void ObjectImpVisitor::visit( const FilledPolygonImp* )
155 {
156 }
157 
158 void ObjectImpVisitor::visit( const ClosedPolygonalImp* )
159 {
160 }
161 
162 void ObjectImpVisitor::visit( const OpenPolygonalImp* )
163 {
164 }
165 
166 void ObjectImpVisitor::visit( const BezierImp* )
167 {
168 }
169 
170 void ObjectImpVisitor::visit( const RationalBezierImp* )
171 {
172 }
173 
174 ObjectImpVisitor::~ObjectImpVisitor()
175 {
176 
177 }
178 
179 void ObjectImpVisitor::visit( const TransformationImp* )
180 {
181 }
182 
183 void ObjectImpVisitor::visit( const TestResultImp* )
184 {
185 }
186 
187 const char* ObjectImp::iconForProperty( int ) const
188 {
189  return "kig_text";
190 }
191 
192 bool ObjectImp::canFillInNextEscape() const
193 {
194  return false;
195 }
196 
197 ObjectImpType::ObjectImpType( const ObjectImpType* parent,
198  const char* internalname,
199  const char* translatedname,
200  const char* selectstatement,
201  const char* selectnamestatement,
202  const char* removeastatement,
203  const char* addastatement,
204  const char* moveastatement,
205  const char* attachtothisstatement,
206  const char* showastatement,
207  const char* hideastatement )
208  : mparent( parent ), minternalname( internalname ),
209  mtranslatedname( translatedname ), mselectstatement( selectstatement ),
210  mselectnamestatement( selectnamestatement ),
211  mremoveastatement( removeastatement ), maddastatement( addastatement ),
212  mmoveastatement( moveastatement ),
213  mattachtothisstatement( attachtothisstatement ),
214  mshowastatement( showastatement ),
215  mhideastatement( hideastatement )
216 {
217  sd()->namemap[minternalname] = this;
218 }
219 
220 ObjectImpType::~ObjectImpType()
221 {
222 }
223 
224 bool ObjectImpType::inherits( const ObjectImpType* t ) const
225 {
226 // return t == this || (mparent && mparent->inherits( t ) );
227  return t->match( this ) || (mparent && mparent->inherits( t ) );
228 }
229 
230 bool ObjectImpType::match( const ObjectImpType* t ) const
231 {
232  return t == this;
233 }
234 
235 const char* ObjectImpType::internalName() const
236 {
237  return minternalname;
238 }
239 
240 QString ObjectImpType::translatedName() const
241 {
242  return i18n( mtranslatedname );
243 }
244 
245 const char* ObjectImpType::selectStatement() const
246 {
247  return mselectstatement;
248 }
249 
250 const char* ObjectImpType::selectNameStatement() const
251 {
252  return mselectnamestatement;
253 }
254 
255 QString ObjectImpType::removeAStatement() const
256 {
257  return i18n( mremoveastatement );
258 }
259 
260 QString ObjectImpType::addAStatement() const
261 {
262  return i18n( maddastatement );
263 }
264 
265 QString ObjectImpType::moveAStatement() const
266 {
267  return i18n( mmoveastatement );
268 }
269 
270 const ObjectImpType* ObjectImpType::typeFromInternalName( const char* string )
271 {
272  QByteArray s( string );
273  std::map<QByteArray, const ObjectImpType*>::iterator i = sd()->namemap.find( s );
274  if ( i == sd()->namemap.end() )
275  return 0;
276  else return i->second;
277 }
278 
279 bool ObjectImp::inherits( const ObjectImpType* t ) const
280 {
281  return type()->inherits( t );
282 }
283 
284 const ObjectImpType* ObjectImp::stype()
285 {
286  static const ObjectImpType t(
287  0, "any",
288  I18N_NOOP( "Object" ),
289  I18N_NOOP( "Select this object" ),
290  I18N_NOOP( "Select object %1" ),
291  I18N_NOOP( "Remove an object" ),
292  I18N_NOOP( "Add an object" ),
293  I18N_NOOP( "Move an object" ),
294  I18N_NOOP( "Attach to this object" ),
295  I18N_NOOP( "Show an object" ),
296  I18N_NOOP( "Hide an object" ) );
297  return &t;
298 }
299 
300 ObjectImpType::StaticPrivate* ObjectImpType::sd()
301 {
302  static StaticPrivate d;
303  return &d;
304 }
305 
306 bool ObjectImp::isCache() const
307 {
308  return false;
309 }
310 
311 QString ObjectImpType::attachToThisStatement() const
312 {
313  return i18n( mattachtothisstatement );
314 }
315 
316 QString ObjectImpType::showAStatement() const
317 {
318  return i18n( mshowastatement );
319 }
320 
321 QString ObjectImpType::hideAStatement() const
322 {
323  return i18n( mhideastatement );
324 }
325 
326 bool ObjectImp::isPropertyDefinedOnOrThroughThisImp( int ) const
327 {
328  return false;
329 }
330 
331 static QByteArrayList propertiesGlobalInternalNames;
332 
333 int ObjectImp::getPropGid( const char* pname ) const
334 {
335  int wp = propertiesGlobalInternalNames.indexOf( pname );
336  if ( wp >= 0 ) return wp;
337 
338  int lp = propertiesInternalNames().indexOf( pname );
339  if ( lp < 0 ) return lp; // insist that this exists as a property
340 
341  propertiesGlobalInternalNames << pname;
342  wp = propertiesGlobalInternalNames.indexOf( pname );
343  assert( wp >= 0 );
344  return wp;
345 }
346 
347 int ObjectImp::getPropLid( int propgid ) const
348 {
349  assert( propgid >= 0 && propgid < propertiesGlobalInternalNames.size() );
350  int proplid = propertiesInternalNames().indexOf(
351  propertiesGlobalInternalNames[propgid] );
352 // printf ("getPropLid: converting %d in %d\n", propgid, proplid);
353  return proplid;
354 }
355 
356 const char* ObjectImp::getPropName( int propgid ) const
357 {
358  assert( propgid >= 0 && propgid < propertiesGlobalInternalNames.size() );
359  return propertiesGlobalInternalNames[propgid];
360 }
object_imp.h
ClosedPolygonalImp
An ObjectImp representing a closed polygonal.
Definition: polygon_imp.h:130
BezierImp
An ObjectImp representing polynomial Bézier Curve.
Definition: bezier_imp.h:31
ObjectImpVisitor::~ObjectImpVisitor
virtual ~ObjectImpVisitor()
Definition: object_imp.cc:174
CubicImp
An ObjectImp representing a cubic.
Definition: cubic_imp.h:29
LocusImp
LocusImp is an imp that consists of a copy of the curveimp that the moving point moves over...
Definition: locus_imp.h:57
ObjectImpType
Instances of this class represent a certain ObjectImp type.
Definition: object_imp.h:95
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
StringImp
This ObjectImp is a BogusImp containing only a string value.
Definition: bogus_imp.h:167
OpenPolygonalImp
An ObjectImp representing an open polygonal.
Definition: polygon_imp.h:157
ObjectImpType::match
virtual bool match(const ObjectImpType *t) const
Definition: object_imp.cc:230
ObjectImp::~ObjectImp
virtual ~ObjectImp()
Definition: object_imp.cc:37
ObjectImpVisitor::visit
void visit(const ObjectImp *imp)
Definition: object_imp.cc:81
CircleImp
An ObjectImp representing a circle.
Definition: circle_imp.h:27
ObjectImp::impRequirementForProperty
virtual const ObjectImpType * impRequirementForProperty(int which) const
Definition: object_imp.cc:76
ObjectImp::visit
virtual void visit(ObjectImpVisitor *vtor) const =0
TextImp
Definition: text_imp.h:26
ObjectImp::property
virtual ObjectImp * property(int which, const KigDocument &d) const
Definition: object_imp.cc:70
ObjectImpType::internalName
const char * internalName() const
Returns an internal name for this ObjectImp type.
Definition: object_imp.cc:235
RayImp
An ObjectImp representing a ray.
Definition: line_imp.h:136
ObjectImp::getPropLid
int getPropLid(int propgid) const
mp: The following three methods (getPropLid, getPropGid, getPropName) deal with the properties of Obj...
Definition: object_imp.cc:347
RationalBezierImp
An ObjectImp representing a rational Bézier curve.
Definition: bezier_imp.h:100
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
propertiesGlobalInternalNames
static QByteArrayList propertiesGlobalInternalNames
Definition: object_imp.cc:331
ObjectImp::propertiesInternalNames
virtual const QByteArrayList propertiesInternalNames() const
Definition: object_imp.cc:63
ObjectImp::stype
static const ObjectImpType * stype()
The ObjectImpType representing the base ObjectImp class.
Definition: object_imp.cc:284
IntImp
This ObjectImp is a BogusImp containing only an int value.
Definition: bogus_imp.h:128
VectorImp
An ObjectImp representing a vector.
Definition: other_imp.h:99
ObjectImp::canFillInNextEscape
virtual bool canFillInNextEscape() const
Definition: object_imp.cc:192
ObjectImp::type
virtual const ObjectImpType * type() const =0
Returns the lowermost ObjectImpType that this object is an instantiation of.
ObjectImp::iconForProperty
virtual const char * iconForProperty(int which) const
Definition: object_imp.cc:187
ObjectImpType::translatedName
QString translatedName() const
The name of this type, translated to the currently used language.
Definition: object_imp.cc:240
bogus_imp.h
ObjectImpType::selectStatement
const char * selectStatement() const
Returns a translatable string of the form "Select this %1".
Definition: object_imp.cc:245
PointImp
An ObjectImp representing a point.
Definition: point_imp.h:27
ObjectImpType::selectNameStatement
const char * selectNameStatement() const
Returns a translatable string of the form "Select point %1".
Definition: object_imp.cc:250
ObjectImpType::moveAStatement
QString moveAStatement() const
Returns a translated string of the form "Move a xxx".
Definition: object_imp.cc:265
ObjectImpType::hideAStatement
QString hideAStatement() const
Returns a translated string of the form "Hide a xxx".
Definition: object_imp.cc:321
TransformationImp
Definition: bogus_imp.h:232
HierarchyImp
Definition: bogus_imp.h:203
ObjectImp::isPropertyDefinedOnOrThroughThisImp
virtual bool isPropertyDefinedOnOrThroughThisImp(int which) const
Definition: object_imp.cc:326
ConicImp
An ObjectImp representing a conic.
Definition: conic_imp.h:39
ObjectImpType::typeFromInternalName
static const ObjectImpType * typeFromInternalName(const char *n)
Returns the type with name n.
Definition: object_imp.cc:270
InvalidImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the InvalidImp type.
Definition: bogus_imp.cc:213
ObjectImp::getPropName
const char * getPropName(int propgid) const
Definition: object_imp.cc:356
ObjectImpType::removeAStatement
QString removeAStatement() const
Returns a translated string of the form "Remove a xxx".
Definition: object_imp.cc:255
ObjectImp::ObjectImp
ObjectImp()
Definition: object_imp.cc:33
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
LineImp
An ObjectImp representing a line.
Definition: line_imp.h:184
ArcImp
An ObjectImp representing an arc.
Definition: other_imp.h:169
ObjectImpType::~ObjectImpType
virtual ~ObjectImpType()
Definition: object_imp.cc:220
QByteArrayList
QList< QByteArray > QByteArrayList
Definition: objects/common.h:50
ObjectImp
The ObjectImp class represents the behaviour of an object after it is calculated. ...
Definition: object_imp.h:226
ObjectImpType::attachToThisStatement
QString attachToThisStatement() const
Returns a translated string of the form "Attach to this xxx".
Definition: object_imp.cc:311
ObjectImp::valid
bool valid() const
Returns true if this is a valid ObjectImp.
Definition: object_imp.cc:41
ObjectImp::isCache
virtual bool isCache() const
Definition: object_imp.cc:306
ObjectImpType::ObjectImpType
ObjectImpType(const ObjectImpType *parent, const char *internalname, const char *translatedname, const char *selectstatement, const char *selectnamestatement, const char *removeastatement, const char *addastatement, const char *moveastatement, const char *attachtothisstatement, const char *showastatement, const char *hideastatement)
Definition: object_imp.cc:197
ObjectImpType::addAStatement
QString addAStatement() const
Returns a translated string of the form "Add a xxx".
Definition: object_imp.cc:260
FilledPolygonImp
An ObjectImp representing a filled polygon.
Definition: polygon_imp.h:101
ObjectImp::fillInNextEscape
virtual void fillInNextEscape(QString &s, const KigDocument &) const
Definition: object_imp.cc:46
ObjectImpType::showAStatement
QString showAStatement() const
Returns a translated string of the form "Show a xxx".
Definition: object_imp.cc:316
TestResultImp
Definition: bogus_imp.h:253
ObjectImp::numberOfProperties
virtual int numberOfProperties() const
Definition: object_imp.cc:58
ObjectImp::getPropGid
int getPropGid(const char *pname) const
Definition: object_imp.cc:333
ObjectImp::properties
virtual const QByteArrayList properties() const
Definition: object_imp.cc:51
InvalidImp
This ObjectImp represents an invalid object.
Definition: bogus_imp.h:61
AngleImp
An ObjectImp representing an angle.
Definition: other_imp.h:28
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: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