Ejemplo n.º 1
0
NumberScale SpectrogramSettings::GetScale
(float minFreq, float maxFreq, double rate, bool bins) const
{
   NumberScaleType type = nstLinear;
   const auto half = GetFFTLength() / 2;

   // Don't assume the correspondence of the enums will remain direct in the future.
   // Do this switch.
   switch (scaleType) {
   default:
      wxASSERT(false);
   case stLinear:
      type = nstLinear; break;
   case stLogarithmic:
      type = nstLogarithmic; break;
   case stMel:
      type = nstMel; break;
   case stBark:
      type = nstBark; break;
   case stErb:
      type = nstErb; break;
   case stPeriod:
      type = nstPeriod; break;
   }

   return NumberScale(type, minFreq, maxFreq,
      bins ? rate / (2 * half) : 1.0f);
}
Ejemplo n.º 2
0
NumberScale SpectrogramSettings::GetScale( float minFreq, float maxFreq ) const
{
   NumberScaleType type = nstLinear;

   // Don't assume the correspondence of the enums will remain direct in the future.
   // Do this switch.
   switch (scaleType) {
   default:
      wxASSERT(false);
   case stLinear:
      type = nstLinear; break;
   case stLogarithmic:
      type = nstLogarithmic; break;
   case stMel:
      type = nstMel; break;
   case stBark:
      type = nstBark; break;
   case stErb:
      type = nstErb; break;
   case stPeriod:
      type = nstPeriod; break;
   }

   return NumberScale(type, minFreq, maxFreq);
}
Ejemplo n.º 3
0
NumberScale SpectrogramSettings::GetScale
(double rate, bool bins) const
{
   int minFreq, maxFreq;
   NumberScaleType type = nstLinear;
   const int half = GetFFTLength() / 2;

   // Don't assume the correspondence of the enums will remain direct in the future.
   // Do this switch.
   switch (scaleType) {
   default:
      wxASSERT(false);
   case stLinear:
      type = nstLinear; break;
   case stLogarithmic:
      type = nstLogarithmic; break;
   case stMel:
      type = nstMel; break;
   case stBark:
      type = nstBark; break;
   case stErb:
      type = nstErb; break;
   case stUndertone:
      type = nstUndertone; break;
   }

   switch (scaleType) {
   default:
      wxASSERT(false);
   case stLinear:
      minFreq = GetMinFreq(rate);
      maxFreq = GetMaxFreq(rate);
      break;
   case stLogarithmic:
   case stMel:
   case stBark:
   case stErb:
      minFreq = GetLogMinFreq(rate);
      maxFreq = GetLogMaxFreq(rate);
      break;
   case stUndertone:
   {
      const float bin2 = rate / half;
      minFreq = std::max(int(0.5 + bin2), GetLogMinFreq(rate));
      maxFreq = GetLogMaxFreq(rate);
   }
   break;
   }

   return NumberScale(type, minFreq, maxFreq,
      bins ? rate / (2 * half) : 1.0f);
}
Ejemplo n.º 4
0
void wxGISMapView::OnMouseWheel(wxMouseEvent& event)
{
	//event.Skip(false);
    DestroyDrawThread();

	int nDirection = event.GetWheelRotation();
	int nDelta = event.GetWheelDelta();
	int nFactor = nDirection / nDelta;
	m_nDrawingState = enumGISMapWheeling;

	m_nFactor += ZOOM_FACTOR * (double)nFactor;


	if(m_pGISDisplay)
	{
		double dZoom = 1;
		if(m_nFactor < 0)
			dZoom = fabs(1.0 / (m_nFactor - 1));
		else if(m_nFactor > 0)
			dZoom = 1 + m_nFactor;
        wxClientDC CDC(this);
		m_pGISDisplay->WheelingDraw(dZoom, &CDC);

		//draw scale text
		OGREnvelope Env = CreateEnvelopeFromZoomFactor(dZoom);
		if(Env.IsInit())
		{
			double sScale = GetScaleRatio( Env, CDC );
			wxString sFormatScale = NumberScale(sScale);
			sFormatScale.Prepend(wxT("1 : "));
			DrawToolTip(CDC, sFormatScale);
		}
	}

	//if(!m_timer.IsRunning())
		m_timer.Start(TM_WHEELING);
}
Ejemplo n.º 5
0
void wxGISMapView::OnMouseWheel(wxMouseEvent& event)
{
	event.Skip();

	m_pTrackCancel->Cancel();
	if(m_pThread)
		m_pThread->Delete();

	wxClientDC CDC(this);

	IDisplayTransformation* pDisplayTransformation = pGISScreenDisplay->GetDisplayTransformation();
	if(pDisplayTransformation)
	{
		if(!(m_MouseState & enumGISMouseWheel))
		{
			m_virtualrc = GetClientRect();
			m_virtualbounds = pDisplayTransformation->GetBounds();

			m_MouseState |= enumGISMouseWheel;
		}
		int direction = event.GetWheelRotation();
		int delta = event.GetWheelDelta();
		int factor = direction / delta;
		
		double world_zoom = ZOOM_FACTOR * (double)factor;


		//calc zoom dc
		int dx(0), dy(0);
		if(factor < 0)
		{
			dx = ((double)m_virtualrc.width * (world_zoom / (world_zoom - 1))) / -2;
			dy = ((double)m_virtualrc.height * (world_zoom / (world_zoom - 1))) / -2;
		}
		else
		{
			//dx = (double)m_virtualrc.width * (world_zoom) / (-2 * (1 + world_zoom));
			//dy = (double)m_virtualrc.height * (world_zoom) / (-2 * (1 + world_zoom));
			dx = ((double)m_virtualrc.width * (world_zoom)) / 2;
			dy = ((double)m_virtualrc.height * (world_zoom)) / 2;
		}

		m_virtualrc.Inflate(dx, dy);
		if(m_virtualrc.width <= 10 || m_virtualrc.height <= 10)
			return;

		m_virtualrc.CenterIn(GetClientRect());
		wxCoord x = m_virtualrc.x;
		wxCoord y = m_virtualrc.y;

		//calc zoom world
		double dwx(0), dwy(0);

		if(factor < 0)
		{
			dwx = (m_virtualbounds.MaxX - m_virtualbounds.MinX) * (world_zoom) / 2;
			dwy = (m_virtualbounds.MaxY - m_virtualbounds.MinY) * (world_zoom) / 2;
		}
		else
		{
			dwx = (m_virtualbounds.MaxX - m_virtualbounds.MinX) * (world_zoom) / (2 * (1 + world_zoom));
			dwy = (m_virtualbounds.MaxY - m_virtualbounds.MinY) * (world_zoom) / (2 * (1 + world_zoom));
		}

		m_virtualbounds.MaxX -= dwx;
		m_virtualbounds.MinX += dwx;
		m_virtualbounds.MaxY -= dwy;
		m_virtualbounds.MinY += dwy;


		wxClientDC CDC(this);

		if(!m_virtualrc.Contains(GetClientRect()))//(factor < 0)
			pGISScreenDisplay->OnStretchDraw(CDC, m_virtualrc.width, m_virtualrc.height, x, y, true, enumGISQualityBicubic/*enumGISQualityBilinear*/);
		else
		{
			wxRect client_rc = GetClientRect();
			wxRect rc = client_rc;
			rc.width = rc.width * rc.width / m_virtualrc.width;
			rc.height = rc.height * rc.height / m_virtualrc.height;
			rc.x = client_rc.x + (client_rc.width - rc.width) / 2;
			rc.y = client_rc.y + (client_rc.height - rc.height) / 2;
			pGISScreenDisplay->OnStretchDraw2(CDC, rc, false, enumGISQualityFourQuadBilinear);//enumGISQualityHalfBilinear//enumGISQualityHalfQuadBilinear//enumGISQualityNearest//
		}

		pDisplayTransformation->SetBounds(m_virtualbounds);
		//draw scale text
		double sc = pDisplayTransformation->GetScaleRatio();
		wxString format_s = NumberScale(sc);
		format_s.Prepend(wxT("1 : "));
		//wxString s = wxString::Format(_("1 : %.2f"), sc);
		//1 / (m_virtualbounds.MaxX - m_virtualbounds.MinX)/*pDisplayTransformation->GetScaleRatio()*/ * 243.84);
		wxSize size = GetClientSize();
		int width, height;

		CDC.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
		CDC.GetTextExtent(format_s, &width, &height);

		wxBrush br(wxSystemSettings::GetColour(wxSYS_COLOUR_INFOBK));
		CDC.SetBrush(br);
		CDC.SetPen(*wxBLACK_PEN);
		int x1 = (size.x - width) / 2, y1 = (size.y - height) - 50/*/ 2*/;
		CDC.DrawRectangle( x1 - 5, y1 - 2, width + 10, height + 4);

		CDC.DrawText(format_s, x1, y1);

		////SetToolTip( //96 * 2.54
			//wxTipWindow* m_pTipWnd;
		//if(m_pTipWnd)
		//	wxDELETE(m_pTipWnd);

		//wxRect client_rc = GetScreenRect();
		//m_pTipWnd = new wxTipWindow(this, wxString::Format(_("1 : %.2f"), 1 / (m_virtualbounds.MaxX - m_virtualbounds.MinX)/*pDisplayTransformation->GetScaleRatio()*/ * 243.84), 200, &m_pTipWnd, &client_rc);
		//m_pTipWnd->Hide();		
		//wxPoint pt = client_rc.GetPosition();
		//pt.x += client_rc.width / 2 - m_pTipWnd->GetSize().GetWidth() * 1.5 ;
		//pt.y += client_rc.height / 2 - m_pTipWnd->GetSize().GetHeight() * 1.5;
		//m_pTipWnd->Position(pt,m_pTipWnd->GetSize());
		//m_pTipWnd->Show();
		//if(m_pTipWnd)
		//{
		//	wxDELETE(m_pTipWnd);
		//	m_pTipWnd = NULL;
		//}
		//, m_pTipWnd(NULL)

		m_timer.Start(WAITTIME);
	}
}