Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_clipper.cpp


Ignore:
Timestamp:
May 10, 2017, 3:20:54 PM (7 years ago)
Author:
stoecker
Message:

update qwt and qwtpolar, many QT5 fixes (unfinished)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_clipper.cpp

    r4271 r8127  
    1111#include "qwt_point_polar.h"
    1212#include <qrect.h>
     13#include <string.h>
     14#include <stdlib.h>
    1315
    1416#if QT_VERSION < 0x040601
     
    4446    {
    4547        double dy = ( p1.y() - p2.y() ) / double( p1.x() - p2.x() );
    46         return Point( d_x1, ( Value ) ( p2.y() + ( d_x1 - p2.x() ) * dy ) );
     48        return Point( d_x1, static_cast< Value >( p2.y() + ( d_x1 - p2.x() ) * dy ) );
    4749    }
    4850private:
     
    6769    {
    6870        double dy = ( p1.y() - p2.y() ) / double( p1.x() - p2.x() );
    69         return Point( d_x2, ( Value ) ( p2.y() + ( d_x2 - p2.x() ) * dy ) );
     71        return Point( d_x2, static_cast<Value>( p2.y() + ( d_x2 - p2.x() ) * dy ) );
    7072    }
    7173
     
    9193    {
    9294        double dx = ( p1.x() - p2.x() ) / double( p1.y() - p2.y() );
    93         return Point( ( Value )( p2.x() + ( d_y1 - p2.y() ) * dx ), d_y1 );
     95        return Point( static_cast<Value>( p2.x() + ( d_y1 - p2.y() ) * dx ), d_y1 );
    9496    }
    9597
     
    115117    {
    116118        double dx = ( p1.x() - p2.x() ) / double( p1.y() - p2.y() );
    117         return Point( ( Value )( p2.x() + ( d_y2 - p2.y() ) * dx ), d_y2 );
     119        return Point( static_cast<Value>( p2.x() + ( d_y2 - p2.y() ) * dx ), d_y2 );
    118120    }
    119121
     
    138140    {
    139141        if ( m_buffer )
    140             qFree( m_buffer );
     142            ::free( m_buffer );
    141143    }
    142144
     
    146148
    147149        m_size = numPoints;
    148         qMemCopy( m_buffer, points, m_size * sizeof( Point ) );
     150        ::memcpy( m_buffer, points, m_size * sizeof( Point ) );
    149151    }
    150152
     
    191193            m_capacity *= 2;
    192194
    193         m_buffer = ( Point * ) qRealloc(
    194             m_buffer, m_capacity * sizeof( Point ) );
     195        m_buffer = static_cast<Point *>(
     196            ::realloc( m_buffer, m_capacity * sizeof( Point ) ) );
    195197    }
    196198
     
    230232        Polygon p;
    231233        p.resize( points1.size() );
    232         qMemCopy( p.data(), points1.data(), points1.size() * sizeof( Point ) );
     234        ::memcpy( p.data(), points1.data(), points1.size() * sizeof( Point ) );
    233235
    234236        return p;
     
    335337    QList<QPointF> points;
    336338    for ( int edge = 0; edge < NEdges; edge++ )
    337         points += cuttingPoints( ( Edge )edge, pos, radius );
     339        points += cuttingPoints( static_cast<Edge>(edge), pos, radius );
    338340
    339341    QVector<QwtInterval> intv;
     
    444446*/
    445447QPolygon QwtClipper::clipPolygon(
     448    const QRectF &clipRect, const QPolygon &polygon, bool closePolygon )
     449{
     450    const int minX = qCeil( clipRect.left() );
     451    const int maxX = qFloor( clipRect.right() );
     452    const int minY = qCeil( clipRect.top() );
     453    const int maxY = qFloor( clipRect.bottom() );
     454
     455    const QRect r( minX, minY, maxX - minX, maxY - minY );
     456
     457    QwtPolygonClipper<QPolygon, QRect, QPoint, int> clipper( r );
     458    return clipper.clipPolygon( polygon, closePolygon );
     459}
     460/*!
     461   Sutherland-Hodgman polygon clipping
     462
     463   \param clipRect Clip rectangle
     464   \param polygon Polygon
     465   \param closePolygon True, when the polygon is closed
     466
     467   \return Clipped polygon
     468*/
     469QPolygon QwtClipper::clipPolygon(
    446470    const QRect &clipRect, const QPolygon &polygon, bool closePolygon )
    447471{
     
    469493   Circle clipping
    470494
    471    clipCircle() devides a circle into intervals of angles representing arcs
     495   clipCircle() divides a circle into intervals of angles representing arcs
    472496   of the circle. When the circle is completely inside the clip rectangle
    473497   an interval [0.0, 2 * M_PI] is returned.
Note: See TracChangeset for help on using the changeset viewer.