On Tue, May 27, 2014 at 9:29 PM, Farrukh <[email protected]> wrote:

>  Thanks for reply you were right i want to like i have drawn a picture but
> they are two shape just overlapping. but i want to display this as a single
> shape. polygon a good idea but in polygon is it possible to do like this.
> [image: shape]
>

I see -- you want a polygon with a hole in it. Unfortunately, we are
limited to what a wx.DC can do.

However, the Polygon Object can do polygons with holes in them if you draw
a continuous line from the outer boundary to the inner boundary -- it works
fine if you just want to fill, but not outline, the object.

If you want to outline the object,  then you'll need to draw the outline as
two separate polylines. You could use three DrawObjects (In this case), or,
better yet, make  new type of object that calls DC.DrawPolygon With no
outline, then calls DrawLines for the outline.

Alternatively, wxGraphicsContext might support this directly -- I haven't
looked.

There is also a DC.DrawPolyPolygon in wxWidgets that _might_ support this,
but it doesn't appear to be there in wxPython 2.9 -- maybe in 3.0? (I'm not
running that at the moment)

I've enclosed an example of a rectangle with a rectangular hole without the
outline.

-Chris






>  Farrukh
>
>
>
> On 27-May-14 8:13 PM, Chris Barker wrote:
>
>  On Tue, May 27, 2014 at 2:22 AM, Farrukh <[email protected]>wrote:
>
>> I am using FloatCanvas. I am adding "FloatCanvas.Rectangle" and for
>> points i m using onDown and onUp. but i m confused that for example
>> consider a rectangle on canvas of (-700, 785), (w=400, h=200 ) and i want
>> subtract a rectangle (-392, 472), (w=150, h=50). i can perform mathematical
>> result but what i cant do is how display this on canvas.
>
>
>  I'm not sure I understand what you mean by "subtract" a rectangle. But
> if you mean you want to display the geometric intersection, or something
> like this (probably only look right with a fixed-width font):
>
>            ----------
>           |        |
>           |        |
> -----------        |
> |                  |
> |                  |
> --------------------
>
>  Then you'll need to compute the corners yourself, and use a Polygon
> object to display in on the Canvas.
>
>  Note that if you have much to do of that sort, you may want to use a
> geometry library, like shapely, for instance.
>
>  -Chris
>
>
>
>
>
>> can you please guide me in the right direction. i will be grateful for
>> your help.
>>
>> Farrukh
>>
>> ---
>> This email is free from viruses and malware because avast! Antivirus
>> protection is active.
>> http://www.avast.com
>>
>>
>
>
>  --
>
> Christopher Barker, Ph.D.
> Oceanographer
>
> Emergency Response Division
> NOAA/NOS/OR&R            (206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115       (206) 526-6317   main reception
>
> [email protected]
>
>
>
>
> ------------------------------
>    <http://www.avast.com/>
>
> This email is free from viruses and malware because avast! 
> Antivirus<http://www.avast.com/>protection is active.
>
>


-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[email protected]
#!/usr/bin/env python

import wx

## import the installed version
#from wx.lib.floatcanvas import NavCanvas, FloatCanvas

## import a local version
import sys
sys.path.append("../")
from floatcanvas import NavCanvas, FloatCanvas


class DrawFrame(wx.Frame):

    """
    A frame used for the FloatCanvas Demo

    """

    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)

        self.CreateStatusBar()

        # Add the Canvas
        Canvas = NavCanvas.NavCanvas(self,-1,
                                     size = (500,500),
                                     ProjectionFun = None,
                                     Debug = 0,
                                     BackgroundColor = "DARK SLATE BLUE",
                                     ).Canvas
        
        self.Canvas = Canvas

        FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove ) 

        Points = (( 0,30),
                  ( 0, 0),
                  (30, 0),
                  (30,30),
                  ( 0,30),
                  (10,20),
                  (10,10),
                  (20,10),
                  (20,20),
                  (10,20),
                  )

        Poly = Canvas.AddPolygon(Points,
                                 FillColor = "blue",
                                 LineColor = None,
                                 )

        self.Show()
        Canvas.ZoomToBB()


    def OnMove(self, event):
        """
        Updates the status bar with the world coordinates

        """
        self.SetStatusText("%.2f, %.2f"%tuple(event.Coords))

app = wx.App(False)
F = DrawFrame(None, title="FloatCanvas Demo App", size=(700,700) )
app.MainLoop()
    
    
    
    









_______________________________________________
FloatCanvas mailing list
[email protected]
http://mailman.paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas

Reply via email to