dmg_edge_item.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.QtGui import QColor
00032 from .hovered_edge_item import HoveredEdgeItem
00033 
00034 
00035 class DmgEdgeItem(HoveredEdgeItem):
00036 
00037     HIGHLIGHTED_COLOR = QColor(0, 0, 0)
00038     HIGHLIGHTED_PEN_WIDTH = 2.0
00039 
00040     def __init__(self, spline, label, label_center, from_node, to_node, parent=None, **kwargs):
00041         super(DmgEdgeItem, self).__init__(spline, label, label_center, from_node, to_node, parent, **kwargs)
00042 
00043         self._highlighted_color = kwargs.get('highlighted_color', self.HIGHLIGHTED_COLOR)
00044         self._highlighted_pen_width = kwargs.get('highlighted_pen_width', self.HIGHLIGHTED_PEN_WIDTH)
00045 
00046         self._current_color = self._color
00047         self._previous_color = self._color
00048 
00049         self._current_pen_width = self._pen_width
00050         self._previous_pen_width = self._pen_width
00051 
00052     def set_color(self, color=None):
00053         if color is None:
00054             color = self._color
00055 
00056         self._previous_color = self._current_color
00057         self._current_color = color
00058 
00059         self._brush.setColor(color)
00060         self._edge_pen.setColor(color)
00061         self._label_pen.setColor(color)
00062 
00063         self._path.setPen(self._edge_pen)
00064 
00065         if self._arrow is not None:
00066             self._arrow.setBrush(self._brush)
00067             self._arrow.setPen(self._edge_pen)
00068         if self._label is not None:
00069             self._label.setBrush(self._brush)
00070             self._label.setPen(self._label_pen)
00071 
00072     def highlight(self, highlighted=True):
00073         if highlighted:
00074             self.set_color(self._highlighted_color)
00075         else:
00076             self.set_color(self._previous_color)
00077 
00078     def hoverEnterEvent(self, event):
00079         self.highlight()
00080         self._highlight_connections()
00081 
00082     def hoverLeaveEvent(self, event):
00083         self.highlight(False)
00084         self._highlight_connections(False)


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