Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 26 additions & 18 deletions RankPanda/Commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,56 +12,64 @@ def __init__(self, length, beginLocation):
self._name = 'Command'


# Given the beginning location, calculates the location that the
# rank should be in after count counts. Uses information such as
# self._delta and the command type, but does NOT use
# self.endLocation.


# Be sure to overwrite this in each Command!
def CalcLocation(self, count, beginLocation):
''' Given the beginning location, calculates the location that the
rank should be in after count counts. Uses information such as
self._delta and the command type, but does NOT use
self.endLocation. '''
return beginLocation

# Splits the command in two, at the specified count. Changes this command
# to be the appropriate length, and returns this command as well as the
# new one.


# Be sure to overwrite this in each Command!
def Split(self, count, beginLocation):
''' Splits the command in two, at the specified count. Changes this command
to be the appropriate length, and returns this command as well as the
new one.'''
pass

# Returns the current value of the self._name field.

def GetName(self):
''' Returns the current value of the self._name field.'''
return self._name

# Sets the value of the self._name field.

def SetName(self, name):
''' Sets the value of the self._name field.'''
self._name = name

# Returns the number of counts this command spans. If you want to change
# this value, make a new command instead.

def GetLength(self):
''' Returns the number of counts this command spans. If you want to change
this value, make a new command instead.'''
return round(self._length)

# Simple getter, in case the beginning location isn't readily available.

def GetEndLocation(self):
''' Simple getter, in case the beginning location isn't readily available.'''
return self._endLocation

def SnapEndLocation(self, newBeginLocation):
self._endLocation = self.CalcLocation(self.GetLength(), newBeginLocation)

# From the ending location, calculate the beginning location. Will require
# basically the same implementation as CalcLocation(), but in reverse.
# count should be the location in the whole command you want it to be
# returned. So, pass in 0 to run the whole command.


# Be sure to overwrite this in each Command!
def CalcBeginLocation(self, count, endLocation):
''' From the ending location, calculate the beginning location. Will require
basically the same implementation as CalcLocation(), but in reverse.
count should be the location in the whole command you want it to be
returned. So, pass in 0 to run the whole command.'''
return None

# Checks following to see if it's a command of the same name. If so,
# return the merged commands.


def MergeWithFollowing(self, following):
''' Checks following to see if it's a command of the same name. If so,
return the merged commands.'''
if ((following._name == self._name) and (isinstance(following, self))):
self._length = self._length + following._length
self._endLocation = following._endLocation
Expand Down
86 changes: 50 additions & 36 deletions RankPanda/CoreWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ class CoreWrapper(object):
def __init__(self, title, numberMeasures, CountsPerMeasureList, StepsPerCountList):
if (numberMeasures < 1):
raise NameError("Number of measures can't be less than 1!")
if (len(CountsPerMeasureList) == 0):
raise NameError("You must input the initial number of counts per measure!")
if (CountsPerMeasureList[0][0] != 1):
if (len(CountsPerMeasureList) == 0 or CountsPerMeasureList[0][0] != 1):
raise NameError("You must input the initial number of counts per measure!")
self._song = Song.Song(title, numberMeasures, CountsPerMeasureList[0][1])
i = 1
Expand Down Expand Up @@ -54,16 +52,21 @@ def GetSong(self):
# [(0, 'Move 0'), (1, 'Move 1'), ...]
def GetMoves(self):
listOfMoves = self._song.GetMoveList()
i = 0
moveInfo = []
while (i < len(listOfMoves)):
curmove = listOfMoves[i]
moveInfo.append((curmove.GetNumber(), curmove.GetName()))
i = i + 1
return moveInfo
#(Brady) Trying list comprehension
return [(curmove.GetNumber(), curmove.GetName()) for curmove in listOfMoves]
#Original Code
#i = 0
#moveInfo = []
#while (i < len(listOfMoves)):
# curmove = listOfMoves[i]
# moveInfo.append((curmove.GetNumber(), curmove.GetName()))
# i = i + 1
#return moveInfo



# Returns (current move number, current move name, current length of move in counts)
# Returns None is there is no current move
# Returns None if there is no current move
def GetCurrentMove(self):
if (self._song.currentMove is None):
return None
Expand All @@ -76,29 +79,37 @@ def GetCurrentMove(self):
# ?
# List of all ranks in current move
# [(id0, name0, location0), (id1, name1, location1)]
def GetRanks(self):
#(Brady) Merged next method with this
def GetRanks(self, moveNumber = None):
if (self._song.currentMove is None):
return None
allRanks = self._song.currentMove.GetAllRanks()
i = 0
allRankInfo = []
while (i < len(allRanks)):
allRankInfo.append((allRanks[i].GetID(), allRanks[i].GetName(), allRanks[i].GetEndLocation(), allRanks[i].GetLabelLocation()))
i = i + 1
return allRankInfo


if (moveNumber is None):
allRanks = self._song.currentMove.GetAllRanks()
else:
allRanks = self._song.GetMoveList()[moveNumber].GetAllRanks()
#(Brady) List comprehensions
return [(r.GetID(), r.GetName(), r.GetEndLocation(), r.GetLabelLocation()) for r in allRanks]
#Orig. code
#i = 0
#allRankInfo = []
#while (i < len(allRanks)):
# allRankInfo.append((allRanks[i].GetID(), allRanks[i].GetName(), allRanks[i].GetEndLocation(), allRanks[i].GetLabelLocation()))
# i = i + 1
#return allRankInfo

#(Brady) merged with prev with optional args. Keeping this so I dont have to change all the method calls.
# Same as above but now you input the move number.
def GetRanksGivenMove(self, moveNumber):
if (self._song.currentMove is None):
return None
allRanks = self._song.GetMoveList()[moveNumber].GetAllRanks()
i = 0
allRankInfo = []
while (i < len(allRanks)):
allRankInfo.append((allRanks[i].GetID(), allRanks[i].GetName(), allRanks[i].GetEndLocation(), allRanks[i].GetLabelLocation()))
i = i + 1
return allRankInfo
return self.GetRanks(moveNumber)
# if (self._song.currentMove is None):
# return None
# allRanks = self._song.GetMoveList()[moveNumber].GetAllRanks()
# i = 0
# allRankInfo = []
# while (i < len(allRanks)):
# allRankInfo.append((allRanks[i].GetID(), allRanks[i].GetName(), allRanks[i].GetEndLocation(), allRanks[i].GetLabelLocation()))
# i = i + 1
# return allRankInfo


def IsRankHeld(self, ID):
Expand All @@ -113,12 +124,15 @@ def GetSelectedRanks(self):
if (self._song.currentMove is None):
return None
allSelectedRanks = self._song.currentMove.GetSelectedRanks()
i = 0
allSelectedRankInfo = []
while (i < len(allSelectedRanks)):
allSelectedRankInfo.append((allSelectedRanks[i].GetID(), allSelectedRanks[i].GetName(), allSelectedRanks[i].GetEndLocation(), allSelectedRanks[i].GetLabelLocation()))
i = i + 1
return allSelectedRankInfo
#(Brady) List comp.
return [(r.GetID(), r.GetName(), r.GetEndLocation(), r.GetLabelLocation()) for r in allSelectedRanks]
#Orig. code
#i = 0
#allSelectedRankInfo = []
#while (i < len(allSelectedRanks)):
# allSelectedRankInfo.append((allSelectedRanks[i].GetID(), allSelectedRanks[i].GetName(), allSelectedRanks[i].GetEndLocation(), allSelectedRanks[i].GetLabelLocation()))
# i = i + 1
#return allSelectedRankInfo

def GetAdditionalRanks(self):
curList = []
Expand Down
10 changes: 5 additions & 5 deletions RankPanda/CubicHermiteSpline.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ def GetPoints(cls, splineList):
NUMBERPERSTEP = 8
lengths = SplineGenerator.GetLengths(splineList)
i = 0
# Ignore and feel free to remove the next lines, I think they're repetitiions of the GetLengths() function.
# while (i < len(splineList)):
# lengths.append(SplineGenerator.GetLength(splineList[i], 0.001))
# i = i + 1
# i = 0
# Ignore and feel free to remove the next lines, I think they're repetitiions of the GetLengths() function.
# while (i < len(splineList)):
# lengths.append(SplineGenerator.GetLength(splineList[i], 0.001))
# i = i + 1
# i = 0
listOfPointLists = []
while (i < len(splineList)):
total = NUMBERPERSTEP*lengths[i]
Expand Down
9 changes: 5 additions & 4 deletions RankPanda/GUIDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def __init__(self, parent, main, endpoint, rankName, length, FTAranks): # endpoi
self.okButton.SetDefault()
self.okButton.Bind(wx.EVT_BUTTON, self.OnOK)

self.straightButton = wx.BitmapButton(self, wx.ID_ANY, wx.Bitmap('icons/zigzagicon.png'))
self.straightButton = wx.BitmapButton(self, wx.ID_ANY, wx.Bitmap('icons/zigzagicon.png'))
self.straightButton.SetDefault()
self.straightButton.Bind(wx.EVT_BUTTON, self.OnStraight)

Expand Down Expand Up @@ -833,14 +833,14 @@ def __init__(self, parent):
# begin layout code
self.directionPanel = wx.BoxSizer(wx.HORIZONTAL)
self.directionChoices = ['Clockwise', 'Counter-clockwise']
self.directionChoicesValues = [0, 1]
#self.directionChoicesValues = [0, 1] #These aren't really needed I dont think
self.directionRadioBox = wx.RadioBox(self, wx.ID_ANY, "Direction", choices = self.directionChoices, majorDimension = 2, style = wx.RA_SPECIFY_COLS)
self.directionRadioBox.SetSelection(0) # clockwise selected by default
self.directionPanel.Add(self.directionRadioBox, 1)

self.pivotPanel = wx.BoxSizer(wx.HORIZONTAL)
self.pivotChoices = ['At arrow ', 'At point']
self.pivotChoicesValues = [0, 1]
#self.pivotChoicesValues = [0, 1]
self.pivotRadioBox = wx.RadioBox(self, wx.ID_ANY, "Non-Pivot Point", choices = self.pivotChoices, majorDimension = 2, style = wx.RA_SPECIFY_COLS)
self.pivotRadioBox.SetSelection(0) # arrow selected by default
self.pivotPanel.Add(self.pivotRadioBox, 1)
Expand Down Expand Up @@ -896,7 +896,8 @@ def OnOK(self, event):
d.ShowModal()
d.Destroy()
return
self.output = (self.directionChoicesValues[self.directionRadioBox.GetSelection()], self.pivotChoicesValues[self.pivotRadioBox.GetSelection()] , length)
#self.output = (self.directionChoicesValues[self.directionRadioBox.GetSelection()], self.pivotChoicesValues[self.pivotRadioBox.GetSelection()] , length)
self.output = (self.directionRadioBox.GetSelection(), self.pivotRadioBox.GetSelection(), length)
self.EndModal(0)

def OnCancel(self, event):
Expand Down
Loading