51 GRAPH_PARALLEL, GRAPH_ORTHOGONAL = range(2) |
51 GRAPH_PARALLEL, GRAPH_ORTHOGONAL = range(2) |
52 |
52 |
53 # Canvas height |
53 # Canvas height |
54 [SIZE_MINI, SIZE_MIDDLE, SIZE_MAXI] = [0, 100, 200] |
54 [SIZE_MINI, SIZE_MIDDLE, SIZE_MAXI] = [0, 100, 200] |
55 |
55 |
56 CANVAS_BORDER = (20., 10.) # Border height on at bottom and top of graph |
56 CANVAS_BORDER = (20., 10.) # Border height on at bottom and top of graph |
57 CANVAS_PADDING = 8.5 # Border inside graph where no label is drawn |
57 CANVAS_PADDING = 8.5 # Border inside graph where no label is drawn |
58 VALUE_LABEL_HEIGHT = 17. # Height of variable label in graph |
58 VALUE_LABEL_HEIGHT = 17. # Height of variable label in graph |
59 AXES_LABEL_HEIGHT = 12.75 # Height of variable value in graph |
59 AXES_LABEL_HEIGHT = 12.75 # Height of variable value in graph |
60 |
60 |
61 # Colors used cyclically for graph curves |
61 # Colors used cyclically for graph curves |
62 COLOR_CYCLE = ['r', 'b', 'g', 'm', 'y', 'k'] |
62 COLOR_CYCLE = ['r', 'b', 'g', 'm', 'y', 'k'] |
63 # Color for graph cursor |
63 # Color for graph cursor |
64 CURSOR_COLOR = '#800080' |
64 CURSOR_COLOR = '#800080' |
644 # Start a drag'n drop from mouse position in wx coordinate of |
644 # Start a drag'n drop from mouse position in wx coordinate of |
645 # parent |
645 # parent |
646 xw, yw = self.GetPosition() |
646 xw, yw = self.GetPosition() |
647 self.ParentWindow.StartDragNDrop(self, |
647 self.ParentWindow.StartDragNDrop(self, |
648 self.ItemsDict.values()[item_idx], |
648 self.ItemsDict.values()[item_idx], |
649 x + xw, y + yw, # Current mouse position |
649 x + xw, y + yw, # Current mouse position |
650 x + xw, y + yw) # Mouse position when button was clicked |
650 x + xw, y + yw) # Mouse position when button was clicked |
651 |
651 |
652 # Don't handle mouse button if canvas is 3D and let matplotlib do |
652 # Don't handle mouse button if canvas is 3D and let matplotlib do |
653 # the default behavior (rotate 3D axes) |
653 # the default behavior (rotate 3D axes) |
654 elif not self.Is3DCanvas(): |
654 elif not self.Is3DCanvas(): |
655 # Save mouse position when clicked |
655 # Save mouse position when clicked |
720 |
720 |
721 # If no button is pressed, show or hide contextual buttons or resize |
721 # If no button is pressed, show or hide contextual buttons or resize |
722 # highlight |
722 # highlight |
723 elif event.button is None: |
723 elif event.button is None: |
724 # Compute direction for items label according graph type |
724 # Compute direction for items label according graph type |
725 if self.GraphType == GRAPH_PARALLEL: # Graph is parallel |
725 if self.GraphType == GRAPH_PARALLEL: # Graph is parallel |
726 directions = [wx.RIGHT] * len(self.AxesLabels) + \ |
726 directions = [wx.RIGHT] * len(self.AxesLabels) + \ |
727 [wx.LEFT] * len(self.Labels) |
727 [wx.LEFT] * len(self.Labels) |
728 elif len(self.AxesLabels) > 0: # Graph is orthogonal in 2D |
728 elif len(self.AxesLabels) > 0: # Graph is orthogonal in 2D |
729 directions = [wx.RIGHT, wx.TOP, # Directions for AxesLabels |
729 directions = [wx.RIGHT, wx.TOP, # Directions for AxesLabels |
730 wx.LEFT, wx.BOTTOM] # Directions for Labels |
730 wx.LEFT, wx.BOTTOM] # Directions for Labels |
731 else: # Graph is orthogonal in 3D |
731 else: # Graph is orthogonal in 3D |
732 directions = [wx.LEFT] * len(self.Labels) |
732 directions = [wx.LEFT] * len(self.Labels) |
733 |
733 |
734 # Find if mouse is over an item label |
734 # Find if mouse is over an item label |
735 item_idx = None |
735 item_idx = None |
736 menu_direction = None |
736 menu_direction = None |
1020 # Set size of X and Y axis labels |
1020 # Set size of X and Y axis labels |
1021 self.Axes.tick_params(axis='x', labelsize='small') |
1021 self.Axes.tick_params(axis='x', labelsize='small') |
1022 self.Axes.tick_params(axis='y', labelsize='small') |
1022 self.Axes.tick_params(axis='y', labelsize='small') |
1023 |
1023 |
1024 # Init variables storing graphical elements added to figure |
1024 # Init variables storing graphical elements added to figure |
1025 self.Plots = [] # List of curves |
1025 self.Plots = [] # List of curves |
1026 self.VLine = None # Vertical line for cursor |
1026 self.VLine = None # Vertical line for cursor |
1027 self.HLine = None # Horizontal line for cursor (only orthogonal 2D) |
1027 self.HLine = None # Horizontal line for cursor (only orthogonal 2D) |
1028 self.AxesLabels = [] # List of items variable path text label |
1028 self.AxesLabels = [] # List of items variable path text label |
1029 self.Labels = [] # List of items text label |
1029 self.Labels = [] # List of items text label |
1030 |
1030 |
1031 # Get function to add a text in figure according to graph type |
1031 # Get function to add a text in figure according to graph type |
1032 add_text_func = self.GetAddTextFunction() |
1032 add_text_func = self.GetAddTextFunction() |
1033 |
1033 |
1034 # Graph type is parallel or orthogonal in 3D |
1034 # Graph type is parallel or orthogonal in 3D |
1082 # canvas size and figure size. As we want that border around figure and |
1082 # canvas size and figure size. As we want that border around figure and |
1083 # text position in figure don't change when canvas size change, we |
1083 # text position in figure don't change when canvas size change, we |
1084 # expressed border and text position in pixel on screen and apply the |
1084 # expressed border and text position in pixel on screen and apply the |
1085 # ratio calculated hereafter to get border and text position in |
1085 # ratio calculated hereafter to get border and text position in |
1086 # matplotlib coordinate |
1086 # matplotlib coordinate |
1087 canvas_ratio = 1. / height # Divide by canvas height in pixel |
1087 canvas_ratio = 1. / height # Divide by canvas height in pixel |
1088 graph_ratio = 1. / ( |
1088 graph_ratio = 1. / ( |
1089 (1.0 - (CANVAS_BORDER[0] + CANVAS_BORDER[1]) * canvas_ratio) |
1089 (1.0 - (CANVAS_BORDER[0] + CANVAS_BORDER[1]) * canvas_ratio) |
1090 * height) # Divide by figure height in pixel |
1090 * height) # Divide by figure height in pixel |
1091 |
1091 |
1092 # Update position of figure (keeping up and bottom border the same |
1092 # Update position of figure (keeping up and bottom border the same |