X-Git-Url: http://git.tremily.us/?p=hooke.git;a=blobdiff_plain;f=hooke%2Fplugin%2Fcurve.py;h=d73a67f90ce2267a58dd3d9ead05bb1aedccb689;hp=e6d5ce322d23eafcaeb24887c65783b1078f0b0c;hb=8aefc576eee45cedbc7cfe009c67bd0ff11e2468;hpb=7f628b00df5065d72e89cc86be596756eb9f1ac0 diff --git a/hooke/plugin/curve.py b/hooke/plugin/curve.py index e6d5ce3..d73a67f 100644 --- a/hooke/plugin/curve.py +++ b/hooke/plugin/curve.py @@ -29,6 +29,7 @@ import copy import numpy from ..command import Command, Argument, Failure +from ..command_stack import CommandStack from ..curve import Data from ..engine import CommandMessage from ..util.calculus import derivative @@ -123,14 +124,15 @@ class CurveCommand (Command): (e.g. :class:`GetCommand`) to avoid adding themselves to the stack entirely. """ - curve = self._curve(hooke=None, params=params) - if (len(curve.command_stack) > 0 - and curve.command_stack[-1].command == self.name - and curve.command_stack[-1].arguments == params): - pass # no need to place duplicate calls on the stack. - else: - curve.command_stack.append(CommandMessage( - self.name, params)) + if params['stack'] == True: + curve = self._curve(hooke=None, params=params) + if (len(curve.command_stack) > 0 + and curve.command_stack[-1].command == self.name + and curve.command_stack[-1].arguments == params): + pass # no need to place duplicate calls on the stack. + else: + curve.command_stack.append(CommandMessage( + self.name, params)) class BlockCommand (CurveCommand): @@ -258,7 +260,8 @@ class CurvePlugin (Builtin): self._commands = [ GetCommand(self), InfoCommand(self), DeltaCommand(self), ExportCommand(self), DifferenceCommand(self), - DerivativeCommand(self), PowerSpectrumCommand(self)] + DerivativeCommand(self), PowerSpectrumCommand(self), + ClearStackCommand(self)] # Define commands @@ -621,6 +624,19 @@ Otherwise, the chunks are end-to-end, and not overlapping. return params +class ClearStackCommand (CurveCommand): + """Empty a curve's command stack. + """ + def __init__(self, plugin): + super(ClearStackCommand, self).__init__( + name='clear curve command stack', + help=self.__doc__, plugin=plugin) + + def _run(self, hooke, inqueue, outqueue, params): + curve = self._curve(hooke, params) + curve.command_stack = CommandStack() + + class OldCruft (object): def do_forcebase(self,args):