<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 2010 <NAME> <<EMAIL>>
//

#include "AprsObject.h"

#include <QtGui/QPixmap>

#include "MarbleDebug.h"
#include "MarbleDirs.h"
#include "GeoDataLineString.h"
#include "GeoPainter.h"
#include "GeoAprsCoordinates.h"

using namespace Marble;

AprsObject::AprsObject( const GeoAprsCoordinates &at, const QString &name )
    : m_myName( name ),
      m_seenFrom( at.seenFrom() ),
      m_havePixmap ( false ),
      m_pixmapFilename( ),
      m_pixmap( 0 )
{
    m_history.push_back( at );
}

AprsObject::~AprsObject()
{
    delete m_pixmap;
}

GeoAprsCoordinates
AprsObject::location() const
{
    return m_history.last();
}

void
AprsObject::setLocation( const GeoAprsCoordinates &location )
{
    // Not ideal but it's unlikely they'll jump to the *exact* same spot again
    if ( !m_history.contains( location ) ) {
        m_history.push_back( location );
        mDebug() << "  moved: " << m_myName.toLocal8Bit().data();
    } else {
        int index = m_history.indexOf( location );
        QTime now;
        m_history[index].setTimestamp( now );
        m_history[index].addSeenFrom( location.seenFrom() );
    }

    m_seenFrom = ( m_seenFrom | location.seenFrom() );
}

void
AprsObject::setPixmapId( QString &pixmap )
{
    QString pixmapFilename = MarbleDirs::path( pixmap );
    if ( QFile( pixmapFilename ).exists() ) {
        m_havePixmap = true;
        m_pixmapFilename = pixmapFilename;
        // We can't load the pixmap here since it's used in a different thread
    }
    else {
        m_havePixmap = false;
    }
}

QColor
AprsObject::calculatePaintColor( int from, const QTime &time, int fadeTime ) const
{
    QColor color;
    if ( from & GeoAprsCoordinates::Directly ) {
        color = QColor( 0, 201, 0, 255 ); // oxygen green if direct
    } else if ( (from & ( GeoAprsCoordinates::FromTCPIP | GeoAprsCoordinates::FromTTY ) ) == ( GeoAprsCoordinates::FromTCPIP | GeoAprsCoordinates::FromTTY ) ) {
        color = QColor( 176, 0, 141, 255 ); // oxygen purple if both
    } else if  ( from & GeoAprsCoordinates::FromTCPIP ) {
        color = QColor( 255, 0, 0, 255 ); // oxygen red if net
    } else if  ( from & GeoAprsCoordinates::FromTTY ) {
        color = QColor( 0, 0, 201, 255 ); // oxygen blue if TNC TTY relay
    } else if ( from & ( GeoAprsCoordinates::FromFile ) ) {
        color = QColor( 255, 255, 0, 255 ); // oxygen yellow if file only
    } else {
        mDebug() << "**************************************** unknown from: "
                 << from;
        color = QColor( 0, 0, 0, 255 ); // shouldn't happen but a user
                                        // could mess up I suppose we
                                        // should at least draw it in
                                        // something.
    }

    if ( fadeTime > 0 && time.elapsed() > fadeTime ) { // 5 min ( 600000 ms )
        color.setAlpha( 160 );
    }

    return color;
}

void
AprsObject::render( GeoPainter *painter, ViewportParams *viewport,
                    int fadeTime, int hideTime )<commit_msg>use named Oxygen colors<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 2010 <NAME> <<EMAIL>>
//

#include "AprsObject.h"

#include <QtGui/QPixmap>

#include "MarbleDebug.h"
#include "MarbleDirs.h"
#include "GeoDataLineString.h"
#include "GeoPainter.h"
#include "GeoAprsCoordinates.h"

using namespace Marble;

AprsObject::AprsObject( const GeoAprsCoordinates &at, const QString &name )
    : m_myName( name ),
      m_seenFrom( at.seenFrom() ),
      m_havePixmap ( false ),
      m_pixmapFilename( ),
      m_pixmap( 0 )
{
    m_history.push_back( at );
}

AprsObject::~AprsObject()
{
    delete m_pixmap;
}

GeoAprsCoordinates
AprsObject::location() const
{
    return m_history.last();
}

void
AprsObject::setLocation( const GeoAprsCoordinates &location )
{
    // Not ideal but it's unlikely they'll jump to the *exact* same spot again
    if ( !m_history.contains( location ) ) {
        m_history.push_back( location );
        mDebug() << "  moved: " << m_myName.toLocal8Bit().data();
    } else {
        int index = m_history.indexOf( location );
        QTime now;
        m_history[index].setTimestamp( now );
        m_history[index].addSeenFrom( location.seenFrom() );
    }

    m_seenFrom = ( m_seenFrom | location.seenFrom() );
}

void
AprsObject::setPixmapId( QString &pixmap )
{
    QString pixmapFilename = MarbleDirs::path( pixmap );
    if ( QFile( pixmapFilename ).exists() ) {
        m_havePixmap = true;
        m_pixmapFilename = pixmapFilename;
        // We can't load the pixmap here since it's used in a different thread
    }
    else {
        m_havePixmap = false;
    }
}

QColor
AprsObject::calculatePaintColor( int from, const QTime &time, int fadeTime ) const
{
    QColor color;
    if ( from & GeoAprsCoordinates::Directly ) {
        color = Oxygen::emeraldGreen4; // oxygen green if direct
    } else if ( (from & ( GeoAprsCoordinates::FromTCPIP | GeoAprsCoordinates::FromTTY ) ) == ( GeoAprsCoordinates::FromTCPIP | GeoAprsCoordinates::FromTTY ) ) {
        color = Oxygen::burgundyPurple4; // oxygen purple if both
    } else if  ( from & GeoAprsCoordinates::FromTCPIP ) {
        color = Oxygen::brickRed4; // oxygen red if net
    } else if  ( from & GeoAprsCoordinates::FromTTY ) {
        color = Oxygen::seaBlue4; // oxygen blue if TNC TTY relay
    } else if ( from & ( GeoAprsCoordinates::FromFile ) ) {
        color = Oxygen::sunYellow3; // oxygen yellow if file only
    } else {
        mDebug() << "**************************************** unknown from: "
                 << from;
        color = Oxygen::aluminumGray5;  // shouldn't happen but a user
                                        // could mess up I suppose we
                                        // should at least draw it in
                                        // something.
    }

    if ( fadeTime > 0 && time.elapsed() > fadeTime ) { // 5 min ( 600000 ms )
        color.setAlpha( 160 );
    }

    return color;
}

void
AprsObject::render( GeoPainter *painter, ViewportParams *viewport,
                    int fadeTime, int hideTime )
{'fraction_non_alphanumeric': 0.1258591721399114, 'fraction_numerical': 0.013746754238582556, 'mean_word_length': 2.5109919571045576, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 15, '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': '7543265', 'n_tokens_mistral': 2177, 'n_tokens_neox': 2026, 'n_words': 571}