From: Sungwoo, Lim
Subject: Q: strange pointer counting..
Date: 
Message-ID: <011220001251173479%sungwoo@cad.strath.ac.uk>
Hello,
I tried to count the number of points during sketching stroke.
Some of you still remember below codes. =)

(defmethod dialog-item-action ((view simple-drawing-item))
  (let ((where (view-mouse-position view)))
    (#_moveto (point-h where) (point-v where))
    (setf max-x (setf first-x (point-h where))) 
    (setf max-y (setf first-y (point-v where))) 
    (setf min-x (setf first-x (point-h where))) 
    (setf min-y (setf first-y (point-v where))) 
    (setf stroke-point-counter 0)   <-- counter initialisation
    (with-pen-saved
      (set-pen-mode view :patOr)   
      (loop while (mouse-down-p)
            do (let* ((pos (view-mouse-position view))) 
                 (#_lineto (point-h pos) (point-v pos))
                 (setf next-x (point-h pos))
                 (setf next-y (point-v pos))
                 (set-initial-region next-x next-y)
                 (setf stroke-point-counter (+ stroke-point-counter
1)))))  <-- counting
      (setf last-x next-x) 
      (setf last-y next-y)
;      (set-rect-region view min-x min-y max-x max-y) ; this is buggy
))

In this code, I initialised the value 'stroke-point-counter' as zero,
then tried to count total points during sketching stroke.
Strange thing is that though I can get some value of the counter, but
it seems not correct. The number is always over thousands even I draw
very short stroke.
I think stroke points are based on the REAL PIXEL (resolution), so the
point-number of a stroke within a window should be smaller than
window's size. Why I can't get the correct point-count in here?
Please let me know. 
Thanks,

Sungowo

From: ········@my-deja.com
Subject: Re: Q: strange pointer counting..
Date: 
Message-ID: <9092vv$r78$1@nnrp1.deja.com>
In article <··························@cad.strath.ac.uk>,
  "Sungwoo, Lim" <·······@cad.strath.ac.uk> wrote:
> Hello,
> I tried to count the number of points during sketching stroke.
> Some of you still remember below codes. =)

Others have solved your problem -- I have a question for you.  What
graphics package is this, and where can I get it?

Thanks a lot,
 -- John


Sent via Deja.com http://www.deja.com/
Before you buy.
From: Sungwoo, Lim
Subject: Re: Q: strange pointer counting..
Date: 
Message-ID: <031220001255478923%sungwoo@cad.strath.ac.uk>
In article <············@nnrp1.deja.com>, <········@my-deja.com> wrote:

> In article <··························@cad.strath.ac.uk>,
>   "Sungwoo, Lim" <·······@cad.strath.ac.uk> wrote:
> > Hello,
> > I tried to count the number of points during sketching stroke.
> > Some of you still remember below codes. =)
> 
> Others have solved your problem -- I have a question for you.  What
> graphics package is this, and where can I get it?
> 
> Thanks a lot,
>  -- John
> 
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.

Yes, many people in this newsgroup helped me to solve my problem. =)
I confused what you saying... do you mean there are another way to
solve my problem? Then, could you show me those codes as well please?
=)
(I want to learn the various way of coding)

I confused again... what do you mean graphics package?
Do you mean that some graphics application?
I don't use any graphics package for this, I draw every sketch stroke
within Lisp (MCL). =)
Hope this is correct answer for you.
Cheers,

Sungwoo
From: Sungwoo, Lim
Subject: Re: Q: strange pointer counting..
Date: 
Message-ID: <011220001309369447%sungwoo@cad.strath.ac.uk>
In article <··························@cad.strath.ac.uk>, Sungwoo, Lim
<·······@cad.strath.ac.uk> wrote:

no contents
From: Martti Halminen
Subject: Re: Q: strange pointer counting..
Date: 
Message-ID: <3A27A6F6.C1D4F5CD@solibri.com>
"Sungwoo, Lim" wrote:
> 
> Hello,
> I tried to count the number of points during sketching stroke.
> Some of you still remember below codes. =)
> 
> (defmethod dialog-item-action ((view simple-drawing-item))
>   (let ((where (view-mouse-position view)))
>     (#_moveto (point-h where) (point-v where))
>     (setf max-x (setf first-x (point-h where)))
>     (setf max-y (setf first-y (point-v where)))
>     (setf min-x (setf first-x (point-h where)))
>     (setf min-y (setf first-y (point-v where)))
>     (setf stroke-point-counter 0)   <-- counter initialisation
>     (with-pen-saved
>       (set-pen-mode view :patOr)
>       (loop while (mouse-down-p)
>             do (let* ((pos (view-mouse-position view)))
>                  (#_lineto (point-h pos) (point-v pos))
>                  (setf next-x (point-h pos))
>                  (setf next-y (point-v pos))
>                  (set-initial-region next-x next-y)
>                  (setf stroke-point-counter (+ stroke-point-counter
> 1)))))  <-- counting
>       (setf last-x next-x)
>       (setf last-y next-y)
> ;      (set-rect-region view min-x min-y max-x max-y) ; this is buggy
> ))
> 
> In this code, I initialised the value 'stroke-point-counter' as zero,
> then tried to count total points during sketching stroke.
> Strange thing is that though I can get some value of the counter, but
> it seems not correct. The number is always over thousands even I draw
> very short stroke.
> I think stroke points are based on the REAL PIXEL (resolution), so the
> point-number of a stroke within a window should be smaller than
> window's size. Why I can't get the correct point-count in here?


Without knowing the system, this looks like you are not counting the
distance moved, you are counting the times through the loop. This will
increase all the time mouse-down-p is T, even if you are not moving
anywhere.

P.S. you could save a little typing by using incf for the counter...
--
From: Sungwoo, Lim
Subject: Re: Q: strange pointer counting..
Date: 
Message-ID: <011220001417284476%sungwoo@cad.strath.ac.uk>
In article <·················@solibri.com>, Martti Halminen
<···············@solibri.com> wrote:

> "Sungwoo, Lim" wrote:
> > 
> > Hello,
> > I tried to count the number of points during sketching stroke.
> > Some of you still remember below codes. =)
> > 
> > (defmethod dialog-item-action ((view simple-drawing-item))
> >   (let ((where (view-mouse-position view)))
> >     (#_moveto (point-h where) (point-v where))
> >     (setf max-x (setf first-x (point-h where)))
> >     (setf max-y (setf first-y (point-v where)))
> >     (setf min-x (setf first-x (point-h where)))
> >     (setf min-y (setf first-y (point-v where)))
> >     (setf stroke-point-counter 0)   <-- counter initialisation
> >     (with-pen-saved
> >       (set-pen-mode view :patOr)
> >       (loop while (mouse-down-p)
> >             do (let* ((pos (view-mouse-position view)))
> >                  (#_lineto (point-h pos) (point-v pos))
> >                  (setf next-x (point-h pos))
> >                  (setf next-y (point-v pos))
> >                  (set-initial-region next-x next-y)
> >                  (setf stroke-point-counter (+ stroke-point-counter
> > 1)))))  <-- counting
> >       (setf last-x next-x)
> >       (setf last-y next-y)
> > ;      (set-rect-region view min-x min-y max-x max-y) ; this is buggy
> > ))
> > 
> > In this code, I initialised the value 'stroke-point-counter' as zero,
> > then tried to count total points during sketching stroke.
> > Strange thing is that though I can get some value of the counter, but
> > it seems not correct. The number is always over thousands even I draw
> > very short stroke.
> > I think stroke points are based on the REAL PIXEL (resolution), so the
> > point-number of a stroke within a window should be smaller than
> > window's size. Why I can't get the correct point-count in here?
> 
> 
> Without knowing the system, this looks like you are not counting the
> distance moved, you are counting the times through the loop. This will
> increase all the time mouse-down-p is T, even if you are not moving
> anywhere.
> 
> P.S. you could save a little typing by using incf for the counter...
> --

Yes, you are right. +_+!
I pushed mouse button for a while, then checked the value of
stroke-point-counter. It increased until I release the mouse button.
Actually, I wanted to count the number of point (first point, next
point ... last point) during drawing a stroke.
So, in this case, should I code one more 'loop-while' in the existing
loop or somethingelse? 
Thanks, =)

Sungwoo
From: Barry Margolin
Subject: Re: Q: strange pointer counting..
Date: 
Message-ID: <EhQV5.35$DL1.394@burlma1-snr2>
In article <··························@cad.strath.ac.uk>,
Sungwoo, Lim <·······@cad.strath.ac.uk> wrote:
>Yes, you are right. +_+!
>I pushed mouse button for a while, then checked the value of
>stroke-point-counter. It increased until I release the mouse button.
>Actually, I wanted to count the number of point (first point, next
>point ... last point) during drawing a stroke.
>So, in this case, should I code one more 'loop-while' in the existing
>loop or somethingelse? 

If you want to count the moves, then you should remember the coordinates
from the last time through the loop, and compare them to the current
coordinates.  If they're different, add 1 to the counter.

-- 
Barry Margolin, ······@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Sungwoo, Lim
Subject: Re: Q: strange pointer counting..
Date: 
Message-ID: <011220001757370657%sungwoo@cad.strath.ac.uk>
In article <················@burlma1-snr2>, Barry Margolin
<······@genuity.net> wrote:

> In article <··························@cad.strath.ac.uk>,
> Sungwoo, Lim <·······@cad.strath.ac.uk> wrote:
> >Yes, you are right. +_+!
> >I pushed mouse button for a while, then checked the value of
> >stroke-point-counter. It increased until I release the mouse button.
> >Actually, I wanted to count the number of point (first point, next
> >point ... last point) during drawing a stroke.
> >So, in this case, should I code one more 'loop-while' in the existing
> >loop or somethingelse? 
> 
> If you want to count the moves, then you should remember the coordinates
> from the last time through the loop, and compare them to the current
> coordinates.  If they're different, add 1 to the counter.

Thanks for your tip!. ^^
It works. I modified the code as below, and
now I can get the correct point number of a sketch stroke.
One thing... in here, I tried make a 'stroke-limit', 'previous-x',
'previous-y' as a local value using 'let'.
But it didn't work. hmm...
The value of troke-limit kept even I draw new stroke.
How can I initialise these all values automatically when I draw new
stroke?
Thanks,

Sungwoo
;-------------------------------------------------
(defclass simple-drawing-item (dialog-item) ())

(defmethod dialog-item-action ((view simple-drawing-item))
  (let ((where (view-mouse-position view)))
    (#_moveto (point-h where) (point-v where))
    (setf max-x (setf first-x (point-h where))) 
    (setf max-y (setf first-y (point-v where))) 
    (setf min-x (setf first-x (point-h where))) 
    (setf min-y (setf first-y (point-v where))) 
    (setf stroke-limit 1)
    (setf previous-x first-x)
    (setf previous-y first-y)
    (with-pen-saved
      (set-pen-mode view :patOr)   
      (loop while (mouse-down-p)
            do (let* ((pos (view-mouse-position view))) 
                 (#_lineto (point-h pos) (point-v pos))
                 (setf next-x (point-h pos))
                 (setf next-y (point-v pos))
                 (set-initial-region next-x next-y)
                 (cond ((or (/= previous-x next-x) (/= previous-y
next-y))
                        (incf stroke-limit))
                       (t nil))
                 (setf previous-x next-x)
                 (setf previous-y next-y))))
      (setf last-x next-x) 
      (setf last-y next-y)
;      (set-rect-region view min-x min-y max-x max-y) ; this is buggy
))
;--------------------------------------------------
From: Barry Margolin
Subject: Re: Q: strange pointer counting..
Date: 
Message-ID: <ueTV5.40$DL1.621@burlma1-snr2>
In article <··························@cad.strath.ac.uk>,
Sungwoo, Lim <·······@cad.strath.ac.uk> wrote:
>In article <················@burlma1-snr2>, Barry Margolin
><······@genuity.net> wrote:
>> If you want to count the moves, then you should remember the coordinates
>> from the last time through the loop, and compare them to the current
>> coordinates.  If they're different, add 1 to the counter.
>
>Thanks for your tip!. ^^
>It works. I modified the code as below, and
>now I can get the correct point number of a sketch stroke.
>One thing... in here, I tried make a 'stroke-limit', 'previous-x',
>'previous-y' as a local value using 'let'.
>But it didn't work. hmm...

Which LET did you try putting them in?  It should work fine if you put them
in the LET on the second line of the function.  But if you put them in the
LET that's inside the LOOP, then each time around the LOOP they will be
re-initialized.

What you probably want is something like:

  (loop for previous-x = first-x then next-x
        for previous-y = first-y then next-y
        for pos = (view-mouse-mosition view)
        for next-x = (point-h pos)
        for next-y = (point-v pos)
        do (set-initial-region next-x next-y)
	   (when (or (/= previous-x next-x) (/= previous-y next-y))
	     (incf stroke-limit))
        finally (setf last-x next-x last-y next-y))

>The value of troke-limit kept even I draw new stroke.
>How can I initialise these all values automatically when I draw new
>stroke?
>Thanks,
>
>Sungwoo
>;-------------------------------------------------
>(defclass simple-drawing-item (dialog-item) ())
>
>(defmethod dialog-item-action ((view simple-drawing-item))
>  (let ((where (view-mouse-position view)))
>    (#_moveto (point-h where) (point-v where))
>    (setf max-x (setf first-x (point-h where))) 
>    (setf max-y (setf first-y (point-v where))) 
>    (setf min-x (setf first-x (point-h where))) 
>    (setf min-y (setf first-y (point-v where))) 
>    (setf stroke-limit 1)
>    (setf previous-x first-x)
>    (setf previous-y first-y)
>    (with-pen-saved
>      (set-pen-mode view :patOr)   
>      (loop while (mouse-down-p)
>            do (let* ((pos (view-mouse-position view))) 
>                 (#_lineto (point-h pos) (point-v pos))
>                 (setf next-x (point-h pos))
>                 (setf next-y (point-v pos))
>                 (set-initial-region next-x next-y)
>                 (cond ((or (/= previous-x next-x) (/= previous-y
>next-y))
>                        (incf stroke-limit))
>                       (t nil))
>                 (setf previous-x next-x)
>                 (setf previous-y next-y))))
>      (setf last-x next-x) 
>      (setf last-y next-y)
>;      (set-rect-region view min-x min-y max-x max-y) ; this is buggy
>))
>;--------------------------------------------------


-- 
Barry Margolin, ······@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Sungwoo, Lim
Subject: Re: Q: strange pointer counting..
Date: 
Message-ID: <031220001438410597%sungwoo@cad.strath.ac.uk>
In article <················@burlma1-snr2>, Barry Margolin
<······@genuity.net> wrote:

> In article <··························@cad.strath.ac.uk>,
> Sungwoo, Lim <·······@cad.strath.ac.uk> wrote:
> >In article <················@burlma1-snr2>, Barry Margolin
> ><······@genuity.net> wrote:
> >> If you want to count the moves, then you should remember the coordinates
> >> from the last time through the loop, and compare them to the current
> >> coordinates.  If they're different, add 1 to the counter.
> >
> >Thanks for your tip!. ^^
> >It works. I modified the code as below, and
> >now I can get the correct point number of a sketch stroke.
> >One thing... in here, I tried make a 'stroke-limit', 'previous-x',
> >'previous-y' as a local value using 'let'.
> >But it didn't work. hmm...
> 
> Which LET did you try putting them in?  It should work fine if you put them
> in the LET on the second line of the function.  But if you put them in the
> LET that's inside the LOOP, then each time around the LOOP they will be
> re-initialized.
> 
> What you probably want is something like:
> 
>   (loop for previous-x = first-x then next-x
>         for previous-y = first-y then next-y
>         for pos = (view-mouse-mosition view)
>         for next-x = (point-h pos)
>         for next-y = (point-v pos)
>         do (set-initial-region next-x next-y)
>            (when (or (/= previous-x next-x) (/= previous-y next-y))
>              (incf stroke-limit))
>         finally (setf last-x next-x last-y next-y))
> 


I am back from saturday night fever. =)

Yes, you are right. When I put 'previous-x' and 'previous-y' inside of
the LOOP, I got the result of re-initialisation each time.

I am sorry, I am getting confused where should I merge your aboove
suggestion. +_+
I put above code followed by the 'let' which is on the second line,
but it seems doesn't work.
(maybe I couldn't fully recovered from the fever. ^^)
Please take a look the comment in the below code as well...
Thanks,

Sungwoo
;-------------------------------------------------------------------
(defclass simple-drawing-item (dialog-item) ())

(setf stroke-limit 0) <-- here I initialised stroke-limit 
                          for every time.

(defmethod dialog-item-action ((view simple-drawing-item))
  (let ((where (view-mouse-position view)))
    (#_moveto (point-h where) (point-v where))
    (setf max-x (setf first-x (point-h where))) 
    (setf max-y (setf first-y (point-v where))) 
    (setf min-x (setf first-x (point-h where))) 
    (setf min-y (setf first-y (point-v where))) 
    (setf stroke-limit 1)  <-- here I put the value of first point.
                               when you click the sketchpad, you will
                               get a point on it. So it should be     
                               checked as one. 
                               This works in a same window.
                               But when I create a news winodw, the 
                               value is one (1). How can I get the zero
                               when I create a new window?
    (setf previous-x first-x) <-- I want to use these two variables
    (setf previous-y first-y)     as a local value.
    (with-pen-saved
      (set-pen-mode view :patOr)   
      (loop while (mouse-down-p)
            do (let* ((pos (view-mouse-position view))) 
                 (#_lineto (point-h pos) (point-v pos))
                 (setf next-x (point-h pos))
                 (setf next-y (point-v pos))
                 (set-initial-region next-x next-y)   
                 (cond ((or (/= previous-x next-x) (/= previous-y
next-y))
                        (incf stroke-limit))
                       (t nil))
                 (setf previous-x next-x)
                 (setf previous-y next-y))))
      (setf last-x next-x) 
      (setf last-y next-y)
;      (set-rect-region view min-x min-y max-x max-y) ; this is buggy
))
;---------------------------------------------------------------------
From: Barry Margolin
Subject: Re: Q: strange pointer counting..
Date: 
Message-ID: <IDPW5.7$5j3.300@burlma1-snr2>
In article <··························@cad.strath.ac.uk>,
Sungwoo, Lim <·······@cad.strath.ac.uk> wrote:
>In article <················@burlma1-snr2>, Barry Margolin
><······@genuity.net> wrote:
>> What you probably want is something like:
>> 
>>   (loop for previous-x = first-x then next-x
>>         for previous-y = first-y then next-y
>>         for pos = (view-mouse-mosition view)
>>         for next-x = (point-h pos)
>>         for next-y = (point-v pos)
>>         do (set-initial-region next-x next-y)
>>            (when (or (/= previous-x next-x) (/= previous-y next-y))
>>              (incf stroke-limit))
>>         finally (setf last-x next-x last-y next-y))
>> 
>
>
>I am back from saturday night fever. =)
>
>Yes, you are right. When I put 'previous-x' and 'previous-y' inside of
>the LOOP, I got the result of re-initialisation each time.
>
>I am sorry, I am getting confused where should I merge your aboove
>suggestion. +_+
>I put above code followed by the 'let' which is on the second line,
>but it seems doesn't work.
>(maybe I couldn't fully recovered from the fever. ^^)
>Please take a look the comment in the below code as well...
>Thanks,

My loop goes where your loop was, and you should also get rid of your lines
that set previous-x, previous-y, last-x, and last-y.

-- 
Barry Margolin, ······@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Sungwoo, Lim
Subject: Re: Q: strange pointer counting..
Date: 
Message-ID: <041220001728511728%sungwoo@cad.strath.ac.uk>
In article <···············@burlma1-snr2>, Barry Margolin
<······@genuity.net> wrote:

> 
> My loop goes where your loop was, and you should also get rid of your lines
> that set previous-x, previous-y, last-x, and last-y.

I will try again. Thanks. =)

Sungwoo