Esempio n. 1
0
    def motion(self,event):

      '''define what happens when the user moves the mouse over the canvas'''

      lon = event.xdata
      lat = event.ydata

      if self.drawinglines:

        if self.dragging:

          print 'Dragging!'
          #print lon,lat

        if self.line:
           self.line[0].remove()
        if self.points:
          self.points[0].remove()
        if self.arrow:
          self.arrow.remove()
        if self.helpfultext:
          self.helpfultext.remove()

        self.linelats = [self.startlat,lat]
        self.linelons = [self.startlon,lon]
        xevent,yevent = self.mapobj(self.linelons,self.linelats)

        az = misctools.coords_for_profile(self.startlon,self.startlat,lon,lat)

        self.arrow = plt.arrow(xevent[0],yevent[0],xevent[1]-xevent[0],yevent[1]-yevent[0],fc="k", ec="k", linewidth = 2, head_width=3, head_length=3)
        self.line = self.mapobj.plot(xevent,yevent,'r-',linewidth=2,alpha=0.9)
        self.points = self.mapobj.plot(xevent,yevent,'ko')

        self.helpfultext = self.axobj.text(self.startlon, self.startlat, 'lon: %g lat: %g az: %g' %(self.startlon,self.startlat,az), style='italic',bbox={'facecolor':'white', 'alpha':0.5, 'pad':10})
        self.figobj.canvas.draw()
Esempio n. 2
0
    def onpick(self, event):
      '''
      Define what happens when the user presses the cursor. If the user chooses to make a cross section
      the Ritsema tools are automatically called and slices though the various models are plotted. A stack of 
      tomography slices is also made and contours associated with the slab are traced 
      '''

      if self.drawinglines:

        if event.button == 3:
          print 'Create profile!'

          s = str(raw_input('Create a profile? [Y/N]: '))

          if s == 'Y':
            print 'making profile!!'
            #print self.linelats
            #print self.linelons

            midlon = self.linelons[0]
            midlat = self.linelats[0]
            lon1 = self.linelons[1]
            lat1 = self.linelats[1]

            #Determine azimuth from the start point to the selected location
            azimuth = misctools.coords_for_profile(self.linelons[0],self.linelats[0],self.linelons[1],self.linelats[1])

            #Two options here: Use Ritsema codes to generate slice through the region of interest or use Becker codes

            #print 'Getting ready to run Ritsema codes with midlon/midlat = %g/%g and azimuth of %g' %(midlon,midlat,azimuth)
            #misctools.Ritsema_180_sections(midlon,midlat,azimuth)

            print 'Getting ready to run Becker codes with midlon/midlat = %g/%g and azimuth of %g' %(midlon,midlat,azimuth)
            misctools.Becker_slice(midlon, midlat, lon1, lat1, azimuth,name='User_defined',showplot=True)

          else:
            print 'No profile selected. Continue'

          self.drawinglines = None

        if event.button == 1:
          print 'Draw desired profile now. Click mouse 3 when done with your profile'
          self.dragging = True

          lon = event.xdata
          lat = event.ydata
          self.startlon = lon
          self.startlat = lat
      
      elif event.button == 3:

        print 'proceeding to draw lines!'
        self.drawinglines = True

      elif event.button == 1:

        print 'No drawing lines!'
        print 'Use mouse 3 to start or stop drawing a profile'
        print 'Use mouse 1 to '

      else:

        print 'Not a recognized command!'