view.py
Go to the documentation of this file.
00001 
00002 class View(object):
00003     """ Interface definations provided by the View for use by the Adapter.  
00004     
00005     NOTE: There should be no Qt specific code here!
00006     """
00007     def __init__(self):
00008         self.adapter = None
00009 
00010     def register_adapter(self,adapter):
00011         """ Saves a pointer to the adapter object."""
00012         self.adapter = adapter
00013 
00014     def update_view(self):
00015         raise NotImplementedError()
00016 
00017 
00018     def add_block_item(self, index):
00019         """ Create a new drawable BlockItem object inside the View with index.
00020         This is intended to be used to create drawable objects that correespond 
00021         with a block of the same index value.
00022         :param int index: position of the BlockItem
00023         :raises: DuplicateItemExistsError
00024         """
00025         raise NotImplementedError()
00026 
00027     def has_block_item(self, index):
00028         """ Returns if a BlockItem with specified index exists inside the view
00029         :param int index: index of desired BlockItem
00030         :rtype: bool
00031         :returns: True if BlockItem exists inside View, else False
00032         """
00033         raise NotImplementedError()
00034 
00035     def remove_block_item(self, index):
00036         """ Remove the drawable BlockItem object from the View that corresponds with index 
00037         This is intended to be used to remove drawable objects that correspond 
00038         with a block of the same index value.
00039         :param int index: index of BlockItem
00040         :raises: ItemDoesNotExistError
00041         """
00042         raise NotImplementedError()
00043    
00044     def set_block_item_settings(self, index, left_index, right_index):
00045         """ Sets the relative position of the BlockItem at index. 
00046         All three BlockItems must exist before this can be called.
00047         'None' may be specified in place of an int for left_index if no BlockItem
00048         exists to the left/right of the target (because it is the leftmost or
00049         rightmost BlockItem). 
00050         :param int index: index of target BlockItem to set position of
00051         :param int left_index: the index of the BlockItem directly to the left of the target
00052         :param int right_index: the index of the BlockItem directly to the right of the target
00053         :raises: ItemDoesNotExistError
00054         """
00055         raise NotImplementedError()
00056 
00057     def set_block_item_attributes(self, index, attributes):
00058         """ Copy settings from a BlockItemViewAttributes object to a BlockItem.
00059         For more information about attributes that can be set, see BlockItemViewAttributes.
00060         :param int index: index of the target BlockItem
00061         :param BlockItemViewAttributes attributes: class containing the desired settings
00062         :raises: ItemDoesNotExistError
00063         """ 
00064         raise NotImplementedError()
00065 
00066     def add_band_item(self, altitude, rank):
00067         """ Create a new drawable BandItem object inside the View. 
00068         This is intended to be used to create drawable objects that correspond 
00069         with a band of the same altitude and rank values.
00070         :param int altitude: vertical position of the BandItem
00071         :param int rank: initial drawing order of the BandItem
00072         :raises: DuplicateItemExistsError
00073         """
00074         raise NotImplementedError()
00075 
00076     def has_band_item(self, altitude):
00077         """ Returns if a BandItem with specified altitude exists inside the view
00078         :param int altitude: altitude of desired BandItem
00079         :rtype: bool
00080         :returns: True if BandItem exists inside View, else False
00081         """
00082         raise NotImplementedError()
00083 
00084     def remove_band_item(self, altitude):
00085         """ Remove the drawable object to correspond to a band
00086         This is intended to be used to remove drawable objects that correspond 
00087         with a band of the same altitude value.
00088         :param int altitude: altitude of BandItem
00089         :raises: ItemDoesNotExistError
00090         """ 
00091         raise NotImplementedError()
00092 
00093     def set_band_item_settings(self, altitude, rank, top_band_alt, bot_band_alt,
00094                                 leftmost_snapkey, rightmost_snapkey):
00095         """ Sets the relative position and size of the BandItem.
00096         The two BandItems corresponding to top_band_alt and bot_band_alt, as well
00097         as the two SnapItems corresponding to leftmost_snapkey and rightmost_snapkey
00098         must exist before this can be called.
00099         'None' may be specified in place of an int for top_band_alt or bot_band_alt
00100         if no BandItem exists to the top/bottom of the target band. This could 
00101         either be because it is the topmost or bottommost BandItem, or because it
00102         is adjacent to the line of BlockItems. 
00103         :param int altitude: altitude of the target BandItem 
00104         :param int rank: the drawing order of the BandItem, higher numbers are drawn above lower numbers
00105         :param int top_band_alt: the altitude of the BandItem directly above the target
00106         :param int bot_band_alt: the altitude of the BandItem directly below the target
00107         :param str leftmost_snapkey: the snapkey of the leftmost SnapItem touched by this band. For positive BandItems this must be a source, for negative bandItems this must be a sink.
00108         :param str rightmost_snapkey: the snapkey of the rightmost SnapItem touched by this band. For positive BandItems this must be a sink, for negative bandItems this must be a source.
00109         :raises: ItemDoesNotExistError
00110         """
00111         raise NotImplementedError()
00112 
00113     def set_band_item_attributes(self, index, attributes):
00114         """ Copy settings from a BandItemViewAttributes object to a BandItem
00115         For more information about attributes that can be set, see BandItemViewAttributes.
00116         :param int index: index of the target BandItem
00117         :param BandItemViewAttributes attributes: class containing the desired settings
00118         :raises: ItemDoesNotExistError
00119         """ 
00120         raise NotImplementedError()
00121 
00122 
00123     def add_snap_item(self, snapkey):
00124         """ Creates a new SnapItem in the view referenced by the given snapkey
00125         This is intended to be used to create drawable objects that correespond 
00126         with a snap of the same snapkey value.
00127         :param str snapkey: position of the SnapItem
00128         :raises: DuplicateItemExistsError
00129         """
00130         raise NotImplementedError()
00131 
00132     def has_snap_item(self, snapkey):
00133         """ Checks to see if a SnapItem corresponding to the snapkey exists in the view 
00134         :param str snapkey: snapkey of desired SnapItem
00135         :rtype: bool
00136         :returns: True if BandItem exists inside View, else False
00137         """
00138         raise NotImplementedError()
00139 
00140     def remove_snap_item(self, snapkey):
00141         """ Removes a SnapItem from the view referenced by the given snapkey
00142         This is intended to be used to remove drawable objects that correspond 
00143         with a snap of the same snapkey value.
00144         :param str snapkey: snapkey of SnapItem
00145         :raises: ItemDoesNotExistError
00146         """
00147         raise NotImplementedError()
00148 
00149     def set_snap_item_settings(self, snapkey, left_order, right_order, pos_band_alt, neg_band_alt):
00150         """ Sets the relative position of the target SnapItem specified by snapkey 
00151         with respect to other SnapItems in the same container of the same Block. 
00152         The SnapItems corresponding to the target, left_order, and right_order, 
00153         as well as the BandItems corresponding to pos_band_alt and neg_band_alt
00154         must all exist before this can be called.
00155         'None' may be specified in place of an int for left_order or right_order
00156         if no SnapItem exists to the left/right of the target SnapItem. This could 
00157         either be because it is the leftmost or rightmost SnapItem in the container. 
00158         It could also be used for pos_band_alt or neg_band_alt.
00159         :param str snapkey: snapkey of the target SnapItem 
00160         :param int left_order: the order of the SnapItem directly to the left of the target
00161         :param int right_order: the order of the SnapItem directly to the right of the target
00162         :param int pos_band_alt: the altitude of the positive BandItem attached to the target, if any
00163         :param int neg_band_alt: the altitude of the negative BandItem attached to the target, if any
00164         :raises: ItemDoesNotExistError
00165         """
00166         raise NotImplementedError()
00167 
00168     def set_snap_item_attributes(self, snapkey, attributes):
00169         """ Copy settings from a SnapItemViewAttributes object to a SnapItem
00170         For more information about attributes that can be set, see SnapItemViewAttributes.
00171         :param str snapkey: snapkey of the target SnapItem
00172         :param SnapItemViewAttributes attributes: class containing the desired settings
00173         :raises: ItemDoesNotExistError
00174         """ 
00175         raise NotImplementedError()
00176 
00177 
00178 class ViewItemAttributes(object):
00179     """ Visual Attributes for Items 
00180     These settings may or may not be applied by the view.
00181 
00182     bgcolor -- the background color
00183     border_color -- color of the border
00184     label -- label text
00185     label_color -- color of the label text
00186     """
00187     def __init__(self):
00188         self.bgcolor = None
00189         self.border_color = None
00190         self.border_width = 0
00191         self.label = None
00192         self.label_color = None
00193         self.tooltip_text = None
00194         self.draw_debug = False
00195 
00196     def copy_attributes(self, attrs):
00197         """ Copies attributes from attrs to this object """
00198         # Subclasses may override some member values with @property methods.
00199         # This copies all the values of the source using whatever method is
00200         # implemented by the destination
00201         for key in attrs.__dict__:
00202             setattr(self, key, attrs.__dict__[key])
00203 
00204 class BlockItemAttributes(ViewItemAttributes):
00205     """ Visual Attributes for BlockItems 
00206     These settings may or may not be applied by the view.
00207     spacerwidth -- distance between emitter and collector
00208     """
00209     def __init__(self):
00210         super(BlockItemAttributes, self).__init__()
00211         self.spacerwidth = None
00212       
00213 class BandItemAttributes(ViewItemAttributes):
00214     def __init__(self):
00215         super(BandItemAttributes, self).__init__()
00216         self.width = None
00217 
00218 class SnapItemAttributes(ViewItemAttributes):
00219     def __init__(self):
00220         super(SnapItemAttributes, self).__init__()
00221         self.width = None
00222 
00223 
00224 
00225 class DuplicateItemExistsError(Exception):
00226     """ An Item with the specified parameters already exists """
00227     pass
00228 
00229 class ItemDoesNotExistError(Exception):
00230     """ An Item with the specified parameters does not already exist """
00231     pass


rqt_graphprofiler
Author(s): Dan Brooks
autogenerated on Thu Jun 6 2019 20:29:31