1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2010 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 __author__="André Ribes - EDF R&D"
23 class DevelException(Exception):
24 def __init__(self, message):
25 """Canonical constructor"""
26 Exception.__init__(self,message)
29 # ==============================================================================
30 # Interface of an eficas observer (for implementing the subject/observer pattern)
31 # ==============================================================================
33 from daGuiImpl.enumerate import Enumerate
37 This class specifies the interface of an eficas observer. See example at the
40 def processEficasEvent(self, eficasWrapper, eficasEvent):
42 This function should be implemented in the concrete Observer.
43 @param eficasWrapper the instance of the source EficasWrapper
44 @param eficasEvent the emitted event (instance of EficasEvent)
46 raise DevelException("processEficasEvent not implemented yet")
49 EVENT_TYPES=Enumerate([
59 def __init__(self,eventType,callbackId=None):
61 Creates an eficas event to be used by an EficasWrapper to notify an
64 The eventType depends of the context of creation. It specify the nature
65 of the event inside EficasWrapper that triggers the creation of this instance.
67 The callbackId is an object used by the EficasObserver to map the
68 notification (this received event) with the initial event (callback)
69 This object can be anything and has to be defined through a convention
70 that both the EficasWrapper and the EficasObserver can understand.
71 Typically, the eficas observer set the callback id to the eficas wrapper
72 before running the asynchronous show. Then, when an event is raised by
73 the eficas wrapper toward its observer, it embeds the callback id so that
74 the observer can match the received event to the initial trigger context.
76 @param the eventType to be choosen in the EVENT_TYPES
77 @param callbackId an arbitrary data object
79 if not self.EVENT_TYPES.isValid(eventType):
80 raise DevelException("The event type "+str(eventType)+" is not defined")
82 self.eventType = eventType
83 self.callbackId = callbackId