OglObject.py :  » UML » Python-UML-Tool » pyut-1.4.0 » src » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » UML » Python UML Tool 
Python UML Tool » pyut 1.4.0 » src » OglObject.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

__version__ = "$Revision: 1.11 $"
__author__  = "EI5, eivd, Group Burgbacher - Waelti"
__date__    = "2001-12-12"

#from wxPython.wx  import *
from MiniOgl import *
from mediator import *
from OglLink import *
from PyutConsts import *

DEFAULT_FONT_SIZE = 10

#----------------------------------------------------------------------

class OglObject(RectangleShape, ShapeEventHandler):
    """
    This is the base class for new OGL objects.
    Every new OGL class must inherate this class and redefines methods if
    necessary. OGL Objects are automatically wx.RectangleShape for
    global link management.

    This class has been introduced quite late in developement and has
    caused some refactoring.

    :version: $Revision: 1.11 $
    :author: Philippe Waelti
    :contact: pwaelti@eivd.ch
    """

    #>------------------------------------------------------------------ 

    def __init__(self, pyutObject = None, width = 0, height = 0):
        """
        Constructor.

        @param PyutObject pyutObject : Associated PyutObject
        @param int width  : Initial width
        @param int height : Initial height
        @since 1.0
        @author Philippe Waelti <pwaelti@eivd.ch>
        """
        # Shape initialization
        #print "OglObject-1"
        RectangleShape.__init__(self, 0, 0, width, height)
        #print "OglObject-2"

        # rectangle will not be resized from the center
        #self.SetCentreResize(False)

        # Attachments must be spaced
        #self.SetAttachmentMode(True)

        # Default, show please
        #self.Show(True)

        # PROTECTED

        # Associated PyutObject
        self._pyutObject = pyutObject

        # Default font
#        self._defaultFont = wx.Font((int)(PyutPreferences()['FONT_SIZE']) \
#                , wx.SWISS, wx.NORMAL, wx.NORMAL)
        self._defaultFont = wx.Font(DEFAULT_FONT_SIZE, wx.SWISS, \
                wx.NORMAL, wx.NORMAL)

        # Connected links
        self._oglLinks = []
        #print "OglObject-3"

        #added by P.Dabrowski 20051202 : it's the command to undo/redo
        #a modification on this object.
        self._modifyCommand = None

    #>------------------------------------------------------------------

    def setPyutObject(self, pyutObject):
        """
        Set the associated pyut object.

        @param PyutObject pyutObject : Associated PyutObject
        @since 1.0
        @author Philippe Waelti <pwaelti@eivd.ch>
        """
        self._pyutObject = pyutObject

    #>------------------------------------------------------------------

    def getPyutObject(self):
        """
        Return the associated pyut object.

        @return PyutObject : Associated PyutObject
        @since 1.0
        @author Philippe Waelti <pwaelti@eivd.ch>
        """
        return self._pyutObject

    #>------------------------------------------------------------------

    def addLink(self, link):
        """
        Add a link to an ogl object.

        @param OglLink link : the link to add
        @since 1.0
        @author Philippe Waelti <pwaelti@eivd.ch>
        """
        self._oglLinks.append(link)

    #>------------------------------------------------------------------

    def getLinks(self):
        """
        Return the links.

        @return OglLink[] : Links connected to object
        @since 1.0
        @author Philippe Waelti <pwaelti@eivd.ch>
        """
        return self._oglLinks

    #>------------------------------------------------------------------

    def OnLeftDown(self, event):
        """
        Handle event on left click.
        @param double x,y : Position
        @since 1.0
        @author Philippe Waelti <pwaelti@eivd.ch>
        """

        #print "OglObject.OnLeftDown"
        # Get mediator and signal selection
        med = getMediator()
        if med.actionWaiting():
            med.shapeSelected(self, event.GetPositionTuple())
            #print "Event processed in OglObject"
            #return EVENT_PROCESSED
            return
        #print "Skipped event in OglObject"
        event.Skip()
        #return SKIP_EVENT

    #>------------------------------------------------------------------------

    def OnLeftUp(self, event):
        pass

        #mediator.getMediator().endChangeRecording(self)



    #>------------------------------------------------------------------------

    def autoResize(self):
        """
        Find the right size to see all the content, and resize self.

        @since 1.0
        @author Philippe Waelti <pwaelti@eivd.ch>
        """
        pass


    #>------------------------------------------------------------------ 

    def SetPosition(self, x, y):
        "Define new position for the object"
        import mediator
        fileHandling = mediator.getMediator().getFileHandling()
        if fileHandling is not None:
            fileHandling.setModified(True)
        RectangleShape.SetPosition(self, x, y)
        
    def SetSelected(self, state=True):

        from mediator import getMediator
        from mediator import ACTION_ZOOM_OUT

        if mediator.getMediator().getCurrentAction() <> ACTION_ZOOM_OUT:
            RectangleShape.SetSelected(self, state)

    #>------------------------------------------------------------------

    #def DrawHandles(self, dc):
    #    """
    #    Draw the handles (selection points) of the shape.
    #    A shape has no handles, because it has no size.

    #    @param wx.DC dc
    #    """
    #    sx, sy = self.GetPosition()
    #    dc.DrawRectangle(sx - 1 - self._ox, sy - 1 - self._oy, 3, 3)
    #    dc.DrawRectangle(sx + self._width - 2 - self._ox,
    #        sy - 1 - self._oy, 3, 3)
    #    dc.DrawRectangle(sx - 1 - self._ox,
    #        sy + self._height - 2 - self._oy, 3, 3)
    #    dc.DrawRectangle(sx + self._width - 2 - self._ox,
    #        sy + self._height - 2 - self._oy, 3, 3)


www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.