hovered_item_factory.py
Go to the documentation of this file.
00001 """
00002 Copyright (c) 2013, Cogniteam
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007 
00008 *   Redistributions of source code must retain the above copyright
00009     notice, this list of conditions and the following disclaimer.
00010 
00011 *   Redistributions in binary form must reproduce the above copyright
00012     notice, this list of conditions and the following disclaimer in the
00013     documentation and/or other materials provided with the distribution.
00014 
00015 *   Neither the name of the Cogniteam nor the
00016     names of its contributors may be used to endorse or promote products
00017     derived from this software without specific prior written permission.
00018 
00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00020 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00021 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00022 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
00023 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00024 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00025 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00026 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00027 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00028 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 """
00030 
00031 from python_qt_binding.QtCore import QRectF
00032 from python_qt_binding.QtGui import QColor
00033 from .graph_item_factory import GraphItemFactory
00034 from .hovered_edge_item import HoveredEdgeItem
00035 from .hovered_node_item import HoveredNodeItem
00036 
00037 
00038 class HoveredGraphItemFactory(GraphItemFactory):
00039 
00040     def __init__(self):
00041         super(HoveredGraphItemFactory, self).__init__()
00042 
00043         self._highlight_level = 1
00044         self._hovered_color = QColor(250, 0, 0)
00045 
00046     def set_highlight_level(self, level):
00047         self._highlight_level = level
00048 
00049     def highlight_level(self):
00050         return self._highlight_level
00051 
00052     def set_hovered_color(self, hovered_color):
00053         self._hovered_color = hovered_color
00054 
00055     def hovered_color(self):
00056         return self._hovered_color
00057 
00058     def create_edge(self, spline, label, label_center, from_node, to_node, parent=None, **kwargs):
00059         self._check_constraints(kwargs, False)
00060         return HoveredEdgeItem(spline, label, label_center, from_node, to_node, parent, **kwargs)
00061 
00062     def create_node(self, bounding_box, shape, label, label_pos=None, url=None, parent=None, cluster=False, **kwargs):
00063         self._check_constraints(kwargs)
00064         node_item = HoveredNodeItem(bounding_box, shape, label, label_pos, url, parent, **kwargs)
00065 
00066         if cluster:
00067             bounding_box = QRectF(bounding_box)
00068             bounding_box.setHeight(30)
00069             node_item.set_hover_shape(bounding_box)
00070 
00071         return node_item
00072 
00073     def _check_constraints(self, dictionary, node=True):
00074         super(HoveredGraphItemFactory, self)._check_constraints(dictionary, node)
00075 
00076         if 'highlight_level' not in dictionary:
00077             dictionary['highlight_level'] = self._highlight_level
00078 
00079         if 'hovered_color' not in dictionary:
00080             dictionary['hovered_color'] = self._hovered_color


rqt_decision_graph
Author(s):
autogenerated on Wed Aug 26 2015 11:16:47