• 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
vector_type.cc
Go to the documentation of this file.
1 // Copyright (C) 2004 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 "vector_type.h"
19 
20 #include "point_imp.h"
21 #include "other_imp.h"
22 #include "bogus_imp.h"
23 
24 static const ArgsParser::spec argsspecVector[] =
25 {
26  { PointImp::stype(), I18N_NOOP( "Construct a vector from this point" ),
27  I18N_NOOP( "Select the start point of the new vector..." ), true },
28  { PointImp::stype(), I18N_NOOP( "Construct a vector to this point" ),
29  I18N_NOOP( "Select the end point of the new vector..." ), true }
30 };
31 
32 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( VectorType )
33 
34 VectorType::VectorType()
35  : ObjectABType( "Vector", argsspecVector, 2 )
36 {
37 }
38 
39 VectorType::~VectorType()
40 {
41 }
42 
43 const VectorType* VectorType::instance()
44 {
45  static const VectorType t;
46  return &t;
47 }
48 
49 ObjectImp* VectorType::calcx( const Coordinate& a, const Coordinate& b ) const
50 {
51  return new VectorImp( a, b );
52 }
53 
54 const ObjectImpType* VectorType::resultId() const
55 {
56  return VectorImp::stype();
57 }
58 
59 static const ArgsParser::spec argsspecVectorSum[] =
60 {
61  { VectorImp::stype(), I18N_NOOP( "Construct the vector sum of this vector and another one." ),
62  I18N_NOOP( "Select the first of the two vectors of which you want to construct the sum..." ), false },
63  { VectorImp::stype(), I18N_NOOP( "Construct the vector sum of this vector and the other one." ),
64  I18N_NOOP( "Select the other of the two vectors of which you want to construct the sum..." ), false },
65  { PointImp::stype(), I18N_NOOP( "Construct the vector sum starting at this point." ),
66  I18N_NOOP( "Select the point to construct the sum vector in..." ), false }
67 };
68 
69 KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( VectorSumType )
70 
71 VectorSumType::VectorSumType()
72  : ArgsParserObjectType( "VectorSum", argsspecVectorSum, 3 )
73 {
74 }
75 
76 VectorSumType::~VectorSumType()
77 {
78 }
79 
80 const VectorSumType* VectorSumType::instance()
81 {
82  static const VectorSumType t;
83  return &t;
84 }
85 
86 ObjectImp* VectorSumType::calc( const Args& args, const KigDocument& ) const
87 {
88  if ( ! margsparser.checkArgs( args ) ) return new InvalidImp;
89 
90  const VectorImp& a = *static_cast<const VectorImp*>( args[0] );
91  const VectorImp& b = *static_cast<const VectorImp*>( args[1] );
92  const PointImp& p = *static_cast<const PointImp*>( args[2] );
93 
94  return new VectorImp( p.coordinate(), p.coordinate() + a.dir() + b.dir() );
95 }
96 
97 const ObjectImpType* VectorSumType::resultId() const
98 {
99  return VectorImp::stype();
100 }
ObjectImpType
Instances of this class represent a certain ObjectImp type.
Definition: object_imp.h:95
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE(SegmentAxisType)
ObjectABType
Definition: base_type.h:27
point_imp.h
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
argsspecVectorSum
static const ArgsParser::spec argsspecVectorSum[]
Definition: vector_type.cc:59
vector_type.h
VectorImp::dir
const Coordinate dir() const
Return the direction of this vector.
Definition: other_imp.cc:300
VectorImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the VectorImp type.
Definition: other_imp.cc:613
PointImp::coordinate
const Coordinate & coordinate() const
Get the coordinate of this PointImp.
Definition: point_imp.h:50
Coordinate
The Coordinate class is the basic class representing a 2D location by its x and y components...
Definition: coordinate.h:33
VectorImp
An ObjectImp representing a vector.
Definition: other_imp.h:99
ArgsParserObjectType::margsparser
const ArgsParser margsparser
Definition: object_type.h:117
VectorSumType
Definition: vector_type.h:34
bogus_imp.h
VectorType::instance
static const VectorType * instance()
Definition: vector_type.cc:43
PointImp
An ObjectImp representing a point.
Definition: point_imp.h:27
Args
std::vector< const ObjectImp * > Args
Definition: objects/common.h:47
ArgsParser::checkArgs
bool checkArgs(const std::vector< ObjectCalcer * > &os) const
Definition: argsparser.cpp:222
ArgsParser::spec
Definition: argsparser.h:113
VectorType::calcx
ObjectImp * calcx(const Coordinate &a, const Coordinate &b) const
Definition: vector_type.cc:49
VectorType
Definition: vector_type.h:23
VectorSumType::instance
static const VectorSumType * instance()
Definition: vector_type.cc:80
PointImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing PointImp's.
Definition: point_imp.cc:159
VectorType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: vector_type.cc:54
KigDocument
KigDocument is the class holding the real data in a Kig document.
Definition: kig_document.h:36
ObjectImp
The ObjectImp class represents the behaviour of an object after it is calculated. ...
Definition: object_imp.h:226
VectorSumType::resultId
const ObjectImpType * resultId() const
returns the ObjectImp id of the ObjectImp's produced by this ObjectType.
Definition: vector_type.cc:97
VectorSumType::calc
ObjectImp * calc(const Args &args, const KigDocument &) const
Definition: vector_type.cc:86
argsspecVector
static const ArgsParser::spec argsspecVector[]
Definition: vector_type.cc:24
InvalidImp
This ObjectImp represents an invalid object.
Definition: bogus_imp.h:61
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