2019-10-09 02:21:28 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2019- Equinor ASA
|
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
2019-10-11 08:54:19 -05:00
|
|
|
#include "RiuQwtPlotLegend.h"
|
2019-10-09 02:21:28 -05:00
|
|
|
|
2019-10-11 08:54:19 -05:00
|
|
|
#include "qwt_dyngrid_layout.h"
|
|
|
|
|
|
|
|
#include <QResizeEvent>
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RiuQwtPlotLegend::RiuQwtPlotLegend( QWidget* parent /*= nullptr */ )
|
|
|
|
: QwtLegend( parent )
|
|
|
|
, m_columnCount( -1 )
|
|
|
|
{
|
|
|
|
}
|
2019-10-09 02:21:28 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-10-11 08:54:19 -05:00
|
|
|
void RiuQwtPlotLegend::resizeEvent( QResizeEvent* event )
|
2019-10-09 02:21:28 -05:00
|
|
|
{
|
2019-10-11 08:54:19 -05:00
|
|
|
QWidget::resizeEvent( event );
|
|
|
|
QSize size = event->size();
|
|
|
|
const QwtDynGridLayout* legendLayout = qobject_cast<QwtDynGridLayout*>( contentsWidget()->layout() );
|
|
|
|
if ( legendLayout )
|
|
|
|
{
|
|
|
|
m_columnCount = legendLayout->columnsForWidth( size.width() );
|
|
|
|
}
|
2019-10-09 02:21:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-10-11 08:54:19 -05:00
|
|
|
int RiuQwtPlotLegend::columnCount() const
|
2019-10-09 02:21:28 -05:00
|
|
|
{
|
2019-10-11 08:54:19 -05:00
|
|
|
return m_columnCount;
|
2019-10-09 02:21:28 -05:00
|
|
|
}
|