def OnMouseMotion(self, event):
     where = self.get_axis(event, self.axis_width)
     if where == 'bottom' or where == 'right' or where == 'left' or where == '3rd':
         wx.SetCursor(wx.Cursor(wx.CURSOR_MAGNIFIER))
     else:
         wx.SetCursor(wx.Cursor(wx.CURSOR_ARROW))
     if where == 'bottom' and self.press:
         dx = event.xdata - self.x0
         dy = event.ydata - self.y0
         self.ax1.set_xlim(self.ax1.get_xlim()[0] - dx,
                           self.ax1.get_xlim()[1] - dx)
         self.Draw(False)
     if where == 'main' and self.press:
         self.span.set_bounds(self.x0,\
                             self.ax1.get_ylim()[0],\
                             event.xdata-self.x0,\
                             self.ax1.get_ylim()[1]-self.ax1.get_ylim()[0])
         self.Draw(True)
     if where == 'main' and self.cursor != None:
         self.cursor.set_xdata(event.xdata)
         xval = event.xdata
         idx = np.searchsorted(self.ax1.get_lines()[0].get_data()[0], xval)
         while self.gpx['ok'][
                 idx] == False and idx >= 0:  #look for nearest enabled point
             idx -= 1
         idx = clamp(idx, 0, self.gpx.get_row_count() - 1)
         self.cursor.set_xdata(self.x_to_num(self.gpx[self.xaxis][idx]))
         msgwrap.message("CurChanged", arg1=self.id, arg2=idx)
         ##send a message for the status bar
         self.UpdateStatusBar(idx)
         self.Draw(True)
 def UpdateStatusBar(self, idx):
     if self.plot1 != "none":
         msg1=self.plot1+\
             " ("+str(self.gpx.get_unit(self.plot1)[0])+"): "\
             +str(self.gpx[self.plot1][idx]*self.gpx.scale[self.plot1])
     else:
         msg1 = ""
     if self.plot2 != "none":
         msg2=self.plot2+\
             " ("+str(self.gpx.get_unit(self.plot2)[0])+"): "\
             +str(self.gpx[self.plot2][idx]*self.gpx.scale[self.plot2])
     else:
         msg2 = ""
     if self.plot3 != "none":
         msg3=self.plot3+\
             " ("+str(self.gpx.get_unit(self.plot3)[0])+"): "\
             +str(self.gpx[self.plot3][idx]*self.gpx.scale[self.plot3])
     else:
         msg3 = ""
     msgwrap.message("StatusChanged",arg1=self.id,\
                         arg2=self.gpx['time'][idx],\
                         arg3=msg1,\
                         arg4=msg2,\
                         arg5=msg3
                         )
Esempio n. 3
0
 def OnReplayTimer(self,event):
     self.idx+=1
     if self.idx > self.selstop-1:
         self.idx=self.selstart
     #skip disabled portions
     while not self.gpx['ok'][self.idx]:
         self.idx+=1
         if self.idx > self.selstop:
             self.idx=self.selstart
     msgwrap.message("CurChanged",arg1=self.id,arg2=self.idx)
Esempio n. 4
0
 def Analyse(self):
     # remove any unkown door number
     self.waypoints = [
         w for w in self.waypoints
         if ((w < len(self.waypointslayer.doors)) and (w >= 0))
     ]
     #now calculate all intersections with these doors...
     if self.gpx != None and len(self.waypoints) > 0:
         sect_door = []
         sect_idx = []
         segments = []
         for p in xrange(1, self.gpx.get_row_count()):
             for d in xrange(0, len(self.waypointslayer.doors)):
                 d1 = (self.waypointslayer.doors[d][0],
                       self.waypointslayer.doors[d][1])
                 d2 = (self.waypointslayer.doors[d][2],
                       self.waypointslayer.doors[d][3])
                 p1 = (self.gpx['lat'][p - 1], self.gpx['lon'][p - 1])
                 p2 = (self.gpx['lat'][p], self.gpx['lon'][p])
                 if intersect(p1, p2, d1, d2) or intersect(
                         p1, p2, d2, d1) or intersect(
                             p2, p1, d2, d1) or intersect(p2, p1, d2, d1):
                     sect_door.append(d)
                     sect_idx.append(p)
         #then find the right sequences...
         for d in xrange(0, len(sect_door)):
             if sect_door[d:d + len(self.waypoints)] == self.waypoints:
                 if np.all(
                         self.gpx['ok'][sect_idx[d] -
                                        1:sect_idx[d + len(self.waypoints) -
                                                   1] + 1]):
                     segments.append(
                         (sect_idx[d] - 1,
                          sect_idx[d + len(self.waypoints) - 1] + 1))
         if self.disableoutside:
             self.gpx['ok'][0:self.gpx.get_last_row_idx() + 1] = False
             for s in segments:
                 self.gpx['ok'][s[0]:s[1]] = True
             msgwrap.message("ValChanged", arg1=self.id)
         data = []
         lap = 0
         for s in segments:
             lap += 1
             #['lap','start','stop','duration','distance','avg speed','top speed']
             data.append([lap,\
                         self.gpx['time'][s[0]][11:19],\
                         self.gpx['time'][s[1]][11:19],\
                         np.sum(self.gpx['deltat'][s[0]:s[1]]), \
                         np.sum(self.gpx['deltaxy'][s[0]:s[1]]),
                         np.sum(self.gpx['deltaxy'][s[0]:s[1]])/np.sum(self.gpx['deltat'][s[0]:s[1]])*self.gpx.get_scale('speed'),\
                         self.gpx[('speed',1)][s[0]:s[1]].max()])
         self.resultsgrid.SetData(data)
         w, h = self.GetSize()
         self.SetSize((w + 1, h))
         self.SetSize((w, h))
Esempio n. 5
0
 def OnUnitsMenu(self,event):
     li=[]
     un='|'.join(gpxobj.units.keys())
     # as _x, _y, _r, _g, _b and _d are no more in gpx file, we could avoid checking first character...
     for head in self.gpx.get_header_names():
         if not head.startswith('_'):
             li.append(("wxcombo",str(head),un,self.gpx.get_unit(head)[0],'str'))
     res=WxQuery("Adjust units",li)
     i=0
     for head in self.gpx.get_header_names():
         if not head.startswith('_'):
             self.gpx.set_unit(head,res[i])
             i+=1
     msgwrap.message("ValChanged",arg1=self.id)
     self.Refresh()
 def OnPopup(self, event):
     item = self.select_menu.FindItemById(event.GetId())
     text = item.GetText()
     if text == "Disable selected":
         self.gpx['ok'][self.selstart:self.selstop] = False
     if text == "Enable selected":
         self.gpx['ok'][self.selstart:self.selstop] = True
     if text == "Disable non selected":
         self.gpx['ok'][:self.selstart] = False
         self.gpx['ok'][self.selstop:] = False
     if text == "Enable non selected":
         self.gpx['ok'][:self.selstart] = True
         self.gpx['ok'][self.selstop:] = True
     if text == "Delete selected":
         if wx.MessageDialog(None, "Delete Points...?",\
                             'Are you sure you want to delete these points',\
                             wx.YES_NO | wx.ICON_QUESTION).ShowModal()==wx.ID_YES:
             for _ in range(self.selstart, self.selstop):
                 self.gpx.drop_row(
                     self.selstart
                 )  #each time we delete, the rest of the array is shifted. so we have to delete always the same index
     if text == "Delete non selected":
         if wx.MessageDialog(None, "Delete Points...?",\
                             'Are you sure you want to delete these points',\
                             wx.YES_NO | wx.ICON_QUESTION).ShowModal()==wx.ID_YES:
             for _ in range(self.selstop, self.gpx.get_row_count()):
                 self.gpx.drop_row(
                     self.selstop
                 )  #delete first end of range, to avoid shifting selstop
             for _ in range(0, self.selstart):
                 self.gpx.drop_row(0)
     if text == "Toggle points":
         self.gpx['ok'] = np.invert(self.gpx['ok'])
     msgwrap.message("ValChanged", arg1=self.id)
     self.update_axis(self.ax1, self.plot1,
                      self.ax1.get_ylim()[0],
                      self.ax1.get_ylim()[1], self.autoy1, self.lineprops1,
                      self.smooth1)
     self.update_axis(self.ax2, self.plot2,
                      self.ax2.get_ylim()[0],
                      self.ax2.get_ylim()[1], self.autoy2, self.lineprops2,
                      self.smooth2)
     self.update_axis(self.ax3, self.plot3,
                      self.ax3.get_ylim()[0],
                      self.ax3.get_ylim()[1], self.autoy3, self.lineprops3,
                      self.smooth3)
 def OnLeftMouseUp(self, event):
     where = self.get_axis(event, self.axis_width)
     self.press = False
     if event.button == 1 and self.span != None:
         if where == 'main':
             idx1 = np.searchsorted(self.ax1.get_lines()[0].get_data()[0],
                                    self.x0)
             idx2 = np.searchsorted(self.ax1.get_lines()[0].get_data()[0],
                                    event.xdata)
             self.selstart = min(idx1, idx2)
             self.selstop = max(idx1, idx2)
             if self.selstart == self.selstop:
                 self.span.set_visible(False)
             msgwrap.message("SelChanged",
                             arg1=self.id,
                             arg2=self.selstart,
                             arg3=self.selstop)
             self.press = False
Esempio n. 8
0
 def OnRowPopup(self,event):
     item = self.row_menu.FindItemById(event.GetId())
     text = item.GetText()
     if text=='Enable selected':
         self.gpxtable.gpx['ok'][self.GetSelectedRows()]=True
     if text=='Disable selected':
         self.gpxtable.gpx['ok'][self.GetSelectedRows()]=False
     if text=='Enable non selected':
         ns=list(set(range(self.gpxtable.gpx.get_row_count()))-set(self.GetSelectedRows()))
         self.gpxtable.gpx['ok'][ns]=True
     if text=='Disable non selected':
         ns=list(set(range(self.gpxtable.gpx.get_row_count()))-set(self.GetSelectedRows()))
         self.gpxtable.gpx['ok'][ns]=False
     if text=='Toggle points':
         self.gpxtable.gpx['ok']=np.invert(self.gpxtable.gpx['ok'])
     self.ForceRefresh()
     '''pub.sendMessage("ValChanged",arg1=self.parent.id)'''
     msgwrap.message("ValChanged",arg1=self.parent.id)
Esempio n. 9
0
 def OnMouseMotion(self, event):
     #if not self.active:
     #    return False
     if not self.parent.dragging:
         if self.gpx != None:
             self._gpx['_d'] = np.power(
                 (self._gpx['_x'] - event.GetX()), 2) + np.power(
                     (self._gpx['_y'] - event.GetY()), 2)
             #i=np.argmin(self.gpx[('_d',0,1)])
             #idx=self.gpx[('idx',0,1)][i]
             i = np.argmin(
                 self._gpx['_d'][np.where(self.gpx['ok'] == True)])
             idx = self.gpx['idx'][np.where(self.gpx['ok'] == True)][i]
             self.current = idx
             self.current_x = self._gpx['_x'][idx]
             self.current_y = self._gpx['_y'][idx]
             msgwrap.message("CurChanged", arg1=self.id, arg2=idx)
             self.parent.Draw(False)
             self.parent.Refresh()
             return False  # let other layer process this event
Esempio n. 10
0
 def OnCellChange(self,event):
     msgwrap.message("ValChanged",arg1=self.parent.id)
     event.Skip()
Esempio n. 11
0
 def upd(self):
     msgwrap.message("ValChanged", arg1=self.id)