[kig] /: Make SegmentAxisType Equivalent to the Previous Macro
David E. Narvaez
david.narvaez at computer.org
Tue Jun 24 17:57:26 UTC 2014
Git commit 494629177ae9360ffd33fd84ae12403f20b920db by David E. Narvaez.
Committed on 24/06/2014 at 17:55.
Pushed by narvaez into branch 'master'.
Make SegmentAxisType Equivalent to the Previous Macro
As pointed out in https://git.reviewboard.kde.org/r/118785/, the new
SegmentAxisABType took two arguments instead of one like the old macro,
so this fixes compatibility with the previous behavior.
CCMAIL: kde-edu at kde.org
M +1 -1 misc/builtin_stuff.cc
M +16 -13 objects/line_type.cc
M +6 -6 objects/line_type.h
http://commits.kde.org/kig/494629177ae9360ffd33fd84ae12403f20b920db
diff --git a/misc/builtin_stuff.cc b/misc/builtin_stuff.cc
index 64184d9..e5312c0 100644
--- a/misc/builtin_stuff.cc
+++ b/misc/builtin_stuff.cc
@@ -73,7 +73,7 @@ void setupBuiltinStuff()
// segment axis...
c = new SimpleObjectTypeConstructor(
- SegmentAxisABType::instance(), I18N_NOOP( "Segment Axis" ),
+ SegmentAxisType::instance(), I18N_NOOP( "Segment Axis" ),
I18N_NOOP( "The perpendicular line through a given segment's mid point." ),
"segmentaxis" );
ctors->add( c );
diff --git a/objects/line_type.cc b/objects/line_type.cc
index eae45c7..269dd8d 100644
--- a/objects/line_type.cc
+++ b/objects/line_type.cc
@@ -129,38 +129,41 @@ ObjectImp* RayABType::calcx( const Coordinate& a, const Coordinate& b ) const
static const ArgsParser::spec argspecSegmentAxisABType[] =
{
- { PointImp::stype(), I18N_NOOP( "Construct the axis of the segment with this and another point" ),
- I18N_NOOP( "Select the first of the two points..." ), true },
- { PointImp::stype(), I18N_NOOP( "Construct the axis of the segment with the previous and this point" ),
- I18N_NOOP( "Select the second of the two points..." ), true }
+ { SegmentImp::stype(), I18N_NOOP( "Construct the axis of this segment" ),
+ I18N_NOOP( "Select the segment of which you want to draw the axis..." ), true }
};
-KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( SegmentAxisABType );
+KIG_INSTANTIATE_OBJECT_TYPE_INSTANCE( SegmentAxisType );
-SegmentAxisABType::SegmentAxisABType()
- : ObjectABType( "Segment Axis", argspecSegmentAxisABType, 2 )
+SegmentAxisType::SegmentAxisType()
+ : ArgsParserObjectType( "Segment Axis", argspecSegmentAxisABType, 1 )
{
}
-SegmentAxisABType::~SegmentAxisABType()
+SegmentAxisType::~SegmentAxisType()
{
}
-const SegmentAxisABType* SegmentAxisABType::instance()
+const SegmentAxisType* SegmentAxisType::instance()
{
- static const SegmentAxisABType s;
+ static const SegmentAxisType s;
return &s;
}
-ObjectImp* SegmentAxisABType::calcx( const Coordinate& a, const Coordinate& b ) const
+ObjectImp* SegmentAxisType::calc( const Args& args, const KigDocument& ) const
{
- const Coordinate mp( ( a + b ) / 2 );
+ if ( ! margsparser.checkArgs( args ) ) return new InvalidImp;
+
+ const SegmentImp * l = static_cast< const SegmentImp * >( args[0] );
+ const Coordinate a = l->data().a;
+ const Coordinate b = l->data().b;
+ const Coordinate mp = ( a + b ) / 2;
const Coordinate dir( b - a );
const Coordinate perpPoint = calcPointOnPerpend( dir, mp );
return new LineImp( mp, perpPoint );
}
-const ObjectImpType* SegmentAxisABType::resultId() const
+const ObjectImpType* SegmentAxisType::resultId() const
{
return LineImp::stype();
}
diff --git a/objects/line_type.h b/objects/line_type.h
index e978610..5171c4a 100644
--- a/objects/line_type.h
+++ b/objects/line_type.h
@@ -63,14 +63,14 @@ public:
const ObjectImpType* resultId() const;
};
-class SegmentAxisABType
- : public ObjectABType
+class SegmentAxisType
+ : public ArgsParserObjectType
{
- SegmentAxisABType();
- ~SegmentAxisABType();
+ SegmentAxisType();
+ ~SegmentAxisType();
public:
- static const SegmentAxisABType* instance();
- ObjectImp* calcx( const Coordinate& a, const Coordinate& b ) const;
+ static const SegmentAxisType* instance();
+ ObjectImp* calc( const Args& parents, const KigDocument& d ) const;
const ObjectImpType* resultId() const;
};
More information about the kde-edu
mailing list