Exemplo n.º 1
0
	def _getPositionsIntensities(self, sourceClass):
		for i,basis in enumerate(sourceClass._basis_dim):#range(self.nBasis):
			nearest_point=_utils.nearestPosition(self.basisMatrix[i],basis._recent_value)
			self._basis_dim[i]._recent_position = nearest_point
			self.positionsIntensities[0][0][i] = nearest_point
Exemplo n.º 2
0
		def mouseMoved(evt):
			if self.view.sceneBoundingRect().contains(evt.x(),evt.y()):
				mousePoint = self.view.vb.mapSceneToView(evt)
				self.indexX = mousePoint.x()
				self.indexY = mousePoint.y()
				#set text of crosshair
				if len(self.show_basis) == 1:
					if self.poi_show_pos:
						if self.transpose_axes:
							posY = _utils.nearestPosition(
								self.basisMatrix[self.show_merge[0]],self.indexY)
						else:
							posX = _utils.nearestPosition(
								self.basisMatrix[self.show_basis[0]],self.indexX)
					if self.poi_show_only_merge:
						self.poiText = "%0.5g" %self.indexY
					else:
						if self.poi_show_pos:
							if self.transpose_axes:
								self.poiText = "x=%0.5g\ny=%0.5g (%s)\n" %(
									self.indexX, self.indexY, posY)
							else:
								self.poiText = "x=%0.5g (%s)\ny=%0.5g\n" %(
									self.indexX,posX, self.indexY)
						else:
							self.poiText = "x=%0.5g\ny=%0.5g\n" %(
								self.indexX, self.indexY)
				elif len(self.show_basis) >= 2:
					if self.transpose_axes:
						posX = _utils.nearestPosition(
							self.basisMatrix[self.show_basis[1]],self.indexX)
						posY = _utils.nearestPosition(
							self.basisMatrix[self.show_basis[0]],self.indexY)
					else:
						posX = _utils.nearestPosition(
							self.basisMatrix[self.show_basis[0]],self.indexX)
						posY = _utils.nearestPosition(
							self.basisMatrix[self.show_basis[1]],self.indexY)
							
					z_value = self.plot.imageItem.image[posX][posY]
					if self.poi_show_only_merge:
							self.poiText = "%0.5g" %z_value
					else:
						if self.poi_show_pos:
							if self.transpose_axes:
								posXn = posX
								posX = posY
								posY = posXn
							self.poiText = "x=%0.5g (%s)\ny=%0.5g (%s)\nz=%0.5g" %(
								self.indexX, posX, self.indexY, posY, z_value)
						else:
							self.poiText = "x=%0.5g\ny=%0.5g\nz=%0.5g" %(
								self.indexX, self.indexY, z_value)

				self.crosshair.setText(self.poiText,color=(0,0,0) )
				# set anchor of crosshair
				if evt.y() - 30 > self.crosshair.boundingRect().height():
					self.anchorY = 1#at upper corner
				else:
					self.anchorY = 0
				if (evt.x() + self.crosshair.boundingRect().width() >
					self.view.sceneBoundingRect().width()):
					self.anchorX = 1 #at right corner
				else:
					self.anchorX = 0
				#set relative position of crosshair
				self.crosshair.anchor = pg.Point((self.anchorX,self.anchorY))
				#set absolute position of crosshair
				self.crosshair.setPos(self.indexX,self.indexY)
				#move crosshair-lines to mousepos.
				self.vLine.setPos(self.indexX)
				self.hLine.setPos(self.indexY)