172 target_idx = self.ParentControl.GetIndex() |
172 target_idx = self.ParentControl.GetIndex() |
173 |
173 |
174 # If mouse is dropped in graph canvas bounding box and graph is |
174 # If mouse is dropped in graph canvas bounding box and graph is |
175 # not 3D canvas, graphs will be merged |
175 # not 3D canvas, graphs will be merged |
176 rect = self.ParentControl.GetAxesBoundingBox() |
176 rect = self.ParentControl.GetAxesBoundingBox() |
177 if not self.ParentControl.Is3DCanvas() and rect.InsideXY(x, y): |
177 if not self.ParentControl.Is3DCanvas() and rect.Contains(x, y): |
178 # Default merge type is parallel |
178 # Default merge type is parallel |
179 merge_type = GRAPH_PARALLEL |
179 merge_type = GRAPH_PARALLEL |
180 |
180 |
181 # If mouse is dropped in left part of graph canvas, graph |
181 # If mouse is dropped in left part of graph canvas, graph |
182 # wall be merged orthogonally |
182 # wall be merged orthogonally |
183 merge_rect = wx.Rect(rect.x, rect.y, |
183 merge_rect = wx.Rect(rect.x, rect.y, |
184 rect.width / 2., rect.height) |
184 rect.width / 2., rect.height) |
185 if merge_rect.InsideXY(x, y): |
185 if merge_rect.Contains(x, y): |
186 merge_type = GRAPH_ORTHOGONAL |
186 merge_type = GRAPH_ORTHOGONAL |
187 |
187 |
188 # Merge graphs |
188 # Merge graphs |
189 wx.CallAfter(self.ParentWindow.MergeGraphs, |
189 wx.CallAfter(self.ParentWindow.MergeGraphs, |
190 values[0], target_idx, |
190 values[0], target_idx, |
623 [pair for pair in enumerate(self.Labels)]): |
623 [pair for pair in enumerate(self.Labels)]): |
624 # Get label bounding box |
624 # Get label bounding box |
625 (x0, y0), (x1, y1) = t.get_window_extent().get_points() |
625 (x0, y0), (x1, y1) = t.get_window_extent().get_points() |
626 rect = wx.Rect(x0, height - y1, x1 - x0, y1 - y0) |
626 rect = wx.Rect(x0, height - y1, x1 - x0, y1 - y0) |
627 # Check if mouse was over label |
627 # Check if mouse was over label |
628 if rect.InsideXY(x, y): |
628 if rect.Contains(x, y): |
629 item_idx = i |
629 item_idx = i |
630 break |
630 break |
631 |
631 |
632 # If an item label have been clicked |
632 # If an item label have been clicked |
633 if item_idx is not None: |
633 if item_idx is not None: |
734 directions): |
734 directions): |
735 # Check every label paired with corresponding item |
735 # Check every label paired with corresponding item |
736 (x0, y0), (x1, y1) = t.get_window_extent().get_points() |
736 (x0, y0), (x1, y1) = t.get_window_extent().get_points() |
737 rect = wx.Rect(x0, height - y1, x1 - x0, y1 - y0) |
737 rect = wx.Rect(x0, height - y1, x1 - x0, y1 - y0) |
738 # Check if mouse was over label |
738 # Check if mouse was over label |
739 if rect.InsideXY(event.x, height - event.y): |
739 if rect.Contains(event.x, height - event.y): |
740 item_idx = i |
740 item_idx = i |
741 menu_direction = dir |
741 menu_direction = dir |
742 break |
742 break |
743 |
743 |
744 # If mouse is over an item label, |
744 # If mouse is over an item label, |
754 self.DismissContextualButtons() |
754 self.DismissContextualButtons() |
755 |
755 |
756 # Update resize highlight |
756 # Update resize highlight |
757 if event.y <= 5: |
757 if event.y <= 5: |
758 if self.SetHighlight(HIGHLIGHT_RESIZE): |
758 if self.SetHighlight(HIGHLIGHT_RESIZE): |
759 self.SetCursor(wx.StockCursor(wx.CURSOR_SIZENS)) |
759 self.SetCursor(wx.Cursor(wx.CURSOR_SIZENS)) |
760 self.ParentWindow.ForceRefresh() |
760 self.ParentWindow.ForceRefresh() |
761 else: |
761 else: |
762 if self.SetHighlight(HIGHLIGHT_NONE): |
762 if self.SetHighlight(HIGHLIGHT_NONE): |
763 self.SetCursor(wx.NullCursor) |
763 self.SetCursor(wx.NullCursor) |
764 self.ParentWindow.ForceRefresh() |
764 self.ParentWindow.ForceRefresh() |
830 @param event: Mouse event |
830 @param event: Mouse event |
831 """ |
831 """ |
832 # Check that double click was done inside figure |
832 # Check that double click was done inside figure |
833 pos = event.GetPosition() |
833 pos = event.GetPosition() |
834 rect = self.GetAxesBoundingBox() |
834 rect = self.GetAxesBoundingBox() |
835 if rect.InsideXY(pos.x, pos.y): |
835 if rect.Contains(pos.x, pos.y): |
836 # Reset Cursor tick to value before starting clicking |
836 # Reset Cursor tick to value before starting clicking |
837 self.ParentWindow.SetCursorTick(self.StartCursorTick) |
837 self.ParentWindow.SetCursorTick(self.StartCursorTick) |
838 # Toggle to text Viewer(s) |
838 # Toggle to text Viewer(s) |
839 self.ParentWindow.ToggleViewerType(self) |
839 self.ParentWindow.ToggleViewerType(self) |
840 |
840 |
924 """ |
924 """ |
925 _width, height = self.GetSize() |
925 _width, height = self.GetSize() |
926 |
926 |
927 # Mouse is over Viewer figure and graph is not 3D |
927 # Mouse is over Viewer figure and graph is not 3D |
928 bbox = self.GetAxesBoundingBox() |
928 bbox = self.GetAxesBoundingBox() |
929 if bbox.InsideXY(x, y) and not self.Is3DCanvas(): |
929 if bbox.Contains(x, y) and not self.Is3DCanvas(): |
930 rect = wx.Rect(bbox.x, bbox.y, bbox.width // 2, bbox.height) |
930 rect = wx.Rect(bbox.x, bbox.y, bbox.width // 2, bbox.height) |
931 # Mouse is over Viewer left part of figure |
931 # Mouse is over Viewer left part of figure |
932 if rect.InsideXY(x, y): |
932 if rect.Contains(x, y): |
933 self.SetHighlight(HIGHLIGHT_LEFT) |
933 self.SetHighlight(HIGHLIGHT_LEFT) |
934 |
934 |
935 # Mouse is over Viewer right part of figure |
935 # Mouse is over Viewer right part of figure |
936 else: |
936 else: |
937 self.SetHighlight(HIGHLIGHT_RIGHT) |
937 self.SetHighlight(HIGHLIGHT_RIGHT) |