New topic: 

Canvas Question

<http://forums.realsoftware.com/viewtopic.php?t=47679>

         Page 1 of 1
   [ 6 posts ]                 Previous topic | Next topic          Author  
Message        mikecotrone          Post subject: Canvas QuestionPosted: Tue 
Apr 23, 2013 1:34 pm                         
Joined: Tue Mar 05, 2013 2:33 pm
Posts: 45
Location: North Carolina                I have two Methods that draw (g, 
pictureobject).  The "Draw" method draws my original picture and works great. 
My "ReDraw" method redraws the picture based on the users resizing that works 
in my code. The way I have it interacting may not be optimal since everything 
is working but with a glitch. When you add picture 1 then picture 2 it works as 
expected. When you resize either picture the canvas is blank until you Mouse 
Up. Here is how I am calling the two methods.

Sub Paint (g as Graphics)
  for each po as  PictureClass in qPictureObject
  if ReDrawToggle = false then
  LogWindow.LogTextArea.appendtext  "Draw" + EndOfLine
  Draw(g, po)
  elseif ReDrawToggle = true then
  LogWindow.LogTextArea.appendtext  "REDRAW" + EndOfLine
  ReDraw(g, po)
  end if
  next
End Sub


Sub MouseUp (X as Integer, Y as Integer)
  ReDrawToggle= False
  Invalidate(False)
End Sub


This was the only Way I could make it work since if I put the 
"RedrawToggle=False" in my MouseUp Event. My code would not stay in the 
"Redraw" Method long enough to see the resizing of the picture when i put the 
"ReDrawToggle=False" at the end of my ReDraw Method. I guess my question is how 
can I have the canvas keep my pictures drawn when I am in the mouse up event? I 
am researching the use of canvas Areas but I was hoping for your thoughts. If 
you need more code I can supply it as I didn't want to overwhelm this thread 
originally.

** The "ReDrawToggle = False" ensures that Paint will then execute the "draw" 
method which is needed for normal drawing after the resize. My issue is that if 
I put the "ReDrawToggle = False" into my MouseDrag event it breaks. It works 
from the MouseUP event but when you are resizing the canvas is blank until you 
MouseDown. 

I think if I could figure out how to call the "Redraw" method directly from the 
MouseDraw Event this may fix it. I am not sure how to pass the (g) from the 
MouseDrag event.

Thanks again for all of the help.      
_________________
Mike Cotrone - CCIE #8411 R&S, CCIE #8411 Voice
Chief Technology Officer 
Onepath Systems, LLC

Real Studio 2012 R2.1 Enterprise, Mac OS, Windows, Ubuntu Linux      

    Last edited by mikecotrone on Tue Apr 23, 2013 2:44 pm, edited 2 times in 
total.   
                             Top                charonn0          Post subject: 
Re: Canvas QuestionPosted: Tue Apr 23, 2013 1:55 pm                             
    
Joined: Mon Apr 02, 2007 2:08 am
Posts: 1201
Location: San Francisco, CA, USA                Maybe:

Sub MouseMove (X as Integer, Y as Integer)
  If ReDrawToggle Then
  Invalidate(False)
  End If
End Sub
      
_________________
Boredom Software  
                             Top                mikecotrone          Post 
subject: Re: Canvas QuestionPosted: Tue Apr 23, 2013 2:17 pm                    
     
Joined: Tue Mar 05, 2013 2:33 pm
Posts: 45
Location: North Carolina                Ah to be fair let me add my "Mouse 
Drag" event to show when I set the "RedrawToggle"

Sub MouseDrag (X as Integer, Y as Integer)
  
  //Enable moving Pictures around on the Canvas
  for each q as Pictureclass in qPictureObject
  
  If qSelectedObject <> Nil And qSelected And (qLastX <> X Or qLastY <> Y ) Then
  qMoved = True
  qSelectedObject.TopLeftX = X - qObjectOffsetX
  qSelectedObject.TopLeftY = Y - qObjectOffsetY
  Invalidate(False)
  //Invalidate(qSelectedObject.TopLeftX, 
qSelectedObject.TopLeftY,qSelectedObject.OriginalWidth, 
qSelectedObject.OriginalHeight,False)
  
  
  ElseIf qSelectedObject <> Nil Then
  qSelected = True
  qObjectOffsetX = X-qSelectedObject.TopLeftX
  qObjectOffsetY = Y-qSelectedObject.TopLeftY
  
  
  Else
  qSelected = False
  End If
  
  
  If X >= q.BottomRightX AND X <= q.BottomRightX+8 And Y >= q.BottomRightY AND 
Y <= q.BottomRightY+5 Then
  // Only Allow Redraw on the Bottom Right Corner
  AnchorTopLeftCorner = True
  ReDrawToggle = True
  
  elseif X >= q.TopRightX AND X <= q.TopRightX+8 And Y >= q.TopRightY AND Y <= 
q.TopRightY+5 Then
  // Only Allow Redraw on the Top Left Corner
  
  
  elseif X >= q.BottomLeftX AND X <= q.BottomLeftX+8 And Y >= q.BottomLeftY AND 
Y <= q.BottomLeftY+5 Then
  // Only Allow Redraw on the Bottom Left Corner
  
  
  elseif X >= q.TopLeftX AND X <= q.TopLeftX+8 And Y >= q.TopLeftY AND Y <= 
q.TopLeftY+5 Then
  // Only Allow Redraw on the Top Left Corner
  
  end if
  
  next
      
_________________
Mike Cotrone - CCIE #8411 R&S, CCIE #8411 Voice
Chief Technology Officer 
Onepath Systems, LLC

Real Studio 2012 R2.1 Enterprise, Mac OS, Windows, Ubuntu Linux      

    Last edited by mikecotrone on Tue Apr 23, 2013 2:38 pm, edited 2 times in 
total.   
                             Top                mikecotrone          Post 
subject: Re: Canvas QuestionPosted: Tue Apr 23, 2013 2:31 pm                    
     
Joined: Tue Mar 05, 2013 2:33 pm
Posts: 45
Location: North Carolina                charonn0 wrote:Maybe:

Sub MouseMove (X as Integer, Y as Integer)
  If ReDrawToggle Then
  Invalidate(False)
  End If
End Sub


Thank you, I tried that and it still is blank when you are in the mouse Up 
Event unfortunately.      
_________________
Mike Cotrone - CCIE #8411 R&S, CCIE #8411 Voice
Chief Technology Officer 
Onepath Systems, LLC

Real Studio 2012 R2.1 Enterprise, Mac OS, Windows, Ubuntu Linux  
                             Top                mikecotrone          Post 
subject: Re: Canvas QuestionPosted: Wed Apr 24, 2013 8:35 am                    
     
Joined: Tue Mar 05, 2013 2:33 pm
Posts: 45
Location: North Carolina                Here is my issue visually. 

1. When I have multiple icons on my map I can move them around and everything 
is fine.

2. I am using the drawrect (drawborder method) to draw my border around the 
icon when selected which works fine when moving icons around the map

3. I am using the fillrect to create little boxes on each corner to indicate 
that they are resize capable

https://www.dropbox.com/s/dnd8z17aichhyyz/Both-Icons-Present-Before-Resize.png?m

4. When I resize the image (holding down the mouse and/or dragging on the 
resize point) the other images go away except for the four resize points that 
are using fillrect.

https://www.dropbox.com/s/y9ly6ty5kq5mv2w/Icon-During-Resize.png

Thanks!      
_________________
Mike Cotrone - CCIE #8411 R&S, CCIE #8411 Voice
Chief Technology Officer 
Onepath Systems, LLC

Real Studio 2012 R2.1 Enterprise, Mac OS, Windows, Ubuntu Linux  
                             Top                mikecotrone          Post 
subject: Re: Canvas QuestionPosted: Wed Apr 24, 2013 8:59 am                    
     
Joined: Tue Mar 05, 2013 2:33 pm
Posts: 45
Location: North Carolina                Wow I had way overcomplicated this.. My 
problem ended up being that I was calling draw and redraw independently (single 
threaded) and my code was doing exactly what I told it to do  When It hit the 
redraw method it JUST drew that and vice versa with the draw method.

for each po as  PictureClass in qPictureObject
  if ReDrawToggle = False then
  Draw(g, po)
  elseif ReDrawToggle = True then
  ReDraw(g, po)
  Draw(g, po)
  end if
next


Phew issue solved.     
_________________
Mike Cotrone - CCIE #8411 R&S, CCIE #8411 Voice
Chief Technology Officer 
Onepath Systems, LLC

Real Studio 2012 R2.1 Enterprise, Mac OS, Windows, Ubuntu Linux  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 6 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to