<commit_before>//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2013      <NAME> <<EMAIL>>
//

// Self
#include "GroundOverlayFrame.h"

// Marble
#include "GeoDataPlacemark.h"
#include "GeoDataTypes.h"
#include "GeoPainter.h"
#include "ViewportParams.h"
#include "SceneGraphicsTypes.h"


namespace Marble
{

GroundOverlayFrame::GroundOverlayFrame( GeoDataPlacemark *placemark,
                                        GeoDataGroundOverlay *overlay,
                                        TextureLayer *textureLayer ) :
    SceneGraphicsItem( placemark ),
    m_overlay( overlay ),
    m_textureLayer( textureLayer ),
    m_movedPoint( -1 ),
    m_viewport( 0 )
{
    update();
}

void GroundOverlayFrame::paint(GeoPainter *painter, const ViewportParams *viewport )
{
    m_viewport = viewport;
    m_regionList.clear();

    painter->save();
    painter->setBrush( Oxygen::aluminumGray4 );
    if ( placemark()->geometry()->nodeType() == GeoDataTypes::GeoDataPolygonType ) {
        GeoDataPolygon *polygon = static_cast<GeoDataPolygon*>( placemark()->geometry() );
        GeoDataLinearRing &ring = polygon->outerBoundary();
        for ( int i = 0; i < ring.size(); ++i ) {
            m_regionList.append( painter->regionFromEllipse( ring.at(i), 10, 10 ) );
        }
        m_regionList.append( painter->regionFromPolygon( ring, Qt::OddEvenFill ) );
    }
    painter->restore();
}

bool GroundOverlayFrame::containsPoint( const QPoint &eventPos ) const
{
    foreach ( const QRegion &region, m_regionList ) {
        if ( region.contains( eventPos ) ) {
            return true;
        }
    }

    return false;
}

void GroundOverlayFrame::dealWithItemChange( const SceneGraphicsItem *other )
{
    Q_UNUSED( other );
}

void GroundOverlayFrame::move( const GeoDataCoordinates &source, const GeoDataCoordinates &destination )
{

}

bool GroundOverlayFrame::mousePressEvent( QMouseEvent *event )
{
    // React to all ellipse as well as to the polygon.
    for ( int i = 0; i < m_regionList.size(); ++i ) {
        if ( m_regionList.at(i).contains( event->pos() ) ) {
            m_movedPoint = i;

            qreal lon, lat;
            m_viewport->geoCoordinates( event->pos().x(),
                                        event->pos().y(),
                                        lon, lat,
                                        GeoDataCoordinates::Radian );
            m_movedPointCoordinates.set( lon, lat );

            return true;
        }
    }
    return false;
}
<commit_msg>The method is intentionally not implemented yet<commit_after>//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2013      <NAME> <<EMAIL>>
//

// Self
#include "GroundOverlayFrame.h"

// Marble
#include "GeoDataPlacemark.h"
#include "GeoDataTypes.h"
#include "GeoPainter.h"
#include "ViewportParams.h"
#include "SceneGraphicsTypes.h"


namespace Marble
{

GroundOverlayFrame::GroundOverlayFrame( GeoDataPlacemark *placemark,
                                        GeoDataGroundOverlay *overlay,
                                        TextureLayer *textureLayer ) :
    SceneGraphicsItem( placemark ),
    m_overlay( overlay ),
    m_textureLayer( textureLayer ),
    m_movedPoint( -1 ),
    m_viewport( 0 )
{
    update();
}

void GroundOverlayFrame::paint(GeoPainter *painter, const ViewportParams *viewport )
{
    m_viewport = viewport;
    m_regionList.clear();

    painter->save();
    painter->setBrush( Oxygen::aluminumGray4 );
    if ( placemark()->geometry()->nodeType() == GeoDataTypes::GeoDataPolygonType ) {
        GeoDataPolygon *polygon = static_cast<GeoDataPolygon*>( placemark()->geometry() );
        GeoDataLinearRing &ring = polygon->outerBoundary();
        for ( int i = 0; i < ring.size(); ++i ) {
            m_regionList.append( painter->regionFromEllipse( ring.at(i), 10, 10 ) );
        }
        m_regionList.append( painter->regionFromPolygon( ring, Qt::OddEvenFill ) );
    }
    painter->restore();
}

bool GroundOverlayFrame::containsPoint( const QPoint &eventPos ) const
{
    foreach ( const QRegion &region, m_regionList ) {
        if ( region.contains( eventPos ) ) {
            return true;
        }
    }

    return false;
}

void GroundOverlayFrame::dealWithItemChange( const SceneGraphicsItem *other )
{
    Q_UNUSED( other );
}

void GroundOverlayFrame::move( const GeoDataCoordinates &source, const GeoDataCoordinates &destination )
{
    // not implemented yet
}

bool GroundOverlayFrame::mousePressEvent( QMouseEvent *event )
{
    // React to all ellipse as well as to the polygon.
    for ( int i = 0; i < m_regionList.size(); ++i ) {
        if ( m_regionList.at(i).contains( event->pos() ) ) {
            m_movedPoint = i;

            qreal lon, lat;
            m_viewport->geoCoordinates( event->pos().x(),
                                        event->pos().y(),
                                        lon, lat,
                                        GeoDataCoordinates::Radian );
            m_movedPointCoordinates.set( lon, lat );

            return true;
        }
    }
    return false;
}

{'fraction_non_alphanumeric': 0.11549815498154982, 'fraction_numerical': 0.004797047970479705, 'mean_word_length': 2.392365456821026, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4147459', 'n_tokens_mistral': 1639, 'n_tokens_neox': 1601, 'n_words': 389}