<commit_before>/*!
  \copyright (c) RDO-Team, 2003-2012
  \file      chart_serie.cpp
  \author     
  \date      31.03.2003
  \brief     
  \indent    4T
*/

// ---------------------------------------------------------------------------- PCH
#include "app/rdo_studio/pch/stdpch.h"
// ----------------------------------------------------------------------- INCLUDES
// ----------------------------------------------------------------------- SYNOPSIS
#include "app/rdo_studio/src/chart/chart_serie.h"
// --------------------------------------------------------------------------------

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

// --------------------------------------------------------------------------------
// -------------------- ChartSerie::Options
// --------------------------------------------------------------------------------
ChartSerie::Options::Options()
	: color            (QColor(0x00, 0x00, 0x00))
	, markerType       (RDOSM_NONE)
	, markerSize       (3)
	, markerNeedDraw   (true)
	, markerTransparent(true)
	, showInLegend     (true)
{}

rbool ChartSerie::Options::operator== (CREF(Options) options) const
{
	return title             == options.title
		&& color             == options.color
		&& markerType        == options.markerType
		&& markerSize        == options.markerSize
		&& markerNeedDraw    == options.markerNeedDraw
		&& markerTransparent == options.markerTransparent
		&& showInLegend      == options.showInLegend;
}

// --------------------------------------------------------------------------------
// -------------------- ChartSerie
// --------------------------------------------------------------------------------
ChartSerie::ChartSerie(TracerSerie* pSerie)
	: m_pSerie(pSerie)
{
	if (m_pSerie)
	{
		m_options.title = m_pSerie->getTitle();
	}
}

ChartSerie::~ChartSerie()
{}

TracerSerie* ChartSerie::getSerie() const
{
	return m_pSerie;
}

CREF(ChartSerie::Options) ChartSerie::options() const
{
	return m_options;
}

void ChartSerie::setOptions(CREF(Options) options)
{
	m_options = options;
}

rbool ChartSerie::isTracerSerie(const TracerSerie* pSerie) const
{
	return m_pSerie == pSerie;
}

void ChartSerie::drawSerie(ChartView* const pView, QPainter& painter, const QRect& rect) const
{
	m_pSerie->drawSerie(pView, painter, rect, m_options.color, m_options.markerType, m_options.markerSize, m_options.markerNeedDraw, m_options.markerTransparent);
}

void ChartSerie::getCaptions(std::vector<tstring> &captions, const int val_count) const
{
	m_pSerie->getCaptions(captions, val_count);
}

void ChartSerie::lock()
{
	m_pSerie->mutex.Lock();
}

void ChartSerie::unlock()
{
	m_pSerie->mutex.Unlock();
}

rbool ChartSerie::empty() const
{
	return m_pSerie->empty();
}

QSize ChartSerie::getLegendSize(const QFontMetrics& fm, const QRect& rect) const
{
	QSize size(0, 0);
	if (!m_options.showInLegend)
		return size;

	QRect tmprect;
	tmprect.setLeft(rect.left() + 10 + m_options.markerSize * 2 + 5);
	tmprect.setRight(rect.right());
	tmprect.setTop(rect.top());
	tmprect.setBottom(rect.bottom());
	tmprect = fm.boundingRect(tmprect, Qt::AlignLeft | Qt::TextSingleLine, QString::fromLocal8Bit(m_options.title.c_str()));
	size.setHeight(tmprect.height());
	if (size.height() < m_options.markerSize * 2)
	{
		size.setHeight(m_options.markerSize * 2);
	}
	size.setWidth(tmprect.width());
	size.setHeight(size.height() + 2);
	return size;
}

QSize ChartSerie::drawLegend(QPainter& painter, const QRect& rect, const QColor& textColor) const
{
	QSize size = getLegendSize(painter.fontMetrics(), rect);
	if (!m_options.showInLegend)
		return size;

	int middle = rect.top() + (size.height() - 2) / 2;
	if (m_options.markerNeedDraw)
	{<commit_msg>* reverted changes from rev.10780<commit_after>/*!
  \copyright (c) RDO-Team, 2003-2012
  \file      chart_serie.cpp
  \author     
  \date      31.03.2003
  \brief     
  \indent    4T
*/

// ---------------------------------------------------------------------------- PCH
#include "app/rdo_studio/pch/stdpch.h"
// ----------------------------------------------------------------------- INCLUDES
// ----------------------------------------------------------------------- SYNOPSIS
#include "app/rdo_studio/src/chart/chart_serie.h"
// --------------------------------------------------------------------------------

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

// --------------------------------------------------------------------------------
// -------------------- ChartSerie::Options
// --------------------------------------------------------------------------------
ChartSerie::Options::Options()
	: color            (QColor(0x00, 0x00, 0x00))
	, markerType       (RDOSM_NONE)
	, markerSize       (3)
	, markerNeedDraw   (true)
	, markerTransparent(true)
	, showInLegend     (true)
{}

rbool ChartSerie::Options::operator== (CREF(Options) options) const
{
	return title             == options.title
		&& color             == options.color
		&& markerType        == options.markerType
		&& markerSize        == options.markerSize
		&& markerNeedDraw    == options.markerNeedDraw
		&& markerTransparent == options.markerTransparent
		&& showInLegend      == options.showInLegend;
}

// --------------------------------------------------------------------------------
// -------------------- ChartSerie
// --------------------------------------------------------------------------------
ChartSerie::ChartSerie(TracerSerie* pSerie)
	: m_pSerie(pSerie)
{
	if (m_pSerie)
	{
		m_options.title = m_pSerie->getTitle();
	}
}

ChartSerie::~ChartSerie()
{}

TracerSerie* ChartSerie::getSerie() const
{
	return m_pSerie;
}

CREF(ChartSerie::Options) ChartSerie::options() const
{
	return m_options;
}

void ChartSerie::setOptions(CREF(Options) options)
{
	m_options = options;
}

rbool ChartSerie::isTracerSerie(const TracerSerie* pSerie) const
{
	return m_pSerie == pSerie;
}

void ChartSerie::drawSerie(ChartView* const pView, QPainter& painter, const QRect& rect) const
{
	m_pSerie->drawSerie(pView, painter, rect, m_options.color, m_options.markerType, m_options.markerSize, m_options.markerNeedDraw, m_options.markerTransparent);
}

void ChartSerie::getCaptions(std::vector<tstring> &captions, const int val_count) const
{
	m_pSerie->getCaptions(captions, val_count);
}

void ChartSerie::lock()
{
	m_pSerie->mutex.Lock();
}

void ChartSerie::unlock()
{
	m_pSerie->mutex.Unlock();
}

rbool ChartSerie::empty() const
{
	return m_pSerie->empty();
}

QSize ChartSerie::getLegendSize(const QFontMetrics& fm, const QRect& rect) const
{
	QSize size(0, 0);
	if (!m_options.showInLegend)
		return size;

	QRect tmprect;
	tmprect.setLeft(rect.left() + 10 + m_options.markerSize * 2 + 5);
	tmprect.setRight(rect.right());
	tmprect.setTop(rect.top());
	tmprect.setBottom(rect.bottom());
	tmprect = fm.boundingRect(tmprect, Qt::AlignLeft | Qt::TextSingleLine, QString::fromLocal8Bit(m_options.title.c_str()));
	size.setHeight(tmprect.height());
	if (size.height() < m_options.markerSize * 2)
	{
		size.setHeight(m_options.markerSize * 2);
	}
	size.setWidth(tmprect.right() - rect.left());
	size.setHeight(size.height() + 2);
	return size;
}

QSize ChartSerie::drawLegend(QPainter& painter, const QRect& rect, const QColor& textColor) const
{
	QSize size = getLegendSize(painter.fontMetrics(), rect);
	if (!m_options.showInLegend)
		return size;

	int middle = rect.top() + (size.height() - 2) / 2;
	if (m_options.markerNeedDraw)
	{
{'fraction_non_alphanumeric': 0.2939765458422175, 'fraction_numerical': 0.011060767590618336, 'mean_word_length': 2.023771152296535, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7653816', 'n_tokens_mistral': 2439, 'n_tokens_neox': 2353, 'n_words': 415}