1
// Copyright (C) 2003 Dominique Devriese <devriese@kde.org>
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.
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.
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
18
#include "transform_types.h"
22
#include "bogus_imp.h"
23
#include "point_imp.h"
25
#include "other_imp.h"
26
#include "polygon_imp.h"
27
#include "special_imptypes.h"
28
#include "../misc/coordinate.h"
29
#include "../misc/kigtransform.h"
33
static const ArgsParser::spec argsspecTranslation[] =
35
{ ObjectImp::stype(), I18N_NOOP("Translate this object"),
36
I18N_NOOP( "Select the object to translate..." ), false },
37
{ VectorImp::stype(), I18N_NOOP("Translate by this vector"),
38
I18N_NOOP( "Select the vector to translate by..." ), false }
41
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( TranslatedType )
43
TranslatedType::TranslatedType()
44
: ArgsParserObjectType( "Translation", argsspecTranslation, 2 )
48
TranslatedType::~TranslatedType()
52
const TranslatedType* TranslatedType::instance()
54
static const TranslatedType t;
58
ObjectImp* TranslatedType::calc( const Args& args, const KigDocument& ) const
60
if ( ! margsparser.checkArgs( args ) ) return new InvalidImp;
62
Coordinate dir = static_cast<const VectorImp*>( args[1] )->dir();
63
Transformation t = Transformation::translation( dir );
65
return args[0]->transform( t );
68
static const ArgsParser::spec argsspecPointReflection[] =
70
{ ObjectImp::stype(), I18N_NOOP( "Reflect this object" ),
71
I18N_NOOP( "Select the object to reflect..." ), false },
72
{ PointImp::stype(), I18N_NOOP( "Reflect in this point" ),
73
I18N_NOOP( "Select the point to reflect in..." ), false }
76
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( PointReflectionType )
78
PointReflectionType::PointReflectionType()
79
: ArgsParserObjectType( "PointReflection", argsspecPointReflection, 2 )
83
PointReflectionType::~PointReflectionType()
87
const PointReflectionType* PointReflectionType::instance()
89
static const PointReflectionType t;
93
ObjectImp* PointReflectionType::calc( const Args& args, const KigDocument& ) const
95
if ( ! margsparser.checkArgs( args ) ) return new InvalidImp;
97
Coordinate center = static_cast<const PointImp*>( args[1] )->coordinate();
98
Transformation t = Transformation::pointReflection( center );
100
return args[0]->transform( t );
103
static const ArgsParser::spec argsspecLineReflection[] =
105
{ ObjectImp::stype(), I18N_NOOP( "Reflect this object" ),
106
I18N_NOOP( "Select the object to reflect..." ), false },
107
{ AbstractLineImp::stype(), I18N_NOOP( "Reflect in this line" ),
108
I18N_NOOP( "Select the line to reflect in..." ), false }
111
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( LineReflectionType )
113
LineReflectionType::LineReflectionType()
114
: ArgsParserObjectType( "LineReflection", argsspecLineReflection, 2 )
118
LineReflectionType::~LineReflectionType()
122
const LineReflectionType* LineReflectionType::instance()
124
static const LineReflectionType t;
128
ObjectImp* LineReflectionType::calc( const Args& args, const KigDocument& ) const
130
if ( ! margsparser.checkArgs( args ) ) return new InvalidImp;
132
LineData d = static_cast<const AbstractLineImp*>( args[1] )->data();
133
Transformation t = Transformation::lineReflection( d );
135
return args[0]->transform( t );
138
static const ArgsParser::spec argsspecRotation[] =
140
{ ObjectImp::stype(), I18N_NOOP( "Rotate this object" ),
141
I18N_NOOP( "Select the object to rotate..." ), false },
142
{ PointImp::stype(), I18N_NOOP( "Rotate around this point" ),
143
I18N_NOOP( "Select the center point of the rotation..." ), false },
144
// { AngleImp::stype(), I18N_NOOP( "Rotate by this angle" ),
145
// I18N_NOOP( "Select the angle of the rotation..." ), false }
146
{ &angleimptypeinstance, I18N_NOOP( "Rotate by this angle" ),
147
I18N_NOOP( "Select the angle of the rotation..." ), false }
150
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( RotationType )
152
RotationType::RotationType()
153
: ArgsParserObjectType( "Rotation", argsspecRotation, 3 )
157
RotationType::~RotationType()
161
const RotationType* RotationType::instance()
163
static const RotationType t;
167
ObjectImp* RotationType::calc( const Args& args, const KigDocument& ) const
169
if ( ! margsparser.checkArgs( args ) ) return new InvalidImp;
171
Coordinate center = static_cast<const PointImp*>( args[1] )->coordinate();
172
// double angle = static_cast<const AngleImp*>( args[2] )->size();
174
double angle = getDoubleFromImp( args[2], valid);
175
if ( ! valid ) return new InvalidImp;
177
return args[0]->transform( Transformation::rotation( angle, center ) );
180
static const ArgsParser::spec argsspecScalingOverCenter[] =
182
{ ObjectImp::stype(), I18N_NOOP( "Scale this object" ),
183
I18N_NOOP( "Select the object to scale..." ), false },
184
{ PointImp::stype(), I18N_NOOP( "Scale with this center" ),
185
I18N_NOOP( "Select the center point of the scaling..." ), false },
186
// { SegmentImp::stype(), I18N_NOOP( "Scale by the length of this segment" ),
187
// I18N_NOOP( "Select a segment whose length is the factor of the scaling..." ), false }
188
{ &lengthimptypeinstance, I18N_NOOP( "Scale by this length" ),
189
I18N_NOOP( "Select a length or a segment whose length is the factor of the scaling..." ), false }
192
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ScalingOverCenterType )
194
ScalingOverCenterType::ScalingOverCenterType()
195
: ArgsParserObjectType( "ScalingOverCenter", argsspecScalingOverCenter, 3 )
199
ScalingOverCenterType::~ScalingOverCenterType()
203
const ScalingOverCenterType* ScalingOverCenterType::instance()
205
static const ScalingOverCenterType t;
209
ObjectImp* ScalingOverCenterType::calc( const Args& args, const KigDocument& ) const
211
if ( ! margsparser.checkArgs( args ) ) return new InvalidImp;
213
Coordinate center = static_cast<const PointImp*>( args[1] )->coordinate();
215
double ratio = getDoubleFromImp( args[2], valid);
216
if ( ! valid ) return new InvalidImp;
218
return args[0]->transform( Transformation::scalingOverPoint( ratio, center ) );
221
static const ArgsParser::spec argsspecScalingOverCenter2[] =
223
{ ObjectImp::stype(), I18N_NOOP( "Scale this object" ),
224
I18N_NOOP( "Select the object to scale..." ), false },
225
{ PointImp::stype(), I18N_NOOP( "Scale with this center" ),
226
I18N_NOOP( "Select the center point of the scaling..." ), false },
227
// { SegmentImp::stype(), I18N_NOOP( "Scale the length of this segment..." ),
228
// I18N_NOOP( "Select the first of two segments whose ratio is the factor of the scaling..." ), false },
229
// { SegmentImp::stype(), I18N_NOOP( "...to the length of this other segment" ),
230
// I18N_NOOP( "Select the second of two segments whose ratio is the factor of the scaling..." ), false }
231
{ &lengthimptypeinstance, I18N_NOOP( "Scale this length..." ),
232
I18N_NOOP( "Select the first of two lengths whose ratio is the factor of the scaling..." ), false },
233
{ &lengthimptypeinstance, I18N_NOOP( "...to this other length" ),
234
I18N_NOOP( "Select the second of two lengths whose ratio is the factor of the scaling..." ), false }
237
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ScalingOverCenter2Type )
239
ScalingOverCenter2Type::ScalingOverCenter2Type()
240
: ArgsParserObjectType( "ScalingOverCenter2", argsspecScalingOverCenter2, 4 )
244
ScalingOverCenter2Type::~ScalingOverCenter2Type()
248
const ScalingOverCenter2Type* ScalingOverCenter2Type::instance()
250
static const ScalingOverCenter2Type t;
254
ObjectImp* ScalingOverCenter2Type::calc( const Args& args, const KigDocument& ) const
256
if ( ! margsparser.checkArgs( args ) ) return new InvalidImp;
258
Coordinate center = static_cast<const PointImp*>( args[1] )->coordinate();
259
// double ratio = static_cast<const SegmentImp*>( args[3] )->length()/
260
// static_cast<const SegmentImp*>( args[2] )->length();
262
double denom = getDoubleFromImp( args[2], valid );
263
if ( ! valid || denom == 0.0 ) return new InvalidImp;
264
double ratio = getDoubleFromImp( args[3], valid )/denom;
265
if ( ! valid ) return new InvalidImp;
267
return args[0]->transform( Transformation::scalingOverPoint( ratio, center ) );
270
static const ArgsParser::spec argsspecScalingOverLine[] =
272
{ ObjectImp::stype(), I18N_NOOP( "Scale this object" ), I18N_NOOP( "Select the object to scale" ), false },
273
{ AbstractLineImp::stype(), I18N_NOOP( "Scale over this line" ), I18N_NOOP( "Select the line to scale over" ), false },
274
// { SegmentImp::stype(), I18N_NOOP( "Scale by the length of this segment" ), I18N_NOOP( "Select a segment whose length is the factor for the scaling" ), false }
275
{ &lengthimptypeinstance, I18N_NOOP( "Scale by this length" ),
276
I18N_NOOP( "Select a length or a segment whose length is the factor of the scaling..." ), false }
279
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ScalingOverLineType )
281
ScalingOverLineType::ScalingOverLineType()
282
: ArgsParserObjectType( "ScalingOverLine", argsspecScalingOverLine, 3 )
286
ScalingOverLineType::~ScalingOverLineType()
290
const ScalingOverLineType* ScalingOverLineType::instance()
292
static const ScalingOverLineType t;
296
ObjectImp* ScalingOverLineType::calc( const Args& args, const KigDocument& ) const
298
if ( ! margsparser.checkArgs( args ) ) return new InvalidImp;
300
LineData line = static_cast<const AbstractLineImp*>( args[1] )->data();
302
double ratio = getDoubleFromImp( args[2], valid);
303
if ( ! valid ) return new InvalidImp;
305
return args[0]->transform( Transformation::scalingOverLine( ratio, line ) );
308
static const ArgsParser::spec argsspecScalingOverLine2[] =
310
{ ObjectImp::stype(), I18N_NOOP( "Scale this object" ), I18N_NOOP( "Select the object to scale" ), false },
311
{ AbstractLineImp::stype(), I18N_NOOP( "Scale over this line" ), I18N_NOOP( "Select the line to scale over" ), false },
312
// { SegmentImp::stype(), I18N_NOOP( "Scale the length of this segment..." ), I18N_NOOP( "Select the first of two segments whose ratio is the factor for the scaling" ), false },
313
// { SegmentImp::stype(), I18N_NOOP( "...to the length of this segment" ), I18N_NOOP( "Select the second of two segments whose ratio is the factor for the scaling" ), false }
314
{ &lengthimptypeinstance, I18N_NOOP( "Scale this length..." ),
315
I18N_NOOP( "Select the first of two lengths whose ratio is the factor of the scaling..." ), false },
316
{ &lengthimptypeinstance, I18N_NOOP( "...to this other length" ),
317
I18N_NOOP( "Select the second of two lengths whose ratio is the factor of the scaling..." ), false }
320
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ScalingOverLine2Type )
322
ScalingOverLine2Type::ScalingOverLine2Type()
323
: ArgsParserObjectType( "ScalingOverLine2", argsspecScalingOverLine2, 4 )
327
ScalingOverLine2Type::~ScalingOverLine2Type()
331
const ScalingOverLine2Type* ScalingOverLine2Type::instance()
333
static const ScalingOverLine2Type t;
337
ObjectImp* ScalingOverLine2Type::calc( const Args& args, const KigDocument& ) const
339
if ( ! margsparser.checkArgs( args ) ) return new InvalidImp;
341
LineData line = static_cast<const AbstractLineImp*>( args[1] )->data();
342
// double ratio = static_cast<const SegmentImp*>( args[3] )->length()/
343
// static_cast<const SegmentImp*>( args[2] )->length();
345
double denom = getDoubleFromImp( args[2], valid );
346
if ( ! valid || denom == 0.0 ) return new InvalidImp;
347
double ratio = getDoubleFromImp( args[3], valid )/denom;
348
if ( ! valid ) return new InvalidImp;
350
return args[0]->transform( Transformation::scalingOverLine( ratio, line ) );
353
static const ArgsParser::spec argsspecProjectiveRotation[] =
355
{ ObjectImp::stype(), I18N_NOOP( "Projectively rotate this object" ), I18N_NOOP( "Select the object to rotate projectively" ), false },
356
{ RayImp::stype(), I18N_NOOP( "Projectively rotate with this half-line" ), I18N_NOOP( "Select the half line of the projective rotation that you want to apply to the object" ), false },
357
{ AngleImp::stype(), I18N_NOOP( "Projectively rotate by this angle" ), I18N_NOOP( "Select the angle of the projective rotation that you want to apply to the object" ), false }
360
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ProjectiveRotationType )
362
ProjectiveRotationType::ProjectiveRotationType()
363
: ArgsParserObjectType( "ProjectiveRotation", argsspecProjectiveRotation, 3 )
367
ProjectiveRotationType::~ProjectiveRotationType()
371
const ProjectiveRotationType* ProjectiveRotationType::instance()
373
static const ProjectiveRotationType t;
377
ObjectImp* ProjectiveRotationType::calc( const Args& args, const KigDocument& ) const
379
if ( ! margsparser.checkArgs( args ) ) return new InvalidImp;
381
const RayImp* ray = static_cast<const RayImp*>( args[1] );
382
Coordinate c1 = ray->data().a;
383
Coordinate dir = ray->data().dir().normalize();
384
double alpha = static_cast<const AngleImp*>( args[2] )->size();
386
return args[0]->transform(
387
Transformation::projectiveRotation( alpha, dir, c1 ) );
390
static const ArgsParser::spec argsspecHarmonicHomology[] =
392
{ ObjectImp::stype(), I18N_NOOP( "Harmonic Homology of this object" ),
393
I18N_NOOP( "Select the object to transform..." ), false },
394
{ PointImp::stype(), I18N_NOOP( "Harmonic Homology with this center" ),
395
I18N_NOOP( "Select the center point of the harmonic homology..." ), false },
396
{ AbstractLineImp::stype(), I18N_NOOP( "Harmonic Homology with this axis" ),
397
I18N_NOOP( "Select the axis of the harmonic homology..." ), false }
400
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( HarmonicHomologyType )
402
HarmonicHomologyType::HarmonicHomologyType()
403
: ArgsParserObjectType( "HarmonicHomology", argsspecHarmonicHomology, 3 )
407
HarmonicHomologyType::~HarmonicHomologyType()
411
const HarmonicHomologyType* HarmonicHomologyType::instance()
413
static const HarmonicHomologyType t;
417
ObjectImp* HarmonicHomologyType::calc( const Args& args, const KigDocument& ) const
419
if ( ! margsparser.checkArgs( args ) ) return new InvalidImp;
421
Coordinate center = static_cast<const PointImp*>( args[1] )->coordinate();
422
LineData axis = static_cast<const AbstractLineImp*>( args[2] )->data();
423
return args[0]->transform(
424
Transformation::harmonicHomology( center, axis ) );
427
static const ArgsParser::spec argsspecAffinityB2Tr[] =
429
{ ObjectImp::stype(), I18N_NOOP( "Generic affinity of this object" ),
430
I18N_NOOP( "Select the object to transform..." ), false },
431
{ FilledPolygonImp::stype3(), I18N_NOOP( "Map this triangle" ),
432
I18N_NOOP( "Select the triangle that has to be transformed onto a given triangle..." ), false },
433
{ FilledPolygonImp::stype3(), I18N_NOOP( "onto this other triangle" ),
434
I18N_NOOP( "Select the triangle that is the image by the affinity of the first triangle..." ), false }
437
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( AffinityB2TrType )
439
AffinityB2TrType::AffinityB2TrType()
440
: ArgsParserObjectType( "AffinityB2Tr", argsspecAffinityB2Tr, 3 )
444
AffinityB2TrType::~AffinityB2TrType()
448
const AffinityB2TrType* AffinityB2TrType::instance()
450
static const AffinityB2TrType t;
454
ObjectImp* AffinityB2TrType::calc( const Args& args, const KigDocument& ) const
456
if ( ! margsparser.checkArgs( args ) ) return new InvalidImp;
458
std::vector<Coordinate> frompoints = static_cast<const FilledPolygonImp*>( args[1] )->points();
459
std::vector<Coordinate> topoints = static_cast<const FilledPolygonImp*>( args[2] )->points();
462
Transformation t = Transformation::affinityGI3P( frompoints, topoints,
465
if (valid == false) return new InvalidImp;
466
return args[0]->transform( t );
469
static const ArgsParser::spec argsspecAffinityGI3P[] =
471
{ ObjectImp::stype(), I18N_NOOP( "Generic affinity of this object" ),
472
I18N_NOOP( "Select the object to transform..." ), false },
473
{ PointImp::stype(), I18N_NOOP( "First of 3 starting points" ),
474
I18N_NOOP( "Select the first of the three starting points of the generic affinity..." ), false },
475
{ PointImp::stype(), I18N_NOOP( "Second of 3 starting points" ),
476
I18N_NOOP( "Select the second of the three starting points of the generic affinity..." ), false },
477
{ PointImp::stype(), I18N_NOOP( "Third of 3 starting points" ),
478
I18N_NOOP( "Select the third of the three starting points of the generic affinity..." ), false },
479
{ PointImp::stype(), I18N_NOOP( "Transformed position of first point" ),
480
I18N_NOOP( "Select the first of the three end points of the generic affinity..." ), false },
481
{ PointImp::stype(), I18N_NOOP( "Transformed position of second point" ),
482
I18N_NOOP( "Select the second of the three end points of the generic affinity..." ), false },
483
{ PointImp::stype(), I18N_NOOP( "Transformed position of third point" ),
484
I18N_NOOP( "Select the third of the three end points of the generic affinity..." ), false },
487
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( AffinityGI3PType )
489
AffinityGI3PType::AffinityGI3PType()
490
: ArgsParserObjectType( "AffinityGI3P", argsspecAffinityGI3P, 7 )
494
AffinityGI3PType::~AffinityGI3PType()
498
const AffinityGI3PType* AffinityGI3PType::instance()
500
static const AffinityGI3PType t;
504
ObjectImp* AffinityGI3PType::calc( const Args& args, const KigDocument& ) const
506
if ( ! margsparser.checkArgs( args ) ) return new InvalidImp;
508
std::vector<Coordinate> frompoints;
509
std::vector<Coordinate> topoints;
510
for ( uint i = 0; i < 3; ++i )
512
frompoints.push_back(
513
static_cast<const PointImp*>( args[i+1] )->coordinate() );
515
static_cast<const PointImp*>( args[i+4] )->coordinate() );
519
Transformation t = Transformation::affinityGI3P( frompoints, topoints,
522
if (valid == false) return new InvalidImp;
523
return args[0]->transform( t );
526
static const ArgsParser::spec argsspecProjectivityB2Qu[] =
528
{ ObjectImp::stype(), I18N_NOOP( "Generic projective transformation of this object" ),
529
I18N_NOOP( "Select the object to transform..." ), false },
530
{ FilledPolygonImp::stype4(), I18N_NOOP( "Map this quadrilateral" ),
531
I18N_NOOP( "Select the quadrilateral that has to be transformed onto a given quadrilateral..." ), false },
532
{ FilledPolygonImp::stype4(), I18N_NOOP( "onto this other quadrilateral" ),
533
I18N_NOOP( "Select the quadrilateral that is the image by the projective transformation of the first quadrilateral..." ), false }
536
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ProjectivityB2QuType )
538
ProjectivityB2QuType::ProjectivityB2QuType()
539
: ArgsParserObjectType( "ProjectivityB2Qu", argsspecProjectivityB2Qu, 3 )
543
ProjectivityB2QuType::~ProjectivityB2QuType()
547
const ProjectivityB2QuType* ProjectivityB2QuType::instance()
549
static const ProjectivityB2QuType t;
553
ObjectImp* ProjectivityB2QuType::calc( const Args& args, const KigDocument& ) const
555
if ( ! margsparser.checkArgs( args ) ) return new InvalidImp;
557
std::vector<Coordinate> frompoints = static_cast<const FilledPolygonImp*>( args[1] )->points();
558
std::vector<Coordinate> topoints = static_cast<const FilledPolygonImp*>( args[2] )->points();
561
Transformation t = Transformation::projectivityGI4P( frompoints, topoints,
564
if (valid == false) return new InvalidImp;
565
return args[0]->transform( t );
568
static const ArgsParser::spec argsspecProjectivityGI4P[] =
570
{ ObjectImp::stype(), I18N_NOOP( "Generic projective transformation of this object" ),
571
I18N_NOOP( "Select the object to transform..." ), false },
572
{ PointImp::stype(), I18N_NOOP( "First of 4 starting points" ),
573
I18N_NOOP( "Select the first of the four starting points of the generic projectivity..." ), false },
574
{ PointImp::stype(), I18N_NOOP( "Second of 4 starting points" ),
575
I18N_NOOP( "Select the second of the four starting points of the generic projectivity..." ), false },
576
{ PointImp::stype(), I18N_NOOP( "Third of 4 starting points" ),
577
I18N_NOOP( "Select the third of the four starting points of the generic projectivity..." ), false },
578
{ PointImp::stype(), I18N_NOOP( "Fourth of 4 starting points" ),
579
I18N_NOOP( "Select the fourth of the four starting points of the generic projectivity..." ), false },
580
{ PointImp::stype(), I18N_NOOP( "Transformed position of first point" ),
581
I18N_NOOP( "Select the first of the four end points of the generic projectivity..." ), false },
582
{ PointImp::stype(), I18N_NOOP( "Transformed position of second point" ),
583
I18N_NOOP( "Select the second of the four end points of the generic projectivity..." ), false },
584
{ PointImp::stype(), I18N_NOOP( "Transformed position of third point" ),
585
I18N_NOOP( "Select the third of the four end points of the generic projectivity..." ), false },
586
{ PointImp::stype(), I18N_NOOP( "Transformed position of fourth point" ),
587
I18N_NOOP( "Select the fourth of the four end points of the generic projectivity..." ), false }
590
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ProjectivityGI4PType )
592
ProjectivityGI4PType::ProjectivityGI4PType()
593
: ArgsParserObjectType( "ProjectivityGI4P", argsspecProjectivityGI4P, 9 )
597
ProjectivityGI4PType::~ProjectivityGI4PType()
601
const ProjectivityGI4PType* ProjectivityGI4PType::instance()
603
static const ProjectivityGI4PType t;
607
ObjectImp* ProjectivityGI4PType::calc( const Args& args, const KigDocument& ) const
609
if ( ! margsparser.checkArgs( args ) ) return new InvalidImp;
611
std::vector<Coordinate> frompoints;
612
std::vector<Coordinate> topoints;
613
for ( uint i = 0; i < 4; ++i )
615
frompoints.push_back(
616
static_cast<const PointImp*>( args[i+1] )->coordinate() );
618
static_cast<const PointImp*>( args[i+5] )->coordinate() );
622
Transformation t = Transformation::projectivityGI4P( frompoints, topoints,
625
if (valid == false) return new InvalidImp;
626
return args[0]->transform( t );
629
static const ArgsParser::spec argsspecCastShadow[] =
631
{ ObjectImp::stype(), I18N_NOOP( "Cast the shadow of this object" ),
632
I18N_NOOP( "Select the object of which you want to construct the shadow..." ), false },
633
{ PointImp::stype(), I18N_NOOP( "Cast a shadow from this light source" ),
634
I18N_NOOP( "Select the light source from which the shadow should originate..." ), false },
635
{ AbstractLineImp::stype(),
636
I18N_NOOP( "Cast a shadow on the horizon represented by this line" ),
637
I18N_NOOP( "Select the horizon for the shadow..." ), false }
640
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( CastShadowType )
642
CastShadowType::CastShadowType()
643
: ArgsParserObjectType( "CastShadow", argsspecCastShadow, 3 )
647
CastShadowType::~CastShadowType()
651
const CastShadowType* CastShadowType::instance()
653
static const CastShadowType t;
657
ObjectImp* CastShadowType::calc( const Args& args, const KigDocument& ) const
659
if ( ! margsparser.checkArgs( args ) ) return new InvalidImp;
661
Coordinate lightsrc = static_cast<const PointImp*>( args[1] )->coordinate();
662
LineData d = static_cast<const AbstractLineImp*>( args[2] )->data();
663
return args[0]->transform(
664
Transformation::castShadow( lightsrc, d ) );
667
const ObjectImpType* TranslatedType::resultId() const
669
return ObjectImp::stype();
672
const ObjectImpType* PointReflectionType::resultId() const
674
return ObjectImp::stype();
677
const ObjectImpType* LineReflectionType::resultId() const
679
return ObjectImp::stype();
682
const ObjectImpType* RotationType::resultId() const
684
return ObjectImp::stype();
687
const ObjectImpType* ScalingOverCenterType::resultId() const
689
return ObjectImp::stype();
692
const ObjectImpType* ScalingOverCenter2Type::resultId() const
694
return ObjectImp::stype();
697
const ObjectImpType* ScalingOverLineType::resultId() const
699
return ObjectImp::stype();
702
const ObjectImpType* ScalingOverLine2Type::resultId() const
704
return ObjectImp::stype();
707
const ObjectImpType* ProjectiveRotationType::resultId() const
709
return ObjectImp::stype();
712
const ObjectImpType* HarmonicHomologyType::resultId() const
714
return ObjectImp::stype();
717
const ObjectImpType* AffinityB2TrType::resultId() const
719
return ObjectImp::stype();
722
const ObjectImpType* AffinityGI3PType::resultId() const
724
return ObjectImp::stype();
727
const ObjectImpType* ProjectivityB2QuType::resultId() const
729
return ObjectImp::stype();
732
const ObjectImpType* ProjectivityGI4PType::resultId() const
734
return ObjectImp::stype();
737
const ObjectImpType* CastShadowType::resultId() const
739
return ObjectImp::stype();
742
bool TranslatedType::isTransform() const
747
bool PointReflectionType::isTransform() const
752
bool LineReflectionType::isTransform() const
757
bool RotationType::isTransform() const
762
bool ScalingOverCenterType::isTransform() const
767
bool ScalingOverCenter2Type::isTransform() const
772
bool ScalingOverLineType::isTransform() const
777
bool ScalingOverLine2Type::isTransform() const
782
bool ProjectiveRotationType::isTransform() const
787
bool HarmonicHomologyType::isTransform() const
792
bool AffinityB2TrType::isTransform() const
797
bool AffinityGI3PType::isTransform() const
802
bool ProjectivityB2QuType::isTransform() const
807
bool ProjectivityGI4PType::isTransform() const
812
bool CastShadowType::isTransform() const
817
static const ArgsParser::spec argsspecApplyTransformation[] =
819
{ ObjectImp::stype(), I18N_NOOP( "Transform this object" ), "SHOULD NOT BE SEEN", false },
820
{ TransformationImp::stype(), I18N_NOOP( "Transform using this transformation" ), "SHOULD NOT BE SEEN", false }
823
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( ApplyTransformationObjectType )
825
ApplyTransformationObjectType::ApplyTransformationObjectType()
826
: ArgsParserObjectType( "ApplyTransformation", argsspecApplyTransformation, 2 )
830
ApplyTransformationObjectType::~ApplyTransformationObjectType()
834
const ApplyTransformationObjectType* ApplyTransformationObjectType::instance()
836
static const ApplyTransformationObjectType t;
840
ObjectImp* ApplyTransformationObjectType::calc( const Args& args, const KigDocument& ) const
842
if ( ! margsparser.checkArgs( args ) ) return new InvalidImp;
843
return args[0]->transform( static_cast<const TransformationImp*>( args[1] )->data() );
846
const ObjectImpType* ApplyTransformationObjectType::resultId() const
848
return ObjectImp::stype();
851
bool ApplyTransformationObjectType::isTransform() const
856
bool SimilitudeType::isTransform() const
861
const ObjectImpType* SimilitudeType::resultId() const
863
return ObjectImp::stype();
866
const SimilitudeType* SimilitudeType::instance()
868
static const SimilitudeType t;
872
ObjectImp* SimilitudeType::calc( const Args& args, const KigDocument& ) const
874
if ( ! margsparser.checkArgs( args ) ) return new InvalidImp;
876
Coordinate c = static_cast<const PointImp*>( args[1] )->coordinate();
877
Coordinate a = static_cast<const PointImp*>( args[2] )->coordinate();
878
Coordinate b = static_cast<const PointImp*>( args[3] )->coordinate();
881
double factor = sqrt( b.squareLength()/a.squareLength() );
882
double theta = atan2( b.y, b.x ) - atan2( a.y, a.x );
884
return args[0]->transform( Transformation::similitude( c, theta, factor ) );
887
SimilitudeType::~SimilitudeType()
891
static const ArgsParser::spec argsspecSimilitude[] =
893
{ ObjectImp::stype(), I18N_NOOP( "Apply a similitude to this object" ),
894
I18N_NOOP( "Select the object to transform..." ), false },
895
{ PointImp::stype(), I18N_NOOP( "Apply a similitude with this center" ),
896
I18N_NOOP( "Select the center for the similitude..." ), false },
897
{ PointImp::stype(), I18N_NOOP( "Apply a similitude mapping this point onto another point" ),
898
I18N_NOOP( "Select the point which the similitude should map onto another point..." ), false },
899
{ PointImp::stype(), I18N_NOOP( "Apply a similitude mapping a point onto this point" ),
900
I18N_NOOP( "Select the point onto which the similitude should map the first point..." ), false }
903
KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( SimilitudeType )
905
SimilitudeType::SimilitudeType()
906
: ArgsParserObjectType( "Similitude", argsspecSimilitude, 4 )