167 merge_type = GRAPH_PARALLEL |
167 merge_type = GRAPH_PARALLEL |
168 |
168 |
169 # If mouse is dropped in left part of graph canvas, graph |
169 # If mouse is dropped in left part of graph canvas, graph |
170 # wall be merged orthogonally |
170 # wall be merged orthogonally |
171 merge_rect = wx.Rect(rect.x, rect.y, |
171 merge_rect = wx.Rect(rect.x, rect.y, |
172 rect.width / 2., rect.height) |
172 rect.width // 2, rect.height) |
173 if merge_rect.Contains(x, y): |
173 if merge_rect.Contains(x, y): |
174 merge_type = GRAPH_ORTHOGONAL |
174 merge_type = GRAPH_ORTHOGONAL |
175 |
175 |
176 # Merge graphs |
176 # Merge graphs |
177 wx.CallAfter(self.ParentWindow.MergeGraphs, |
177 wx.CallAfter(self.ParentWindow.MergeGraphs, |
611 # Check every label paired with corresponding item |
611 # Check every label paired with corresponding item |
612 for i, t in ([pair for pair in enumerate(self.AxesLabels)] + |
612 for i, t in ([pair for pair in enumerate(self.AxesLabels)] + |
613 [pair for pair in enumerate(self.Labels)]): |
613 [pair for pair in enumerate(self.Labels)]): |
614 # Get label bounding box |
614 # Get label bounding box |
615 (x0, y0), (x1, y1) = t.get_window_extent().get_points() |
615 (x0, y0), (x1, y1) = t.get_window_extent().get_points() |
|
616 x0, y0, x1, y1 = map(int,(x0, y0, x1, y1)) |
616 rect = wx.Rect(x0, height - y1, x1 - x0, y1 - y0) |
617 rect = wx.Rect(x0, height - y1, x1 - x0, y1 - y0) |
617 # Check if mouse was over label |
618 # Check if mouse was over label |
618 if rect.Contains(x, y): |
619 if rect.Contains(x, y): |
619 item_idx = i |
620 item_idx = i |
620 break |
621 break |
722 [pair for pair in enumerate(self.AxesLabels)] + |
723 [pair for pair in enumerate(self.AxesLabels)] + |
723 [pair for pair in enumerate(self.Labels)], |
724 [pair for pair in enumerate(self.Labels)], |
724 directions): |
725 directions): |
725 # Check every label paired with corresponding item |
726 # Check every label paired with corresponding item |
726 (x0, y0), (x1, y1) = t.get_window_extent().get_points() |
727 (x0, y0), (x1, y1) = t.get_window_extent().get_points() |
|
728 x0, y0, x1, y1 = map(int,(x0, y0, x1, y1)) |
727 rect = wx.Rect(x0, height - y1, x1 - x0, y1 - y0) |
729 rect = wx.Rect(x0, height - y1, x1 - x0, y1 - y0) |
728 # Check if mouse was over label |
730 # Check if mouse was over label |
729 if rect.Contains(event.x, height - event.y): |
731 if rect.Contains(event.x, height - event.y): |
730 item_idx = i |
732 item_idx = i |
731 menu_direction = dir |
733 menu_direction = dir |
804 |
806 |
805 # Calculate position of fixed tick point according to graph type |
807 # Calculate position of fixed tick point according to graph type |
806 # and mouse position |
808 # and mouse position |
807 if self.GraphType == GRAPH_ORTHOGONAL: |
809 if self.GraphType == GRAPH_ORTHOGONAL: |
808 start_tick, end_tick = self.ParentWindow.GetRange() |
810 start_tick, end_tick = self.ParentWindow.GetRange() |
809 tick = (start_tick + end_tick) / 2. |
811 tick = (start_tick + end_tick) // 2. |
810 else: |
812 else: |
811 tick = event.xdata |
813 tick = event.xdata |
812 self.ParentWindow.ChangeRange(int(-event.step) // 3, tick) |
814 self.ParentWindow.ChangeRange(int(-event.step) // 3, tick) |
813 |
815 |
814 # Vetoing event to prevent parent panel to be scrolled |
816 # Vetoing event to prevent parent panel to be scrolled |
870 @return: wx.Size containing Viewer minimum size |
872 @return: wx.Size containing Viewer minimum size |
871 """ |
873 """ |
872 # The minimum height take in account the height of all items, padding |
874 # The minimum height take in account the height of all items, padding |
873 # inside figure and border around figure |
875 # inside figure and border around figure |
874 return wx.Size(200, |
876 return wx.Size(200, |
875 CANVAS_BORDER[0] + CANVAS_BORDER[1] + |
877 int(CANVAS_BORDER[0] + CANVAS_BORDER[1] + |
876 2 * CANVAS_PADDING + VALUE_LABEL_HEIGHT * len(self.Items)) |
878 2 * CANVAS_PADDING + VALUE_LABEL_HEIGHT * len(self.Items)) ) |
877 |
879 |
878 def SetCanvasHeight(self, height): |
880 def SetCanvasHeight(self, height): |
879 """ |
881 """ |
880 Set Viewer size checking that it respects Viewer minimum size |
882 Set Viewer size checking that it respects Viewer minimum size |
881 @param height: Viewer height |
883 @param height: Viewer height |
892 @param parent_coordinate: True if use parent coordinate (default False) |
894 @param parent_coordinate: True if use parent coordinate (default False) |
893 """ |
895 """ |
894 # Calculate figure bounding box. Y coordinate is inverted in matplotlib |
896 # Calculate figure bounding box. Y coordinate is inverted in matplotlib |
895 # figure comparing to wx panel |
897 # figure comparing to wx panel |
896 width, height = self.GetSize() |
898 width, height = self.GetSize() |
897 ax, ay, aw, ah = self.figure.gca().get_position().bounds |
899 ax, ay, aw, ah = map(int, self.figure.gca().get_position().bounds) |
898 bbox = wx.Rect(ax * width, height - (ay + ah) * height - 1, |
900 bbox = wx.Rect(ax * width, height - (ay + ah) * height - 1, |
899 aw * width + 2, ah * height + 1) |
901 aw * width + 2, ah * height + 1) |
900 |
902 |
901 # If parent_coordinate, add Viewer position in parent |
903 # If parent_coordinate, add Viewer position in parent |
902 if parent_coordinate: |
904 if parent_coordinate: |