• 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
point_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 "point_imp.h"
19 
20 #include "bogus_imp.h"
21 #include "../misc/kigtransform.h"
22 #include "../misc/kigpainter.h"
23 #include "../misc/coordinate_system.h"
24 #include "../kig/kig_document.h"
25 #include "../kig/kig_view.h"
26 
27 #include <klocale.h>
28 
29 PointImp::PointImp( const Coordinate& c )
30  : mc( c )
31 {
32 }
33 
34 Coordinate PointImp::attachPoint() const
35 {
36  return mc;
37 // return Coordinate::invalidCoord();
38 }
39 
40 void PointImp::draw( KigPainter& p ) const
41 {
42  p.drawFatPoint( mc );
43 }
44 
45 bool PointImp::contains( const Coordinate& p, int width, const KigWidget& w ) const
46 {
47  int twidth = width == -1 ? 5 : width;
48  return (p - mc).length() - twidth*w.screenInfo().pixelWidth() < 0;
49 }
50 
51 bool PointImp::inRect( const Rect& r, int width, const KigWidget& w ) const
52 {
53  double am = w.screenInfo().normalMiss( width );
54  return r.contains( mc, am );
55 }
56 
57 int PointImp::numberOfProperties() const
58 {
59  return Parent::numberOfProperties() + 3;
60 }
61 
62 const QByteArrayList PointImp::propertiesInternalNames() const
63 {
64  QByteArrayList l = Parent::propertiesInternalNames();
65  l << "coordinate";
66  l << "coordinate-x";
67  l << "coordinate-y";
68  assert( l.size() == PointImp::numberOfProperties() );
69  return l;
70 }
71 
72 const QByteArrayList PointImp::properties() const
73 {
74  QByteArrayList l = Parent::properties();
75  l << I18N_NOOP( "Coordinate" );
76  l << I18N_NOOP( "X coordinate" );
77  l << I18N_NOOP( "Y coordinate" );
78  assert( l.size() == PointImp::numberOfProperties() );
79  return l;
80 }
81 
82 const ObjectImpType* PointImp::impRequirementForProperty( int which ) const
83 {
84  if ( which < Parent::numberOfProperties() )
85  return Parent::impRequirementForProperty( which );
86  else return PointImp::stype();
87 }
88 
89 const char* PointImp::iconForProperty( int which ) const
90 {
91  if ( which < Parent::numberOfProperties() )
92  return Parent::iconForProperty( which );
93  if ( which == Parent::numberOfProperties() )
94  return "pointxy"; // coordinate
95  if ( which == Parent::numberOfProperties() + 1 )
96  return "pointxy"; // coordinate-x
97  if ( which == Parent::numberOfProperties() + 2 )
98  return "pointxy"; // coordinate-y
99  else assert( false );
100  return "";
101 }
102 
103 ObjectImp* PointImp::property( int which, const KigDocument& d ) const
104 {
105  if ( which < Parent::numberOfProperties() )
106  return Parent::property( which, d );
107  if ( which == Parent::numberOfProperties() )
108  return new PointImp( mc );
109  if ( which == Parent::numberOfProperties() + 1 )
110  return new DoubleImp( mc.x );
111  if ( which == Parent::numberOfProperties() + 2 )
112  return new DoubleImp( mc.y );
113 // else assert( false );
114  return new InvalidImp;
115 }
116 
117 PointImp::~PointImp()
118 {
119 }
120 
121 PointImp* PointImp::copy() const
122 {
123  return new PointImp( mc );
124 }
125 
126 ObjectImp* PointImp::transform( const Transformation& t ) const
127 {
128  Coordinate nc = t.apply( mc );
129  if ( nc.valid() ) return new PointImp( nc );
130  else return new InvalidImp();
131 }
132 
133 void PointImp::setCoordinate( const Coordinate& c )
134 {
135  mc = c;
136 }
137 
138 void PointImp::fillInNextEscape( QString& s, const KigDocument& doc ) const
139 {
140  s = s.arg( doc.coordinateSystem().fromScreen( mc, doc ) );
141 }
142 
143 void PointImp::visit( ObjectImpVisitor* vtor ) const
144 {
145  vtor->visit( this );
146 }
147 
148 bool PointImp::equals( const ObjectImp& rhs ) const
149 {
150  return rhs.inherits( PointImp::stype() ) &&
151  static_cast<const PointImp&>( rhs ).coordinate() == coordinate();
152 }
153 
154 bool PointImp::canFillInNextEscape() const
155 {
156  return true;
157 }
158 
159 const ObjectImpType* PointImp::stype()
160 {
161  static const ObjectImpType t(
162  Parent::stype(), "point",
163  I18N_NOOP( "point" ),
164  I18N_NOOP( "Select this point" ),
165  I18N_NOOP( "Select point %1" ),
166  I18N_NOOP( "Remove a Point" ),
167  I18N_NOOP( "Add a Point" ),
168  I18N_NOOP( "Move a Point" ),
169  I18N_NOOP( "Attach to this point" ),
170  I18N_NOOP( "Show a Point" ),
171  I18N_NOOP( "Hide a Point" )
172  );
173  return &t;
174 }
175 
176 const ObjectImpType* PointImp::type() const
177 {
178  return PointImp::stype();
179 }
180 
181 bool PointImp::isPropertyDefinedOnOrThroughThisImp( int which ) const
182 {
183  return Parent::isPropertyDefinedOnOrThroughThisImp( which );
184 }
185 
186 Rect PointImp::surroundingRect() const
187 {
188  return Rect( mc, 0., 0. );
189 }
190 
191 /*
192  */
193 
194 BogusPointImp::BogusPointImp( const Coordinate& c )
195  : PointImp( c )
196 {
197 }
198 
199 BogusPointImp::~BogusPointImp()
200 {
201 }
202 
203 const ObjectImpType* BogusPointImp::stype()
204 {
205  static const ObjectImpType t(
206  0, "boguspoint",
207  "SHOULDNOTBESEEN",
208  "SHOULDNOTBESEEN",
209  "SHOULDNOTBESEEN",
210  "SHOULDNOTBESEEN",
211  "SHOULDNOTBESEEN",
212  "SHOULDNOTBESEEN",
213  "SHOULDNOTBESEEN",
214  "SHOULDNOTBESEEN",
215  "SHOULDNOTBESEEN"
216  );
217  return &t;
218 }
219 
220 const ObjectImpType* BogusPointImp::type() const
221 {
222  return BogusPointImp::stype();
223 }
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
PointImp::iconForProperty
const char * iconForProperty(int which) const
Definition: point_imp.cc:89
point_imp.h
PointImp::isPropertyDefinedOnOrThroughThisImp
bool isPropertyDefinedOnOrThroughThisImp(int which) const
Definition: point_imp.cc:181
PointImp::~PointImp
~PointImp()
Definition: point_imp.cc:117
ScreenInfo::normalMiss
double normalMiss(int width) const
Definition: screeninfo.cc:88
PointImp::equals
bool equals(const ObjectImp &rhs) const
Returns true if this ObjectImp is equal to rhs.
Definition: point_imp.cc:148
PointImp::property
ObjectImp * property(int which, const KigDocument &d) const
Definition: point_imp.cc:103
PointImp::attachPoint
Coordinate attachPoint() const
Returns a reference point where to attach labels; when this returns an invalidCoord then the attachme...
Definition: point_imp.cc:34
ObjectImpVisitor::visit
void visit(const ObjectImp *imp)
Definition: object_imp.cc:81
BogusPointImp::stype
static const ObjectImpType * stype()
Definition: point_imp.cc:203
PointImp::propertiesInternalNames
const QByteArrayList propertiesInternalNames() const
Definition: point_imp.cc:62
ObjectImp::impRequirementForProperty
virtual const ObjectImpType * impRequirementForProperty(int which) const
Definition: object_imp.cc:76
ObjectImp::property
virtual ObjectImp * property(int which, const KigDocument &d) const
Definition: object_imp.cc:70
Rect
This file is part of Kig, a KDE program for Interactive Geometry...
Definition: rect.h:34
KigPainter::drawFatPoint
void drawFatPoint(const Coordinate &p)
draw a thick point.
Definition: kigpainter.cpp:101
PointImp::PointImp
PointImp(const Coordinate &c)
Construct a PointImp with coordinate c.
Definition: point_imp.cc:29
CoordinateSystem::fromScreen
virtual QString fromScreen(const Coordinate &pt, const KigDocument &w) const =0
PointImp::surroundingRect
Rect surroundingRect() const
Definition: point_imp.cc:186
PointImp::coordinate
const Coordinate & coordinate() const
Get the coordinate of this PointImp.
Definition: point_imp.h:50
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
PointImp::impRequirementForProperty
const ObjectImpType * impRequirementForProperty(int which) const
Definition: point_imp.cc:82
Coordinate
The Coordinate class is the basic class representing a 2D location by its x and y components...
Definition: coordinate.h:33
PointImp::setCoordinate
void setCoordinate(const Coordinate &c)
Set the coordinate of this PointImp.
Definition: point_imp.cc:133
KigWidget::screenInfo
const ScreenInfo & screenInfo() const
the part of the document we're currently showing i.e.
Definition: kig_view.cpp:272
BogusPointImp::~BogusPointImp
~BogusPointImp()
Definition: point_imp.cc:199
ObjectImp::iconForProperty
virtual const char * iconForProperty(int which) const
Definition: object_imp.cc:187
PointImp::fillInNextEscape
void fillInNextEscape(QString &s, const KigDocument &) const
Definition: point_imp.cc:138
Rect::contains
bool contains(const Coordinate &p) const
Definition: rect.cc:222
PointImp::type
const ObjectImpType * type() const
Returns the lowermost ObjectImpType that this object is an instantiation of.
Definition: point_imp.cc:176
KigPainter
KigPainter is an extended QPainter.
Definition: kigpainter.h:51
PointImp::numberOfProperties
int numberOfProperties() const
Definition: point_imp.cc:57
bogus_imp.h
PointImp
An ObjectImp representing a point.
Definition: point_imp.h:27
Transformation
Class representing a transformation.
Definition: kigtransform.h:37
KigWidget
This class is the real widget showing the document.
Definition: kig_view.h:50
ObjectImp::isPropertyDefinedOnOrThroughThisImp
virtual bool isPropertyDefinedOnOrThroughThisImp(int which) const
Definition: object_imp.cc:326
Transformation::apply
const Coordinate apply(const double x0, const double x1, const double x2) const
Apply this Tranformation.
Definition: kigtransform.cpp:611
BogusPointImp::BogusPointImp
BogusPointImp(const Coordinate &c)
Definition: point_imp.cc:194
PointImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing PointImp's.
Definition: point_imp.cc:159
BogusPointImp::type
const ObjectImpType * type() const
Returns the lowermost ObjectImpType that this object is an instantiation of.
Definition: point_imp.cc:220
PointImp::visit
void visit(ObjectImpVisitor *vtor) const
Definition: point_imp.cc:143
PointImp::draw
void draw(KigPainter &p) const
Definition: point_imp.cc:40
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
PointImp::copy
PointImp * copy() const
Returns a copy of this ObjectImp.
Definition: point_imp.cc:121
Coordinate::x
double x
X Component.
Definition: coordinate.h:126
ScreenInfo::pixelWidth
double pixelWidth() const
Definition: screeninfo.cc:61
QByteArrayList
QList< QByteArray > QByteArrayList
Definition: objects/common.h:50
PointImp::transform
ObjectImp * transform(const Transformation &) const
Return this ObjectImp, transformed by the transformation t.
Definition: point_imp.cc:126
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
PointImp::inRect
bool inRect(const Rect &r, int width, const KigWidget &) const
Definition: point_imp.cc:51
KigDocument::coordinateSystem
const CoordinateSystem & coordinateSystem() const
Definition: kig_document.cc:40
PointImp::contains
bool contains(const Coordinate &p, int width, const KigWidget &) const
Definition: point_imp.cc:45
ObjectImp::numberOfProperties
virtual int numberOfProperties() const
Definition: object_imp.cc:58
Coordinate::valid
bool valid() const
Return whether this is a valid Coordinate.
Definition: coordinate.cpp:176
ObjectImpVisitor
Definition: object_imp.h:56
ObjectImp::properties
virtual const QByteArrayList properties() const
Definition: object_imp.cc:51
InvalidImp
This ObjectImp represents an invalid object.
Definition: bogus_imp.h:61
PointImp::properties
const QByteArrayList properties() const
Definition: point_imp.cc:72
PointImp::canFillInNextEscape
bool canFillInNextEscape() const
Definition: point_imp.cc:154
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