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

List:       kde-commits
Subject:    KDE/kdeedu/kig/objects
From:       Maurizio Paolini <paolini () dmf ! unicatt ! it>
Date:       2009-10-27 18:03:46
Message-ID: 1256666626.678553.24427.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1041270 by paolini:

added only a reminder concerning removal from locus_imp of function getDist
and a couple of local related functions


 M  +59 -0     locus_imp.cc  
 M  +11 -0     locus_imp.h  


--- trunk/KDE/kdeedu/kig/objects/locus_imp.cc #1041269:1041270
@@ -155,6 +155,11 @@
   return mhier;
 }
 
+/*
+ * TODO: (Maurizio Paolini <paolini@dmf.unicatt.it> and Petr Gajdos <pgajdos@suse.cz>)
+ * getDist should be removed, see comment about getParamofmin
+ */
+
 /**
  * This function returns the distance between the point with parameter
  * param and point p.  param is allowed to not be between 0 and 1, in
@@ -200,6 +205,53 @@
   }
 }
 
+/*
+ * TODO: (Maurizio Paolini <paolini@dmf.unicatt.it> and Petr Gajdos <pgajdos@suse.cz>)
+ * the following function is duplicated exactly in curve_imp.cc.
+ * ideally it should be removed from here, which we shall do in the
+ * next future.
+ *
+ * before removing this we should however clarify the reason of the following
+ * changes:
+--------------------------------------------------------------------
+$ diff -u getParam_from_locus_imp.txt getParam_from_curve_imp.txt
+--- getParam_from_locus_imp.txt 2009-10-27 18:54:26.000000000 +0100
++++ getParam_from_curve_imp.txt 2009-10-27 18:52:55.000000000 +0100
+@@ -1,12 +1,9 @@
+-double LocusImp::getParam( const Coordinate& p, const KigDocument& doc ) const
++double CurveImp::getParam( const Coordinate& p, const KigDocument& doc ) const
+ {
+   // this function ( and related functions like getInterval etc. ) is
+   // written by Franco Pasquarelli <pasqui@dmf.bs.unicatt.it>.
+   // I ( domi ) have adapted and documented it a bit.
+
+-  if ( cachedparam >= 0. && cachedparam <= 1. &&
+-       getPoint ( cachedparam, doc ) == p ) return cachedparam;
+-
+   // consider the function that returns the distance for a point at
+   // parameter x to the locus for a given parameter x.  What we do
+   // here is look for the global minimum of this function.  We do that
+@@ -14,7 +11,7 @@
+   // for a local minimum from there on.  If we find one, we keep it if
+   // it is the lowest of all the ones we've already found..
+
+-  const int N = 50;
++  const int N = 100;
+   const double incr = 1. / (double) N;
+
+   // xm is the best parameter we've found so far, fxm is the distance
+@@ -28,7 +25,7 @@
+   int j = 0;
+   double mm = fxm;
+
+-  while( j < N )
++  while( j < N - 1 )
+   {
+     // [x1,x2] is the range we're currently considering..
+     double x1 = j * incr;
+--------------------------------------------------------------------
+ */
+
 double LocusImp::getParam( const Coordinate& p, const KigDocument& doc ) const
 {
   // this function ( and related functions like getInterval etc. ) is
@@ -283,6 +335,13 @@
   return xm;
 }
 
+/*
+ * TODO: (Maurizio Paolini <paolini@dmf.unicatt.it> and Petr Gajdos <pgajdos@suse.cz>)
+ * the following function is duplicated exactly in curve_imp.cc.
+ * ideally it should be removed from here, which we shall do in the
+ * next future.
+ */
+
 /**
  * This function calculates the parameter of the point that realizes the
  * minimum in [a,b] of the distance between the points of the locus and
--- trunk/KDE/kdeedu/kig/objects/locus_imp.h #1041269:1041270
@@ -46,14 +46,24 @@
  * i hope this is a bit clear, if not, feel free to ask for
  * explanation of what you don't understand.
  */
+
+/**
+ * TODO: getParam has been moved by Petr Gajdos at the "curve_imp" level
+ * which should be fine, since it makes sense more generally for curves
+ * and not only for locuses.  In particular it will be useful for the
+ * new "bezier" curves, to be added shortly
+ */
+
 class LocusImp
   : public CurveImp
 {
   CurveImp* mcurve;
   const ObjectHierarchy mhier;
 
+// TODO: getDist should be removed from here
   double getDist(double param, const Coordinate& p, const KigDocument& doc) const;
   void getInterval(double& x1,double& x2,double incr,const Coordinate& p, const KigDocument& doc) const;
+// TODO: getParamofmin should be removed from here
   double getParamofmin(double a, double b, const Coordinate& p, const KigDocument& doc) const;
   double revert (int n) const;
 public:
@@ -70,6 +80,7 @@
   bool contains( const Coordinate& p, int width, const KigWidget& ) const;
   Rect surroundingRect() const;
   bool inRect( const Rect& r, int width, const KigWidget& ) const;
+// TODO: getParam should be removed from here
   double getParam( const Coordinate& point, const KigDocument& ) const;
   const Coordinate getPoint( double param, const KigDocument& ) const;
 
[prev in list] [next in list] [prev in thread] [next in thread] 

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