コード例 #1
0
ファイル: ogl_animate1.py プロジェクト: neo-nie/pynsource
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          "Demo",
                          size=(500, 300),
                          style=wx.DEFAULT_FRAME_STYLE)
        sizer = wx.BoxSizer(wx.VERTICAL)
        # put stuff into sizer

        self.oglcanvas = ogl.ShapeCanvas(self)
        sizer.Add(self.oglcanvas, 1, wx.GROW)

        self.oglcanvas.SetBackgroundColour("LIGHT BLUE")

        self.oglcanvas.Bind(wx.EVT_RIGHT_DOWN, self.OnRightButtonEvent)

        diagram = ogl.Diagram()
        self.oglcanvas.SetDiagram(diagram)
        diagram.SetCanvas(self.oglcanvas)

        shape = ogl.CircleShape(60.0)
        self.mycircle = shape
        shape.SetX(25.0)
        shape.SetY(25.0)
        self.oglcanvas.AddShape(shape)
        diagram.ShowAll(1)

        # apply sizer
        self.SetSizer(sizer)
        self.SetAutoLayout(1)
        self.Show(1)

        self.Start()
コード例 #2
0
    def __init__(self, parent):
        wx.Frame.__init__(
            self,
            parent,
            id=wx.ID_ANY,
            title=wx.EmptyString,
            pos=wx.DefaultPosition,
            size=wx.Size(500, 300),
            style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL,
        )

        self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)

        bSizer9 = wx.BoxSizer(wx.VERTICAL)

        self.canvas = ogl.ShapeCanvas(self)
        diagram = ogl.Diagram()
        self.canvas.SetDiagram(diagram)
        diagram.SetCanvas(self.canvas)
        bSizer9.Add(self.canvas, 1, wx.ALL | wx.EXPAND, 5)

        self.SetSizer(bSizer9)
        self.Layout()

        self.Centre(wx.BOTH)
コード例 #3
0
ファイル: callgraph.py プロジェクト: gzqichang/visualpytune
    def __init__(self,
                 parent,
                 initleft=150,
                 inittop=50,
                 width=250,
                 height=100,
                 max_width=10000,
                 max_height=10000,
                 rect_width=150,
                 rect_height=50):
        ogl.ShapeCanvas.__init__(self, parent)

        self.width = width
        self.height = height
        self.initleft = initleft
        self.inittop = inittop
        self.rect_width = rect_width
        self.rect_height = rect_height
        self.SetScrollbars(20, 20, max_width / 20, max_height / 20)
        self.parent = parent
        self.SetBackgroundColour("LIGHT BLUE")
        self.diagram = ogl.Diagram()
        self.SetDiagram(self.diagram)
        self.diagram.SetCanvas(self)
        self.shapes = []
        self.lines = []
        self.total_func = 0
        self.layer_cnt = []
コード例 #4
0
    def _CreateCanvas(self, parent):
        self._canvas = ogl.ShapeCanvas(parent)
        wx.EVT_LEFT_DOWN(self._canvas, self.OnLeftClick)
        wx.EVT_LEFT_UP(self._canvas, self.OnLeftUp)
        wx.EVT_MOTION(self._canvas, self.OnLeftDrag)
        wx.EVT_LEFT_DCLICK(self._canvas, self.OnLeftDoubleClick)
        wx.EVT_KEY_DOWN(self._canvas, self.OnKeyPressed)

        # need this otherwise mouse clicks don't set focus to this view
        wx.EVT_LEFT_DOWN(self._canvas, self.FocusOnClick)
        wx.EVT_LEFT_DCLICK(self._canvas, self.FocusOnClick)
        wx.EVT_RIGHT_DOWN(self._canvas, self.FocusOnClick)
        wx.EVT_RIGHT_DCLICK(self._canvas, self.FocusOnClick)
        wx.EVT_MIDDLE_DOWN(self._canvas, self.FocusOnClick)
        wx.EVT_MIDDLE_DCLICK(self._canvas, self.FocusOnClick)

        wx.EVT_KILL_FOCUS(self._canvas, self.OnKillFocus)
        wx.EVT_SET_FOCUS(self._canvas, self.OnFocus)

        self._canvas.SetScrollbars(20, 20, self._maxWidth / 20,
                                   self._maxHeight / 20)

        self._canvas.SetBackgroundColour(self._backgroundColor)
        self._diagram = ogl.Diagram()
        self._canvas.SetDiagram(self._diagram)
        self._diagram.SetCanvas(self._canvas)
        self._canvas.SetFont(NORMALFONT)
コード例 #5
0
    def __init__(self, parent, model, actions = ()):
        ScrollingContainer.__init__(self, parent, wx.Size(self.defSize, self.defSize))
        EditorViews.EditorView.__init__(self, model,
          ((_('(Re)load diagram'), self.OnLoad, self.loadBmp, ''),
           (_('Save diagram'), self.OnSave, self.saveBmp, ''),
           (_('Print diagram to PostScript'), self.OnPrintToPS, '-', ''), 
           ('-', None, '-', ''),
           (_('Change size'), self.OnSetSize, '-', ''),
           )+actions)

        self.shapes = []
        self.canvas = PersistentShapeCanvas(self, self.shapes)
        self.canvas.SetSize(self.GetVirtualSize())

        self.canvas.Bind(wx.EVT_RIGHT_UP, self.OnRightClick)

        self.diagram = ogl.Diagram()
        self.canvas.SetDiagram(self.diagram)
        self.diagram.SetCanvas(self.canvas)

        self.shapeMenu = None

        self.size = self.defSize

        self._loaded = False

        self.active = True
コード例 #6
0
    def __init__(self, frame):
        ogl.ShapeCanvas.__init__(self, frame)

        maxWidth = 1000
        maxHeight = 1000
        self.SetScrollbars(20, 20, maxWidth / 20, maxHeight / 20)

        self.frame = frame
        self.SetBackgroundColour("LIGHT BLUE")
        self.diagram = ogl.Diagram()
        ##        # can't get below to work for triangles, aligment is wrong
        self.diagram.SetGridSpacing(1)
        self.diagram.SetSnapToGrid(True)
        self.SetDiagram(self.diagram)
        self.diagram.SetCanvas(self)
        self.shapes = []
        self.save_gdi = []

        rRectBrush = wx.Brush("MEDIUM TURQUOISE", wx.SOLID)
        dsBrush = wx.Brush("WHEAT", wx.SOLID)

        dc = wx.ClientDC(self)
        self.PrepareDC(dc)

        self.selectedShape = None
コード例 #7
0
    def __init__(self, parent, log, frame):
        ogl.ShapeCanvas.__init__(self, parent)

        self.observers = multicast()
        self.app = None  # assigned later by app boot

        self.log = log
        self.frame = frame
        self.SetBackgroundColour("LIGHT BLUE")

        self.SetDiagram(ogl.Diagram())
        self.GetDiagram().SetCanvas(self)

        wx.EVT_WINDOW_DESTROY(self, self.OnDestroy)
        self.Bind(wx.EVT_MOUSEWHEEL, self.OnWheelZoom)
        self.Bind(wx.EVT_KEY_DOWN, self.onKeyPress)
        self.Bind(wx.EVT_CHAR, self.onKeyChar)

        self.font1 = wx.Font(14, wx.MODERN, wx.NORMAL, wx.NORMAL, False)
        self.font2 = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False)

        self.working = False
        self._kill_layout = False  # flag to communicate with layout engine.  aborting keypress in gui should set this to true

        @property
        def kill_layout(self):
            return self._kill_layout

        @kill_layout.setter
        def kill_layout(self, value):
            self._kill_layout = value
コード例 #8
0
    def __init__(self, parent, log, frame):
        ogl.ShapeCanvas.__init__(self, parent)

        maxWidth  = 1000
        maxHeight = 1000
        self.SetScrollbars(20, 20, maxWidth/20, maxHeight/20)

        self.log = log
        self.frame = frame
        self.SetBackgroundColour("LIGHT BLUE") #wxWHITE)

        self.diagram = ogl.Diagram()
        self.SetDiagram(self.diagram)
        self.diagram.SetCanvas(self)
        self.shapes = []
        self.save_gdi = []
        wx.EVT_WINDOW_DESTROY(self, self.OnDestroy)

        self.font1 = wx.Font(14, wx.MODERN, wx.NORMAL, wx.NORMAL, False)
        self.font2 = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False)

        #self.Go(path=r'C:\Documents and Settings\Administrator\My Documents\aa Python\pyNsource\Tests\outputters.PythonToJavaTest01\pythoninput01\*.py')

        self.associations_generalisation = None
        self.associations_composition = None
コード例 #9
0
 def __init__(self, parent):
     wxOgl.ShapeCanvas.__init__(self, parent)
     self.SetDiagram(wxOgl.Diagram())
     self.GetDiagram().SetCanvas(self)
     self.SetBackgroundColour(wx.WHITE)
     self.lastShape = None
     self.Bind(wx.EVT_MOTION, self.OnMouseMove)
コード例 #10
0
    def __init__(self,
                 parent,
                 _id=-1,
                 pos=wx.DefaultPosition,
                 size=wx.Size(250, 240),
                 style=wx.TAB_TRAVERSAL | wx.NO_BORDER,
                 name=wx.PanelNameStr):
        super(ShapePreviewPanel, self).__init__(parent, _id, pos, size, style,
                                                name)
        self.shape = None
        self.pen = wx.Pen(wx.BLACK)
        self.brush = wx.Brush(wx.BLACK)

        bSizer = wx.BoxSizer(wx.VERTICAL)

        self.diagram = ogl.ShapeCanvas(self)
        bSizer.Add(self.diagram,
                   proportion=1,
                   flag=wx.EXPAND | wx.ALL,
                   border=5)

        self.SetSizer(bSizer)
        self.Layout()

        # fix-ups for event handler
        self.diagram.Selection = []
        self.diagram.SetDiagram(ogl.Diagram())
        self.diagram.GetDiagram().SetCanvas(self.diagram)
        self.Bind(wx.EVT_SIZE, self.OnSize)
コード例 #11
0
ファイル: ogl_simple3.py プロジェクト: yssource/pynsource
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          "Demo",
                          size=(300, 200),
                          style=wx.DEFAULT_FRAME_STYLE)
        sizer = wx.BoxSizer(wx.VERTICAL)
        # put stuff into sizer

        canvas = ogl.ShapeCanvas(self)
        sizer.Add(canvas, 1, wx.GROW)

        canvas.SetBackgroundColour("LIGHT BLUE")  #

        diagram = ogl.Diagram()
        canvas.SetDiagram(diagram)
        diagram.SetCanvas(canvas)

        def setpos(shape, x, y):
            width, height = shape.GetBoundingBoxMax()
            shape.SetX(x + width / 2)
            shape.SetY(y + height / 2)

        def getpos(shape):
            width, height = shape.GetBoundingBoxMax()
            x = shape.GetX()
            y = shape.GetY()
            return (x - width / 2, y - height / 2)

        shape = ogl.RectangleShape(60, 60)
        setpos(shape, 0, 0)
        canvas.AddShape(shape)
        shape = ogl.RectangleShape(60, 60)
        setpos(shape, 60, 0)
        canvas.AddShape(shape)

        shape = ogl.RectangleShape(60, 60)
        setpos(shape, 120, 0)
        canvas.AddShape(shape)

        # Next row

        shape = ogl.RectangleShape(100, 100)
        setpos(shape, 0, 60)
        canvas.AddShape(shape)

        shape = ogl.RectangleShape(100, 100)
        setpos(shape, 100, 60)
        canvas.AddShape(shape)

        print([getpos(shape) for shape in canvas.GetDiagram().GetShapeList()])

        diagram.ShowAll(1)

        # apply sizer
        self.SetSizer(sizer)
        self.SetAutoLayout(1)
        self.Show(1)
コード例 #12
0
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "Demo", size=(700, 700), style=wx.DEFAULT_FRAME_STYLE)
        sizer = wx.BoxSizer(wx.VERTICAL)
        # put stuff into sizer

        canvas = ogl.ShapeCanvas(self)
        sizer.Add(canvas, 1, wx.GROW)

        canvas.SetBackgroundColour("LIGHT BLUE")  #

        diagram = ogl.Diagram()
        canvas.SetDiagram(diagram)
        diagram.SetCanvas(canvas)

        # shape = ogl.RectangleShape(60, 60)
        # shape.SetX(30)
        # shape.SetY(30)
        # print(shape.GetBoundingBoxMax())
        # canvas.AddShape(shape)

        # shape = ogl.RectangleShape(60, 60)
        # shape.SetX(90)
        # shape.SetY(30)
        # canvas.AddShape(shape)

        # shape = ogl.RectangleShape(160, 160)
        # shape.SetX(250)
        # shape.SetY(130)
        # canvas.AddShape(shape)

        # diagram.ShowAll(1)

        # apply sizer
        # self.SetSizer(sizer)
        # self.SetAutoLayout(1)
        # self.Show(1)

    # def BootStrap(self):
        y = 0
        
        # for x in range(0, 1200, 70):
        for x in range(0, 600, 70):
            shape = ogl.RectangleShape(60, 60)
            shape.AddText("%d,%d" % (x, y))
            setpos(shape, x, y)
            diagram.AddShape(shape)

            y += 70

        diagram.ShowAll(1)
        self.Show(1)
        
        canvas.Bind(wx.EVT_LEFT_DCLICK, self.OnXXX)
        
        self.diagram = diagram  # remember
        self.canvas = canvas  # remember

        if ASYNC:
            StartCoroutine(self.YYY, self)
コード例 #13
0
    def test_lib_oglEllipseShape(self):
        ogl.OGLInitialize()
        osc = ogl.ShapeCanvas(self.frame)
        self.diagram = ogl.Diagram()
        osc.SetDiagram(self.diagram)
        self.diagram.SetCanvas(osc)

        aShape = ogl.EllipseShape(50, 50)
        aShape.SetCanvas(osc)
        self.diagram.AddShape(aShape)
コード例 #14
0
    def test_lib_oglCtor(self):
        ogl.OGLInitialize()
        osc = ogl.ShapeCanvas(self.frame)
        self.diagram = ogl.Diagram()
        osc.SetDiagram(self.diagram)
        self.diagram.SetCanvas(osc)

        aShape = ogl.RectangleShape(w=50, h=50)
        aShape.SetCanvas(osc)
        self.diagram.AddShape(aShape)
コード例 #15
0
    def __init__(self, parent, **keyw):
        PrintCanvas.__init__(self, parent, **keyw)

        self.parent = parent
        self.SetBackgroundColour(wx.WHITE)
        self.diagram = ogl.Diagram()
        self.SetDiagram(self.diagram)
        self.diagram.SetCanvas(self)
        self.shapes = []
        self.save_gdi = []
        self.__test__()
コード例 #16
0
    def test_lib_oglTextShape(self):
        ogl.OGLInitialize()
        osc = ogl.ShapeCanvas(self.frame)
        self.diagram = ogl.Diagram()
        osc.SetDiagram(self.diagram)
        self.diagram.SetCanvas(osc)

        aShape = ogl.TextShape(50, 50)
        aShape.SetCanvas(osc)
        aShape.AddText("Some nice text here")
        self.diagram.AddShape(aShape)
コード例 #17
0
    def add_ogl_canvas(self):
        # Add OGL

        sizer = wx.BoxSizer(wx.VERTICAL)
        # put stuff into sizer

        self.canvas = canvas = ogl.ShapeCanvas(self)
        sizer.Add(canvas, 1, wx.GROW)

        canvas.SetBackgroundColour("LIGHT BLUE")  #

        diagram = ogl.Diagram()
        canvas.SetDiagram(diagram)
        diagram.SetCanvas(canvas)

        def setpos(shape, x, y):
            width, height = shape.GetBoundingBoxMax()
            shape.SetX(x + width / 2)
            shape.SetY(y + height / 2)

        def getpos(shape):
            width, height = shape.GetBoundingBoxMax()
            x = shape.GetX()
            y = shape.GetY()
            return (x - width / 2, y - height / 2)

        shape = ogl.RectangleShape(60, 60)
        setpos(shape, 0, 0)
        canvas.AddShape(shape)
        shape = ogl.RectangleShape(60, 60)
        setpos(shape, 60, 0)
        canvas.AddShape(shape)

        shape = ogl.RectangleShape(60, 60)
        setpos(shape, 120, 0)
        canvas.AddShape(shape)

        # Next row

        shape = ogl.RectangleShape(100, 100)
        setpos(shape, 0, 60)
        canvas.AddShape(shape)

        shape = ogl.RectangleShape(100, 100)
        setpos(shape, 100, 60)
        canvas.AddShape(shape)

        print[getpos(shape) for shape in canvas.GetDiagram().GetShapeList()]

        diagram.ShowAll(1)

        # apply sizer
        self.SetSizer(sizer)
        self.SetAutoLayout(1)
コード例 #18
0
    def __init__(self, frame):
        ogl.OGLInitialize()
        ogl.ShapeCanvas.__init__(self, frame)

        maxWidth = 10000
        maxHeight = 10000
        self.SetScrollbars(20, 20, maxWidth / 20, maxHeight / 20)

        self.nodeShapes = {}
        self.connShapes = []  #Connection line shapes
        self.linesFrom = {}
        self.linesTo = {}

        self.viewMode = 'static'

        self.SetBackgroundColour(wx.Color(*Config.backgroundColorStatic))
        self.diagram = ogl.Diagram()
        self.SetDiagram(self.diagram)
        self.diagram.SetCanvas(self)
        self.SetSize((640, 480))

        self.zoom = 1
        self.mainFrame = mf = app.mainFrame

        self.menu = \
        mf.AddMenu( _('&Canvas'),   ( mf.MenuEntry( _('&Zoom +') + '\tCtrl++', _('Zooms in'), self.OnZoomPlus, 'Art/viewmag.png' ),
                                      mf.MenuEntry( _('&Zoom -') + '\tCtrl+-', _('Zooms out'), self.OnZoomMinus, 'Art/viewmag.png' ),
                                      mf.MenuEntry( _('Zoom &100%') + '\tCtrl+*', _('Reset zoom to 100%'), self.OnZoomReset, 'Art/viewmag.png' ),
                                     )
                   )

        sb = mf.statusBar
        self.zoomStatusBarWidget = wx.StaticText(sb, -1, '100%')
        noItems = sb.GetFieldsCount()
        sb.SetFieldsCount(noItems + 1)
        sb.AddWidget(self.zoomStatusBarWidget, pos=noItems)
        newWidths = sb.GetStatusWidths()[0:-1] + [60]
        sb.SetStatusWidths(newWidths)

        self.SetDropTarget(CanvasDropTarget(self))

        louie.connect(self.OnNewNode, Events.instantiateClassFinished)
        louie.connect(self.OnDeleteNode, Events.deleteNodeFinished)
        louie.connect(self.OnChangePresenterInfo,
                      Events.changePresenterInfoFinished)
        louie.connect(self.OnChangePresenterClassInfo,
                      Events.setPresenterClassInfoFinished)
        louie.connect(self.OnNewConnection, Events.createConnectionFinished)
        louie.connect(self.OnDeleteConnection, Events.deleteConnectionFinished)
        louie.connect(self.OnSetViewMode, Events.setViewMode)
        louie.connect(self.OnChangePropertyValue, Events.changePropertyValue)
        louie.connect(self.OnDisconnected, Events.disconnected)
        louie.connect(self.OnClearCanvas, Events.resetServerWorkspaceFinished)
コード例 #19
0
ファイル: icsimpleoglviewer.py プロジェクト: XHermitOne/defis
    def _init_ogl_default(self):
        """
        Инициализация внутренних объектов компонента и установка значений по умолчанию.
        """
        # Диаграмма
        self.diagram = parentModule.Diagram()
        self.SetDiagram(self.diagram)
        self.diagram.SetCanvas(self)

        # Список фигур диаграммы
        self.shapes = dict()
        # Список линий/связей
        self.lines = dict()

        # Данные диаграммы
        self.diagram_res = None
コード例 #20
0
    def test_lib_oglShapeRegion(self):
        ogl.OGLInitialize()
        osc = ogl.ShapeCanvas(self.frame)
        self.diagram = ogl.Diagram()
        osc.SetDiagram(self.diagram)
        self.diagram.SetCanvas(osc)

        aShape = ogl.RectangleShape(w=50, h=50)
        aShape.SetCanvas(osc)
        self.diagram.AddShape(aShape)

        region1 = ogl.ShapeRegion()
        region1.SetText('DividedShape')
        region1.SetProportions(0.0, 0.2)
        region1.SetFormatMode(ogl.FORMAT_CENTRE_HORIZ)
        aShape.AddRegion(region1)
コード例 #21
0
    def test_lib_oglDivisonShape(self):
        ogl.OGLInitialize()
        osc = ogl.ShapeCanvas(self.frame)
        self.diagram = ogl.Diagram()
        osc.SetDiagram(self.diagram)
        self.diagram.SetCanvas(osc)

        aShape = ogl.CompositeShape()
        aShape.SetCanvas(osc)
        self.diagram.AddShape(aShape)

        # create a division in the composite
        aShape.MakeContainer()

        # add a shape to the original division
        shape2 = ogl.RectangleShape(40, 60)
        aShape.GetDivisions()[0].AddChild(shape2)
コード例 #22
0
 def __init__(self, parent):
     ogl.OGLInitialize()
     ogl.ShapeCanvas.__init__(self, parent)
     #self.SetBackgroundColour("LIGHT BLUE") #wx.WHITE)
     self.diagram = ogl.Diagram()
     self.SetDiagram(self.diagram)
     self.diagram.SetCanvas(self)
     self.shapes = []
     if parent.Parent:
         print_size = parent.Parent.fitting_size
     else:
         from config import print_size
     w, h = print_size
     w *= 1
     h *= 1
     self.SetVirtualSize(wx.Size(w, h))
     #self.SetScrollbars(20,20,55,40)
     self.SetScrollRate(20, 20)
コード例 #23
0
    def __init__(self, parent, tilesize=32):
        wx.Panel.__init__(self, parent, -1)
        self.sizer = wx.BoxSizer(wx.HORIZONTAL)
        if not TilingWindow.oglInitialized:
            ogl.OGLInitialize()
            TilingWindow.oglInitialized = True
        self.tileset = None
        self.mapWindow = ogl.ShapeCanvas(self, -1, (400, 400))
        self.sizer.Add(self.mapWindow, True, wx.EXPAND)
        self.map = ogl.Diagram()
        self.map.SetCanvas(self.mapWindow)
        self.mapWindow.SetDiagram(self.map)
        self.area = None
        self.tilelist = None
        self.mapWindow.SetBackgroundColour("LIGHT BLUE")

        self.map.SetGridSpacing(tilesize)
        self.map.SetSnapToGrid(True)

        self.map.ShowAll(True)
        self.vertSizer = wx.BoxSizer(wx.VERTICAL)
        self.tileListCtrl = wx.ListCtrl(self,
                                        style=wx.LC_REPORT | wx.LC_NO_HEADER
                                        | wx.LC_SINGLE_SEL)
        self.vertSizer.Add(self.tileListCtrl, True, wx.EXPAND)
        self.modelWindow = ModelWindow(self)
        self.modelWindow.SetSize((150, 150))
        self.vertSizer.Add(self.modelWindow, False,
                           wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM)
        self.sizer.Add(self.vertSizer, False, wx.EXPAND)

        self.SetAutoLayout(True)
        self.SetSizer(self.sizer)
        self.sizer.Fit(self)

        self.Layout()
        self.Update()

        self.tilesize = tilesize
        self.tileshapes = []
        self.tileImageList = wx.ImageList(self.tilesize, self.tilesize)
        self.tileImageMap = {}
        self.tilelist = []
コード例 #24
0
ファイル: node_graph.py プロジェクト: gdgly/HMT-platform
    def __init__(self, parent):
        """ Initializes the NodeScriptWindow class.
            
            Args:
                parent: A reference to another wxPython object.
        """
        ogl.ShapeCanvas.__init__(self, parent)
        self.max_width = 0
        self.max_height = 0
        self.SetScrollbars(20, 20, self.max_width / 20, self.max_height / 20)

        self.SetBackgroundColour("LIGHT BLUE")
        self.diagram = ogl.Diagram()
        self.SetDiagram(self.diagram)
        self.diagram.SetCanvas(self)
        self.shapes = []
        self.id_counter = 0
        self.pos = (0, 0)
        self.parent = parent
コード例 #25
0
    def test_lib_oglPolygonShape(self):
        ogl.OGLInitialize()
        osc = ogl.ShapeCanvas(self.frame)
        self.diagram = ogl.Diagram()
        osc.SetDiagram(self.diagram)
        self.diagram.SetCanvas(osc)

        aShape = ogl.PolygonShape()
        w, h = 60, 60
        points = [
            (0.0, -h / 2.0),
            (w / 2.0, 0.0),
            (0.0, h / 2.0),
            (-w / 2.0, 0.0),
        ]

        aShape.Create(points)
        aShape.SetCanvas(osc)
        self.diagram.AddShape(aShape)
コード例 #26
0
    def __init__(self, parent, log, frame):
        ogl.ShapeCanvas.__init__(self, parent)
        maxWidth = 1000
        maxHeight = 1000
        self.SetScrollbars(20, 20, maxWidth / 20, maxHeight / 20)

        self.log = log
        self.frame = frame
        self.SetBackgroundColour("LIGHT BLUE")  # wxWHITE)

        self.SetDiagram(ogl.Diagram())
        self.GetDiagram().SetCanvas(self)
        self.save_gdi = []
        wx.EVT_WINDOW_DESTROY(self, self.OnDestroy)

        self.Bind(wx.EVT_CHAR, self.onKeyChar)
        self.working = False

        self.font1 = wx.Font(14, wx.MODERN, wx.NORMAL, wx.NORMAL, False)
        self.font2 = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False)
コード例 #27
0
    def __init__(self, parent, log, frame):
        ogl.ShapeCanvas.__init__(self, parent)

        # self.observers = multicast()
        self.app = None  # assigned later by app boot

        self.log = log
        self.frame = frame
        self.SetBackgroundColour("LIGHT BLUE")

        self.SetDiagram(ogl.Diagram())
        self.GetDiagram().SetCanvas(self)

        # wx.EVT_WINDOW_DESTROY(self, self.OnDestroy)
        # self.Bind(wx.EVT_MOUSEWHEEL, self.OnWheelZoom)
        # self.Bind(wx.EVT_KEY_DOWN, self.onKeyPress)
        # self.Bind(wx.EVT_CHAR, self.onKeyChar)

        self.font1 = wx.Font(14, wx.MODERN, wx.NORMAL, wx.NORMAL, False)
        self.font2 = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False)
コード例 #28
0
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          "Demo",
                          size=(300, 200),
                          style=wx.DEFAULT_FRAME_STYLE)
        sizer = wx.BoxSizer(wx.VERTICAL)
        # put stuff into sizer

        canvas = ogl.ShapeCanvas(self)
        sizer.Add(canvas, 1, wx.GROW)

        canvas.SetBackgroundColour("LIGHT BLUE")  #

        diagram = ogl.Diagram()
        canvas.SetDiagram(diagram)
        diagram.SetCanvas(canvas)

        shape = ogl.RectangleShape(60, 60)
        shape.SetX(30)
        shape.SetY(30)
        print shape.GetBoundingBoxMax()
        canvas.AddShape(shape)

        shape = ogl.RectangleShape(60, 60)
        shape.SetX(90)
        shape.SetY(30)
        canvas.AddShape(shape)

        shape = ogl.RectangleShape(60, 60)
        shape.SetX(150)
        shape.SetY(30)
        canvas.AddShape(shape)

        diagram.ShowAll(1)

        # apply sizer
        self.SetSizer(sizer)
        self.SetAutoLayout(1)
        self.Show(1)
コード例 #29
0
    def __init__(self, parent, frame):
        ogl.ShapeCanvas.__init__(self, parent)

        self.SetBackgroundColour("LIGHT BLUE")
        self.diagram = ogl.Diagram()
        self.SetDiagram(self.diagram)
        self.diagram.SetCanvas(self)

        self.circle = ogl.CircleShape(100)
        self.circle.SetCanvas(self)
        self.circle.a = "Circle identified"
        self.diagram.AddShape(self.circle)
        self.circle.Show(True)

        if CLICK_TO_DRAG:
            self.evthandler = MyEvtHandler()
            self.evthandler.SetShape(self.circle)
            self.evthandler.SetPreviousHandler(self.circle.GetEventHandler())
            self.circle.SetEventHandler(self.evthandler)
        else:
            self.Bind(wx.EVT_MOTION, self.OnMotion, self)
コード例 #30
0
    def test_lib_oglLineShape(self):
        ogl.OGLInitialize()
        osc = ogl.ShapeCanvas(self.frame)
        self.diagram = ogl.Diagram()
        osc.SetDiagram(self.diagram)
        self.diagram.SetCanvas(osc)

        fromShape = ogl.RectangleShape(w=50, h=50)
        fromShape.SetCanvas(osc)
        self.diagram.AddShape(fromShape)

        toShape = ogl.RectangleShape(w=50, h=50)
        toShape.SetCanvas(osc)
        self.diagram.AddShape(toShape)

        lShape = ogl.LineShape()
        lShape.SetCanvas(osc)
        lShape.MakeLineControlPoints(2)
        fromShape.AddLine(lShape, toShape)
        self.diagram.AddShape(lShape)
        lShape.Show(True)