diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-12-11 21:51:45 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-12-11 21:55:45 +0900 |
commit | a3dcc6228458572e91916d3e837bc1c06c55cb0a (patch) | |
tree | 9c7d61125a4f4b90ade1df2aa8368936750516d6 /kig/objects/special_calcers.cpp | |
parent | 5b6bbcf2b60f26a670df462e02643fde115ea49d (diff) | |
download | tdeedu-a3dcc6228458572e91916d3e837bc1c06c55cb0a.tar.gz tdeedu-a3dcc6228458572e91916d3e837bc1c06c55cb0a.zip |
Renaming of files in preparation for code style tools.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit 65a9f54e1051ee8ab936975e78dcb7117b265ef5)
Diffstat (limited to 'kig/objects/special_calcers.cpp')
-rw-r--r-- | kig/objects/special_calcers.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/kig/objects/special_calcers.cpp b/kig/objects/special_calcers.cpp new file mode 100644 index 00000000..e70bd4e9 --- /dev/null +++ b/kig/objects/special_calcers.cpp @@ -0,0 +1,84 @@ +// Copyright (C) 2004 Dominique Devriese <devriese@kde.org> + +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +// 02110-1301, USA. + +#include "special_calcers.h" + +static const ArgsParser::spec argsspecMeasureTransport[] = +{ + { CircleImp::stype(), I18N_NOOP( "Transport a measure on this circle" ) }, + { PointImp::stype(), I18N_NOOP( "Project this point onto the circle" ) }, + { SegmentImp::stype(), I18N_NOOP( "Segment to transport" ) } +}; + +static ArgsParser measuretransportargsparser( argsspecMeasureTransport, 3 ); + +std::vector<ObjectCalcer*> MeasureTransportCalcer::parents() const +{ + std::vector<ObjectCalcer*> ret; + ret.push_back( mcircle ); + ret.push_back( mpoint ); + ret.push_back( msegment ); + return ret; +} + +MeasureTransportCalcer::MeasureTransportCalcer(ObjectCalcer* circle, ObjectCalcer* point, ObjectCalcer* segment ) + : mcircle( circle ), mpoint( point ), msegment( segment ), mimp( 0 ) +{ +} + +MeasureTransportCalcer::~MeasureTransportCalcer() +{ +} + +void MeasureTransportCalcer::calc( const KigDocument& ) +{ + if ( ! measuretransportargsparser.checkArgs( parents() ) ) + return new InvalidImp(); + + if ( ! isPointOnCurve( mpoint, mcircle ) ) + return new InvalidImp(); + + const CircleImp* c = static_cast<const CircleImp*>( mcircle->imp() ); + const PointImp* p = static_cast<const PointImp*>( mpoint->imp() ); + const SegmentImp* s = static_cast<const SegmentImp*>( msegment->imp() ); + double param = c->getParam( p->coordinate(), doc ); + double measure = s->length(); + measure /= 2*c->radius()*M_PI; + param += measure; + while (param > 1) param -= 1; + + const Coordinate nc = c->getPoint( param, doc ); + if ( nc.valid() ) return new PointImp( nc ); + else return new InvalidImp; +} + +const ObjectImpType* MeasureTransportCalcer::impRequirement( + ObjectCalcer* o, const std::vector<ObjectCalcer*>& os ) const +{ + if ( o->imp()->inherits( CircleImp::stype() ) ) + return CircleImp::stype(); + else if ( o->imp()->inherits( PointImp::stype() ) ) + return PointImp::stype(); + else if ( o->imp()->inherits( SegmentImp::stype() ) ) + return SegmentImp::stype(); + else + { + assert( false ); + return 0; + } +} + |