controls/DebugVariablePanel/DebugVariableGraphicViewer.py
changeset 1497 7330c85534ea
parent 1485 a30776c43846
child 1571 486f94a8032c
equal deleted inserted replaced
1496:ac8a90b278f1 1497:7330c85534ea
    38 from editors.DebugViewer import REFRESH_PERIOD
    38 from editors.DebugViewer import REFRESH_PERIOD
    39 
    39 
    40 from DebugVariableItem import DebugVariableItem
    40 from DebugVariableItem import DebugVariableItem
    41 from DebugVariableViewer import *
    41 from DebugVariableViewer import *
    42 from GraphButton import GraphButton
    42 from GraphButton import GraphButton
       
    43 
       
    44 
       
    45 from distutils.version import LooseVersion
       
    46 if LooseVersion(matplotlib.__version__) >= LooseVersion("1.5.0"):
       
    47     from cycler import cycler
       
    48 
    43 
    49 
    44 # Graph variable display type
    50 # Graph variable display type
    45 GRAPH_PARALLEL, GRAPH_ORTHOGONAL = range(2)
    51 GRAPH_PARALLEL, GRAPH_ORTHOGONAL = range(2)
    46 
    52 
    47 # Canvas height
    53 # Canvas height
   973         def AddText(*args, **kwargs):
   979         def AddText(*args, **kwargs):
   974             args = [0, 0, ""]
   980             args = [0, 0, ""]
   975             kwargs["transform"] = self.Axes.transAxes
   981             kwargs["transform"] = self.Axes.transAxes
   976             return text_func(*args, **kwargs)
   982             return text_func(*args, **kwargs)
   977         return AddText
   983         return AddText
   978     
   984 
       
   985     def SetAxesColor(self, color):
       
   986         if LooseVersion(matplotlib.__version__) >= LooseVersion("1.5.0"):
       
   987             self.Axes.set_prop_cycle(cycler('color',color))
       
   988         else:
       
   989             self.Axes.set_color_cycle(color)
       
   990         
   979     def ResetGraphics(self):
   991     def ResetGraphics(self):
   980         """
   992         """
   981         Reset figure and graphical elements displayed in it
   993         Reset figure and graphical elements displayed in it
   982         Called any time list of items or graph type change 
   994         Called any time list of items or graph type change 
   983         """
   995         """
   985         self.Figure.clear()
   997         self.Figure.clear()
   986         
   998         
   987         # Add 3D projection if graph is in 3D
   999         # Add 3D projection if graph is in 3D
   988         if self.Is3DCanvas():
  1000         if self.Is3DCanvas():
   989             self.Axes = self.Figure.gca(projection='3d')
  1001             self.Axes = self.Figure.gca(projection='3d')
   990             self.Axes.set_color_cycle(['b'])
  1002             self.SetAxesColor(['b'])
   991             
  1003             
   992             # Override function to prevent too much refresh when graph is 
  1004             # Override function to prevent too much refresh when graph is 
   993             # rotated
  1005             # rotated
   994             self.LastMotionTime = gettime()
  1006             self.LastMotionTime = gettime()
   995             setattr(self.Axes, "_on_move", self.OnAxesMotion)
  1007             setattr(self.Axes, "_on_move", self.OnAxesMotion)
  1000             # Set size of Z axis labels
  1012             # Set size of Z axis labels
  1001             self.Axes.tick_params(axis='z', labelsize='small')
  1013             self.Axes.tick_params(axis='z', labelsize='small')
  1002         
  1014         
  1003         else:
  1015         else:
  1004             self.Axes = self.Figure.gca()
  1016             self.Axes = self.Figure.gca()
  1005             self.Axes.set_color_cycle(COLOR_CYCLE)
  1017             self.SetAxesColor(COLOR_CYCLE)
  1006         
  1018         
  1007         # Set size of X and Y axis labels
  1019         # Set size of X and Y axis labels
  1008         self.Axes.tick_params(axis='x', labelsize='small')
  1020         self.Axes.tick_params(axis='x', labelsize='small')
  1009         self.Axes.tick_params(axis='y', labelsize='small')
  1021         self.Axes.tick_params(axis='y', labelsize='small')
  1010         
  1022