当前位置: 首页>>代码示例>>C++>>正文


C++ wxRound函数代码示例

本文整理汇总了C++中wxRound函数的典型用法代码示例。如果您正苦于以下问题:C++ wxRound函数的具体用法?C++ wxRound怎么用?C++ wxRound使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wxRound函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetDoublePixFromLL

// TODO: eliminate the use of this function
wxPoint ViewPort::GetPixFromLL( double lat, double lon )
{
    wxPoint2DDouble p = GetDoublePixFromLL(lat, lon);
    if(wxIsNaN(p.m_x) || wxIsNaN(p.m_y))
        return wxPoint(INVALID_COORD, INVALID_COORD);
    return wxPoint(wxRound(p.m_x), wxRound(p.m_y));
}
开发者ID:cagscat,项目名称:OpenCPN,代码行数:8,代码来源:viewport.cpp

示例2: GetSize

void BITMAP_BASE::DrawBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPos )
{
    if( m_bitmap == NULL )
        return;

    wxPoint pos  = aPos;
    wxSize  size = GetSize();

    // To draw the bitmap, pos is the upper left corner position
    pos.x -= size.x / 2;
    pos.y -= size.y / 2;

    double scale;
    int    logicalOriginX, logicalOriginY;
    aDC->GetUserScale( &scale, &scale );
    aDC->GetLogicalOrigin( &logicalOriginX, &logicalOriginY );
    aDC->SetUserScale( scale * GetScalingFactor(), scale * GetScalingFactor() );
    aDC->SetLogicalOrigin( logicalOriginX / GetScalingFactor(),
                          logicalOriginY / GetScalingFactor() );
    aDC->DrawBitmap( *m_bitmap,
                     wxRound( pos.x / GetScalingFactor() ),
                     wxRound( pos.y / GetScalingFactor() ),
                     true );
    aDC->SetUserScale( scale, scale );
    aDC->SetLogicalOrigin( logicalOriginX, logicalOriginY );
}
开发者ID:hellamps,项目名称:kicad,代码行数:26,代码来源:class_bitmap_base.cpp

示例3: wxASSERT

void wxGCDCImpl::DoDrawPolyPolygon(int n,
                               const int count[],
                               const wxPoint points[],
                               wxCoord xoffset,
                               wxCoord yoffset,
                               wxPolygonFillMode fillStyle)
{
    wxASSERT(n > 1);
    wxGraphicsPath path = m_graphicContext->CreatePath();

    int i = 0;
    for ( int j = 0; j < n; ++j)
    {
        wxPoint start = points[i];
        path.MoveToPoint( start.x+ xoffset, start.y+ yoffset);
        ++i;
        int l = count[j];
        for ( int k = 1; k < l; ++k)
        {
            path.AddLineToPoint( points[i].x+ xoffset, points[i].y+ yoffset);
            ++i;
        }
        // close the polygon
        if ( start != points[i-1])
            path.AddLineToPoint( start.x+ xoffset, start.y+ yoffset);
    }
    m_graphicContext->DrawPath( path , fillStyle);

    wxRect2DDouble box = path.GetBox();
    CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y));
    CalcBoundingBox(wxRound(box.m_x + box.m_width),
                    wxRound(box.m_y + box.m_height));
}
开发者ID:animecomico,项目名称:wxWidgets,代码行数:33,代码来源:dcgraph.cpp

示例4: iter

// Deduce m_FromFrequency from the samples at the beginning of
// the selection. Then set some other params accordingly.
void EffectChangePitch::DeduceFrequencies()
{
   // As a neat trick, attempt to get the frequency of the note at the
   // beginning of the selection.
   SelectedTrackListOfKindIterator iter(Track::Wave, inputTracks());
   WaveTrack *track = (WaveTrack *) iter.First();
   if (track) {
      double rate = track->GetRate();

      // Auto-size window -- high sample rates require larger windowSize.
      // Aim for around 2048 samples at 44.1 kHz (good down to about 100 Hz).
      // To detect single notes, analysis period should be about 0.2 seconds.
      // windowSize must be a power of 2.
      const size_t windowSize =
         // windowSize < 256 too inaccurate
         std::max(256, wxRound(pow(2.0, floor((log(rate / 20.0)/log(2.0)) + 0.5))));

      // we want about 0.2 seconds to catch the first note.
      // number of windows rounded to nearest integer >= 1.
      const unsigned numWindows =
         std::max(1, wxRound((double)(rate / (5.0f * windowSize))));

      double trackStart = track->GetStartTime();
      double t0 = mT0 < trackStart? trackStart: mT0;
      auto start = track->TimeToLongSamples(t0);

      auto analyzeSize = windowSize * numWindows;
      Floats buffer{ analyzeSize };

      Floats freq{ windowSize / 2 };
      Floats freqa{ windowSize / 2, true };

      track->Get((samplePtr) buffer.get(), floatSample, start, analyzeSize);
      for(unsigned i = 0; i < numWindows; i++) {
         ComputeSpectrum(buffer.get() + i * windowSize, windowSize,
                         windowSize, rate, freq.get(), true);
         for(size_t j = 0; j < windowSize / 2; j++)
            freqa[j] += freq[j];
      }
      size_t argmax = 0;
      for(size_t j = 1; j < windowSize / 2; j++)
         if (freqa[j] > freqa[argmax])
            argmax = j;

      auto lag = (windowSize / 2 - 1) - argmax;
      m_dStartFrequency = rate / lag;
   }

   double dFromMIDInote = FreqToMIDInote(m_dStartFrequency);
   double dToMIDInote = dFromMIDInote + m_dSemitonesChange;
   m_nFromPitch = PitchIndex(dFromMIDInote);
   m_nFromOctave = PitchOctave(dFromMIDInote);
   m_nToPitch = PitchIndex(dToMIDInote);
   m_nToOctave = PitchOctave(dToMIDInote);

   m_FromFrequency = m_dStartFrequency;
   Calc_PercentChange();
   Calc_ToFrequency();
}
开发者ID:MindFy,项目名称:audacity,代码行数:61,代码来源:ChangePitch.cpp

示例5: DoGetSizeMM

void wxSVGFileDCImpl::DoGetSizeMM( int *width, int *height ) const
{
    if (width)
        *width = wxRound( (double)m_width / m_mm_to_pix_x );

    if (height)
        *height = wxRound( (double)m_height / m_mm_to_pix_y );
}
开发者ID:Jasonudoo,项目名称:wxWidgets,代码行数:8,代码来源:dcsvg.cpp

示例6: wxCHECK_RET

void wxGCDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
                               double angle)
{
    wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") );

    if ( text.empty() )
        return;
    if ( !m_logicalFunctionSupported )
        return;

    // we test that we have some font because otherwise we should still use the
    // "else" part below to avoid that DrawRotatedText(angle = 180) and
    // DrawRotatedText(angle = 0) use different fonts (we can't use the default
    // font for drawing rotated fonts unfortunately)
    if ( (angle == 0.0) && m_font.IsOk() )
    {
        DoDrawText(text, x, y);
        
        // Bounding box already updated by DoDrawText(), no need to do it again.
        return;
    }
            
    // Get extent of whole text.
    wxCoord w, h, heightLine;
    GetOwner()->GetMultiLineTextExtent(text, &w, &h, &heightLine);
    
    // Compute the shift for the origin of the next line.
    const double rad = wxDegToRad(angle);
    const double dx = heightLine * sin(rad);
    const double dy = heightLine * cos(rad);
    
    // Draw all text line by line
    const wxArrayString lines = wxSplit(text, '\n', '\0');
    for ( size_t lineNum = 0; lineNum < lines.size(); lineNum++ )
    {
        // Calculate origin for each line to avoid accumulation of
        // rounding errors.
        if ( m_backgroundMode == wxTRANSPARENT )
            m_graphicContext->DrawText( lines[lineNum], x + wxRound(lineNum*dx), y + wxRound(lineNum*dy), wxDegToRad(angle ));
        else
            m_graphicContext->DrawText( lines[lineNum], x + wxRound(lineNum*dx), y + wxRound(lineNum*dy), wxDegToRad(angle ), m_graphicContext->CreateBrush(m_textBackgroundColour) );
   }
            
    // call the bounding box by adding all four vertices of the rectangle
    // containing the text to it (simpler and probably not slower than
    // determining which of them is really topmost/leftmost/...)
    
    // "upper left" and "upper right"
    CalcBoundingBox(x, y);
    CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
    
    // "bottom left" and "bottom right"
    x += (wxCoord)(h*sin(rad));
    y += (wxCoord)(h*cos(rad));
    CalcBoundingBox(x, y);
    CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
}
开发者ID:animecomico,项目名称:wxWidgets,代码行数:57,代码来源:dcgraph.cpp

示例7: wxGetDisplaySizeMM

wxSize wxGetDisplaySizeMM()
{
    const wxSize ppi = wxGetDisplayPPI();
    if ( !ppi.x || !ppi.y )
        return wxSize(0, 0);

    const wxSize pixels = wxGetDisplaySize();
    return wxSize(wxRound(pixels.x * inches2mm / ppi.x),
                  wxRound(pixels.y * inches2mm / ppi.y));
}
开发者ID:CodeSmithyIDE,项目名称:wxWidgets,代码行数:10,代码来源:gdicmn.cpp

示例8: GetScalingFactor

wxPoint BASE_SCREEN::GetCrossHairScreenPosition() const
{
    wxPoint pos = m_crossHairPosition - m_DrawOrg;
    double scalar = GetScalingFactor();

    pos.x = wxRound( (double) pos.x * scalar );
    pos.y = wxRound( (double) pos.y * scalar );

    return pos;
}
开发者ID:hellamps,项目名称:kicad,代码行数:10,代码来源:base_screen.cpp

示例9: WXUNUSED

void wxGenericStaticBitmap::OnPaint(wxPaintEvent& WXUNUSED(event))
{
    if ( !m_bitmap.IsOk() )
        return;

    wxPaintDC dc(this);
    const wxSize drawSize = GetClientSize();
    const wxSize bmpSize = m_bitmap.GetSize();
    wxDouble w = 0;
    wxDouble h = 0;
    switch ( m_scaleMode )
    {
        case Scale_None:
            dc.DrawBitmap(m_bitmap, 0, 0, true);
            return;
        case Scale_Fill:
            w = drawSize.x;
            h = drawSize.y;
            break;
        case Scale_AspectFill:
        case Scale_AspectFit:
        {
            wxDouble scaleFactor;
            wxDouble scaleX = (wxDouble)drawSize.x / (wxDouble)bmpSize.x;
            wxDouble scaleY = (wxDouble)drawSize.y / (wxDouble)bmpSize.y;
            if ( ( m_scaleMode == Scale_AspectFit && scaleY < scaleX ) ||
                 ( m_scaleMode == Scale_AspectFill && scaleY > scaleX ) )
                scaleFactor = scaleY;
            else
                scaleFactor = scaleX;

            w = bmpSize.x * scaleFactor;
            h = bmpSize.y * scaleFactor;

            break;
        }
    }

    wxASSERT_MSG(w, wxS("Unknown scale mode"));

    wxDouble x = (drawSize.x - w) / 2;
    wxDouble y = (drawSize.y - h) / 2;
#if wxUSE_GRAPHICS_CONTEXT
    wxScopedPtr<wxGraphicsContext> const
        gc(wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc));
    gc->DrawBitmap(m_bitmap, x, y, w, h);
#else
    wxImage img = m_bitmap.ConvertToImage();
    img.Rescale(wxRound(w), wxRound(h), wxIMAGE_QUALITY_HIGH);
    dc.DrawBitmap(wxBitmap(img), wxRound(x), wxRound(y), true);
#endif
}
开发者ID:CodeSmithyIDE,项目名称:wxWidgets,代码行数:52,代码来源:statbmpg.cpp

示例10: wxDisplaySize

bool wxUIActionSimulator::MouseMove(long x, long y)
{
    // Because MOUSEEVENTF_ABSOLUTE takes measurements scaled between 0 & 65535
    // we need to scale our input too
    int displayx, displayy;
    wxDisplaySize(&displayx, &displayy);

    int scaledx = wxRound(((float)x / displayx) * 65535);
    int scaledy = wxRound(((float)y / displayy) * 65535);
    mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, scaledx, scaledy, 0, 0);

    return true;
}
开发者ID:Richard-Ni,项目名称:wxWidgets,代码行数:13,代码来源:uiaction.cpp

示例11: wxRound

/* Function GetSize
 * returns the actual size (in user units, not in pixels) of the image
 */
wxSize BITMAP_BASE::GetSize() const
{
    wxSize size;

    if( m_bitmap )
    {
        size.x = m_bitmap->GetWidth();
        size.y = m_bitmap->GetHeight();

        size.x = wxRound( size.x * GetScalingFactor() );
        size.y = wxRound( size.y * GetScalingFactor() );
    }

    return size;
}
开发者ID:hellamps,项目名称:kicad,代码行数:18,代码来源:class_bitmap_base.cpp

示例12: Create

numberPopup::numberPopup(wxWindow* parent,int ratio, wxColour colourGreen, wxWindowID)
{
    //wxSizerFlags flagsExpand(1);
    //flagsExpand.Expand().Border(wxALL, 2);
	//(*Initialize(numberPopup)
	wxBoxSizer* BoxSizer1;

	Create(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSTAY_ON_TOP|wxDEFAULT_FRAME_STYLE|wxFRAME_NO_TASKBAR|wxNO_BORDER, _T("wxID_ANY"));
	BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
	Button1 = new wxButton(this, ID_BUTTON1, _("Label"), wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxDefaultValidator, _T("ID_BUTTON1"));
	BoxSizer1->Add(Button1, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	SetSizer(BoxSizer1);
	Timer1.SetOwner(this, ID_TIMER1);
	BoxSizer1->Fit(this);
	BoxSizer1->SetSizeHints(this);
	Center();

	Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&numberPopup::OnButton1Click);
	Connect(ID_TIMER1,wxEVT_TIMER,(wxObjectEventFunction)&numberPopup::OnTimer1Trigger);
	//*)
	//find the screen size
	wxSize displaySize = wxGetDisplaySize();
    this->SetSize(wxDefaultCoord,wxDefaultCoord,wxRound((double(displaySize.GetWidth()))*(((double)ratio)/100)), wxRound((double(displaySize.GetHeight()))*(((double)ratio)/100)),wxSIZE_FORCE);
    Button1->SetBackgroundColour(colourGreen);
    this->SetBackgroundColour(colourGreen);

}
开发者ID:ian57,项目名称:LotoClic,代码行数:27,代码来源:numberPopup.cpp

示例13: initSashPosition

 void SplitterWindow2::updateSashPosition(const wxSize& oldSize, const wxSize& newSize) {
     initSashPosition();
     
     if (m_splitMode != SplitMode_Unset) {
         const wxSize diff = newSize - oldSize;
         const int actualDiff = wxRound(m_sashGravity * h(diff));
         setSashPosition(sashPosition(m_currentSplitRatio, h(oldSize)) + actualDiff);
     }
 }
开发者ID:Gustavo6046,项目名称:TrenchBroom,代码行数:9,代码来源:SplitterWindow2.cpp

示例14: wxRound

void wxNativeFontInfo::SetFractionalPointSize(float pointsize)
{
    wxString s;
    if ( pointsize < 0 )
        s = '*';
    else
        s.Printf("%d", wxRound(10*pointsize));

    SetXFontComponent(wxXLFD_POINTSIZE, s);
}
开发者ID:CodeSmithyIDE,项目名称:wxWidgets,代码行数:10,代码来源:fontutil.cpp

示例15: GetGridSize

wxPoint BASE_SCREEN::GetNearestGridPosition( const wxPoint& aPosition, wxRealPoint* aGridSize )
{
    wxPoint pt;
    wxRealPoint gridSize;

    if( aGridSize )
        gridSize = *aGridSize;
    else
        gridSize = GetGridSize();

    wxPoint gridOrigin = m_GridOrigin;

    double offset = fmod( gridOrigin.x, gridSize.x );
    int x = wxRound( (aPosition.x - offset) / gridSize.x );
    pt.x = wxRound( x * gridSize.x + offset );

    offset = fmod( gridOrigin.y, gridSize.y );
    int y = wxRound( (aPosition.y - offset) / gridSize.y );
    pt.y = wxRound ( y * gridSize.y + offset );

    return pt;
}
开发者ID:hellamps,项目名称:kicad,代码行数:22,代码来源:base_screen.cpp


注:本文中的wxRound函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。