[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdeedu/kig
From:       Maurizio Paolini <paolini () dmf ! unicatt ! it>
Date:       2004-03-01 13:51:35
Message-ID: 20040301135135.482389959 () office ! kde ! org
[Download RAW message or body]

CVS commit by paolini: 

Added a first attempt at a "measure transport" action.
It requires a circle, a point on the circle and a segment and constructs
a new point on the circle at a distance (measured counterclockwise on the
circle itself) from the given point equal to the length of the segment.
This is motivated for compatibility reasons with Cabri.

At the moment the point is not tested to belong to the circle, and it is
projected onto it.


  M +1 -0      kig/kigpartui.rc   1.73
  M +8 -0      misc/builtin_stuff.cc   1.27
  M +56 -0     objects/point_type.cc   1.23
  M +16 -0     objects/point_type.h   1.10


--- kdeedu/kig/kig/kigpartui.rc  #1.72:1.73
@@ -97,4 +97,5 @@
         <Action name="objects_new_textlabel" />
         <Action name="objects_new_script_object" />
+        <Action name="objects_new_measuretransport" />
         <ActionList name="user_other_types" />
       </Menu>

--- kdeedu/kig/misc/builtin_stuff.cc  #1.26:1.27
@@ -410,4 +410,12 @@ void setupBuiltinStuff()
     actions->add( new ConstructibleAction( c, "objects_new_containstest" ) );
 
+    c = new SimpleObjectTypeConstructor(
+      MeasureTransportType::instance(),
+      I18N_NOOP( "Measure transport" ),
+      I18N_NOOP( "Transport the measure of a segment over a circle." ),
+      "measuretransport" );
+    ctors->add( c );
+    actions->add( new ConstructibleAction( c, "objects_new_measuretransport" ) );
+
     // the generic intersection constructor..
     c = new GenericIntersectionConstructor();

--- kdeedu/kig/objects/point_type.cc  #1.22:1.23
@@ -298,2 +298,58 @@ std::vector<ObjectCalcer*> ConstrainedPo
   return ret;
 }
+
+ObjectImp* MeasureTransportType::calc( const Args& parents, const KigDocument& doc ) const
+{
+  if ( ! margsparser.checkArgs( parents ) ) return new InvalidImp;
+
+  const CircleImp* c = static_cast<const CircleImp*>( parents[0] );
+  const PointImp* p = static_cast<const PointImp*>( parents[1] );
+  const SegmentImp* s = static_cast<const SegmentImp*>( parents[2] );
+  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 = static_cast<const CurveImp*>c->getPoint( param, doc );
+  const Coordinate nc = c->getPoint( param, doc );
+  if ( nc.valid() ) return new PointImp( nc );
+  else return new InvalidImp;
+}
+
+const ArgsParser::spec argsspecMeasureTransport[] =
+{
+  { CircleImp::stype(), "transport measure on this circle" },
+  { PointImp::stype(), "project this point onto the circle" },
+  { SegmentImp::stype(), "Segment to transport" }
+};
+
+MeasureTransportType::MeasureTransportType()
+  : ArgsParserObjectType( "MeasureTransport", argsspecMeasureTransport, 3 )
+{
+}
+
+MeasureTransportType::~MeasureTransportType()
+{
+}
+
+bool MeasureTransportType::canMove() const
+{
+  return false;
+}
+
+bool MeasureTransportType::inherits( int type ) const
+{
+  return type == ID_ConstrainedPointType;
+}
+
+const MeasureTransportType* MeasureTransportType::instance()
+{
+  static const MeasureTransportType t;
+  return &t;
+}
+
+const ObjectImpType* MeasureTransportType::resultId() const
+{
+  return PointImp::stype();
+}

--- kdeedu/kig/objects/point_type.h  #1.9:1.10
@@ -22,4 +22,5 @@
 #include "base_type.h"
 #include "common.h"
+#include "circle_imp.h"
 
 class FixedPointType
@@ -81,3 +82,18 @@ public:
 };
 
+class MeasureTransportType
+  : public ArgsParserObjectType
+{
+  MeasureTransportType();
+  ~MeasureTransportType();
+public:
+  static const MeasureTransportType* instance();
+
+  bool inherits( int type ) const;
+
+  ObjectImp* calc( const Args& parents, const KigDocument& ) const;
+  bool canMove() const;
+  const ObjectImpType* resultId() const;
+};
+
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic