-FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitch )
+FramePropertiesDock::FramePropertiesDock( QWidget* parent, bool* pbMainPlaySwitch )
: QWidget( parent ), m_pbIsPlaying( pbMainPlaySwitch )
{
// -------------- Variables definition --------------
@@ -146,24 +146,24 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitc
QLabel* rangeSelectionLabel = new QLabel( tr( "Range:" ) );
rangeSelectionLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
- minInterv = new QSpinBox;
- minInterv->setRange( 0, 255 );
- minInterv->setSingleStep( 1 );
- minInterv->setValue( 0 );
- minInterv->setWhatsThis( tr( "Select here the minimal intensity "
+ mininterv = new QSpinBox;
+ mininterv->setRange( 0, 255 );
+ mininterv->setSingleStep( 1 );
+ mininterv->setValue( 0 );
+ mininterv->setWhatsThis( tr( "
Select here the minimal intensity "
"value of the histogram selection." ) );
- maxInterv = new QSpinBox;
- maxInterv->setRange( 0, 255 );
- maxInterv->setSingleStep( 1 );
- maxInterv->setValue( 0 );
- minInterv->setWhatsThis( tr( "
Select here the maximal intensity value"
+ maxinterv = new QSpinBox;
+ maxinterv->setRange( 0, 255 );
+ maxinterv->setSingleStep( 1 );
+ maxinterv->setValue( 0 );
+ mininterv->setWhatsThis( tr( "
Select here the maximal intensity value"
" of the histogram selection." ) );
QHBoxLayout* rangeLayout = new QHBoxLayout;
rangeLayout->addWidget( rangeSelectionLabel );
- rangeLayout->addWidget( minInterv );
- rangeLayout->addWidget( maxInterv );
+ rangeLayout->addWidget( mininterv );
+ rangeLayout->addWidget( maxinterv );
mainLayout->addLayout( rangeLayout, 4, 0, 1, 4 );
@@ -204,7 +204,7 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitc
labelPercentileValue = new QLabel;
labelPercentileValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
- Int gridRow = 0;
+ int gridRow = 0;
QGridLayout* statisticsLayout = new QGridLayout;
statisticsLayout->addWidget( pixelsLabel, gridRow, 0 );
statisticsLayout->addWidget( labelPixelsValue, gridRow++, 1 );
@@ -235,13 +235,13 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitc
connect( scaleButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( slotScaleChanged( int ) ) );
connect( colorsCB, SIGNAL( activated( int ) ), this, SLOT( slotColorsChanged( int ) ) );
connect( renderingButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( slotRenderingChanged( int ) ) );
- connect( histogramWidget, SIGNAL( signalIntervalChanged( int, int ) ), this, SLOT( slotUpdateInterval( int, int ) ) );
- connect( histogramWidget, SIGNAL( signalMaximumValueChanged( int ) ), this, SLOT( slotUpdateIntervRange( int ) ) );
+ connect( histogramWidget, SIGNAL( signalintervalChanged( int, int ) ), this, SLOT( slotUpdateinterval( int, int ) ) );
+ connect( histogramWidget, SIGNAL( signalMaximumValueChanged( int ) ), this, SLOT( slotUpdateintervRange( int ) ) );
connect( histogramWidget, SIGNAL( signalHistogramComputationDone( int ) ), this, SLOT( slotRefreshOptions( int ) ) );
connect( histogramWidget, SIGNAL( signalHistogramComputationFailed( void ) ), this,
SLOT( slotHistogramComputationFailed( void ) ) );
- connect( minInterv, SIGNAL( valueChanged( int ) ), this, SLOT( slotMinValueChanged( int ) ) );
- connect( maxInterv, SIGNAL( valueChanged( int ) ), this, SLOT( slotMaxValueChanged( int ) ) );
+ connect( mininterv, SIGNAL( valueChanged( int ) ), this, SLOT( slotMinValueChanged( int ) ) );
+ connect( maxinterv, SIGNAL( valueChanged( int ) ), this, SLOT( slotMaxValueChanged( int ) ) );
}
FramePropertiesDock::~FramePropertiesDock()
@@ -262,7 +262,7 @@ QSize FramePropertiesDock::sizeHint() const
return currSize;
}
-Void FramePropertiesDock::reset()
+void FramePropertiesDock::reset()
{
m_pcFrame = NULL;
m_cSelectionArea = QRect();
@@ -287,29 +287,29 @@ Void FramePropertiesDock::reset()
setEnabled( false );
}
-Void FramePropertiesDock::setFrame( PlaYUVerFrame* pcFrame )
+void FramePropertiesDock::setFrame( CalypFrame* pcFrame )
{
- Int colorSpace = pcFrame->getColorSpace();
+ int colorSpace = pcFrame->getColorSpace();
if( m_iLastFrameType != colorSpace )
{
m_iLastFrameType = colorSpace;
- if( colorSpace == PlaYUVerPixel::COLOR_RGB || colorSpace == PlaYUVerPixel::COLOR_RGBA )
+ if( colorSpace == CLP_COLOR_RGB || colorSpace == CLP_COLOR_RGBA )
{
channelCB->clear();
- channelCB->addItem( QIcon( ":/images/channel-luma.png" ), "Luminance", PlaYUVerFrame::HIST_LUMA );
- channelCB->addItem( QIcon( ":/images/channel-red.png" ), "Red", PlaYUVerFrame::HIST_COLOR_R );
- channelCB->addItem( QIcon( ":/images/channel-green.png" ), "Green", PlaYUVerFrame::HIST_COLOR_G );
- channelCB->addItem( QIcon( ":/images/channel-blue.png" ), "Blue", PlaYUVerFrame::HIST_COLOR_B );
- if( colorSpace == PlaYUVerPixel::COLOR_RGBA )
+ channelCB->addItem( QIcon( ":/images/channel-luma.png" ), "Luminance", CalypFrame::HIST_LUMA );
+ channelCB->addItem( QIcon( ":/images/channel-red.png" ), "Red", CalypFrame::HIST_COLOR_R );
+ channelCB->addItem( QIcon( ":/images/channel-green.png" ), "Green", CalypFrame::HIST_COLOR_G );
+ channelCB->addItem( QIcon( ":/images/channel-blue.png" ), "Blue", CalypFrame::HIST_COLOR_B );
+ if( colorSpace == CLP_COLOR_RGBA )
{
- channelCB->addItem( QIcon( ":/images/channel-alpha.png" ), "Alpha", PlaYUVerFrame::HIST_COLOR_A );
+ channelCB->addItem( QIcon( ":/images/channel-alpha.png" ), "Alpha", CalypFrame::HIST_COLOR_A );
}
- channelCB->addItem( QIcon( ":/images/channel-all.png" ), "Colors", PlaYUVerFrame::HIST_ALL_CHANNELS );
+ channelCB->addItem( QIcon( ":/images/channel-all.png" ), "Colors", CalypFrame::HIST_ALL_CHANNELS );
colorsCB->clear();
- colorsCB->addItem( "Red", PlaYUVerFrame::HIST_COLOR_R );
- colorsCB->addItem( "Green", PlaYUVerFrame::HIST_COLOR_G );
- colorsCB->addItem( "Blue", PlaYUVerFrame::HIST_COLOR_B );
+ colorsCB->addItem( "Red", CalypFrame::HIST_COLOR_R );
+ colorsCB->addItem( "Green", CalypFrame::HIST_COLOR_G );
+ colorsCB->addItem( "Blue", CalypFrame::HIST_COLOR_B );
colorsCB->setEnabled( false );
colorsCB->setWhatsThis( tr( "
Select here the main color displayed with Colors Channel mode:"
"
Red: Draw the Red image channel in the foreground.
"
@@ -318,18 +318,18 @@ Void FramePropertiesDock::setFrame( PlaYUVerFrame* pcFrame )
colorsCB->show();
colorsLabel->show();
}
- else if( colorSpace == PlaYUVerPixel::COLOR_YUV )
+ else if( colorSpace == CLP_COLOR_YUV )
{
channelCB->clear();
- channelCB->addItem( QIcon( ":/images/channel-luma.png" ), "Luminance", PlaYUVerFrame::HIST_LUMA );
- channelCB->addItem( QIcon( ":/images/channel-red.png" ), "Chroma U", PlaYUVerFrame::HIST_CHROMA_U );
- channelCB->addItem( QIcon( ":/images/channel-green.png" ), "Chroma V", PlaYUVerFrame::HIST_CHROMA_V );
- channelCB->addItem( QIcon( ":/images/channel-all.png" ), "All Channels", PlaYUVerFrame::HIST_ALL_CHANNELS );
+ channelCB->addItem( QIcon( ":/images/channel-luma.png" ), "Luminance", CalypFrame::HIST_LUMA );
+ channelCB->addItem( QIcon( ":/images/channel-red.png" ), "Chroma U", CalypFrame::HIST_CHROMA_U );
+ channelCB->addItem( QIcon( ":/images/channel-green.png" ), "Chroma V", CalypFrame::HIST_CHROMA_V );
+ channelCB->addItem( QIcon( ":/images/channel-all.png" ), "All Channels", CalypFrame::HIST_ALL_CHANNELS );
colorsCB->clear();
- colorsCB->addItem( "Luminance", PlaYUVerFrame::HIST_LUMA );
- colorsCB->addItem( "Chroma U", PlaYUVerFrame::HIST_CHROMA_U );
- colorsCB->addItem( "Chroma V", PlaYUVerFrame::HIST_CHROMA_V );
+ colorsCB->addItem( "Luminance", CalypFrame::HIST_LUMA );
+ colorsCB->addItem( "Chroma U", CalypFrame::HIST_CHROMA_U );
+ colorsCB->addItem( "Chroma V", CalypFrame::HIST_CHROMA_V );
colorsCB->setEnabled( false );
colorsCB->setWhatsThis( tr( "
Select here the main color displayed with Colors Channel mode:"
"
Luminance: DraupdateDataw the Luminance channel in the "
@@ -343,7 +343,7 @@ Void FramePropertiesDock::setFrame( PlaYUVerFrame* pcFrame )
else
{
channelCB->clear();
- channelCB->addItem( QIcon( ":/images/channel-luma.png" ), "Luminance", PlaYUVerFrame::HIST_LUMA );
+ channelCB->addItem( QIcon( ":/images/channel-luma.png" ), "Luminance", CalypFrame::HIST_LUMA );
colorsCB->hide();
colorsLabel->hide();
}
@@ -356,11 +356,11 @@ Void FramePropertiesDock::setFrame( PlaYUVerFrame* pcFrame )
}
}
-Void FramePropertiesDock::setSelection( const QRect& selectionArea )
+void FramePropertiesDock::setSelection( const QRect& selectionArea )
{
if( m_pcFrame )
{
- Bool bSelectionChanged = !( selectionArea.size() == m_cSelectionArea.size() );
+ bool bSelectionChanged = !( selectionArea.size() == m_cSelectionArea.size() );
m_cSelectionArea = selectionArea;
if( selectionArea.isValid() )
{
@@ -376,8 +376,8 @@ Void FramePropertiesDock::setSelection( const QRect& selectionArea )
{
delete m_pcSelectedFrame;
}
- m_pcSelectedFrame = new PlaYUVerFrame( m_pcFrame, selectionArea.x(), selectionArea.y(), selectionArea.width(),
- selectionArea.height() );
+ m_pcSelectedFrame = new CalypFrame( m_pcFrame, selectionArea.x(), selectionArea.y(), selectionArea.width(),
+ selectionArea.height() );
}
updateDataHistogram();
selectionImageButton->click();
@@ -392,7 +392,7 @@ Void FramePropertiesDock::setSelection( const QRect& selectionArea )
}
}
-Void FramePropertiesDock::updateDataHistogram()
+void FramePropertiesDock::updateDataHistogram()
{
if( m_pcFrame && isVisible() )
{
@@ -424,18 +424,18 @@ Void FramePropertiesDock::updateDataHistogram()
}
}
-Void FramePropertiesDock::updateStatistiques()
+void FramePropertiesDock::updateStatistiques()
{
QString value;
- Int min = minInterv->value();
- Int max = maxInterv->value();
- Int channel = histogramWidget->m_channelType;
+ int min = mininterv->value();
+ int max = maxinterv->value();
+ int channel = histogramWidget->m_channelType;
- if( channel == PlaYUVerFrame::HIST_ALL_CHANNELS )
+ if( channel == CalypFrame::HIST_ALL_CHANNELS )
channel = colorsCB->itemData( colorsCB->currentIndex() ).toInt();
- PlaYUVerFrame* frame;
+ CalypFrame* frame;
if( histogramWidget->m_renderingType == HistogramWidget::FullImageHistogram )
frame = histogramWidget->m_fullImage;
@@ -468,7 +468,7 @@ Void FramePropertiesDock::updateStatistiques()
}
}
-Void FramePropertiesDock::stopHistogram()
+void FramePropertiesDock::stopHistogram()
{
histogramWidget->stopHistogramComputation();
}
@@ -477,7 +477,7 @@ Void FramePropertiesDock::stopHistogram()
// SLOTS
////////////////////////////////////////////////////////////////////////////////
-Void FramePropertiesDock::slotRefreshOptions( int range )
+void FramePropertiesDock::slotRefreshOptions( int range )
{
if( !isVisible() )
return;
@@ -500,17 +500,17 @@ Void FramePropertiesDock::slotRefreshOptions( int range )
}
}
-Void FramePropertiesDock::slotHistogramComputationFailed()
+void FramePropertiesDock::slotHistogramComputationFailed()
{
m_pcFrame = NULL;
}
-Void FramePropertiesDock::slotChannelChanged( Int index )
+void FramePropertiesDock::slotChannelChanged( int index )
{
- Int channel = channelCB->itemData( index ).toInt();
+ int channel = channelCB->itemData( index ).toInt();
histogramWidget->m_channelType = channel;
- if( channel == PlaYUVerFrame::HIST_ALL_CHANNELS )
+ if( channel == CalypFrame::HIST_ALL_CHANNELS )
colorsCB->setEnabled( true );
else
colorsCB->setEnabled( false );
@@ -518,72 +518,72 @@ Void FramePropertiesDock::slotChannelChanged( Int index )
updateStatistiques();
}
-Void FramePropertiesDock::slotScaleChanged( Int scale )
+void FramePropertiesDock::slotScaleChanged( int scale )
{
histogramWidget->m_scaleType = scale;
histogramWidget->update();
}
-Void FramePropertiesDock::slotColorsChanged( Int index )
+void FramePropertiesDock::slotColorsChanged( int index )
{
- Int color = colorsCB->itemData( index ).toInt();
+ int color = colorsCB->itemData( index ).toInt();
histogramWidget->m_colorType = color;
histogramWidget->update();
updateStatistiques();
}
-Void FramePropertiesDock::slotRenderingChanged( Int rendering )
+void FramePropertiesDock::slotRenderingChanged( int rendering )
{
histogramWidget->m_renderingType = rendering;
histogramWidget->update();
updateStatistiques();
}
-Void FramePropertiesDock::slotMinValueChanged( Int min )
+void FramePropertiesDock::slotMinValueChanged( int min )
{
// Called when user changes values of spin box.
// Communicate the change to histogram widget.
// make the one control "push" the other
- if( min == maxInterv->value() + 1 )
- maxInterv->setValue( min );
+ if( min == maxinterv->value() + 1 )
+ maxinterv->setValue( min );
- maxInterv->setMinimum( min - 1 );
+ maxinterv->setMinimum( min - 1 );
histogramWidget->slotMinValueChanged( min );
updateStatistiques();
}
-Void FramePropertiesDock::slotMaxValueChanged( Int max )
+void FramePropertiesDock::slotMaxValueChanged( int max )
{
- if( max == minInterv->value() - 1 )
- minInterv->setValue( max );
+ if( max == mininterv->value() - 1 )
+ mininterv->setValue( max );
- minInterv->setMaximum( max + 1 );
+ mininterv->setMaximum( max + 1 );
histogramWidget->slotMaxValueChanged( max );
updateStatistiques();
}
-Void FramePropertiesDock::slotUpdateInterval( Int min, Int max )
+void FramePropertiesDock::slotUpdateinterval( int min, int max )
{
// Called when value is set from within histogram widget.
// Block signals to prevent slotMinValueChanged and
// slotMaxValueChanged being called.
- minInterv->blockSignals( true );
- minInterv->setMaximum( max + 1 );
- minInterv->setValue( min );
- minInterv->blockSignals( false );
+ mininterv->blockSignals( true );
+ mininterv->setMaximum( max + 1 );
+ mininterv->setValue( min );
+ mininterv->blockSignals( false );
- maxInterv->blockSignals( true );
- maxInterv->setMinimum( min - 1 );
- maxInterv->setValue( max );
- maxInterv->blockSignals( false );
+ maxinterv->blockSignals( true );
+ maxinterv->setMinimum( min - 1 );
+ maxinterv->setValue( max );
+ maxinterv->blockSignals( false );
updateStatistiques();
}
-Void FramePropertiesDock::slotUpdateIntervRange( Int range )
+void FramePropertiesDock::slotUpdateintervRange( int range )
{
- maxInterv->blockSignals( true );
- maxInterv->setMaximum( range );
- maxInterv->blockSignals( false );
+ maxinterv->blockSignals( true );
+ maxinterv->setMaximum( range );
+ maxinterv->blockSignals( false );
}
diff --git a/app/FramePropertiesDock.h b/app/docks/FramePropertiesDock.h
similarity index 77%
rename from app/FramePropertiesDock.h
rename to app/docks/FramePropertiesDock.h
index af8472d..f6ca275 100644
--- a/app/FramePropertiesDock.h
+++ b/app/docks/FramePropertiesDock.h
@@ -1,4 +1,4 @@
-/* This file is a part of PlaYUVer project
+/* This file is a part of Calyp project
* Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@gmail.com)
*
@@ -25,11 +25,11 @@
#ifndef __FRAMEPROPERTIESDOCK_H__
#define __FRAMEPROPERTIESDOCK_H__
+#include "CommonDefs.h"
#include "HistogramWidget.h"
-#include "PlaYUVerAppDefs.h"
#include "config.h"
-#include "lib/PlaYUVerFrame.h"
-#include "lib/PlaYUVerStream.h"
+#include "lib/CalypFrame.h"
+#include "lib/CalypStream.h"
#include
@@ -37,22 +37,22 @@ class FramePropertiesDock : public QWidget
{
Q_OBJECT
public:
- FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitch );
+ FramePropertiesDock( QWidget* parent, bool* pbMainPlaySwitch );
~FramePropertiesDock();
QSize sizeHint() const;
- Void setFrame( PlaYUVerFrame* m_pcFrame );
- Void setSelection( const QRect& selectionArea );
- Void reset();
- Void stopHistogram();
+ void setFrame( CalypFrame* m_pcFrame );
+ void setSelection( const QRect& selectionArea );
+ void reset();
+ void stopHistogram();
private:
- PlaYUVerFrame* m_pcFrame;
- PlaYUVerFrame* m_pcSelectedFrame;
- Int m_iLastFrameType;
+ CalypFrame* m_pcFrame;
+ CalypFrame* m_pcSelectedFrame;
+ int m_iLastFrameType;
- Bool* m_pbIsPlaying;
+ bool* m_pbIsPlaying;
QComboBox* channelCB;
QComboBox* colorsCB;
@@ -66,8 +66,8 @@ private:
QButtonGroup* scaleButtonGroup;
QButtonGroup* renderingButtonGroup;
- QSpinBox* minInterv;
- QSpinBox* maxInterv;
+ QSpinBox* mininterv;
+ QSpinBox* maxinterv;
QLabel* labelPixelsValue;
QLabel* labelCountValue;
@@ -83,8 +83,8 @@ private:
HistogramWidget* histogramWidget;
- Void updateStatistiques();
- Void updateDataHistogram();
+ void updateStatistiques();
+ void updateDataHistogram();
private Q_SLOTS:
void slotRefreshOptions( int range );
@@ -96,8 +96,8 @@ private Q_SLOTS:
void slotMinValueChanged( int );
void slotMaxValueChanged( int );
- void slotUpdateInterval( int min, int max );
- void slotUpdateIntervRange( int range );
+ void slotUpdateinterval( int min, int max );
+ void slotUpdateintervRange( int range );
};
#endif // __FRAMEPROPERTIESDOCK_H__
diff --git a/app/ModuleHandleDock.cpp b/app/docks/ModuleHandleDock.cpp
similarity index 86%
rename from app/ModuleHandleDock.cpp
rename to app/docks/ModuleHandleDock.cpp
index f95dea1..7389476 100644
--- a/app/ModuleHandleDock.cpp
+++ b/app/docks/ModuleHandleDock.cpp
@@ -1,4 +1,4 @@
-/* This file is a part of PlaYUVer project
+/* This file is a part of Calyp project
* Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@gmail.com)
*
@@ -24,15 +24,15 @@
#include "ModuleHandleDock.h"
+#include "CalypAppModuleIf.h"
#include "ModulesHandle.h"
-#include "PlaYUVerAppModuleIf.h"
#include
#include
#include
#include
-ModuleHandleDock::ModuleHandleDock( QWidget* parent, PlaYUVerAppModuleIf* moduleIf )
+ModuleHandleDock::ModuleHandleDock( QWidget* parent, CalypAppModuleIf* moduleIf )
: QWidget( parent ), m_pcCurrModuleIf( moduleIf )
{
// ----------------- Dock definition -----------------
@@ -47,7 +47,7 @@ ModuleHandleDock::ModuleHandleDock( QWidget* parent, PlaYUVerAppModuleIf* module
labelModulueReturnValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
QGridLayout* modulesPropertiesLayout = new QGridLayout;
- Int layout_line = 0;
+ int layout_line = 0;
modulesPropertiesLayout->addWidget( labelModulueValueLabel, layout_line, 0 );
modulesPropertiesLayout->addWidget( labelModulueReturnValue, layout_line, 1 );
layout_line++;
@@ -60,18 +60,18 @@ ModuleHandleDock::ModuleHandleDock( QWidget* parent, PlaYUVerAppModuleIf* module
ModuleHandleDock::~ModuleHandleDock() {}
-Void ModuleHandleDock::setModulueReturnValue( Double value )
+void ModuleHandleDock::setModulueReturnValue( double value )
{
labelModulueReturnValue->clear();
QString strValue = QString( "%1" ).arg( value );
labelModulueReturnValue->setText( strValue );
}
-Void ModuleHandleDock::visibilityChangedSlot( bool visiblity )
+void ModuleHandleDock::visibilityChangedSlot( bool visiblity )
{
if( !visiblity && m_pcCurrModuleIf )
{
- PlaYUVerAppModuleIf* pcCurrentModule = m_pcCurrModuleIf;
+ CalypAppModuleIf* pcCurrentModule = m_pcCurrModuleIf;
m_pcCurrModuleIf = NULL;
ModulesHandle::destroyModuleIf( pcCurrentModule );
}
diff --git a/app/ModuleHandleDock.h b/app/docks/ModuleHandleDock.h
similarity index 83%
rename from app/ModuleHandleDock.h
rename to app/docks/ModuleHandleDock.h
index 1591dd1..c854edc 100644
--- a/app/ModuleHandleDock.h
+++ b/app/docks/ModuleHandleDock.h
@@ -1,4 +1,4 @@
-/* This file is a part of PlaYUVer project
+/* This file is a part of Calyp project
* Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@gmail.com)
*
@@ -25,7 +25,7 @@
#ifndef __MODULEHANDLEDOCK_H__
#define __MODULEHANDLEDOCK_H__
-#include "PlaYUVerAppDefs.h"
+#include "CommonDefs.h"
#include "config.h"
#include
@@ -33,23 +33,23 @@
class QLabel;
-class PlaYUVerAppModuleIf;
+class CalypAppModuleIf;
class ModuleHandleDock : public QWidget
{
Q_OBJECT
public:
- ModuleHandleDock( QWidget* parent, PlaYUVerAppModuleIf* moduleIf );
+ ModuleHandleDock( QWidget* parent, CalypAppModuleIf* moduleIf );
~ModuleHandleDock();
- Void setModulueReturnValue( Double value );
+ void setModulueReturnValue( double value );
QSize sizeHint() const;
private:
- PlaYUVerAppModuleIf* m_pcCurrModuleIf;
+ CalypAppModuleIf* m_pcCurrModuleIf;
- Bool m_bIsVisible;
+ bool m_bIsVisible;
QLabel* labelModulueValueLabel;
QLabel* labelModulueReturnValue;
diff --git a/app/QualityMeasurementSidebar.cpp b/app/docks/QualityMeasurementSidebar.cpp
similarity index 71%
rename from app/QualityMeasurementSidebar.cpp
rename to app/docks/QualityMeasurementSidebar.cpp
index b2ced4d..0b5e9cf 100644
--- a/app/QualityMeasurementSidebar.cpp
+++ b/app/docks/QualityMeasurementSidebar.cpp
@@ -1,4 +1,4 @@
-/* This file is a part of PlaYUVer project
+/* This file is a part of Calyp project
* Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@gmail.com)
*
@@ -24,12 +24,12 @@
#include "QualityMeasurementSidebar.h"
-#include "PlaYUVerSubWindowHandle.h"
+#include "SubWindowHandle.h"
#include "VideoSubWindow.h"
#include
-QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, PlaYUVerSubWindowHandle* windowManager )
+QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, SubWindowHandle* windowManager )
: QWidget( parent ), m_pcMainWindowManager( windowManager ), m_pcCurrentVideoSubWindow( NULL )
{
// Side bar area -----------------------------------------------------
@@ -44,9 +44,9 @@ QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, PlaYUVerS
RecLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
m_comboBoxMetric = new QComboBox;
- for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ )
+ for( unsigned int i = 0; i < CalypFrame::supportedQualityMetricsList().size(); i++ )
{
- m_comboBoxMetric->insertItem( i, PlaYUVerFrame::supportedQualityMetricsList()[i].c_str() );
+ m_comboBoxMetric->insertItem( i, CalypFrame::supportedQualityMetricsList()[i].c_str() );
}
m_comboBoxMetric->setSizeAdjustPolicy( QComboBox::AdjustToContents );
m_comboBoxMetric->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
@@ -64,28 +64,28 @@ QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, PlaYUVerS
mainLayout->addWidget( RefLabel, 1, 0, Qt::AlignLeft );
mainLayout->addWidget( m_comboBoxRef, 1, 1, 1, 2, Qt::AlignLeft );
- m_ppcLabelQualityLabel[LUMA] = new QLabel( "PSNR Y:" );
- m_ppcLabelQualityLabel[LUMA]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
- m_ppcLabelQualityValue[LUMA] = new QLabel;
- m_ppcLabelQualityValue[LUMA]->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
+ m_ppcLabelQualityLabel[CLP_LUMA] = new QLabel( "PSNR Y:" );
+ m_ppcLabelQualityLabel[CLP_LUMA]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
+ m_ppcLabelQualityValue[CLP_LUMA] = new QLabel;
+ m_ppcLabelQualityValue[CLP_LUMA]->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
- m_ppcLabelQualityLabel[CHROMA_U] = new QLabel( "PSNR U:" );
- m_ppcLabelQualityLabel[CHROMA_U]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
- m_ppcLabelQualityValue[CHROMA_U] = new QLabel;
- m_ppcLabelQualityValue[CHROMA_U]->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
+ m_ppcLabelQualityLabel[CLP_CHROMA_U] = new QLabel( "PSNR U:" );
+ m_ppcLabelQualityLabel[CLP_CHROMA_U]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
+ m_ppcLabelQualityValue[CLP_CHROMA_U] = new QLabel;
+ m_ppcLabelQualityValue[CLP_CHROMA_U]->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
- m_ppcLabelQualityLabel[CHROMA_V] = new QLabel( "PSNR V:" );
- m_ppcLabelQualityLabel[CHROMA_V]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
- m_ppcLabelQualityValue[CHROMA_V] = new QLabel;
- m_ppcLabelQualityValue[CHROMA_V]->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
+ m_ppcLabelQualityLabel[CLP_CHROMA_V] = new QLabel( "PSNR V:" );
+ m_ppcLabelQualityLabel[CLP_CHROMA_V]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
+ m_ppcLabelQualityValue[CLP_CHROMA_V] = new QLabel;
+ m_ppcLabelQualityValue[CLP_CHROMA_V]->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
QGridLayout* qualityResultsLayout = new QGridLayout;
- qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[LUMA], 0, 0 );
- qualityResultsLayout->addWidget( m_ppcLabelQualityValue[LUMA], 0, 1 );
- qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[CHROMA_U], 1, 0 );
- qualityResultsLayout->addWidget( m_ppcLabelQualityValue[CHROMA_U], 1, 1 );
- qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[CHROMA_V], 2, 0 );
- qualityResultsLayout->addWidget( m_ppcLabelQualityValue[CHROMA_V], 2, 1 );
+ qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[CLP_LUMA], 0, 0 );
+ qualityResultsLayout->addWidget( m_ppcLabelQualityValue[CLP_LUMA], 0, 1 );
+ qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[CLP_CHROMA_U], 1, 0 );
+ qualityResultsLayout->addWidget( m_ppcLabelQualityValue[CLP_CHROMA_U], 1, 1 );
+ qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[CLP_CHROMA_V], 2, 0 );
+ qualityResultsLayout->addWidget( m_ppcLabelQualityValue[CLP_CHROMA_V], 2, 1 );
// QGroupBox *statisticsGroup = new QGroupBox( tr( "Quality" ) );
QGroupBox* statisticsGroup = new QGroupBox;
@@ -114,14 +114,14 @@ QSize QualityMeasurementSidebar::sizeHint() const
return currSize;
}
-Void QualityMeasurementSidebar::updateSideBar( Bool hasSubWindow )
+void QualityMeasurementSidebar::updateSideBar( bool hasSubWindow )
{
if( !hasSubWindow )
m_comboBoxRef->clear();
setEnabled( hasSubWindow );
}
-Void QualityMeasurementSidebar::updateSubWindowList()
+void QualityMeasurementSidebar::updateSubWindowList()
{
QString currSubWindowName;
m_pcWindowListNames.clear();
@@ -129,7 +129,7 @@ Void QualityMeasurementSidebar::updateSubWindowList()
VideoSubWindow* pcVideoSubWindow;
QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
- for( Int i = 0; i < subWindowList.size(); i++ )
+ for( int i = 0; i < subWindowList.size(); i++ )
{
pcVideoSubWindow = qobject_cast( subWindowList.at( i ) );
if( m_pcCurrentVideoSubWindow == pcVideoSubWindow )
@@ -154,19 +154,19 @@ Void QualityMeasurementSidebar::updateSubWindowList()
{
if( VideoSubWindow* refSubWindow = m_pcCurrentVideoSubWindow->getRefSubWindow() )
{
- Int index = m_pcVideoWindowList.indexOf( refSubWindow );
+ int index = m_pcVideoWindowList.indexOf( refSubWindow );
m_comboBoxRef->setCurrentIndex( index );
}
}
// m_comboBoxRef->setSizeAdjustPolicy( QComboBox::AdjustToContents );
}
-Void QualityMeasurementSidebar::updateCurrentWindow( VideoSubWindow* subWindow )
+void QualityMeasurementSidebar::updateCurrentWindow( VideoSubWindow* subWindow )
{
m_pcCurrentVideoSubWindow = subWindow;
if( m_pcCurrentVideoSubWindow )
{
- Int index = -1;
+ int index = -1;
if( VideoSubWindow* refSubWindow = m_pcCurrentVideoSubWindow->getRefSubWindow() )
{
index = m_pcVideoWindowList.indexOf( refSubWindow );
@@ -177,7 +177,7 @@ Void QualityMeasurementSidebar::updateCurrentWindow( VideoSubWindow* subWindow )
}
}
-Void QualityMeasurementSidebar::updateSidebarData()
+void QualityMeasurementSidebar::updateSidebarData()
{
QString zeroValue( "0.0000" );
if( m_pcCurrentVideoSubWindow )
@@ -185,11 +185,11 @@ Void QualityMeasurementSidebar::updateSidebarData()
VideoSubWindow* refSubWindow = m_pcCurrentVideoSubWindow->getRefSubWindow();
if( refSubWindow )
{
- PlaYUVerFrame* currFrame = m_pcCurrentVideoSubWindow->getCurrFrame();
- PlaYUVerFrame* refFrame = refSubWindow->getCurrFrame();
- Double quality;
+ CalypFrame* currFrame = m_pcCurrentVideoSubWindow->getCurrFrame();
+ CalypFrame* refFrame = refSubWindow->getCurrFrame();
+ double quality;
QString value;
- UInt component = 0;
+ unsigned int component = 0;
for( ; component < currFrame->getNumberChannels(); component++ )
{
quality = currFrame->getQuality( m_comboBoxMetric->currentIndex(), refFrame, component );
@@ -207,23 +207,23 @@ Void QualityMeasurementSidebar::updateSidebarData()
m_comboBoxRef->setCurrentIndex( -1 );
}
}
- for( Int component = 0; component < 3; component++ )
+ for( int component = 0; component < 3; component++ )
{
m_ppcLabelQualityValue[component]->setText( zeroValue );
}
}
-Void QualityMeasurementSidebar::updateQualityMetric( Int idx )
+void QualityMeasurementSidebar::updateQualityMetric( int idx )
{
m_comboBoxMetric->setCurrentIndex( idx );
- QString labelQuality( PlaYUVerFrame::supportedQualityMetricsList()[idx].c_str() );
- m_ppcLabelQualityLabel[LUMA]->setText( labelQuality + " Y" );
- m_ppcLabelQualityLabel[CHROMA_U]->setText( labelQuality + " U" );
- m_ppcLabelQualityLabel[CHROMA_V]->setText( labelQuality + " V" );
+ QString labelQuality( CalypFrame::supportedQualityMetricsList()[idx].c_str() );
+ m_ppcLabelQualityLabel[CLP_LUMA]->setText( labelQuality + " Y" );
+ m_ppcLabelQualityLabel[CLP_CHROMA_U]->setText( labelQuality + " U" );
+ m_ppcLabelQualityLabel[CLP_CHROMA_V]->setText( labelQuality + " V" );
updateSidebarData();
}
-Void QualityMeasurementSidebar::slotReferenceChanged( Int index )
+void QualityMeasurementSidebar::slotReferenceChanged( int index )
{
if( index > -1 && m_pcCurrentVideoSubWindow )
{
@@ -245,7 +245,7 @@ Void QualityMeasurementSidebar::slotReferenceChanged( Int index )
}
}
-Void QualityMeasurementSidebar::slotQualityMetricChanged( Int idx )
+void QualityMeasurementSidebar::slotQualityMetricChanged( int idx )
{
emit signalQualityMetricChanged( idx );
// updateQualityMetric( idx );
diff --git a/app/QualityMeasurementSidebar.h b/app/docks/QualityMeasurementSidebar.h
similarity index 80%
rename from app/QualityMeasurementSidebar.h
rename to app/docks/QualityMeasurementSidebar.h
index db3668a..77e7691 100644
--- a/app/QualityMeasurementSidebar.h
+++ b/app/docks/QualityMeasurementSidebar.h
@@ -1,4 +1,4 @@
-/* This file is a part of PlaYUVer project
+/* This file is a part of Calyp project
* Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@gmail.com)
*
@@ -25,35 +25,35 @@
#ifndef __QUALITYMEASUREMENTSIDEBAR_H__
#define __QUALITYMEASUREMENTSIDEBAR_H__
+#include "CommonDefs.h"
#include "HistogramWidget.h"
-#include "PlaYUVerAppDefs.h"
#include "config.h"
-#include "lib/PlaYUVerFrame.h"
-#include "lib/PlaYUVerStream.h"
+#include "lib/CalypFrame.h"
+#include "lib/CalypStream.h"
#include
-class PlaYUVerSubWindowHandle;
+class SubWindowHandle;
class VideoSubWindow;
class QualityMeasurementSidebar : public QWidget
{
Q_OBJECT
public:
- QualityMeasurementSidebar( QWidget*, PlaYUVerSubWindowHandle* );
+ QualityMeasurementSidebar( QWidget*, SubWindowHandle* );
~QualityMeasurementSidebar();
QSize sizeHint() const;
- Void updateSideBar( Bool hasSubWindow );
+ void updateSideBar( bool hasSubWindow );
- Void updateSubWindowList();
- Void updateCurrentWindow( VideoSubWindow* );
- Void updateSidebarData();
- Void updateQualityMetric( Int );
+ void updateSubWindowList();
+ void updateCurrentWindow( VideoSubWindow* );
+ void updateSidebarData();
+ void updateQualityMetric( int );
private:
- PlaYUVerSubWindowHandle* m_pcMainWindowManager;
+ SubWindowHandle* m_pcMainWindowManager;
QVector m_pcVideoWindowList;
QStringList m_pcWindowListNames;
diff --git a/app/external/CMakeLists.txt b/app/external/CMakeLists.txt
index 11967aa..9e28baf 100644
--- a/app/external/CMakeLists.txt
+++ b/app/external/CMakeLists.txt
@@ -1,5 +1,5 @@
###
-### CMakeLists for playuver app external component
+### CMakeLists for calyp external components
###
ADD_SUBDIRECTORY( qcustomplot )
diff --git a/app/external/qcustomplot/qcustomplot.cpp b/app/external/qcustomplot/qcustomplot.cpp
index b882a76..154576a 100644
--- a/app/external/qcustomplot/qcustomplot.cpp
+++ b/app/external/qcustomplot/qcustomplot.cpp
@@ -25,6 +25,7 @@
#include "qcustomplot.h"
+
/* including file 'src/vector2d.cpp', size 7340 */
/* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */
@@ -107,8 +108,9 @@
/*!
Creates a QCPVector2D object and initializes the x and y coordinates to 0.
*/
-QCPVector2D::QCPVector2D()
- : mX( 0 ), mY( 0 )
+QCPVector2D::QCPVector2D() :
+ mX(0),
+ mY(0)
{
}
@@ -116,8 +118,9 @@ QCPVector2D::QCPVector2D()
Creates a QCPVector2D object and initializes the \a x and \a y coordinates with the specified
values.
*/
-QCPVector2D::QCPVector2D( double x, double y )
- : mX( x ), mY( y )
+QCPVector2D::QCPVector2D(double x, double y) :
+ mX(x),
+ mY(y)
{
}
@@ -125,8 +128,9 @@ QCPVector2D::QCPVector2D( double x, double y )
Creates a QCPVector2D object and initializes the x and y coordinates respective coordinates of
the specified \a point.
*/
-QCPVector2D::QCPVector2D( const QPoint& point )
- : mX( point.x() ), mY( point.y() )
+QCPVector2D::QCPVector2D(const QPoint &point) :
+ mX(point.x()),
+ mY(point.y())
{
}
@@ -134,8 +138,9 @@ QCPVector2D::QCPVector2D( const QPoint& point )
Creates a QCPVector2D object and initializes the x and y coordinates respective coordinates of
the specified \a point.
*/
-QCPVector2D::QCPVector2D( const QPointF& point )
- : mX( point.x() ), mY( point.y() )
+QCPVector2D::QCPVector2D(const QPointF &point) :
+ mX(point.x()),
+ mY(point.y())
{
}
@@ -158,7 +163,7 @@ void QCPVector2D::normalize()
*/
QCPVector2D QCPVector2D::normalized() const
{
- QCPVector2D result( mX, mY );
+ QCPVector2D result(mX, mY);
result.normalize();
return result;
}
@@ -170,22 +175,21 @@ QCPVector2D QCPVector2D::normalized() const
\see distanceToStraightLine
*/
-double QCPVector2D::distanceSquaredToLine( const QCPVector2D& start, const QCPVector2D& end ) const
+double QCPVector2D::distanceSquaredToLine(const QCPVector2D &start, const QCPVector2D &end) const
{
- QCPVector2D v( end - start );
+ QCPVector2D v(end-start);
double vLengthSqr = v.lengthSquared();
- if( !qFuzzyIsNull( vLengthSqr ) )
+ if (!qFuzzyIsNull(vLengthSqr))
{
- double mu = v.dot( *this - start ) / vLengthSqr;
- if( mu < 0 )
- return ( *this - start ).lengthSquared();
- else if( mu > 1 )
- return ( *this - end ).lengthSquared();
+ double mu = v.dot(*this-start)/vLengthSqr;
+ if (mu < 0)
+ return (*this-start).lengthSquared();
+ else if (mu > 1)
+ return (*this-end).lengthSquared();
else
- return ( ( start + mu * v ) - *this ).lengthSquared();
- }
- else
- return ( *this - start ).lengthSquared();
+ return ((start + mu*v)-*this).lengthSquared();
+ } else
+ return (*this-start).lengthSquared();
}
/*! \overload
@@ -195,9 +199,9 @@ double QCPVector2D::distanceSquaredToLine( const QCPVector2D& start, const QCPVe
\see distanceToStraightLine
*/
-double QCPVector2D::distanceSquaredToLine( const QLineF& line ) const
+double QCPVector2D::distanceSquaredToLine(const QLineF &line) const
{
- return distanceSquaredToLine( QCPVector2D( line.p1() ), QCPVector2D( line.p2() ) );
+ return distanceSquaredToLine(QCPVector2D(line.p1()), QCPVector2D(line.p2()));
}
/*!
@@ -206,16 +210,16 @@ double QCPVector2D::distanceSquaredToLine( const QLineF& line ) const
\see distanceSquaredToLine
*/
-double QCPVector2D::distanceToStraightLine( const QCPVector2D& base, const QCPVector2D& direction ) const
+double QCPVector2D::distanceToStraightLine(const QCPVector2D &base, const QCPVector2D &direction) const
{
- return qAbs( ( *this - base ).dot( direction.perpendicular() ) ) / direction.length();
+ return qAbs((*this-base).dot(direction.perpendicular()))/direction.length();
}
/*!
Scales this vector by the given \a factor, i.e. the x and y components are multiplied by \a
factor.
*/
-QCPVector2D& QCPVector2D::operator*=( double factor )
+QCPVector2D &QCPVector2D::operator*=(double factor)
{
mX *= factor;
mY *= factor;
@@ -226,7 +230,7 @@ QCPVector2D& QCPVector2D::operator*=( double factor )
Scales this vector by the given \a divisor, i.e. the x and y components are divided by \a
divisor.
*/
-QCPVector2D& QCPVector2D::operator/=( double divisor )
+QCPVector2D &QCPVector2D::operator/=(double divisor)
{
mX /= divisor;
mY /= divisor;
@@ -236,7 +240,7 @@ QCPVector2D& QCPVector2D::operator/=( double divisor )
/*!
Adds the given \a vector to this vector component-wise.
*/
-QCPVector2D& QCPVector2D::operator+=( const QCPVector2D& vector )
+QCPVector2D &QCPVector2D::operator+=(const QCPVector2D &vector)
{
mX += vector.mX;
mY += vector.mY;
@@ -246,7 +250,7 @@ QCPVector2D& QCPVector2D::operator+=( const QCPVector2D& vector )
/*!
subtracts the given \a vector from this vector component-wise.
*/
-QCPVector2D& QCPVector2D::operator-=( const QCPVector2D& vector )
+QCPVector2D &QCPVector2D::operator-=(const QCPVector2D &vector)
{
mX -= vector.mX;
mY -= vector.mY;
@@ -254,6 +258,7 @@ QCPVector2D& QCPVector2D::operator-=( const QCPVector2D& vector )
}
/* end of 'src/vector2d.cpp' */
+
/* including file 'src/painter.cpp', size 8670 */
/* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */
@@ -277,8 +282,10 @@ QCPVector2D& QCPVector2D::operator-=( const QCPVector2D& vector )
/*!
Creates a new QCPPainter instance and sets default values
*/
-QCPPainter::QCPPainter()
- : QPainter(), mModes( pmDefault ), mIsAntialiasing( false )
+QCPPainter::QCPPainter() :
+ QPainter(),
+ mModes(pmDefault),
+ mIsAntialiasing(false)
{
// don't setRenderHint(QPainter::NonCosmeticDefautPen) here, because painter isn't active yet and
// a call to begin() will follow
@@ -290,12 +297,14 @@ QCPPainter::QCPPainter()
Like \ref begin, this method sets QPainter::NonCosmeticDefaultPen in Qt versions before Qt5.
*/
-QCPPainter::QCPPainter( QPaintDevice* device )
- : QPainter( device ), mModes( pmDefault ), mIsAntialiasing( false )
+QCPPainter::QCPPainter(QPaintDevice *device) :
+ QPainter(device),
+ mModes(pmDefault),
+ mIsAntialiasing(false)
{
-#if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 ) // before Qt5, default pens used to be cosmetic if NonCosmeticDefaultPen flag isn't set. So we set it to get consistency across Qt versions.
- if( isActive() )
- setRenderHint( QPainter::NonCosmeticDefaultPen );
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) // before Qt5, default pens used to be cosmetic if NonCosmeticDefaultPen flag isn't set. So we set it to get consistency across Qt versions.
+ if (isActive())
+ setRenderHint(QPainter::NonCosmeticDefaultPen);
#endif
}
@@ -305,10 +314,10 @@ QCPPainter::QCPPainter( QPaintDevice* device )
\note this function hides the non-virtual base class implementation.
*/
-void QCPPainter::setPen( const QPen& pen )
+void QCPPainter::setPen(const QPen &pen)
{
- QPainter::setPen( pen );
- if( mModes.testFlag( pmNonCosmetic ) )
+ QPainter::setPen(pen);
+ if (mModes.testFlag(pmNonCosmetic))
makeNonCosmetic();
}
@@ -319,10 +328,10 @@ void QCPPainter::setPen( const QPen& pen )
\note this function hides the non-virtual base class implementation.
*/
-void QCPPainter::setPen( const QColor& color )
+void QCPPainter::setPen(const QColor &color)
{
- QPainter::setPen( color );
- if( mModes.testFlag( pmNonCosmetic ) )
+ QPainter::setPen(color);
+ if (mModes.testFlag(pmNonCosmetic))
makeNonCosmetic();
}
@@ -333,10 +342,10 @@ void QCPPainter::setPen( const QColor& color )
\note this function hides the non-virtual base class implementation.
*/
-void QCPPainter::setPen( Qt::PenStyle penStyle )
+void QCPPainter::setPen(Qt::PenStyle penStyle)
{
- QPainter::setPen( penStyle );
- if( mModes.testFlag( pmNonCosmetic ) )
+ QPainter::setPen(penStyle);
+ if (mModes.testFlag(pmNonCosmetic))
makeNonCosmetic();
}
@@ -348,12 +357,12 @@ void QCPPainter::setPen( Qt::PenStyle penStyle )
\note this function hides the non-virtual base class implementation.
*/
-void QCPPainter::drawLine( const QLineF& line )
+void QCPPainter::drawLine(const QLineF &line)
{
- if( mIsAntialiasing || mModes.testFlag( pmVectorized ) )
- QPainter::drawLine( line );
+ if (mIsAntialiasing || mModes.testFlag(pmVectorized))
+ QPainter::drawLine(line);
else
- QPainter::drawLine( line.toLine() );
+ QPainter::drawLine(line.toLine());
}
/*!
@@ -362,18 +371,18 @@ void QCPPainter::drawLine( const QLineF& line )
antialiased and non-antialiased painting (Since Qt < 5.0 uses slightly different coordinate systems for
AA/Non-AA painting).
*/
-void QCPPainter::setAntialiasing( bool enabled )
+void QCPPainter::setAntialiasing(bool enabled)
{
- setRenderHint( QPainter::Antialiasing, enabled );
- if( mIsAntialiasing != enabled )
+ setRenderHint(QPainter::Antialiasing, enabled);
+ if (mIsAntialiasing != enabled)
{
mIsAntialiasing = enabled;
- if( !mModes.testFlag( pmVectorized ) ) // antialiasing half-pixel shift only needed for rasterized outputs
+ if (!mModes.testFlag(pmVectorized)) // antialiasing half-pixel shift only needed for rasterized outputs
{
- if( mIsAntialiasing )
- translate( 0.5, 0.5 );
+ if (mIsAntialiasing)
+ translate(0.5, 0.5);
else
- translate( -0.5, -0.5 );
+ translate(-0.5, -0.5);
}
}
}
@@ -382,7 +391,7 @@ void QCPPainter::setAntialiasing( bool enabled )
Sets the mode of the painter. This controls whether the painter shall adjust its
fixes/workarounds optimized for certain output devices.
*/
-void QCPPainter::setModes( QCPPainter::PainterModes modes )
+void QCPPainter::setModes(QCPPainter::PainterModes modes)
{
mModes = modes;
}
@@ -398,12 +407,12 @@ void QCPPainter::setModes( QCPPainter::PainterModes modes )
\note this function hides the non-virtual base class implementation.
*/
-bool QCPPainter::begin( QPaintDevice* device )
+bool QCPPainter::begin(QPaintDevice *device)
{
- bool result = QPainter::begin( device );
-#if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 ) // before Qt5, default pens used to be cosmetic if NonCosmeticDefaultPen flag isn't set. So we set it to get consistency across Qt versions.
- if( result )
- setRenderHint( QPainter::NonCosmeticDefaultPen );
+ bool result = QPainter::begin(device);
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) // before Qt5, default pens used to be cosmetic if NonCosmeticDefaultPen flag isn't set. So we set it to get consistency across Qt versions.
+ if (result)
+ setRenderHint(QPainter::NonCosmeticDefaultPen);
#endif
return result;
}
@@ -413,11 +422,11 @@ bool QCPPainter::begin( QPaintDevice* device )
Sets the mode of the painter. This controls whether the painter shall adjust its
fixes/workarounds optimized for certain output devices.
*/
-void QCPPainter::setMode( QCPPainter::PainterMode mode, bool enabled )
+void QCPPainter::setMode(QCPPainter::PainterMode mode, bool enabled)
{
- if( !enabled && mModes.testFlag( mode ) )
+ if (!enabled && mModes.testFlag(mode))
mModes &= ~mode;
- else if( enabled && !mModes.testFlag( mode ) )
+ else if (enabled && !mModes.testFlag(mode))
mModes |= mode;
}
@@ -431,7 +440,7 @@ void QCPPainter::setMode( QCPPainter::PainterMode mode, bool enabled )
*/
void QCPPainter::save()
{
- mAntialiasingStack.push( mIsAntialiasing );
+ mAntialiasingStack.push(mIsAntialiasing);
QPainter::save();
}
@@ -445,7 +454,7 @@ void QCPPainter::save()
*/
void QCPPainter::restore()
{
- if( !mAntialiasingStack.isEmpty() )
+ if (!mAntialiasingStack.isEmpty())
mIsAntialiasing = mAntialiasingStack.pop();
else
qDebug() << Q_FUNC_INFO << "Unbalanced save/restore";
@@ -458,15 +467,16 @@ void QCPPainter::restore()
*/
void QCPPainter::makeNonCosmetic()
{
- if( qFuzzyIsNull( pen().widthF() ) )
+ if (qFuzzyIsNull(pen().widthF()))
{
QPen p = pen();
- p.setWidth( 1 );
- QPainter::setPen( p );
+ p.setWidth(1);
+ QPainter::setPen(p);
}
}
/* end of 'src/painter.cpp' */
+
/* including file 'src/paintbuffer.cpp', size 18502 */
/* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */
@@ -557,8 +567,10 @@ void QCPPainter::makeNonCosmetic()
Subclasses must call their \ref reallocateBuffer implementation in their respective constructors.
*/
-QCPAbstractPaintBuffer::QCPAbstractPaintBuffer( const QSize& size, double devicePixelRatio )
- : mSize( size ), mDevicePixelRatio( devicePixelRatio ), mInvalidated( true )
+QCPAbstractPaintBuffer::QCPAbstractPaintBuffer(const QSize &size, double devicePixelRatio) :
+ mSize(size),
+ mDevicePixelRatio(devicePixelRatio),
+ mInvalidated(true)
{
}
@@ -574,9 +586,9 @@ QCPAbstractPaintBuffer::~QCPAbstractPaintBuffer()
If \a size is already the current buffer size, this method does nothing.
*/
-void QCPAbstractPaintBuffer::setSize( const QSize& size )
+void QCPAbstractPaintBuffer::setSize(const QSize &size)
{
- if( mSize != size )
+ if (mSize != size)
{
mSize = size;
reallocateBuffer();
@@ -598,7 +610,7 @@ void QCPAbstractPaintBuffer::setSize( const QSize& size )
Under normal circumstances, it is not necessary to manually call this method.
*/
-void QCPAbstractPaintBuffer::setInvalidated( bool invalidated )
+void QCPAbstractPaintBuffer::setInvalidated(bool invalidated)
{
mInvalidated = invalidated;
}
@@ -612,9 +624,9 @@ void QCPAbstractPaintBuffer::setInvalidated( bool invalidated )
\note This method is only available for Qt versions 5.4 and higher.
*/
-void QCPAbstractPaintBuffer::setDevicePixelRatio( double ratio )
+void QCPAbstractPaintBuffer::setDevicePixelRatio(double ratio)
{
- if( !qFuzzyCompare( ratio, mDevicePixelRatio ) )
+ if (!qFuzzyCompare(ratio, mDevicePixelRatio))
{
#ifdef QCP_DEVICEPIXELRATIO_SUPPORTED
mDevicePixelRatio = ratio;
@@ -641,8 +653,8 @@ void QCPAbstractPaintBuffer::setDevicePixelRatio( double ratio )
Creates a pixmap paint buffer instancen with the specified \a size and \a devicePixelRatio, if
applicable.
*/
-QCPPaintBufferPixmap::QCPPaintBufferPixmap( const QSize& size, double devicePixelRatio )
- : QCPAbstractPaintBuffer( size, devicePixelRatio )
+QCPPaintBufferPixmap::QCPPaintBufferPixmap(const QSize &size, double devicePixelRatio) :
+ QCPAbstractPaintBuffer(size, devicePixelRatio)
{
QCPPaintBufferPixmap::reallocateBuffer();
}
@@ -652,49 +664,49 @@ QCPPaintBufferPixmap::~QCPPaintBufferPixmap()
}
/* inherits documentation from base class */
-QCPPainter* QCPPaintBufferPixmap::startPainting()
+QCPPainter *QCPPaintBufferPixmap::startPainting()
{
- QCPPainter* result = new QCPPainter( &mBuffer );
- result->setRenderHint( QPainter::HighQualityAntialiasing );
+ QCPPainter *result = new QCPPainter(&mBuffer);
+ result->setRenderHint(QPainter::HighQualityAntialiasing);
return result;
}
/* inherits documentation from base class */
-void QCPPaintBufferPixmap::draw( QCPPainter* painter ) const
+void QCPPaintBufferPixmap::draw(QCPPainter *painter) const
{
- if( painter && painter->isActive() )
- painter->drawPixmap( 0, 0, mBuffer );
+ if (painter && painter->isActive())
+ painter->drawPixmap(0, 0, mBuffer);
else
qDebug() << Q_FUNC_INFO << "invalid or inactive painter passed";
}
/* inherits documentation from base class */
-void QCPPaintBufferPixmap::clear( const QColor& color )
+void QCPPaintBufferPixmap::clear(const QColor &color)
{
- mBuffer.fill( color );
+ mBuffer.fill(color);
}
/* inherits documentation from base class */
void QCPPaintBufferPixmap::reallocateBuffer()
{
setInvalidated();
- if( !qFuzzyCompare( 1.0, mDevicePixelRatio ) )
+ if (!qFuzzyCompare(1.0, mDevicePixelRatio))
{
#ifdef QCP_DEVICEPIXELRATIO_SUPPORTED
- mBuffer = QPixmap( mSize * mDevicePixelRatio );
- mBuffer.setDevicePixelRatio( mDevicePixelRatio );
+ mBuffer = QPixmap(mSize*mDevicePixelRatio);
+ mBuffer.setDevicePixelRatio(mDevicePixelRatio);
#else
qDebug() << Q_FUNC_INFO << "Device pixel ratios not supported for Qt versions before 5.4";
mDevicePixelRatio = 1.0;
- mBuffer = QPixmap( mSize );
+ mBuffer = QPixmap(mSize);
#endif
- }
- else
+ } else
{
- mBuffer = QPixmap( mSize );
+ mBuffer = QPixmap(mSize);
}
}
+
#ifdef QCP_OPENGL_PBUFFER
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// QCPPaintBufferGlPbuffer
@@ -719,74 +731,76 @@ void QCPPaintBufferPixmap::reallocateBuffer()
result in higher quality antialiasing. If the specified \a multisamples value exceeds the
capability of the graphics hardware, the highest supported multisampling is used.
*/
-QCPPaintBufferGlPbuffer::QCPPaintBufferGlPbuffer( const QSize& size, double devicePixelRatio, int multisamples )
- : QCPAbstractPaintBuffer( size, devicePixelRatio ), mGlPBuffer( 0 ), mMultisamples( qMax( 0, multisamples ) )
+QCPPaintBufferGlPbuffer::QCPPaintBufferGlPbuffer(const QSize &size, double devicePixelRatio, int multisamples) :
+ QCPAbstractPaintBuffer(size, devicePixelRatio),
+ mGlPBuffer(0),
+ mMultisamples(qMax(0, multisamples))
{
QCPPaintBufferGlPbuffer::reallocateBuffer();
}
QCPPaintBufferGlPbuffer::~QCPPaintBufferGlPbuffer()
{
- if( mGlPBuffer )
+ if (mGlPBuffer)
delete mGlPBuffer;
}
/* inherits documentation from base class */
-QCPPainter* QCPPaintBufferGlPbuffer::startPainting()
+QCPPainter *QCPPaintBufferGlPbuffer::startPainting()
{
- if( !mGlPBuffer->isValid() )
+ if (!mGlPBuffer->isValid())
{
qDebug() << Q_FUNC_INFO << "OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?";
return 0;
}
-
- QCPPainter* result = new QCPPainter( mGlPBuffer );
- result->setRenderHint( QPainter::HighQualityAntialiasing );
+
+ QCPPainter *result = new QCPPainter(mGlPBuffer);
+ result->setRenderHint(QPainter::HighQualityAntialiasing);
return result;
}
/* inherits documentation from base class */
-void QCPPaintBufferGlPbuffer::draw( QCPPainter* painter ) const
+void QCPPaintBufferGlPbuffer::draw(QCPPainter *painter) const
{
- if( !painter || !painter->isActive() )
+ if (!painter || !painter->isActive())
{
qDebug() << Q_FUNC_INFO << "invalid or inactive painter passed";
return;
}
- if( !mGlPBuffer->isValid() )
+ if (!mGlPBuffer->isValid())
{
qDebug() << Q_FUNC_INFO << "OpenGL pbuffer isn't valid, reallocateBuffer was not called?";
return;
}
- painter->drawImage( 0, 0, mGlPBuffer->toImage() );
+ painter->drawImage(0, 0, mGlPBuffer->toImage());
}
/* inherits documentation from base class */
-void QCPPaintBufferGlPbuffer::clear( const QColor& color )
+void QCPPaintBufferGlPbuffer::clear(const QColor &color)
{
- if( mGlPBuffer->isValid() )
+ if (mGlPBuffer->isValid())
{
mGlPBuffer->makeCurrent();
- glClearColor( color.redF(), color.greenF(), color.blueF(), color.alphaF() );
- glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+ glClearColor(color.redF(), color.greenF(), color.blueF(), color.alphaF());
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
mGlPBuffer->doneCurrent();
- }
- else
+ } else
qDebug() << Q_FUNC_INFO << "OpenGL pbuffer invalid or context not current";
}
/* inherits documentation from base class */
void QCPPaintBufferGlPbuffer::reallocateBuffer()
{
- if( mGlPBuffer )
+ if (mGlPBuffer)
delete mGlPBuffer;
-
+
QGLFormat format;
- format.setAlpha( true );
- format.setSamples( mMultisamples );
- mGlPBuffer = new QGLPixelBuffer( mSize, format );
+ format.setAlpha(true);
+ format.setSamples(mMultisamples);
+ mGlPBuffer = new QGLPixelBuffer(mSize, format);
}
-#endif // QCP_OPENGL_PBUFFER
+#endif // QCP_OPENGL_PBUFFER
+
#ifdef QCP_OPENGL_FBO
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -813,84 +827,87 @@ void QCPPaintBufferGlPbuffer::reallocateBuffer()
QCustomPlot::setupOpenGl and the context and paint device are managed by the parent QCustomPlot
instance.
*/
-QCPPaintBufferGlFbo::QCPPaintBufferGlFbo( const QSize& size, double devicePixelRatio, QWeakPointer glContext, QWeakPointer glPaintDevice )
- : QCPAbstractPaintBuffer( size, devicePixelRatio ), mGlContext( glContext ), mGlPaintDevice( glPaintDevice ), mGlFrameBuffer( 0 )
+QCPPaintBufferGlFbo::QCPPaintBufferGlFbo(const QSize &size, double devicePixelRatio, QWeakPointer glContext, QWeakPointer glPaintDevice) :
+ QCPAbstractPaintBuffer(size, devicePixelRatio),
+ mGlContext(glContext),
+ mGlPaintDevice(glPaintDevice),
+ mGlFrameBuffer(0)
{
QCPPaintBufferGlFbo::reallocateBuffer();
}
QCPPaintBufferGlFbo::~QCPPaintBufferGlFbo()
{
- if( mGlFrameBuffer )
+ if (mGlFrameBuffer)
delete mGlFrameBuffer;
}
/* inherits documentation from base class */
-QCPPainter* QCPPaintBufferGlFbo::startPainting()
+QCPPainter *QCPPaintBufferGlFbo::startPainting()
{
- if( mGlPaintDevice.isNull() )
+ if (mGlPaintDevice.isNull())
{
qDebug() << Q_FUNC_INFO << "OpenGL paint device doesn't exist";
return 0;
}
- if( !mGlFrameBuffer )
+ if (!mGlFrameBuffer)
{
qDebug() << Q_FUNC_INFO << "OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?";
return 0;
}
-
- if( QOpenGLContext::currentContext() != mGlContext.data() )
- mGlContext.data()->makeCurrent( mGlContext.data()->surface() );
+
+ if (QOpenGLContext::currentContext() != mGlContext.data())
+ mGlContext.data()->makeCurrent(mGlContext.data()->surface());
mGlFrameBuffer->bind();
- QCPPainter* result = new QCPPainter( mGlPaintDevice.data() );
- result->setRenderHint( QPainter::HighQualityAntialiasing );
+ QCPPainter *result = new QCPPainter(mGlPaintDevice.data());
+ result->setRenderHint(QPainter::HighQualityAntialiasing);
return result;
}
/* inherits documentation from base class */
void QCPPaintBufferGlFbo::donePainting()
{
- if( mGlFrameBuffer && mGlFrameBuffer->isBound() )
+ if (mGlFrameBuffer && mGlFrameBuffer->isBound())
mGlFrameBuffer->release();
else
qDebug() << Q_FUNC_INFO << "Either OpenGL frame buffer not valid or was not bound";
}
/* inherits documentation from base class */
-void QCPPaintBufferGlFbo::draw( QCPPainter* painter ) const
+void QCPPaintBufferGlFbo::draw(QCPPainter *painter) const
{
- if( !painter || !painter->isActive() )
+ if (!painter || !painter->isActive())
{
qDebug() << Q_FUNC_INFO << "invalid or inactive painter passed";
return;
}
- if( !mGlFrameBuffer )
+ if (!mGlFrameBuffer)
{
qDebug() << Q_FUNC_INFO << "OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?";
return;
}
- painter->drawImage( 0, 0, mGlFrameBuffer->toImage() );
+ painter->drawImage(0, 0, mGlFrameBuffer->toImage());
}
/* inherits documentation from base class */
-void QCPPaintBufferGlFbo::clear( const QColor& color )
+void QCPPaintBufferGlFbo::clear(const QColor &color)
{
- if( mGlContext.isNull() )
+ if (mGlContext.isNull())
{
qDebug() << Q_FUNC_INFO << "OpenGL context doesn't exist";
return;
}
- if( !mGlFrameBuffer )
+ if (!mGlFrameBuffer)
{
qDebug() << Q_FUNC_INFO << "OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?";
return;
}
-
- if( QOpenGLContext::currentContext() != mGlContext.data() )
- mGlContext.data()->makeCurrent( mGlContext.data()->surface() );
+
+ if (QOpenGLContext::currentContext() != mGlContext.data())
+ mGlContext.data()->makeCurrent(mGlContext.data()->surface());
mGlFrameBuffer->bind();
- glClearColor( color.redF(), color.greenF(), color.blueF(), color.alphaF() );
- glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+ glClearColor(color.redF(), color.greenF(), color.blueF(), color.alphaF());
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
mGlFrameBuffer->release();
}
@@ -898,40 +915,41 @@ void QCPPaintBufferGlFbo::clear( const QColor& color )
void QCPPaintBufferGlFbo::reallocateBuffer()
{
// release and delete possibly existing framebuffer:
- if( mGlFrameBuffer )
+ if (mGlFrameBuffer)
{
- if( mGlFrameBuffer->isBound() )
+ if (mGlFrameBuffer->isBound())
mGlFrameBuffer->release();
delete mGlFrameBuffer;
mGlFrameBuffer = 0;
}
-
- if( mGlContext.isNull() )
+
+ if (mGlContext.isNull())
{
qDebug() << Q_FUNC_INFO << "OpenGL context doesn't exist";
return;
}
- if( mGlPaintDevice.isNull() )
+ if (mGlPaintDevice.isNull())
{
qDebug() << Q_FUNC_INFO << "OpenGL paint device doesn't exist";
return;
}
-
+
// create new fbo with appropriate size:
- mGlContext.data()->makeCurrent( mGlContext.data()->surface() );
+ mGlContext.data()->makeCurrent(mGlContext.data()->surface());
QOpenGLFramebufferObjectFormat frameBufferFormat;
- frameBufferFormat.setSamples( mGlContext.data()->format().samples() );
- frameBufferFormat.setAttachment( QOpenGLFramebufferObject::CombinedDepthStencil );
- mGlFrameBuffer = new QOpenGLFramebufferObject( mSize * mDevicePixelRatio, frameBufferFormat );
- if( mGlPaintDevice.data()->size() != mSize * mDevicePixelRatio )
- mGlPaintDevice.data()->setSize( mSize * mDevicePixelRatio );
+ frameBufferFormat.setSamples(mGlContext.data()->format().samples());
+ frameBufferFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
+ mGlFrameBuffer = new QOpenGLFramebufferObject(mSize*mDevicePixelRatio, frameBufferFormat);
+ if (mGlPaintDevice.data()->size() != mSize*mDevicePixelRatio)
+ mGlPaintDevice.data()->setSize(mSize*mDevicePixelRatio);
#ifdef QCP_DEVICEPIXELRATIO_SUPPORTED
- mGlPaintDevice.data()->setDevicePixelRatio( mDevicePixelRatio );
+ mGlPaintDevice.data()->setDevicePixelRatio(mDevicePixelRatio);
#endif
}
-#endif // QCP_OPENGL_FBO
+#endif // QCP_OPENGL_FBO
/* end of 'src/paintbuffer.cpp' */
+
/* including file 'src/layer.cpp', size 37064 */
/* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */
@@ -1021,10 +1039,13 @@ void QCPPaintBufferGlFbo::reallocateBuffer()
\warning It is not checked that \a layerName is actually a unique layer name in \a parentPlot.
This check is only performed by \ref QCustomPlot::addLayer.
*/
-QCPLayer::QCPLayer( QCustomPlot* parentPlot, const QString& layerName )
- : QObject( parentPlot ), mParentPlot( parentPlot ), mName( layerName ), mIndex( -1 ), // will be set to a proper value by the QCustomPlot layer creation function
- mVisible( true )
- , mMode( lmLogical )
+QCPLayer::QCPLayer(QCustomPlot *parentPlot, const QString &layerName) :
+ QObject(parentPlot),
+ mParentPlot(parentPlot),
+ mName(layerName),
+ mIndex(-1), // will be set to a proper value by the QCustomPlot layer creation function
+ mVisible(true),
+ mMode(lmLogical)
{
// Note: no need to make sure layerName is unique, because layer
// management is done with QCustomPlot functions.
@@ -1036,11 +1057,11 @@ QCPLayer::~QCPLayer()
// then invalid layer once they get deleted/moved themselves. This only happens when layers are deleted
// directly, like in the QCustomPlot destructor. (The regular layer removal procedure for the user is to
// call QCustomPlot::removeLayer, which moves all layerables off this layer before deleting it.)
-
- while( !mChildren.isEmpty() )
- mChildren.last()->setLayer( 0 ); // removes itself from mChildren via removeChild()
-
- if( mParentPlot->currentLayer() == this )
+
+ while (!mChildren.isEmpty())
+ mChildren.last()->setLayer(0); // removes itself from mChildren via removeChild()
+
+ if (mParentPlot->currentLayer() == this)
qDebug() << Q_FUNC_INFO << "The parent plot's mCurrentLayer will be a dangling pointer. Should have been set to a valid layer or 0 beforehand.";
}
@@ -1052,7 +1073,7 @@ QCPLayer::~QCPLayer()
QCPLayerable::setVisible), but the \ref QCPLayerable::realVisibility of each layerable takes the
visibility of the parent layer into account.
*/
-void QCPLayer::setVisible( bool visible )
+void QCPLayer::setVisible(bool visible)
{
mVisible = visible;
}
@@ -1078,12 +1099,12 @@ void QCPLayer::setVisible( bool visible )
\see replot
*/
-void QCPLayer::setMode( QCPLayer::LayerMode mode )
+void QCPLayer::setMode(QCPLayer::LayerMode mode)
{
- if( mMode != mode )
+ if (mMode != mode)
{
mMode = mode;
- if( !mPaintBuffer.isNull() )
+ if (!mPaintBuffer.isNull())
mPaintBuffer.data()->setInvalidated();
}
}
@@ -1094,16 +1115,16 @@ void QCPLayer::setMode( QCPLayer::LayerMode mode )
\see replot, drawToPaintBuffer
*/
-void QCPLayer::draw( QCPPainter* painter )
+void QCPLayer::draw(QCPPainter *painter)
{
- foreach( QCPLayerable* child, mChildren )
+ foreach (QCPLayerable *child, mChildren)
{
- if( child->realVisibility() )
+ if (child->realVisibility())
{
painter->save();
- painter->setClipRect( child->clipRect().translated( 0, -1 ) );
- child->applyDefaultAntialiasingHint( painter );
- child->draw( painter );
+ painter->setClipRect(child->clipRect().translated(0, -1));
+ child->applyDefaultAntialiasingHint(painter);
+ child->draw(painter);
painter->restore();
}
}
@@ -1119,21 +1140,19 @@ void QCPLayer::draw( QCPPainter* painter )
*/
void QCPLayer::drawToPaintBuffer()
{
- if( !mPaintBuffer.isNull() )
+ if (!mPaintBuffer.isNull())
{
- if( QCPPainter* painter = mPaintBuffer.data()->startPainting() )
+ if (QCPPainter *painter = mPaintBuffer.data()->startPainting())
{
- if( painter->isActive() )
- draw( painter );
+ if (painter->isActive())
+ draw(painter);
else
qDebug() << Q_FUNC_INFO << "paint buffer returned inactive painter";
delete painter;
mPaintBuffer.data()->donePainting();
- }
- else
+ } else
qDebug() << Q_FUNC_INFO << "paint buffer returned zero painter";
- }
- else
+ } else
qDebug() << Q_FUNC_INFO << "no valid paint buffer associated with this layer";
}
@@ -1152,19 +1171,17 @@ void QCPLayer::drawToPaintBuffer()
*/
void QCPLayer::replot()
{
- if( mMode == lmBuffered && !mParentPlot->hasInvalidatedPaintBuffers() )
+ if (mMode == lmBuffered && !mParentPlot->hasInvalidatedPaintBuffers())
{
- if( !mPaintBuffer.isNull() )
+ if (!mPaintBuffer.isNull())
{
- mPaintBuffer.data()->clear( Qt::transparent );
+ mPaintBuffer.data()->clear(Qt::transparent);
drawToPaintBuffer();
- mPaintBuffer.data()->setInvalidated( false );
+ mPaintBuffer.data()->setInvalidated(false);
mParentPlot->update();
- }
- else
+ } else
qDebug() << Q_FUNC_INFO << "no valid paint buffer associated with this layer";
- }
- else if( mMode == lmLogical )
+ } else if (mMode == lmLogical)
mParentPlot->replot();
}
@@ -1178,19 +1195,18 @@ void QCPLayer::replot()
\see removeChild
*/
-void QCPLayer::addChild( QCPLayerable* layerable, bool prepend )
+void QCPLayer::addChild(QCPLayerable *layerable, bool prepend)
{
- if( !mChildren.contains( layerable ) )
+ if (!mChildren.contains(layerable))
{
- if( prepend )
- mChildren.prepend( layerable );
+ if (prepend)
+ mChildren.prepend(layerable);
else
- mChildren.append( layerable );
- if( !mPaintBuffer.isNull() )
+ mChildren.append(layerable);
+ if (!mPaintBuffer.isNull())
mPaintBuffer.data()->setInvalidated();
- }
- else
- qDebug() << Q_FUNC_INFO << "layerable is already child of this layer" << reinterpret_cast( layerable );
+ } else
+ qDebug() << Q_FUNC_INFO << "layerable is already child of this layer" << reinterpret_cast(layerable);
}
/*! \internal
@@ -1202,17 +1218,17 @@ void QCPLayer::addChild( QCPLayerable* layerable, bool prepend )
\see addChild
*/
-void QCPLayer::removeChild( QCPLayerable* layerable )
+void QCPLayer::removeChild(QCPLayerable *layerable)
{
- if( mChildren.removeOne( layerable ) )
+ if (mChildren.removeOne(layerable))
{
- if( !mPaintBuffer.isNull() )
+ if (!mPaintBuffer.isNull())
mPaintBuffer.data()->setInvalidated();
- }
- else
- qDebug() << Q_FUNC_INFO << "layerable is not child of this layer" << reinterpret_cast( layerable );
+ } else
+ qDebug() << Q_FUNC_INFO << "layerable is not child of this layer" << reinterpret_cast(layerable);
}
+
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// QCPLayerable
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1320,23 +1336,28 @@ void QCPLayer::removeChild( QCPLayerable* layerable )
plot does. It is not uncommon to set the QObject-parent to something else in the constructors of
QCPLayerable subclasses, to guarantee a working destruction hierarchy.
*/
-QCPLayerable::QCPLayerable( QCustomPlot* plot, QString targetLayer, QCPLayerable* parentLayerable )
- : QObject( plot ), mVisible( true ), mParentPlot( plot ), mParentLayerable( parentLayerable ), mLayer( 0 ), mAntialiased( true )
+QCPLayerable::QCPLayerable(QCustomPlot *plot, QString targetLayer, QCPLayerable *parentLayerable) :
+ QObject(plot),
+ mVisible(true),
+ mParentPlot(plot),
+ mParentLayerable(parentLayerable),
+ mLayer(0),
+ mAntialiased(true)
{
- if( mParentPlot )
+ if (mParentPlot)
{
- if( targetLayer.isEmpty() )
- setLayer( mParentPlot->currentLayer() );
- else if( !setLayer( targetLayer ) )
+ if (targetLayer.isEmpty())
+ setLayer(mParentPlot->currentLayer());
+ else if (!setLayer(targetLayer))
qDebug() << Q_FUNC_INFO << "setting QCPlayerable initial layer to" << targetLayer << "failed.";
}
}
QCPLayerable::~QCPLayerable()
{
- if( mLayer )
+ if (mLayer)
{
- mLayer->removeChild( this );
+ mLayer->removeChild(this);
mLayer = 0;
}
}
@@ -1346,7 +1367,7 @@ QCPLayerable::~QCPLayerable()
on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not
possible.
*/
-void QCPLayerable::setVisible( bool on )
+void QCPLayerable::setVisible(bool on)
{
mVisible = on;
}
@@ -1360,9 +1381,9 @@ void QCPLayerable::setVisible( bool on )
Returns true if the layer of this layerable was successfully changed to \a layer.
*/
-bool QCPLayerable::setLayer( QCPLayer* layer )
+bool QCPLayerable::setLayer(QCPLayer *layer)
{
- return moveToLayer( layer, false );
+ return moveToLayer(layer, false);
}
/*! \overload
@@ -1370,18 +1391,17 @@ bool QCPLayerable::setLayer( QCPLayer* layer )
Returns true on success, i.e. if \a layerName is a valid layer name.
*/
-bool QCPLayerable::setLayer( const QString& layerName )
+bool QCPLayerable::setLayer(const QString &layerName)
{
- if( !mParentPlot )
+ if (!mParentPlot)
{
qDebug() << Q_FUNC_INFO << "no parent QCustomPlot set";
return false;
}
- if( QCPLayer* layer = mParentPlot->layer( layerName ) )
+ if (QCPLayer *layer = mParentPlot->layer(layerName))
{
- return setLayer( layer );
- }
- else
+ return setLayer(layer);
+ } else
{
qDebug() << Q_FUNC_INFO << "there is no layer with name" << layerName;
return false;
@@ -1394,7 +1414,7 @@ bool QCPLayerable::setLayer( const QString& layerName )
Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and
QCustomPlot::setNotAntialiasedElements.
*/
-void QCPLayerable::setAntialiased( bool enabled )
+void QCPLayerable::setAntialiased(bool enabled)
{
mAntialiased = enabled;
}
@@ -1411,7 +1431,7 @@ void QCPLayerable::setAntialiased( bool enabled )
*/
bool QCPLayerable::realVisibility() const
{
- return mVisible && ( !mLayer || mLayer->visible() ) && ( !mParentLayerable || mParentLayerable.data()->realVisibility() );
+ return mVisible && (!mLayer || mLayer->visible()) && (!mParentLayerable || mParentLayerable.data()->realVisibility());
}
/*!
@@ -1448,11 +1468,11 @@ bool QCPLayerable::realVisibility() const
\see selectEvent, deselectEvent, mousePressEvent, wheelEvent, QCustomPlot::setInteractions
*/
-double QCPLayerable::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const
+double QCPLayerable::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const
{
- Q_UNUSED( pos )
- Q_UNUSED( onlySelectable )
- Q_UNUSED( details )
+ Q_UNUSED(pos)
+ Q_UNUSED(onlySelectable)
+ Q_UNUSED(details)
return -1.0;
}
@@ -1473,19 +1493,19 @@ double QCPLayerable::selectTest( const QPointF& pos, bool onlySelectable, QVaria
so they can react accordingly (e.g. also initialize the parent plot of child layerables, like
QCPLayout does).
*/
-void QCPLayerable::initializeParentPlot( QCustomPlot* parentPlot )
+void QCPLayerable::initializeParentPlot(QCustomPlot *parentPlot)
{
- if( mParentPlot )
+ if (mParentPlot)
{
qDebug() << Q_FUNC_INFO << "called with mParentPlot already initialized";
return;
}
-
- if( !parentPlot )
+
+ if (!parentPlot)
qDebug() << Q_FUNC_INFO << "called with parentPlot zero";
-
+
mParentPlot = parentPlot;
- parentPlotInitialized( mParentPlot );
+ parentPlotInitialized(mParentPlot);
}
/*! \internal
@@ -1499,7 +1519,7 @@ void QCPLayerable::initializeParentPlot( QCustomPlot* parentPlot )
\see realVisibility
*/
-void QCPLayerable::setParentLayerable( QCPLayerable* parentLayerable )
+void QCPLayerable::setParentLayerable(QCPLayerable *parentLayerable)
{
mParentLayerable = parentLayerable;
}
@@ -1512,27 +1532,27 @@ void QCPLayerable::setParentLayerable( QCPLayerable* parentLayerable )
Returns true on success, i.e. if \a layer is a valid layer.
*/
-bool QCPLayerable::moveToLayer( QCPLayer* layer, bool prepend )
+bool QCPLayerable::moveToLayer(QCPLayer *layer, bool prepend)
{
- if( layer && !mParentPlot )
+ if (layer && !mParentPlot)
{
qDebug() << Q_FUNC_INFO << "no parent QCustomPlot set";
return false;
}
- if( layer && layer->parentPlot() != mParentPlot )
+ if (layer && layer->parentPlot() != mParentPlot)
{
qDebug() << Q_FUNC_INFO << "layer" << layer->name() << "is not in same QCustomPlot as this layerable";
return false;
}
-
- QCPLayer* oldLayer = mLayer;
- if( mLayer )
- mLayer->removeChild( this );
+
+ QCPLayer *oldLayer = mLayer;
+ if (mLayer)
+ mLayer->removeChild(this);
mLayer = layer;
- if( mLayer )
- mLayer->addChild( this, prepend );
- if( mLayer != oldLayer )
- emit layerChanged( mLayer );
+ if (mLayer)
+ mLayer->addChild(this, prepend);
+ if (mLayer != oldLayer)
+ emit layerChanged(mLayer);
return true;
}
@@ -1543,14 +1563,14 @@ bool QCPLayerable::moveToLayer( QCPLayer* layer, bool prepend )
QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is
controlled via \a overrideElement.
*/
-void QCPLayerable::applyAntialiasingHint( QCPPainter* painter, bool localAntialiased, QCP::AntialiasedElement overrideElement ) const
+void QCPLayerable::applyAntialiasingHint(QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
{
- if( mParentPlot && mParentPlot->notAntialiasedElements().testFlag( overrideElement ) )
- painter->setAntialiasing( false );
- else if( mParentPlot && mParentPlot->antialiasedElements().testFlag( overrideElement ) )
- painter->setAntialiasing( true );
+ if (mParentPlot && mParentPlot->notAntialiasedElements().testFlag(overrideElement))
+ painter->setAntialiasing(false);
+ else if (mParentPlot && mParentPlot->antialiasedElements().testFlag(overrideElement))
+ painter->setAntialiasing(true);
else
- painter->setAntialiasing( localAntialiased );
+ painter->setAntialiasing(localAntialiased);
}
/*! \internal
@@ -1569,8 +1589,10 @@ void QCPLayerable::applyAntialiasingHint( QCPPainter* painter, bool localAntiali
\see initializeParentPlot
*/
-void QCPLayerable::parentPlotInitialized( QCustomPlot* parentPlot ){
- Q_UNUSED( parentPlot )}
+void QCPLayerable::parentPlotInitialized(QCustomPlot *parentPlot)
+{
+ Q_UNUSED(parentPlot)
+}
/*! \internal
@@ -1599,7 +1621,7 @@ QCP::Interaction QCPLayerable::selectionCategory() const
*/
QRect QCPLayerable::clipRect() const
{
- if( mParentPlot )
+ if (mParentPlot)
return mParentPlot->viewport();
else
return QRect();
@@ -1633,12 +1655,12 @@ QRect QCPLayerable::clipRect() const
\see selectTest, deselectEvent
*/
-void QCPLayerable::selectEvent( QMouseEvent* event, bool additive, const QVariant& details, bool* selectionStateChanged )
+void QCPLayerable::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
{
- Q_UNUSED( event )
- Q_UNUSED( additive )
- Q_UNUSED( details )
- Q_UNUSED( selectionStateChanged )
+ Q_UNUSED(event)
+ Q_UNUSED(additive)
+ Q_UNUSED(details)
+ Q_UNUSED(selectionStateChanged)
}
/*! \internal
@@ -1653,9 +1675,9 @@ void QCPLayerable::selectEvent( QMouseEvent* event, bool additive, const QVarian
\see selectTest, selectEvent
*/
-void QCPLayerable::deselectEvent( bool* selectionStateChanged )
+void QCPLayerable::deselectEvent(bool *selectionStateChanged)
{
- Q_UNUSED( selectionStateChanged )
+ Q_UNUSED(selectionStateChanged)
}
/*!
@@ -1683,9 +1705,9 @@ void QCPLayerable::deselectEvent( bool* selectionStateChanged )
\see mouseMoveEvent, mouseReleaseEvent, mouseDoubleClickEvent, wheelEvent
*/
-void QCPLayerable::mousePressEvent( QMouseEvent* event, const QVariant& details )
+void QCPLayerable::mousePressEvent(QMouseEvent *event, const QVariant &details)
{
- Q_UNUSED( details )
+ Q_UNUSED(details)
event->ignore();
}
@@ -1701,9 +1723,9 @@ void QCPLayerable::mousePressEvent( QMouseEvent* event, const QVariant& details
\see mousePressEvent, mouseReleaseEvent, mouseDoubleClickEvent, wheelEvent
*/
-void QCPLayerable::mouseMoveEvent( QMouseEvent* event, const QPointF& startPos )
+void QCPLayerable::mouseMoveEvent(QMouseEvent *event, const QPointF &startPos)
{
- Q_UNUSED( startPos )
+ Q_UNUSED(startPos)
event->ignore();
}
@@ -1719,9 +1741,9 @@ void QCPLayerable::mouseMoveEvent( QMouseEvent* event, const QPointF& startPos )
\see mousePressEvent, mouseMoveEvent, mouseDoubleClickEvent, wheelEvent
*/
-void QCPLayerable::mouseReleaseEvent( QMouseEvent* event, const QPointF& startPos )
+void QCPLayerable::mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos)
{
- Q_UNUSED( startPos )
+ Q_UNUSED(startPos)
event->ignore();
}
@@ -1751,9 +1773,9 @@ void QCPLayerable::mouseReleaseEvent( QMouseEvent* event, const QPointF& startPo
\see mousePressEvent, mouseMoveEvent, mouseReleaseEvent, wheelEvent
*/
-void QCPLayerable::mouseDoubleClickEvent( QMouseEvent* event, const QVariant& details )
+void QCPLayerable::mouseDoubleClickEvent(QMouseEvent *event, const QVariant &details)
{
- Q_UNUSED( details )
+ Q_UNUSED(details)
event->ignore();
}
@@ -1774,12 +1796,13 @@ void QCPLayerable::mouseDoubleClickEvent( QMouseEvent* event, const QVariant& de
\see mousePressEvent, mouseMoveEvent, mouseReleaseEvent, mouseDoubleClickEvent
*/
-void QCPLayerable::wheelEvent( QWheelEvent* event )
+void QCPLayerable::wheelEvent(QWheelEvent *event)
{
event->ignore();
}
/* end of 'src/layer.cpp' */
+
/* including file 'src/axis/range.cpp', size 12221 */
/* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */
@@ -1869,8 +1892,9 @@ const double QCPRange::maxRange = 1e250;
/*!
Constructs a range with \a lower and \a upper set to zero.
*/
-QCPRange::QCPRange()
- : lower( 0 ), upper( 0 )
+QCPRange::QCPRange() :
+ lower(0),
+ upper(0)
{
}
@@ -1881,8 +1905,9 @@ QCPRange::QCPRange()
The resulting range will be normalized (see \ref normalize), so if \a lower is not numerically
smaller than \a upper, they will be swapped.
*/
-QCPRange::QCPRange( double lower, double upper )
- : lower( lower ), upper( upper )
+QCPRange::QCPRange(double lower, double upper) :
+ lower(lower),
+ upper(upper)
{
normalize();
}
@@ -1899,11 +1924,11 @@ QCPRange::QCPRange( double lower, double upper )
\see expanded
*/
-void QCPRange::expand( const QCPRange& otherRange )
+void QCPRange::expand(const QCPRange &otherRange)
{
- if( lower > otherRange.lower || qIsNaN( lower ) )
+ if (lower > otherRange.lower || qIsNaN(lower))
lower = otherRange.lower;
- if( upper < otherRange.upper || qIsNaN( upper ) )
+ if (upper < otherRange.upper || qIsNaN(upper))
upper = otherRange.upper;
}
@@ -1919,14 +1944,15 @@ void QCPRange::expand( const QCPRange& otherRange )
\see expand
*/
-void QCPRange::expand( double includeCoord )
+void QCPRange::expand(double includeCoord)
{
- if( lower > includeCoord || qIsNaN( lower ) )
+ if (lower > includeCoord || qIsNaN(lower))
lower = includeCoord;
- if( upper < includeCoord || qIsNaN( upper ) )
+ if (upper < includeCoord || qIsNaN(upper))
upper = includeCoord;
}
+
/*! \overload
Returns an expanded range that contains this and \a otherRange. It is assumed that both this
@@ -1937,10 +1963,10 @@ void QCPRange::expand( double includeCoord )
\see expand
*/
-QCPRange QCPRange::expanded( const QCPRange& otherRange ) const
+QCPRange QCPRange::expanded(const QCPRange &otherRange) const
{
QCPRange result = *this;
- result.expand( otherRange );
+ result.expand(otherRange);
return result;
}
@@ -1954,10 +1980,10 @@ QCPRange QCPRange::expanded( const QCPRange& otherRange ) const
\see expand
*/
-QCPRange QCPRange::expanded( double includeCoord ) const
+QCPRange QCPRange::expanded(double includeCoord) const
{
QCPRange result = *this;
- result.expand( includeCoord );
+ result.expand(includeCoord);
return result;
}
@@ -1969,27 +1995,26 @@ QCPRange QCPRange::expanded( double includeCoord ) const
QCPRange::maxRange. If it shall only be bounded at the upper side, set \a lowerBound to -\ref
QCPRange::maxRange.
*/
-QCPRange QCPRange::bounded( double lowerBound, double upperBound ) const
+QCPRange QCPRange::bounded(double lowerBound, double upperBound) const
{
- if( lowerBound > upperBound )
- qSwap( lowerBound, upperBound );
-
- QCPRange result( lower, upper );
- if( result.lower < lowerBound )
+ if (lowerBound > upperBound)
+ qSwap(lowerBound, upperBound);
+
+ QCPRange result(lower, upper);
+ if (result.lower < lowerBound)
{
result.lower = lowerBound;
result.upper = lowerBound + size();
- if( result.upper > upperBound || qFuzzyCompare( size(), upperBound - lowerBound ) )
+ if (result.upper > upperBound || qFuzzyCompare(size(), upperBound-lowerBound))
result.upper = upperBound;
- }
- else if( result.upper > upperBound )
+ } else if (result.upper > upperBound)
{
result.upper = upperBound;
result.lower = upperBound - size();
- if( result.lower < lowerBound || qFuzzyCompare( size(), upperBound - lowerBound ) )
+ if (result.lower < lowerBound || qFuzzyCompare(size(), upperBound-lowerBound))
result.lower = lowerBound;
}
-
+
return result;
}
@@ -2008,44 +2033,42 @@ QCPRange QCPRange::bounded( double lowerBound, double upperBound ) const
QCPRange QCPRange::sanitizedForLogScale() const
{
double rangeFac = 1e-3;
- QCPRange sanitizedRange( lower, upper );
+ QCPRange sanitizedRange(lower, upper);
sanitizedRange.normalize();
// can't have range spanning negative and positive values in log plot, so change range to fix it
//if (qFuzzyCompare(sanitizedRange.lower+1, 1) && !qFuzzyCompare(sanitizedRange.upper+1, 1))
- if( sanitizedRange.lower == 0.0 && sanitizedRange.upper != 0.0 )
+ if (sanitizedRange.lower == 0.0 && sanitizedRange.upper != 0.0)
{
// case lower is 0
- if( rangeFac < sanitizedRange.upper * rangeFac )
+ if (rangeFac < sanitizedRange.upper*rangeFac)
sanitizedRange.lower = rangeFac;
else
- sanitizedRange.lower = sanitizedRange.upper * rangeFac;
- } //else if (!qFuzzyCompare(lower+1, 1) && qFuzzyCompare(upper+1, 1))
- else if( sanitizedRange.lower != 0.0 && sanitizedRange.upper == 0.0 )
+ sanitizedRange.lower = sanitizedRange.upper*rangeFac;
+ } //else if (!qFuzzyCompare(lower+1, 1) && qFuzzyCompare(upper+1, 1))
+ else if (sanitizedRange.lower != 0.0 && sanitizedRange.upper == 0.0)
{
// case upper is 0
- if( -rangeFac > sanitizedRange.lower * rangeFac )
+ if (-rangeFac > sanitizedRange.lower*rangeFac)
sanitizedRange.upper = -rangeFac;
else
- sanitizedRange.upper = sanitizedRange.lower * rangeFac;
- }
- else if( sanitizedRange.lower < 0 && sanitizedRange.upper > 0 )
+ sanitizedRange.upper = sanitizedRange.lower*rangeFac;
+ } else if (sanitizedRange.lower < 0 && sanitizedRange.upper > 0)
{
// find out whether negative or positive interval is wider to decide which sign domain will be chosen
- if( -sanitizedRange.lower > sanitizedRange.upper )
+ if (-sanitizedRange.lower > sanitizedRange.upper)
{
// negative is wider, do same as in case upper is 0
- if( -rangeFac > sanitizedRange.lower * rangeFac )
+ if (-rangeFac > sanitizedRange.lower*rangeFac)
sanitizedRange.upper = -rangeFac;
else
- sanitizedRange.upper = sanitizedRange.lower * rangeFac;
- }
- else
+ sanitizedRange.upper = sanitizedRange.lower*rangeFac;
+ } else
{
// positive is wider, do same as in case lower is 0
- if( rangeFac < sanitizedRange.upper * rangeFac )
+ if (rangeFac < sanitizedRange.upper*rangeFac)
sanitizedRange.lower = rangeFac;
else
- sanitizedRange.lower = sanitizedRange.upper * rangeFac;
+ sanitizedRange.lower = sanitizedRange.upper*rangeFac;
}
}
// due to normalization, case lower>0 && upper<0 should never occur, because that implies upper -maxRange &&
- upper < maxRange &&
- qAbs( lower - upper ) > minRange &&
- qAbs( lower - upper ) < maxRange &&
- !( lower > 0 && qIsInf( upper / lower ) ) &&
- !( upper < 0 && qIsInf( lower / upper ) ) );
+ return (lower > -maxRange &&
+ upper < maxRange &&
+ qAbs(lower-upper) > minRange &&
+ qAbs(lower-upper) < maxRange &&
+ !(lower > 0 && qIsInf(upper/lower)) &&
+ !(upper < 0 && qIsInf(lower/upper)));
}
/*!
@@ -2090,17 +2113,18 @@ bool QCPRange::validRange( double lower, double upper )
\li range size above minRange
\li range size below maxRange
*/
-bool QCPRange::validRange( const QCPRange& range )
+bool QCPRange::validRange(const QCPRange &range)
{
- return ( range.lower > -maxRange &&
- range.upper < maxRange &&
- qAbs( range.lower - range.upper ) > minRange &&
- qAbs( range.lower - range.upper ) < maxRange &&
- !( range.lower > 0 && qIsInf( range.upper / range.lower ) ) &&
- !( range.upper < 0 && qIsInf( range.lower / range.upper ) ) );
+ return (range.lower > -maxRange &&
+ range.upper < maxRange &&
+ qAbs(range.lower-range.upper) > minRange &&
+ qAbs(range.lower-range.upper) < maxRange &&
+ !(range.lower > 0 && qIsInf(range.upper/range.lower)) &&
+ !(range.upper < 0 && qIsInf(range.lower/range.upper)));
}
/* end of 'src/axis/range.cpp' */
+
/* including file 'src/selection.cpp', size 21906 */
/* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */
@@ -2198,8 +2222,9 @@ bool QCPRange::validRange( const QCPRange& range )
/*!
Creates an empty QCPDataRange, with begin and end set to 0.
*/
-QCPDataRange::QCPDataRange()
- : mBegin( 0 ), mEnd( 0 )
+QCPDataRange::QCPDataRange() :
+ mBegin(0),
+ mEnd(0)
{
}
@@ -2208,8 +2233,9 @@ QCPDataRange::QCPDataRange()
No checks or corrections are made to ensure the resulting range is valid (\ref isValid).
*/
-QCPDataRange::QCPDataRange( int begin, int end )
- : mBegin( begin ), mEnd( end )
+QCPDataRange::QCPDataRange(int begin, int end) :
+ mBegin(begin),
+ mEnd(end)
{
}
@@ -2222,15 +2248,15 @@ QCPDataRange::QCPDataRange( int begin, int end )
to the respective boundary side of \a other, at which this range is residing. (\ref intersection
would just return a range with begin and end set to 0.)
*/
-QCPDataRange QCPDataRange::bounded( const QCPDataRange& other ) const
+QCPDataRange QCPDataRange::bounded(const QCPDataRange &other) const
{
- QCPDataRange result( intersection( other ) );
- if( result.isEmpty() ) // no intersection, preserve respective bounding side of otherRange as both begin and end of return value
+ QCPDataRange result(intersection(other));
+ if (result.isEmpty()) // no intersection, preserve respective bounding side of otherRange as both begin and end of return value
{
- if( mEnd <= other.mBegin )
- result = QCPDataRange( other.mBegin, other.mBegin );
+ if (mEnd <= other.mBegin)
+ result = QCPDataRange(other.mBegin, other.mBegin);
else
- result = QCPDataRange( other.mEnd, other.mEnd );
+ result = QCPDataRange(other.mEnd, other.mEnd);
}
return result;
}
@@ -2238,9 +2264,9 @@ QCPDataRange QCPDataRange::bounded( const QCPDataRange& other ) const
/*!
Returns a data range that contains both this data range as well as \a other.
*/
-QCPDataRange QCPDataRange::expanded( const QCPDataRange& other ) const
+QCPDataRange QCPDataRange::expanded(const QCPDataRange &other) const
{
- return QCPDataRange( qMin( mBegin, other.mBegin ), qMax( mEnd, other.mEnd ) );
+ return QCPDataRange(qMin(mBegin, other.mBegin), qMax(mEnd, other.mEnd));
}
/*!
@@ -2253,10 +2279,10 @@ QCPDataRange QCPDataRange::expanded( const QCPDataRange& other ) const
\see QCPDataSelection::intersection
*/
-QCPDataRange QCPDataRange::intersection( const QCPDataRange& other ) const
+QCPDataRange QCPDataRange::intersection(const QCPDataRange &other) const
{
- QCPDataRange result( qMax( mBegin, other.mBegin ), qMin( mEnd, other.mEnd ) );
- if( result.isValid() )
+ QCPDataRange result(qMax(mBegin, other.mBegin), qMin(mEnd, other.mEnd));
+ if (result.isValid())
return result;
else
return QCPDataRange();
@@ -2267,10 +2293,10 @@ QCPDataRange QCPDataRange::intersection( const QCPDataRange& other ) const
\see intersection, contains
*/
-bool QCPDataRange::intersects( const QCPDataRange& other ) const
+bool QCPDataRange::intersects(const QCPDataRange &other) const
{
- return !( ( mBegin > other.mBegin && mBegin >= other.mEnd ) ||
- ( mEnd <= other.mBegin && mEnd < other.mEnd ) );
+ return !( (mBegin > other.mBegin && mBegin >= other.mEnd) ||
+ (mEnd <= other.mBegin && mEnd < other.mEnd) );
}
/*!
@@ -2278,11 +2304,13 @@ bool QCPDataRange::intersects( const QCPDataRange& other ) const
\see intersects
*/
-bool QCPDataRange::contains( const QCPDataRange& other ) const
+bool QCPDataRange::contains(const QCPDataRange &other) const
{
return mBegin <= other.mBegin && mEnd >= other.mEnd;
}
+
+
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// QCPDataSelection
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -2359,9 +2387,9 @@ QCPDataSelection::QCPDataSelection()
/*!
Creates a QCPDataSelection containing the provided \a range.
*/
-QCPDataSelection::QCPDataSelection( const QCPDataRange& range )
+QCPDataSelection::QCPDataSelection(const QCPDataRange &range)
{
- mDataRanges.append( range );
+ mDataRanges.append(range);
}
/*!
@@ -2371,13 +2399,13 @@ QCPDataSelection::QCPDataSelection( const QCPDataRange& range )
Note that both data selections must be in simplified state (the usual state of the selection, see
\ref simplify) for this operator to return correct results.
*/
-bool QCPDataSelection::operator==( const QCPDataSelection& other ) const
+bool QCPDataSelection::operator==(const QCPDataSelection &other) const
{
- if( mDataRanges.size() != other.mDataRanges.size() )
+ if (mDataRanges.size() != other.mDataRanges.size())
return false;
- for( int i = 0; i < mDataRanges.size(); ++i )
+ for (int i=0; i= other.end() )
- break; // since data ranges are sorted after the simplify() call, no ranges which contain other will come after this
-
- if( thisEnd > other.begin() ) // ranges which don't fulfill this are entirely before other and can be ignored
+ const int thisBegin = mDataRanges.at(i).begin();
+ const int thisEnd = mDataRanges.at(i).end();
+ if (thisBegin >= other.end())
+ break; // since data ranges are sorted after the simplify() call, no ranges which contain other will come after this
+
+ if (thisEnd > other.begin()) // ranges which don't fulfill this are entirely before other and can be ignored
{
- if( thisBegin >= other.begin() ) // range leading segment is encompassed
+ if (thisBegin >= other.begin()) // range leading segment is encompassed
{
- if( thisEnd <= other.end() ) // range fully encompassed, remove completely
+ if (thisEnd <= other.end()) // range fully encompassed, remove completely
{
- mDataRanges.removeAt( i );
+ mDataRanges.removeAt(i);
continue;
- }
- else // only leading segment is encompassed, trim accordingly
- mDataRanges[i].setBegin( other.end() );
- }
- else // leading segment is not encompassed
+ } else // only leading segment is encompassed, trim accordingly
+ mDataRanges[i].setBegin(other.end());
+ } else // leading segment is not encompassed
{
- if( thisEnd <= other.end() ) // only trailing segment is encompassed, trim accordingly
+ if (thisEnd <= other.end()) // only trailing segment is encompassed, trim accordingly
{
- mDataRanges[i].setEnd( other.begin() );
- }
- else // other lies inside this range, so split range
+ mDataRanges[i].setEnd(other.begin());
+ } else // other lies inside this range, so split range
{
- mDataRanges[i].setEnd( other.begin() );
- mDataRanges.insert( i + 1, QCPDataRange( other.end(), thisEnd ) );
- break; // since data ranges are sorted (and don't overlap) after simplify() call, we're done here
+ mDataRanges[i].setEnd(other.begin());
+ mDataRanges.insert(i+1, QCPDataRange(other.end(), thisEnd));
+ break; // since data ranges are sorted (and don't overlap) after simplify() call, we're done here
}
}
}
++i;
}
-
+
return *this;
}
@@ -2471,8 +2496,8 @@ QCPDataSelection& QCPDataSelection::operator-=( const QCPDataRange& other )
int QCPDataSelection::dataPointCount() const
{
int result = 0;
- for( int i = 0; i < mDataRanges.size(); ++i )
- result += mDataRanges.at( i ).length();
+ for (int i=0; i= 0 && index < mDataRanges.size() )
+ if (index >= 0 && index < mDataRanges.size())
{
- return mDataRanges.at( index );
- }
- else
+ return mDataRanges.at(index);
+ } else
{
qDebug() << Q_FUNC_INFO << "index out of range:" << index;
return QCPDataRange();
@@ -2503,10 +2527,10 @@ QCPDataRange QCPDataSelection::dataRange( int index ) const
*/
QCPDataRange QCPDataSelection::span() const
{
- if( isEmpty() )
+ if (isEmpty())
return QCPDataRange();
else
- return QCPDataRange( mDataRanges.first().begin(), mDataRanges.last().end() );
+ return QCPDataRange(mDataRanges.first().begin(), mDataRanges.last().end());
}
/*!
@@ -2515,10 +2539,10 @@ QCPDataRange QCPDataSelection::span() const
performance if adding a very large amount of data ranges successively. In this case, make sure to
call \ref simplify manually, after the operation.
*/
-void QCPDataSelection::addDataRange( const QCPDataRange& dataRange, bool simplify )
+void QCPDataSelection::addDataRange(const QCPDataRange &dataRange, bool simplify)
{
- mDataRanges.append( dataRange );
- if( simplify )
+ mDataRanges.append(dataRange);
+ if (simplify)
this->simplify();
}
@@ -2544,27 +2568,26 @@ void QCPDataSelection::clear()
void QCPDataSelection::simplify()
{
// remove any empty ranges:
- for( int i = mDataRanges.size() - 1; i >= 0; --i )
+ for (int i=mDataRanges.size()-1; i>=0; --i)
{
- if( mDataRanges.at( i ).isEmpty() )
- mDataRanges.removeAt( i );
+ if (mDataRanges.at(i).isEmpty())
+ mDataRanges.removeAt(i);
}
- if( mDataRanges.isEmpty() )
+ if (mDataRanges.isEmpty())
return;
-
+
// sort ranges by starting value, ascending:
- std::sort( mDataRanges.begin(), mDataRanges.end(), lessThanDataRangeBegin );
-
+ std::sort(mDataRanges.begin(), mDataRanges.end(), lessThanDataRangeBegin);
+
// join overlapping/contiguous ranges:
int i = 1;
- while( i < mDataRanges.size() )
+ while (i < mDataRanges.size())
{
- if( mDataRanges.at( i - 1 ).end() >= mDataRanges.at( i ).begin() ) // range i overlaps/joins with i-1, so expand range i-1 appropriately and remove range i from list
+ if (mDataRanges.at(i-1).end() >= mDataRanges.at(i).begin()) // range i overlaps/joins with i-1, so expand range i-1 appropriately and remove range i from list
{
- mDataRanges[i - 1].setEnd( qMax( mDataRanges.at( i - 1 ).end(), mDataRanges.at( i ).end() ) );
- mDataRanges.removeAt( i );
- }
- else
+ mDataRanges[i-1].setEnd(qMax(mDataRanges.at(i-1).end(), mDataRanges.at(i).end()));
+ mDataRanges.removeAt(i);
+ } else
++i;
}
}
@@ -2579,43 +2602,43 @@ void QCPDataSelection::simplify()
\see QCP::SelectionType
*/
-void QCPDataSelection::enforceType( QCP::SelectionType type )
+void QCPDataSelection::enforceType(QCP::SelectionType type)
{
simplify();
- switch( type )
+ switch (type)
{
- case QCP::stNone:
- {
- mDataRanges.clear();
- break;
- }
- case QCP::stWhole:
- {
- // whole selection isn't defined by data range, so don't change anything (is handled in plottable methods)
- break;
- }
- case QCP::stSingleData:
- {
- // reduce all data ranges to the single first data point:
- if( !mDataRanges.isEmpty() )
+ case QCP::stNone:
{
- if( mDataRanges.size() > 1 )
- mDataRanges = QList() << mDataRanges.first();
- if( mDataRanges.first().length() > 1 )
- mDataRanges.first().setEnd( mDataRanges.first().begin() + 1 );
+ mDataRanges.clear();
+ break;
+ }
+ case QCP::stWhole:
+ {
+ // whole selection isn't defined by data range, so don't change anything (is handled in plottable methods)
+ break;
+ }
+ case QCP::stSingleData:
+ {
+ // reduce all data ranges to the single first data point:
+ if (!mDataRanges.isEmpty())
+ {
+ if (mDataRanges.size() > 1)
+ mDataRanges = QList() << mDataRanges.first();
+ if (mDataRanges.first().length() > 1)
+ mDataRanges.first().setEnd(mDataRanges.first().begin()+1);
+ }
+ break;
+ }
+ case QCP::stDataRange:
+ {
+ mDataRanges = QList() << span();
+ break;
+ }
+ case QCP::stMultipleDataRanges:
+ {
+ // this is the selection type that allows all concievable combinations of ranges, so do nothing
+ break;
}
- break;
- }
- case QCP::stDataRange:
- {
- mDataRanges = QList() << span();
- break;
- }
- case QCP::stMultipleDataRanges:
- {
- // this is the selection type that allows all concievable combinations of ranges, so do nothing
- break;
- }
}
}
@@ -2625,21 +2648,20 @@ void QCPDataSelection::enforceType( QCP::SelectionType type )
\see QCPDataRange::contains
*/
-bool QCPDataSelection::contains( const QCPDataSelection& other ) const
+bool QCPDataSelection::contains(const QCPDataSelection &other) const
{
- if( other.isEmpty() )
- return false;
-
+ if (other.isEmpty()) return false;
+
int otherIndex = 0;
int thisIndex = 0;
- while( thisIndex < mDataRanges.size() && otherIndex < other.mDataRanges.size() )
+ while (thisIndex < mDataRanges.size() && otherIndex < other.mDataRanges.size())
{
- if( mDataRanges.at( thisIndex ).contains( other.mDataRanges.at( otherIndex ) ) )
+ if (mDataRanges.at(thisIndex).contains(other.mDataRanges.at(otherIndex)))
++otherIndex;
else
++thisIndex;
}
- return thisIndex < mDataRanges.size(); // if thisIndex ran all the way to the end to find a containing range for the current otherIndex, other is not contained in this
+ return thisIndex < mDataRanges.size(); // if thisIndex ran all the way to the end to find a containing range for the current otherIndex, other is not contained in this
}
/*!
@@ -2650,11 +2672,11 @@ bool QCPDataSelection::contains( const QCPDataSelection& other ) const
using \ref QCPDataContainer::dataRange as \a other. One can then safely iterate over the returned
data selection without exceeding the data container's bounds.
*/
-QCPDataSelection QCPDataSelection::intersection( const QCPDataRange& other ) const
+QCPDataSelection QCPDataSelection::intersection(const QCPDataRange &other) const
{
QCPDataSelection result;
- for( int i = 0; i < mDataRanges.size(); ++i )
- result.addDataRange( mDataRanges.at( i ).intersection( other ), false );
+ for (int i=0; iorientation() == Qt::Horizontal )
- return QCPRange( axis->pixelToCoord( mRect.left() ), axis->pixelToCoord( mRect.left() + mRect.width() ) );
+ if (axis->orientation() == Qt::Horizontal)
+ return QCPRange(axis->pixelToCoord(mRect.left()), axis->pixelToCoord(mRect.left()+mRect.width()));
else
- return QCPRange( axis->pixelToCoord( mRect.top() + mRect.height() ), axis->pixelToCoord( mRect.top() ) );
- }
- else
+ return QCPRange(axis->pixelToCoord(mRect.top()+mRect.height()), axis->pixelToCoord(mRect.top()));
+ } else
{
qDebug() << Q_FUNC_INFO << "called with axis zero";
return QCPRange();
@@ -2822,7 +2847,7 @@ QCPRange QCPSelectionRect::range( const QCPAxis* axis ) const
\see setBrush
*/
-void QCPSelectionRect::setPen( const QPen& pen )
+void QCPSelectionRect::setPen(const QPen &pen)
{
mPen = pen;
}
@@ -2833,7 +2858,7 @@ void QCPSelectionRect::setPen( const QPen& pen )
\see setPen
*/
-void QCPSelectionRect::setBrush( const QBrush& brush )
+void QCPSelectionRect::setBrush(const QBrush &brush)
{
mBrush = brush;
}
@@ -2844,10 +2869,10 @@ void QCPSelectionRect::setBrush( const QBrush& brush )
*/
void QCPSelectionRect::cancel()
{
- if( mActive )
+ if (mActive)
{
mActive = false;
- emit canceled( mRect, 0 );
+ emit canceled(mRect, 0);
}
}
@@ -2857,11 +2882,11 @@ void QCPSelectionRect::cancel()
The default implementation sets the selection rect to active, initializes the selection rect
geometry and emits the \ref started signal.
*/
-void QCPSelectionRect::startSelection( QMouseEvent* event )
+void QCPSelectionRect::startSelection(QMouseEvent *event)
{
mActive = true;
- mRect = QRect( event->pos(), event->pos() );
- emit started( event );
+ mRect = QRect(event->pos(), event->pos());
+ emit started(event);
}
/*! \internal
@@ -2870,10 +2895,10 @@ void QCPSelectionRect::startSelection( QMouseEvent* event )
to update its geometry. The default implementation updates the rect and emits the \ref changed
signal.
*/
-void QCPSelectionRect::moveSelection( QMouseEvent* event )
+void QCPSelectionRect::moveSelection(QMouseEvent *event)
{
- mRect.setBottomRight( event->pos() );
- emit changed( mRect, event );
+ mRect.setBottomRight(event->pos());
+ emit changed(mRect, event);
layer()->replot();
}
@@ -2883,11 +2908,11 @@ void QCPSelectionRect::moveSelection( QMouseEvent* event )
finished by the user releasing the mouse button. The default implementation deactivates the
selection rect and emits the \ref accepted signal.
*/
-void QCPSelectionRect::endSelection( QMouseEvent* event )
+void QCPSelectionRect::endSelection(QMouseEvent *event)
{
- mRect.setBottomRight( event->pos() );
+ mRect.setBottomRight(event->pos());
mActive = false;
- emit accepted( mRect, event );
+ emit accepted(mRect, event);
}
/*! \internal
@@ -2896,19 +2921,19 @@ void QCPSelectionRect::endSelection( QMouseEvent* event )
rect interaction is active. The default implementation allows to \ref cancel the interaction by
hitting the escape key.
*/
-void QCPSelectionRect::keyPressEvent( QKeyEvent* event )
+void QCPSelectionRect::keyPressEvent(QKeyEvent *event)
{
- if( event->key() == Qt::Key_Escape && mActive )
+ if (event->key() == Qt::Key_Escape && mActive)
{
mActive = false;
- emit canceled( mRect, event );
+ emit canceled(mRect, event);
}
}
/* inherits documentation from base class */
-void QCPSelectionRect::applyDefaultAntialiasingHint( QCPPainter* painter ) const
+void QCPSelectionRect::applyDefaultAntialiasingHint(QCPPainter *painter) const
{
- applyAntialiasingHint( painter, mAntialiased, QCP::aeOther );
+ applyAntialiasingHint(painter, mAntialiased, QCP::aeOther);
}
/*! \internal
@@ -2917,17 +2942,18 @@ void QCPSelectionRect::applyDefaultAntialiasingHint( QCPPainter* painter ) const
\seebaseclassmethod
*/
-void QCPSelectionRect::draw( QCPPainter* painter )
+void QCPSelectionRect::draw(QCPPainter *painter)
{
- if( mActive )
+ if (mActive)
{
- painter->setPen( mPen );
- painter->setBrush( mBrush );
- painter->drawRect( mRect );
+ painter->setPen(mPen);
+ painter->setBrush(mBrush);
+ painter->drawRect(mRect);
}
}
/* end of 'src/selectionrect.cpp' */
+
/* including file 'src/layout.cpp', size 79064 */
/* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */
@@ -2979,13 +3005,14 @@ void QCPSelectionRect::draw( QCPPainter* painter )
/*!
Creates a new QCPMarginGroup instance in \a parentPlot.
*/
-QCPMarginGroup::QCPMarginGroup( QCustomPlot* parentPlot )
- : QObject( parentPlot ), mParentPlot( parentPlot )
+QCPMarginGroup::QCPMarginGroup(QCustomPlot *parentPlot) :
+ QObject(parentPlot),
+ mParentPlot(parentPlot)
{
- mChildren.insert( QCP::msLeft, QList() );
- mChildren.insert( QCP::msRight, QList() );
- mChildren.insert( QCP::msTop, QList() );
- mChildren.insert( QCP::msBottom, QList() );
+ mChildren.insert(QCP::msLeft, QList());
+ mChildren.insert(QCP::msRight, QList());
+ mChildren.insert(QCP::msTop, QList());
+ mChildren.insert(QCP::msBottom, QList());
}
QCPMarginGroup::~QCPMarginGroup()
@@ -2999,11 +3026,11 @@ QCPMarginGroup::~QCPMarginGroup()
*/
bool QCPMarginGroup::isEmpty() const
{
- QHashIterator > it( mChildren );
- while( it.hasNext() )
+ QHashIterator > it(mChildren);
+ while (it.hasNext())
{
it.next();
- if( !it.value().isEmpty() )
+ if (!it.value().isEmpty())
return false;
}
return true;
@@ -3016,13 +3043,13 @@ bool QCPMarginGroup::isEmpty() const
void QCPMarginGroup::clear()
{
// make all children remove themselves from this margin group:
- QHashIterator > it( mChildren );
- while( it.hasNext() )
+ QHashIterator > it(mChildren);
+ while (it.hasNext())
{
it.next();
const QList elements = it.value();
- for( int i = elements.size() - 1; i >= 0; --i )
- elements.at( i )->setMarginGroup( it.key(), 0 ); // removes itself from mChildren via removeChild
+ for (int i=elements.size()-1; i>=0; --i)
+ elements.at(i)->setMarginGroup(it.key(), 0); // removes itself from mChildren via removeChild
}
}
@@ -3036,17 +3063,17 @@ void QCPMarginGroup::clear()
group, and choosing the largest returned value. (QCPLayoutElement::minimumMargins is taken into
account, too.)
*/
-int QCPMarginGroup::commonMargin( QCP::MarginSide side ) const
+int QCPMarginGroup::commonMargin(QCP::MarginSide side) const
{
// query all automatic margins of the layout elements in this margin group side and find maximum:
int result = 0;
- const QList elements = mChildren.value( side );
- for( int i = 0; i < elements.size(); ++i )
+ const QList elements = mChildren.value(side);
+ for (int i=0; iautoMargins().testFlag( side ) )
+ if (!elements.at(i)->autoMargins().testFlag(side))
continue;
- int m = qMax( elements.at( i )->calculateAutoMargin( side ), QCP::getMarginValue( elements.at( i )->minimumMargins(), side ) );
- if( m > result )
+ int m = qMax(elements.at(i)->calculateAutoMargin(side), QCP::getMarginValue(elements.at(i)->minimumMargins(), side));
+ if (m > result)
result = m;
}
return result;
@@ -3058,12 +3085,12 @@ int QCPMarginGroup::commonMargin( QCP::MarginSide side ) const
This function does not modify the margin group property of \a element.
*/
-void QCPMarginGroup::addChild( QCP::MarginSide side, QCPLayoutElement* element )
+void QCPMarginGroup::addChild(QCP::MarginSide side, QCPLayoutElement *element)
{
- if( !mChildren[side].contains( element ) )
- mChildren[side].append( element );
+ if (!mChildren[side].contains(element))
+ mChildren[side].append(element);
else
- qDebug() << Q_FUNC_INFO << "element is already child of this margin group side" << reinterpret_cast( element );
+ qDebug() << Q_FUNC_INFO << "element is already child of this margin group side" << reinterpret_cast(element);
}
/*! \internal
@@ -3072,12 +3099,13 @@ void QCPMarginGroup::addChild( QCP::MarginSide side, QCPLayoutElement* element )
This function does not modify the margin group property of \a element.
*/
-void QCPMarginGroup::removeChild( QCP::MarginSide side, QCPLayoutElement* element )
+void QCPMarginGroup::removeChild(QCP::MarginSide side, QCPLayoutElement *element)
{
- if( !mChildren[side].removeOne( element ) )
- qDebug() << Q_FUNC_INFO << "element is not child of this margin group side" << reinterpret_cast( element );
+ if (!mChildren[side].removeOne(element))
+ qDebug() << Q_FUNC_INFO << "element is not child of this margin group side" << reinterpret_cast(element);
}
+
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// QCPLayoutElement
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -3144,26 +3172,26 @@ void QCPMarginGroup::removeChild( QCP::MarginSide side, QCPLayoutElement* elemen
/*!
Creates an instance of QCPLayoutElement and sets default values.
*/
-QCPLayoutElement::QCPLayoutElement( QCustomPlot* parentPlot )
- : QCPLayerable( parentPlot ), // parenthood is changed as soon as layout element gets inserted into a layout (except for top level layout)
- mParentLayout( 0 )
- , mMinimumSize()
- , mMaximumSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX )
- , mSizeConstraintRect( scrInnerRect )
- , mRect( 0, 0, 0, 0 )
- , mOuterRect( 0, 0, 0, 0 )
- , mMargins( 0, 0, 0, 0 )
- , mMinimumMargins( 0, 0, 0, 0 )
- , mAutoMargins( QCP::msAll )
+QCPLayoutElement::QCPLayoutElement(QCustomPlot *parentPlot) :
+ QCPLayerable(parentPlot), // parenthood is changed as soon as layout element gets inserted into a layout (except for top level layout)
+ mParentLayout(0),
+ mMinimumSize(),
+ mMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX),
+ mSizeConstraintRect(scrInnerRect),
+ mRect(0, 0, 0, 0),
+ mOuterRect(0, 0, 0, 0),
+ mMargins(0, 0, 0, 0),
+ mMinimumMargins(0, 0, 0, 0),
+ mAutoMargins(QCP::msAll)
{
}
QCPLayoutElement::~QCPLayoutElement()
{
- setMarginGroup( QCP::msAll, 0 ); // unregister at margin groups, if there are any
+ setMarginGroup(QCP::msAll, 0); // unregister at margin groups, if there are any
// unregister at layout:
- if( qobject_cast( mParentLayout ) ) // the qobject_cast is just a safeguard in case the layout forgets to call clear() in its dtor and this dtor is called by QObject dtor
- mParentLayout->take( this );
+ if (qobject_cast(mParentLayout)) // the qobject_cast is just a safeguard in case the layout forgets to call clear() in its dtor and this dtor is called by QObject dtor
+ mParentLayout->take(this);
}
/*!
@@ -3177,12 +3205,12 @@ QCPLayoutElement::~QCPLayoutElement()
\see rect
*/
-void QCPLayoutElement::setOuterRect( const QRect& rect )
+void QCPLayoutElement::setOuterRect(const QRect &rect)
{
- if( mOuterRect != rect )
+ if (mOuterRect != rect)
{
mOuterRect = rect;
- mRect = mOuterRect.adjusted( mMargins.left(), mMargins.top(), -mMargins.right(), -mMargins.bottom() );
+ mRect = mOuterRect.adjusted(mMargins.left(), mMargins.top(), -mMargins.right(), -mMargins.bottom());
}
}
@@ -3197,12 +3225,12 @@ void QCPLayoutElement::setOuterRect( const QRect& rect )
\see setAutoMargins
*/
-void QCPLayoutElement::setMargins( const QMargins& margins )
+void QCPLayoutElement::setMargins(const QMargins &margins)
{
- if( mMargins != margins )
+ if (mMargins != margins)
{
mMargins = margins;
- mRect = mOuterRect.adjusted( mMargins.left(), mMargins.top(), -mMargins.right(), -mMargins.bottom() );
+ mRect = mOuterRect.adjusted(mMargins.left(), mMargins.top(), -mMargins.right(), -mMargins.bottom());
}
}
@@ -3215,9 +3243,9 @@ void QCPLayoutElement::setMargins( const QMargins& margins )
\see setAutoMargins
*/
-void QCPLayoutElement::setMinimumMargins( const QMargins& margins )
+void QCPLayoutElement::setMinimumMargins(const QMargins &margins)
{
- if( mMinimumMargins != margins )
+ if (mMinimumMargins != margins)
{
mMinimumMargins = margins;
}
@@ -3233,7 +3261,7 @@ void QCPLayoutElement::setMinimumMargins( const QMargins& margins )
\see setMinimumMargins, setMargins, QCP::MarginSide
*/
-void QCPLayoutElement::setAutoMargins( QCP::MarginSides sides )
+void QCPLayoutElement::setAutoMargins(QCP::MarginSides sides)
{
mAutoMargins = sides;
}
@@ -3250,12 +3278,12 @@ void QCPLayoutElement::setAutoMargins( QCP::MarginSides sides )
Whether this constraint applies to the inner or the outer rect can be specified with \ref
setSizeConstraintRect (see \ref rect and \ref outerRect).
*/
-void QCPLayoutElement::setMinimumSize( const QSize& size )
+void QCPLayoutElement::setMinimumSize(const QSize &size)
{
- if( mMinimumSize != size )
+ if (mMinimumSize != size)
{
mMinimumSize = size;
- if( mParentLayout )
+ if (mParentLayout)
mParentLayout->sizeConstraintsChanged();
}
}
@@ -3267,9 +3295,9 @@ void QCPLayoutElement::setMinimumSize( const QSize& size )
Whether this constraint applies to the inner or the outer rect can be specified with \ref
setSizeConstraintRect (see \ref rect and \ref outerRect).
*/
-void QCPLayoutElement::setMinimumSize( int width, int height )
+void QCPLayoutElement::setMinimumSize(int width, int height)
{
- setMinimumSize( QSize( width, height ) );
+ setMinimumSize(QSize(width, height));
}
/*!
@@ -3279,12 +3307,12 @@ void QCPLayoutElement::setMinimumSize( int width, int height )
Whether this constraint applies to the inner or the outer rect can be specified with \ref
setSizeConstraintRect (see \ref rect and \ref outerRect).
*/
-void QCPLayoutElement::setMaximumSize( const QSize& size )
+void QCPLayoutElement::setMaximumSize(const QSize &size)
{
- if( mMaximumSize != size )
+ if (mMaximumSize != size)
{
mMaximumSize = size;
- if( mParentLayout )
+ if (mParentLayout)
mParentLayout->sizeConstraintsChanged();
}
}
@@ -3296,9 +3324,9 @@ void QCPLayoutElement::setMaximumSize( const QSize& size )
Whether this constraint applies to the inner or the outer rect can be specified with \ref
setSizeConstraintRect (see \ref rect and \ref outerRect).
*/
-void QCPLayoutElement::setMaximumSize( int width, int height )
+void QCPLayoutElement::setMaximumSize(int width, int height)
{
- setMaximumSize( QSize( width, height ) );
+ setMaximumSize(QSize(width, height));
}
/*!
@@ -3310,12 +3338,12 @@ void QCPLayoutElement::setMaximumSize( int width, int height )
\see setMinimumSize, setMaximumSize
*/
-void QCPLayoutElement::setSizeConstraintRect( SizeConstraintRect constraintRect )
+void QCPLayoutElement::setSizeConstraintRect(SizeConstraintRect constraintRect)
{
- if( mSizeConstraintRect != constraintRect )
+ if (mSizeConstraintRect != constraintRect)
{
mSizeConstraintRect = constraintRect;
- if( mParentLayout )
+ if (mParentLayout)
mParentLayout->sizeConstraintsChanged();
}
}
@@ -3333,35 +3361,30 @@ void QCPLayoutElement::setSizeConstraintRect( SizeConstraintRect constraintRect
\see QCP::MarginSide
*/
-void QCPLayoutElement::setMarginGroup( QCP::MarginSides sides, QCPMarginGroup* group )
+void QCPLayoutElement::setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *group)
{
QVector sideVector;
- if( sides.testFlag( QCP::msLeft ) )
- sideVector.append( QCP::msLeft );
- if( sides.testFlag( QCP::msRight ) )
- sideVector.append( QCP::msRight );
- if( sides.testFlag( QCP::msTop ) )
- sideVector.append( QCP::msTop );
- if( sides.testFlag( QCP::msBottom ) )
- sideVector.append( QCP::msBottom );
-
- for( int i = 0; i < sideVector.size(); ++i )
+ if (sides.testFlag(QCP::msLeft)) sideVector.append(QCP::msLeft);
+ if (sides.testFlag(QCP::msRight)) sideVector.append(QCP::msRight);
+ if (sides.testFlag(QCP::msTop)) sideVector.append(QCP::msTop);
+ if (sides.testFlag(QCP::msBottom)) sideVector.append(QCP::msBottom);
+
+ for (int i=0; iremoveChild( side, this );
-
- if( !group ) // if setting to 0, remove hash entry. Else set hash entry to new group and register there
+ QCPMarginGroup *oldGroup = marginGroup(side);
+ if (oldGroup) // unregister at old group
+ oldGroup->removeChild(side, this);
+
+ if (!group) // if setting to 0, remove hash entry. Else set hash entry to new group and register there
{
- mMarginGroups.remove( side );
- }
- else // setting to a new group
+ mMarginGroups.remove(side);
+ } else // setting to a new group
{
mMarginGroups[side] = group;
- group->addChild( side, this );
+ group->addChild(side, this);
}
}
}
@@ -3379,29 +3402,29 @@ void QCPLayoutElement::setMarginGroup( QCP::MarginSides sides, QCPMarginGroup* g
The default implementation executes the automatic margin mechanism in the \ref upMargins phase.
Subclasses should make sure to call the base class implementation.
*/
-void QCPLayoutElement::update( UpdatePhase phase )
+void QCPLayoutElement::update(UpdatePhase phase)
{
- if( phase == upMargins )
+ if (phase == upMargins)
{
- if( mAutoMargins != QCP::msNone )
+ if (mAutoMargins != QCP::msNone)
{
// set the margins of this layout element according to automatic margin calculation, either directly or via a margin group:
QMargins newMargins = mMargins;
QList allMarginSides = QList() << QCP::msLeft << QCP::msRight << QCP::msTop << QCP::msBottom;
- foreach( QCP::MarginSide side, allMarginSides )
+ foreach (QCP::MarginSide side, allMarginSides)
{
- if( mAutoMargins.testFlag( side ) ) // this side's margin shall be calculated automatically
+ if (mAutoMargins.testFlag(side)) // this side's margin shall be calculated automatically
{
- if( mMarginGroups.contains( side ) )
- QCP::setMarginValue( newMargins, side, mMarginGroups[side]->commonMargin( side ) ); // this side is part of a margin group, so get the margin value from that group
+ if (mMarginGroups.contains(side))
+ QCP::setMarginValue(newMargins, side, mMarginGroups[side]->commonMargin(side)); // this side is part of a margin group, so get the margin value from that group
else
- QCP::setMarginValue( newMargins, side, calculateAutoMargin( side ) ); // this side is not part of a group, so calculate the value directly
+ QCP::setMarginValue(newMargins, side, calculateAutoMargin(side)); // this side is not part of a group, so calculate the value directly
// apply minimum margin restrictions:
- if( QCP::getMarginValue( newMargins, side ) < QCP::getMarginValue( mMinimumMargins, side ) )
- QCP::setMarginValue( newMargins, side, QCP::getMarginValue( mMinimumMargins, side ) );
+ if (QCP::getMarginValue(newMargins, side) < QCP::getMarginValue(mMinimumMargins, side))
+ QCP::setMarginValue(newMargins, side, QCP::getMarginValue(mMinimumMargins, side));
}
}
- setMargins( newMargins );
+ setMargins(newMargins);
}
}
}
@@ -3422,7 +3445,7 @@ void QCPLayoutElement::update( UpdatePhase phase )
*/
QSize QCPLayoutElement::minimumOuterSizeHint() const
{
- return QSize( mMargins.left() + mMargins.right(), mMargins.top() + mMargins.bottom() );
+ return QSize(mMargins.left()+mMargins.right(), mMargins.top()+mMargins.bottom());
}
/*!
@@ -3441,7 +3464,7 @@ QSize QCPLayoutElement::minimumOuterSizeHint() const
*/
QSize QCPLayoutElement::maximumOuterSizeHint() const
{
- return QSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX );
+ return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
}
/*!
@@ -3451,9 +3474,9 @@ QSize QCPLayoutElement::maximumOuterSizeHint() const
\warning There may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have
empty cells which yield 0 at the respective index.)
*/
-QList QCPLayoutElement::elements( bool recursive ) const
+QList QCPLayoutElement::elements(bool recursive) const
{
- Q_UNUSED( recursive )
+ Q_UNUSED(recursive)
return QList();
}
@@ -3468,24 +3491,23 @@ QList QCPLayoutElement::elements( bool recursive ) const
QCPLayoutElement subclasses may reimplement this method to provide more specific selection test
behaviour.
*/
-double QCPLayoutElement::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const
+double QCPLayoutElement::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const
{
- Q_UNUSED( details )
-
- if( onlySelectable )
+ Q_UNUSED(details)
+
+ if (onlySelectable)
return -1;
-
- if( QRectF( mOuterRect ).contains( pos ) )
+
+ if (QRectF(mOuterRect).contains(pos))
{
- if( mParentPlot )
- return mParentPlot->selectionTolerance() * 0.99;
+ if (mParentPlot)
+ return mParentPlot->selectionTolerance()*0.99;
else
{
qDebug() << Q_FUNC_INFO << "parent plot not defined";
return -1;
}
- }
- else
+ } else
return -1;
}
@@ -3494,12 +3516,12 @@ double QCPLayoutElement::selectTest( const QPointF& pos, bool onlySelectable, QV
propagates the parent plot initialization to all child elements, by calling \ref
QCPLayerable::initializeParentPlot on them.
*/
-void QCPLayoutElement::parentPlotInitialized( QCustomPlot* parentPlot )
+void QCPLayoutElement::parentPlotInitialized(QCustomPlot *parentPlot)
{
- foreach( QCPLayoutElement* el, elements( false ) )
+ foreach (QCPLayoutElement* el, elements(false))
{
- if( !el->parentPlot() )
- el->initializeParentPlot( parentPlot );
+ if (!el->parentPlot())
+ el->initializeParentPlot(parentPlot);
}
}
@@ -3512,9 +3534,9 @@ void QCPLayoutElement::parentPlotInitialized( QCustomPlot* parentPlot )
The default implementation just returns the respective manual margin (\ref setMargins) or the
minimum margin, whichever is larger.
*/
-int QCPLayoutElement::calculateAutoMargin( QCP::MarginSide side )
+int QCPLayoutElement::calculateAutoMargin(QCP::MarginSide side)
{
- return qMax( QCP::getMarginValue( mMargins, side ), QCP::getMarginValue( mMinimumMargins, side ) );
+ return qMax(QCP::getMarginValue(mMargins, side), QCP::getMarginValue(mMinimumMargins, side));
}
/*! \internal
@@ -3622,39 +3644,39 @@ QCPLayout::QCPLayout()
For details about this method and the update phases, see the documentation of \ref
QCPLayoutElement::update.
*/
-void QCPLayout::update( UpdatePhase phase )
+void QCPLayout::update(UpdatePhase phase)
{
- QCPLayoutElement::update( phase );
-
+ QCPLayoutElement::update(phase);
+
// set child element rects according to layout:
- if( phase == upLayout )
+ if (phase == upLayout)
updateLayout();
-
+
// propagate update call to child elements:
const int elCount = elementCount();
- for( int i = 0; i < elCount; ++i )
+ for (int i=0; iupdate( phase );
+ if (QCPLayoutElement *el = elementAt(i))
+ el->update(phase);
}
}
/* inherits documentation from base class */
-QList QCPLayout::elements( bool recursive ) const
+QList QCPLayout::elements(bool recursive) const
{
const int c = elementCount();
QList result;
-#if QT_VERSION >= QT_VERSION_CHECK( 4, 7, 0 )
- result.reserve( c );
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
+ result.reserve(c);
#endif
- for( int i = 0; i < c; ++i )
- result.append( elementAt( i ) );
- if( recursive )
+ for (int i=0; ielements( recursive );
+ if (result.at(i))
+ result << result.at(i)->elements(recursive);
}
}
return result;
@@ -3682,14 +3704,13 @@ void QCPLayout::simplify()
\see remove, takeAt
*/
-bool QCPLayout::removeAt( int index )
+bool QCPLayout::removeAt(int index)
{
- if( QCPLayoutElement* el = takeAt( index ) )
+ if (QCPLayoutElement *el = takeAt(index))
{
delete el;
return true;
- }
- else
+ } else
return false;
}
@@ -3704,14 +3725,13 @@ bool QCPLayout::removeAt( int index )
\see removeAt, take
*/
-bool QCPLayout::remove( QCPLayoutElement* element )
+bool QCPLayout::remove(QCPLayoutElement *element)
{
- if( take( element ) )
+ if (take(element))
{
delete element;
return true;
- }
- else
+ } else
return false;
}
@@ -3723,10 +3743,10 @@ bool QCPLayout::remove( QCPLayoutElement* element )
*/
void QCPLayout::clear()
{
- for( int i = elementCount() - 1; i >= 0; --i )
+ for (int i=elementCount()-1; i>=0; --i)
{
- if( elementAt( i ) )
- removeAt( i );
+ if (elementAt(i))
+ removeAt(i);
}
simplify();
}
@@ -3741,9 +3761,9 @@ void QCPLayout::clear()
*/
void QCPLayout::sizeConstraintsChanged() const
{
- if( QWidget* w = qobject_cast( parent() ) )
+ if (QWidget *w = qobject_cast(parent()))
w->updateGeometry();
- else if( QCPLayout* l = qobject_cast( parent() ) )
+ else if (QCPLayout *l = qobject_cast(parent()))
l->sizeConstraintsChanged();
}
@@ -3763,6 +3783,7 @@ void QCPLayout::updateLayout()
{
}
+
/*! \internal
Associates \a el with this layout. This is done by setting the \ref QCPLayoutElement::layout, the
@@ -3775,18 +3796,17 @@ void QCPLayout::updateLayout()
method only changes properties in \a el. The removal from the old layout and the insertion into
the new layout must be done additionally.
*/
-void QCPLayout::adoptElement( QCPLayoutElement* el )
+void QCPLayout::adoptElement(QCPLayoutElement *el)
{
- if( el )
+ if (el)
{
el->mParentLayout = this;
- el->setParentLayerable( this );
- el->setParent( this );
- if( !el->parentPlot() )
- el->initializeParentPlot( mParentPlot );
+ el->setParentLayerable(this);
+ el->setParent(this);
+ if (!el->parentPlot())
+ el->initializeParentPlot(mParentPlot);
el->layoutChanged();
- }
- else
+ } else
qDebug() << Q_FUNC_INFO << "Null element passed";
}
@@ -3800,16 +3820,15 @@ void QCPLayout::adoptElement( QCPLayoutElement* el )
take or \ref takeAt). Note that this method only changes properties in \a el. The removal from
the old layout must be done additionally.
*/
-void QCPLayout::releaseElement( QCPLayoutElement* el )
+void QCPLayout::releaseElement(QCPLayoutElement *el)
{
- if( el )
+ if (el)
{
el->mParentLayout = 0;
- el->setParentLayerable( 0 );
- el->setParent( mParentPlot );
+ el->setParentLayerable(0);
+ el->setParent(mParentPlot);
// Note: Don't initializeParentPlot(0) here, because layout element will stay in same parent plot
- }
- else
+ } else
qDebug() << Q_FUNC_INFO << "Null element passed";
}
@@ -3842,53 +3861,53 @@ void QCPLayout::releaseElement( QCPLayoutElement* el )
The return value is a QVector containing the section sizes.
*/
-QVector QCPLayout::getSectionSizes( QVector maxSizes, QVector minSizes, QVector stretchFactors, int totalSize ) const
+QVector QCPLayout::getSectionSizes(QVector maxSizes, QVector minSizes, QVector stretchFactors, int totalSize) const
{
- if( maxSizes.size() != minSizes.size() || minSizes.size() != stretchFactors.size() )
+ if (maxSizes.size() != minSizes.size() || minSizes.size() != stretchFactors.size())
{
qDebug() << Q_FUNC_INFO << "Passed vector sizes aren't equal:" << maxSizes << minSizes << stretchFactors;
return QVector();
}
- if( stretchFactors.isEmpty() )
+ if (stretchFactors.isEmpty())
return QVector();
int sectionCount = stretchFactors.size();
- QVector sectionSizes( sectionCount );
+ QVector sectionSizes(sectionCount);
// if provided total size is forced smaller than total minimum size, ignore minimum sizes (squeeze sections):
int minSizeSum = 0;
- for( int i = 0; i < sectionCount; ++i )
- minSizeSum += minSizes.at( i );
- if( totalSize < minSizeSum )
+ for (int i=0; i minimumLockedSections;
QList unfinishedSections;
- for( int i = 0; i < sectionCount; ++i )
- unfinishedSections.append( i );
+ for (int i=0; i QCPLayout::getSectionSizes( QVector maxSizes, QVector min
// check if that maximum is actually within the bounds of the total size (i.e. can we stretch all remaining sections so far that the found section
// actually hits its maximum, without exceeding the total size when we add up all sections)
double stretchFactorSum = 0;
- for( int i = 0; i < unfinishedSections.size(); ++i )
- stretchFactorSum += stretchFactors.at( unfinishedSections.at( i ) );
- double nextMaxLimit = freeSize / stretchFactorSum;
- if( nextMax < nextMaxLimit ) // next maximum is actually hit, move forward to that point and fix the size of that section
+ for (int i=0; i result( sectionCount );
- for( int i = 0; i < sectionCount; ++i )
- result[i] = qRound( sectionSizes.at( i ) );
+
+ QVector result(sectionCount);
+ for (int i=0; i QCPLayout::getSectionSizes( QVector maxSizes, QVector min
QCPLayoutElement::setSizeConstraintRect), as well as the minimum size hint, if no manual minimum
size was set (\ref QCPLayoutElement::minimumOuterSizeHint).
*/
-QSize QCPLayout::getFinalMinimumOuterSize( const QCPLayoutElement* el )
+QSize QCPLayout::getFinalMinimumOuterSize(const QCPLayoutElement *el)
{
QSize minOuterHint = el->minimumOuterSizeHint();
- QSize minOuter = el->minimumSize(); // depending on sizeConstraitRect this might be with respect to inner rect, so possibly add margins in next four lines (preserving unset minimum of 0)
- if( minOuter.width() > 0 && el->sizeConstraintRect() == QCPLayoutElement::scrInnerRect )
+ QSize minOuter = el->minimumSize(); // depending on sizeConstraitRect this might be with respect to inner rect, so possibly add margins in next four lines (preserving unset minimum of 0)
+ if (minOuter.width() > 0 && el->sizeConstraintRect() == QCPLayoutElement::scrInnerRect)
minOuter.rwidth() += el->margins().left() + el->margins().right();
- if( minOuter.height() > 0 && el->sizeConstraintRect() == QCPLayoutElement::scrInnerRect )
+ if (minOuter.height() > 0 && el->sizeConstraintRect() == QCPLayoutElement::scrInnerRect)
minOuter.rheight() += el->margins().top() + el->margins().bottom();
-
- return QSize( minOuter.width() > 0 ? minOuter.width() : minOuterHint.width(),
- minOuter.height() > 0 ? minOuter.height() : minOuterHint.height() );
- ;
+
+ return QSize(minOuter.width() > 0 ? minOuter.width() : minOuterHint.width(),
+ minOuter.height() > 0 ? minOuter.height() : minOuterHint.height());;
}
/*! \internal
@@ -3994,19 +4011,20 @@ QSize QCPLayout::getFinalMinimumOuterSize( const QCPLayoutElement* el )
QCPLayoutElement::setSizeConstraintRect), as well as the maximum size hint, if no manual maximum
size was set (\ref QCPLayoutElement::maximumOuterSizeHint).
*/
-QSize QCPLayout::getFinalMaximumOuterSize( const QCPLayoutElement* el )
+QSize QCPLayout::getFinalMaximumOuterSize(const QCPLayoutElement *el)
{
QSize maxOuterHint = el->maximumOuterSizeHint();
- QSize maxOuter = el->maximumSize(); // depending on sizeConstraitRect this might be with respect to inner rect, so possibly add margins in next four lines (preserving unset maximum of QWIDGETSIZE_MAX)
- if( maxOuter.width() < QWIDGETSIZE_MAX && el->sizeConstraintRect() == QCPLayoutElement::scrInnerRect )
+ QSize maxOuter = el->maximumSize(); // depending on sizeConstraitRect this might be with respect to inner rect, so possibly add margins in next four lines (preserving unset maximum of QWIDGETSIZE_MAX)
+ if (maxOuter.width() < QWIDGETSIZE_MAX && el->sizeConstraintRect() == QCPLayoutElement::scrInnerRect)
maxOuter.rwidth() += el->margins().left() + el->margins().right();
- if( maxOuter.height() < QWIDGETSIZE_MAX && el->sizeConstraintRect() == QCPLayoutElement::scrInnerRect )
+ if (maxOuter.height() < QWIDGETSIZE_MAX && el->sizeConstraintRect() == QCPLayoutElement::scrInnerRect)
maxOuter.rheight() += el->margins().top() + el->margins().bottom();
-
- return QSize( maxOuter.width() < QWIDGETSIZE_MAX ? maxOuter.width() : maxOuterHint.width(),
- maxOuter.height() < QWIDGETSIZE_MAX ? maxOuter.height() : maxOuterHint.height() );
+
+ return QSize(maxOuter.width() < QWIDGETSIZE_MAX ? maxOuter.width() : maxOuterHint.width(),
+ maxOuter.height() < QWIDGETSIZE_MAX ? maxOuter.height() : maxOuterHint.height());
}
+
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// QCPLayoutGrid
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -4052,8 +4070,11 @@ QSize QCPLayout::getFinalMaximumOuterSize( const QCPLayoutElement* el )
/*!
Creates an instance of QCPLayoutGrid and sets default values.
*/
-QCPLayoutGrid::QCPLayoutGrid()
- : mColumnSpacing( 5 ), mRowSpacing( 5 ), mWrap( 0 ), mFillOrder( foRowsFirst )
+QCPLayoutGrid::QCPLayoutGrid() :
+ mColumnSpacing(5),
+ mRowSpacing(5),
+ mWrap(0),
+ mFillOrder(foRowsFirst)
{
}
@@ -4072,25 +4093,24 @@ QCPLayoutGrid::~QCPLayoutGrid()
\see addElement, hasElement
*/
-QCPLayoutElement* QCPLayoutGrid::element( int row, int column ) const
+QCPLayoutElement *QCPLayoutGrid::element(int row, int column) const
{
- if( row >= 0 && row < mElements.size() )
+ if (row >= 0 && row < mElements.size())
{
- if( column >= 0 && column < mElements.first().size() )
+ if (column >= 0 && column < mElements.first().size())
{
- if( QCPLayoutElement* result = mElements.at( row ).at( column ) )
+ if (QCPLayoutElement *result = mElements.at(row).at(column))
return result;
else
qDebug() << Q_FUNC_INFO << "Requested cell is empty. Row:" << row << "Column:" << column;
- }
- else
+ } else
qDebug() << Q_FUNC_INFO << "Invalid column. Row:" << row << "Column:" << column;
- }
- else
+ } else
qDebug() << Q_FUNC_INFO << "Invalid row. Row:" << row << "Column:" << column;
return 0;
}
+
/*! \overload
Adds the \a element to cell with \a row and \a column. If \a element is already in a layout, it
@@ -4105,19 +4125,18 @@ QCPLayoutElement* QCPLayoutGrid::element( int row, int column ) const
\see element, hasElement, take, remove
*/
-bool QCPLayoutGrid::addElement( int row, int column, QCPLayoutElement* element )
+bool QCPLayoutGrid::addElement(int row, int column, QCPLayoutElement *element)
{
- if( !hasElement( row, column ) )
+ if (!hasElement(row, column))
{
- if( element && element->layout() ) // remove from old layout first
- element->layout()->take( element );
- expandTo( row + 1, column + 1 );
+ if (element && element->layout()) // remove from old layout first
+ element->layout()->take(element);
+ expandTo(row+1, column+1);
mElements[row][column] = element;
- if( element )
- adoptElement( element );
+ if (element)
+ adoptElement(element);
return true;
- }
- else
+ } else
qDebug() << Q_FUNC_INFO << "There is already an element in the specified row/column:" << row << column;
return false;
}
@@ -4132,35 +4151,34 @@ bool QCPLayoutGrid::addElement( int row, int column, QCPLayoutElement* element )
\see setFillOrder, setWrap, element, hasElement, take, remove
*/
-bool QCPLayoutGrid::addElement( QCPLayoutElement* element )
+bool QCPLayoutGrid::addElement(QCPLayoutElement *element)
{
int rowIndex = 0;
int colIndex = 0;
- if( mFillOrder == foColumnsFirst )
+ if (mFillOrder == foColumnsFirst)
{
- while( hasElement( rowIndex, colIndex ) )
+ while (hasElement(rowIndex, colIndex))
{
++colIndex;
- if( colIndex >= mWrap && mWrap > 0 )
+ if (colIndex >= mWrap && mWrap > 0)
{
colIndex = 0;
++rowIndex;
}
}
- }
- else
+ } else
{
- while( hasElement( rowIndex, colIndex ) )
+ while (hasElement(rowIndex, colIndex))
{
++rowIndex;
- if( rowIndex >= mWrap && mWrap > 0 )
+ if (rowIndex >= mWrap && mWrap > 0)
{
rowIndex = 0;
++colIndex;
}
}
}
- return addElement( rowIndex, colIndex, element );
+ return addElement(rowIndex, colIndex, element);
}
/*!
@@ -4169,10 +4187,10 @@ bool QCPLayoutGrid::addElement( QCPLayoutElement* element )
\see element
*/
-bool QCPLayoutGrid::hasElement( int row, int column )
+bool QCPLayoutGrid::hasElement(int row, int column)
{
- if( row >= 0 && row < rowCount() && column >= 0 && column < columnCount() )
- return mElements.at( row ).at( column );
+ if (row >= 0 && row < rowCount() && column >= 0 && column < columnCount())
+ return mElements.at(row).at(column);
else
return false;
}
@@ -4189,16 +4207,15 @@ bool QCPLayoutGrid::hasElement( int row, int column )
\see setColumnStretchFactors, setRowStretchFactor
*/
-void QCPLayoutGrid::setColumnStretchFactor( int column, double factor )
+void QCPLayoutGrid::setColumnStretchFactor(int column, double factor)
{
- if( column >= 0 && column < columnCount() )
+ if (column >= 0 && column < columnCount())
{
- if( factor > 0 )
+ if (factor > 0)
mColumnStretchFactors[column] = factor;
else
qDebug() << Q_FUNC_INFO << "Invalid stretch factor, must be positive:" << factor;
- }
- else
+ } else
qDebug() << Q_FUNC_INFO << "Invalid column:" << column;
}
@@ -4214,21 +4231,20 @@ void QCPLayoutGrid::setColumnStretchFactor( int column, double factor )
\see setColumnStretchFactor, setRowStretchFactors
*/
-void QCPLayoutGrid::setColumnStretchFactors( const QList& factors )
+void QCPLayoutGrid::setColumnStretchFactors(const QList &factors)
{
- if( factors.size() == mColumnStretchFactors.size() )
+ if (factors.size() == mColumnStretchFactors.size())
{
mColumnStretchFactors = factors;
- for( int i = 0; i < mColumnStretchFactors.size(); ++i )
+ for (int i=0; i& factors )
\see setColumnStretchFactors, setRowStretchFactor
*/
-void QCPLayoutGrid::setRowStretchFactor( int row, double factor )
+void QCPLayoutGrid::setRowStretchFactor(int row, double factor)
{
- if( row >= 0 && row < rowCount() )
+ if (row >= 0 && row < rowCount())
{
- if( factor > 0 )
+ if (factor > 0)
mRowStretchFactors[row] = factor;
else
qDebug() << Q_FUNC_INFO << "Invalid stretch factor, must be positive:" << factor;
- }
- else
+ } else
qDebug() << Q_FUNC_INFO << "Invalid row:" << row;
}
@@ -4269,21 +4284,20 @@ void QCPLayoutGrid::setRowStretchFactor( int row, double factor )
\see setRowStretchFactor, setColumnStretchFactors
*/
-void QCPLayoutGrid::setRowStretchFactors( const QList& factors )
+void QCPLayoutGrid::setRowStretchFactors(const QList &factors)
{
- if( factors.size() == mRowStretchFactors.size() )
+ if (factors.size() == mRowStretchFactors.size())
{
mRowStretchFactors = factors;
- for( int i = 0; i < mRowStretchFactors.size(); ++i )
+ for (int i=0; i& factors )
\see setRowSpacing
*/
-void QCPLayoutGrid::setColumnSpacing( int pixels )
+void QCPLayoutGrid::setColumnSpacing(int pixels)
{
mColumnSpacing = pixels;
}
@@ -4302,7 +4316,7 @@ void QCPLayoutGrid::setColumnSpacing( int pixels )
\see setColumnSpacing
*/
-void QCPLayoutGrid::setRowSpacing( int pixels )
+void QCPLayoutGrid::setRowSpacing(int pixels)
{
mRowSpacing = pixels;
}
@@ -4324,9 +4338,9 @@ void QCPLayoutGrid::setRowSpacing( int pixels )
\see setFillOrder
*/
-void QCPLayoutGrid::setWrap( int count )
+void QCPLayoutGrid::setWrap(int count)
{
- mWrap = qMax( 0, count );
+ mWrap = qMax(0, count);
}
/*!
@@ -4353,28 +4367,28 @@ void QCPLayoutGrid::setWrap( int count )
\see setWrap, addElement(QCPLayoutElement*)
*/
-void QCPLayoutGrid::setFillOrder( FillOrder order, bool rearrange )
+void QCPLayoutGrid::setFillOrder(FillOrder order, bool rearrange)
{
// if rearranging, take all elements via linear index of old fill order:
const int elCount = elementCount();
QVector tempElements;
- if( rearrange )
+ if (rearrange)
{
- tempElements.reserve( elCount );
- for( int i = 0; i < elCount; ++i )
+ tempElements.reserve(elCount);
+ for (int i=0; i() );
- mRowStretchFactors.append( 1 );
+ mElements.append(QList());
+ mRowStretchFactors.append(1);
}
// go through rows and expand columns as necessary:
- int newColCount = qMax( columnCount(), newColumnCount );
- for( int i = 0; i < rowCount(); ++i )
+ int newColCount = qMax(columnCount(), newColumnCount);
+ for (int i=0; i rowCount() )
+ if (newIndex > rowCount())
newIndex = rowCount();
-
- mRowStretchFactors.insert( newIndex, 1 );
+
+ mRowStretchFactors.insert(newIndex, 1);
QList newRow;
- for( int col = 0; col < columnCount(); ++col )
- newRow.append( (QCPLayoutElement*)0 );
- mElements.insert( newIndex, newRow );
+ for (int col=0; col columnCount() )
+ if (newIndex > columnCount())
newIndex = columnCount();
-
- mColumnStretchFactors.insert( newIndex, 1 );
- for( int row = 0; row < rowCount(); ++row )
- mElements[row].insert( newIndex, (QCPLayoutElement*)0 );
+
+ mColumnStretchFactors.insert(newIndex, 1);
+ for (int row=0; row= 0 && row < rowCount() )
+ if (row >= 0 && row < rowCount())
{
- if( column >= 0 && column < columnCount() )
+ if (column >= 0 && column < columnCount())
{
- switch( mFillOrder )
+ switch (mFillOrder)
{
- case foRowsFirst:
- return column * rowCount() + row;
- case foColumnsFirst:
- return row * columnCount() + column;
+ case foRowsFirst: return column*rowCount() + row;
+ case foColumnsFirst: return row*columnCount() + column;
}
- }
- else
+ } else
qDebug() << Q_FUNC_INFO << "row index out of bounds:" << row;
- }
- else
+ } else
qDebug() << Q_FUNC_INFO << "column index out of bounds:" << column;
return 0;
}
@@ -4512,34 +4522,34 @@ int QCPLayoutGrid::rowColToIndex( int row, int column ) const
\see rowColToIndex
*/
-void QCPLayoutGrid::indexToRowCol( int index, int& row, int& column ) const
+void QCPLayoutGrid::indexToRowCol(int index, int &row, int &column) const
{
row = -1;
column = -1;
const int nCols = columnCount();
const int nRows = rowCount();
- if( nCols == 0 || nRows == 0 )
+ if (nCols == 0 || nRows == 0)
return;
- if( index < 0 || index >= elementCount() )
+ if (index < 0 || index >= elementCount())
{
qDebug() << Q_FUNC_INFO << "index out of bounds:" << index;
return;
}
-
- switch( mFillOrder )
+
+ switch (mFillOrder)
{
- case foRowsFirst:
- {
- column = index / nRows;
- row = index % nRows;
- break;
- }
- case foColumnsFirst:
- {
- row = index / nCols;
- column = index % nCols;
- break;
- }
+ case foRowsFirst:
+ {
+ column = index / nRows;
+ row = index % nRows;
+ break;
+ }
+ case foColumnsFirst:
+ {
+ row = index / nCols;
+ column = index % nCols;
+ break;
+ }
}
}
@@ -4547,27 +4557,27 @@ void QCPLayoutGrid::indexToRowCol( int index, int& row, int& column ) const
void QCPLayoutGrid::updateLayout()
{
QVector minColWidths, minRowHeights, maxColWidths, maxRowHeights;
- getMinimumRowColSizes( &minColWidths, &minRowHeights );
- getMaximumRowColSizes( &maxColWidths, &maxRowHeights );
-
- int totalRowSpacing = ( rowCount() - 1 ) * mRowSpacing;
- int totalColSpacing = ( columnCount() - 1 ) * mColumnSpacing;
- QVector colWidths = getSectionSizes( maxColWidths, minColWidths, mColumnStretchFactors.toVector(), mRect.width() - totalColSpacing );
- QVector rowHeights = getSectionSizes( maxRowHeights, minRowHeights, mRowStretchFactors.toVector(), mRect.height() - totalRowSpacing );
-
+ getMinimumRowColSizes(&minColWidths, &minRowHeights);
+ getMaximumRowColSizes(&maxColWidths, &maxRowHeights);
+
+ int totalRowSpacing = (rowCount()-1) * mRowSpacing;
+ int totalColSpacing = (columnCount()-1) * mColumnSpacing;
+ QVector colWidths = getSectionSizes(maxColWidths, minColWidths, mColumnStretchFactors.toVector(), mRect.width()-totalColSpacing);
+ QVector rowHeights = getSectionSizes(maxRowHeights, minRowHeights, mRowStretchFactors.toVector(), mRect.height()-totalRowSpacing);
+
// go through cells and set rects accordingly:
int yOffset = mRect.top();
- for( int row = 0; row < rowCount(); ++row )
+ for (int row=0; row 0 )
- yOffset += rowHeights.at( row - 1 ) + mRowSpacing;
+ if (row > 0)
+ yOffset += rowHeights.at(row-1)+mRowSpacing;
int xOffset = mRect.left();
- for( int col = 0; col < columnCount(); ++col )
+ for (int col=0; col 0 )
- xOffset += colWidths.at( col - 1 ) + mColumnSpacing;
- if( mElements.at( row ).at( col ) )
- mElements.at( row ).at( col )->setOuterRect( QRect( xOffset, yOffset, colWidths.at( col ), rowHeights.at( row ) ) );
+ if (col > 0)
+ xOffset += colWidths.at(col-1)+mColumnSpacing;
+ if (mElements.at(row).at(col))
+ mElements.at(row).at(col)->setOuterRect(QRect(xOffset, yOffset, colWidths.at(col), rowHeights.at(row)));
}
}
}
@@ -4580,15 +4590,14 @@ void QCPLayoutGrid::updateLayout()
\see rowColToIndex
*/
-QCPLayoutElement* QCPLayoutGrid::elementAt( int index ) const
+QCPLayoutElement *QCPLayoutGrid::elementAt(int index) const
{
- if( index >= 0 && index < elementCount() )
+ if (index >= 0 && index < elementCount())
{
int row, col;
- indexToRowCol( index, row, col );
- return mElements.at( row ).at( col );
- }
- else
+ indexToRowCol(index, row, col);
+ return mElements.at(row).at(col);
+ } else
return 0;
}
@@ -4600,17 +4609,16 @@ QCPLayoutElement* QCPLayoutGrid::elementAt( int index ) const
\see rowColToIndex
*/
-QCPLayoutElement* QCPLayoutGrid::takeAt( int index )
+QCPLayoutElement *QCPLayoutGrid::takeAt(int index)
{
- if( QCPLayoutElement* el = elementAt( index ) )
+ if (QCPLayoutElement *el = elementAt(index))
{
- releaseElement( el );
+ releaseElement(el);
int row, col;
- indexToRowCol( index, row, col );
+ indexToRowCol(index, row, col);
mElements[row][col] = 0;
return el;
- }
- else
+ } else
{
qDebug() << Q_FUNC_INFO << "Attempt to take invalid index:" << index;
return 0;
@@ -4618,41 +4626,40 @@ QCPLayoutElement* QCPLayoutGrid::takeAt( int index )
}
/* inherits documentation from base class */
-bool QCPLayoutGrid::take( QCPLayoutElement* element )
+bool QCPLayoutGrid::take(QCPLayoutElement *element)
{
- if( element )
+ if (element)
{
- for( int i = 0; i < elementCount(); ++i )
+ for (int i=0; i QCPLayoutGrid::elements( bool recursive ) const
+QList QCPLayoutGrid::elements(bool recursive) const
{
QList result;
const int elCount = elementCount();
-#if QT_VERSION >= QT_VERSION_CHECK( 4, 7, 0 )
- result.reserve( elCount );
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
+ result.reserve(elCount);
#endif
- for( int i = 0; i < elCount; ++i )
- result.append( elementAt( i ) );
- if( recursive )
+ for (int i=0; ielements( recursive );
+ if (result.at(i))
+ result << result.at(i)->elements(recursive);
}
}
return result;
@@ -4664,43 +4671,43 @@ QList QCPLayoutGrid::elements( bool recursive ) const
void QCPLayoutGrid::simplify()
{
// remove rows with only empty cells:
- for( int row = rowCount() - 1; row >= 0; --row )
+ for (int row=rowCount()-1; row>=0; --row)
{
bool hasElements = false;
- for( int col = 0; col < columnCount(); ++col )
+ for (int col=0; col= 0; --col )
+ for (int col=columnCount()-1; col>=0; --col)
{
bool hasElements = false;
- for( int row = 0; row < rowCount(); ++row )
+ for (int row=0; row minColWidths, minRowHeights;
- getMinimumRowColSizes( &minColWidths, &minRowHeights );
- QSize result( 0, 0 );
- for( int i = 0; i < minColWidths.size(); ++i )
- result.rwidth() += minColWidths.at( i );
- for( int i = 0; i < minRowHeights.size(); ++i )
- result.rheight() += minRowHeights.at( i );
- result.rwidth() += qMax( 0, columnCount() - 1 ) * mColumnSpacing;
- result.rheight() += qMax( 0, rowCount() - 1 ) * mRowSpacing;
- result.rwidth() += mMargins.left() + mMargins.right();
- result.rheight() += mMargins.top() + mMargins.bottom();
+ getMinimumRowColSizes(&minColWidths, &minRowHeights);
+ QSize result(0, 0);
+ for (int i=0; i maxColWidths, maxRowHeights;
- getMaximumRowColSizes( &maxColWidths, &maxRowHeights );
-
- QSize result( 0, 0 );
- for( int i = 0; i < maxColWidths.size(); ++i )
- result.setWidth( qMin( result.width() + maxColWidths.at( i ), QWIDGETSIZE_MAX ) );
- for( int i = 0; i < maxRowHeights.size(); ++i )
- result.setHeight( qMin( result.height() + maxRowHeights.at( i ), QWIDGETSIZE_MAX ) );
- result.rwidth() += qMax( 0, columnCount() - 1 ) * mColumnSpacing;
- result.rheight() += qMax( 0, rowCount() - 1 ) * mRowSpacing;
- result.rwidth() += mMargins.left() + mMargins.right();
- result.rheight() += mMargins.top() + mMargins.bottom();
- if( result.height() > QWIDGETSIZE_MAX )
- result.setHeight( QWIDGETSIZE_MAX );
- if( result.width() > QWIDGETSIZE_MAX )
- result.setWidth( QWIDGETSIZE_MAX );
+ getMaximumRowColSizes(&maxColWidths, &maxRowHeights);
+
+ QSize result(0, 0);
+ for (int i=0; i QWIDGETSIZE_MAX)
+ result.setHeight(QWIDGETSIZE_MAX);
+ if (result.width() > QWIDGETSIZE_MAX)
+ result.setWidth(QWIDGETSIZE_MAX);
return result;
}
@@ -4757,21 +4764,21 @@ QSize QCPLayoutGrid::maximumOuterSizeHint() const
\see getMaximumRowColSizes
*/
-void QCPLayoutGrid::getMinimumRowColSizes( QVector* minColWidths, QVector* minRowHeights ) const
+void QCPLayoutGrid::getMinimumRowColSizes(QVector *minColWidths, QVector *minRowHeights) const
{
- *minColWidths = QVector( columnCount(), 0 );
- *minRowHeights = QVector( rowCount(), 0 );
- for( int row = 0; row < rowCount(); ++row )
+ *minColWidths = QVector(columnCount(), 0);
+ *minRowHeights = QVector(rowCount(), 0);
+ for (int row=0; rowat( col ) < minSize.width() )
- ( *minColWidths )[col] = minSize.width();
- if( minRowHeights->at( row ) < minSize.height() )
- ( *minRowHeights )[row] = minSize.height();
+ QSize minSize = getFinalMinimumOuterSize(el);
+ if (minColWidths->at(col) < minSize.width())
+ (*minColWidths)[col] = minSize.width();
+ if (minRowHeights->at(row) < minSize.height())
+ (*minRowHeights)[row] = minSize.height();
}
}
}
@@ -4790,26 +4797,27 @@ void QCPLayoutGrid::getMinimumRowColSizes( QVector* minColWidths, QVector* maxColWidths, QVector* maxRowHeights ) const
+void QCPLayoutGrid::getMaximumRowColSizes(QVector *maxColWidths, QVector *maxRowHeights) const
{
- *maxColWidths = QVector( columnCount(), QWIDGETSIZE_MAX );
- *maxRowHeights = QVector( rowCount(), QWIDGETSIZE_MAX );
- for( int row = 0; row < rowCount(); ++row )
+ *maxColWidths = QVector(columnCount(), QWIDGETSIZE_MAX);
+ *maxRowHeights = QVector(rowCount(), QWIDGETSIZE_MAX);
+ for (int row=0; rowat( col ) > maxSize.width() )
- ( *maxColWidths )[col] = maxSize.width();
- if( maxRowHeights->at( row ) > maxSize.height() )
- ( *maxRowHeights )[row] = maxSize.height();
+ QSize maxSize = getFinalMaximumOuterSize(el);
+ if (maxColWidths->at(col) > maxSize.width())
+ (*maxColWidths)[col] = maxSize.width();
+ if (maxRowHeights->at(row) > maxSize.height())
+ (*maxRowHeights)[row] = maxSize.height();
}
}
}
}
+
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// QCPLayoutInset
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -4858,10 +4866,10 @@ QCPLayoutInset::~QCPLayoutInset()
/*!
Returns the placement type of the element with the specified \a index.
*/
-QCPLayoutInset::InsetPlacement QCPLayoutInset::insetPlacement( int index ) const
+QCPLayoutInset::InsetPlacement QCPLayoutInset::insetPlacement(int index) const
{
- if( elementAt( index ) )
- return mInsetPlacement.at( index );
+ if (elementAt(index))
+ return mInsetPlacement.at(index);
else
{
qDebug() << Q_FUNC_INFO << "Invalid element index:" << index;
@@ -4873,10 +4881,10 @@ QCPLayoutInset::InsetPlacement QCPLayoutInset::insetPlacement( int index ) const
Returns the alignment of the element with the specified \a index. The alignment only has a
meaning, if the inset placement (\ref setInsetPlacement) is \ref ipBorderAligned.
*/
-Qt::Alignment QCPLayoutInset::insetAlignment( int index ) const
+Qt::Alignment QCPLayoutInset::insetAlignment(int index) const
{
- if( elementAt( index ) )
- return mInsetAlignment.at( index );
+ if (elementAt(index))
+ return mInsetAlignment.at(index);
else
{
qDebug() << Q_FUNC_INFO << "Invalid element index:" << index;
@@ -4888,10 +4896,10 @@ Qt::Alignment QCPLayoutInset::insetAlignment( int index ) const
Returns the rect of the element with the specified \a index. The rect only has a
meaning, if the inset placement (\ref setInsetPlacement) is \ref ipFree.
*/
-QRectF QCPLayoutInset::insetRect( int index ) const
+QRectF QCPLayoutInset::insetRect(int index) const
{
- if( elementAt( index ) )
- return mInsetRect.at( index );
+ if (elementAt(index))
+ return mInsetRect.at(index);
else
{
qDebug() << Q_FUNC_INFO << "Invalid element index:" << index;
@@ -4904,9 +4912,9 @@ QRectF QCPLayoutInset::insetRect( int index ) const
\see InsetPlacement
*/
-void QCPLayoutInset::setInsetPlacement( int index, QCPLayoutInset::InsetPlacement placement )
+void QCPLayoutInset::setInsetPlacement(int index, QCPLayoutInset::InsetPlacement placement)
{
- if( elementAt( index ) )
+ if (elementAt(index))
mInsetPlacement[index] = placement;
else
qDebug() << Q_FUNC_INFO << "Invalid element index:" << index;
@@ -4920,9 +4928,9 @@ void QCPLayoutInset::setInsetPlacement( int index, QCPLayoutInset::InsetPlacemen
Qt::AlignHCenter, Qt::AlighRight, Qt::AlignTop, Qt::AlignVCenter, Qt::AlignBottom. Any other
alignment flags will be ignored.
*/
-void QCPLayoutInset::setInsetAlignment( int index, Qt::Alignment alignment )
+void QCPLayoutInset::setInsetAlignment(int index, Qt::Alignment alignment)
{
- if( elementAt( index ) )
+ if (elementAt(index))
mInsetAlignment[index] = alignment;
else
qDebug() << Q_FUNC_INFO << "Invalid element index:" << index;
@@ -4939,9 +4947,9 @@ void QCPLayoutInset::setInsetAlignment( int index, Qt::Alignment alignment )
Note that the minimum and maximum sizes of the embedded element (\ref
QCPLayoutElement::setMinimumSize, \ref QCPLayoutElement::setMaximumSize) are enforced.
*/
-void QCPLayoutInset::setInsetRect( int index, const QRectF& rect )
+void QCPLayoutInset::setInsetRect(int index, const QRectF &rect)
{
- if( elementAt( index ) )
+ if (elementAt(index))
mInsetRect[index] = rect;
else
qDebug() << Q_FUNC_INFO << "Invalid element index:" << index;
@@ -4950,45 +4958,38 @@ void QCPLayoutInset::setInsetRect( int index, const QRectF& rect )
/* inherits documentation from base class */
void QCPLayoutInset::updateLayout()
{
- for( int i = 0; i < mElements.size(); ++i )
+ for (int i=0; i finalMaxSize.width() )
- insetRect.setWidth( finalMaxSize.width() );
- if( insetRect.size().height() > finalMaxSize.height() )
- insetRect.setHeight( finalMaxSize.height() );
- }
- else if( mInsetPlacement.at( i ) == ipBorderAligned )
+ insetRect = QRect(rect().x()+rect().width()*mInsetRect.at(i).x(),
+ rect().y()+rect().height()*mInsetRect.at(i).y(),
+ rect().width()*mInsetRect.at(i).width(),
+ rect().height()*mInsetRect.at(i).height());
+ if (insetRect.size().width() < finalMinSize.width())
+ insetRect.setWidth(finalMinSize.width());
+ if (insetRect.size().height() < finalMinSize.height())
+ insetRect.setHeight(finalMinSize.height());
+ if (insetRect.size().width() > finalMaxSize.width())
+ insetRect.setWidth(finalMaxSize.width());
+ if (insetRect.size().height() > finalMaxSize.height())
+ insetRect.setHeight(finalMaxSize.height());
+ } else if (mInsetPlacement.at(i) == ipBorderAligned)
{
- insetRect.setSize( finalMinSize );
- Qt::Alignment al = mInsetAlignment.at( i );
- if( al.testFlag( Qt::AlignLeft ) )
- insetRect.moveLeft( rect().x() );
- else if( al.testFlag( Qt::AlignRight ) )
- insetRect.moveRight( rect().x() + rect().width() );
- else
- insetRect.moveLeft( rect().x() + rect().width() * 0.5 - finalMinSize.width() * 0.5 ); // default to Qt::AlignHCenter
- if( al.testFlag( Qt::AlignTop ) )
- insetRect.moveTop( rect().y() );
- else if( al.testFlag( Qt::AlignBottom ) )
- insetRect.moveBottom( rect().y() + rect().height() );
- else
- insetRect.moveTop( rect().y() + rect().height() * 0.5 - finalMinSize.height() * 0.5 ); // default to Qt::AlignVCenter
+ insetRect.setSize(finalMinSize);
+ Qt::Alignment al = mInsetAlignment.at(i);
+ if (al.testFlag(Qt::AlignLeft)) insetRect.moveLeft(rect().x());
+ else if (al.testFlag(Qt::AlignRight)) insetRect.moveRight(rect().x()+rect().width());
+ else insetRect.moveLeft(rect().x()+rect().width()*0.5-finalMinSize.width()*0.5); // default to Qt::AlignHCenter
+ if (al.testFlag(Qt::AlignTop)) insetRect.moveTop(rect().y());
+ else if (al.testFlag(Qt::AlignBottom)) insetRect.moveBottom(rect().y()+rect().height());
+ else insetRect.moveTop(rect().y()+rect().height()*0.5-finalMinSize.height()*0.5); // default to Qt::AlignVCenter
}
- mElements.at( i )->setOuterRect( insetRect );
+ mElements.at(i)->setOuterRect(insetRect);
}
}
@@ -4999,27 +5000,26 @@ int QCPLayoutInset::elementCount() const
}
/* inherits documentation from base class */
-QCPLayoutElement* QCPLayoutInset::elementAt( int index ) const
+QCPLayoutElement *QCPLayoutInset::elementAt(int index) const
{
- if( index >= 0 && index < mElements.size() )
- return mElements.at( index );
+ if (index >= 0 && index < mElements.size())
+ return mElements.at(index);
else
return 0;
}
/* inherits documentation from base class */
-QCPLayoutElement* QCPLayoutInset::takeAt( int index )
+QCPLayoutElement *QCPLayoutInset::takeAt(int index)
{
- if( QCPLayoutElement* el = elementAt( index ) )
+ if (QCPLayoutElement *el = elementAt(index))
{
- releaseElement( el );
- mElements.removeAt( index );
- mInsetPlacement.removeAt( index );
- mInsetAlignment.removeAt( index );
- mInsetRect.removeAt( index );
+ releaseElement(el);
+ mElements.removeAt(index);
+ mInsetPlacement.removeAt(index);
+ mInsetAlignment.removeAt(index);
+ mInsetRect.removeAt(index);
return el;
- }
- else
+ } else
{
qDebug() << Q_FUNC_INFO << "Attempt to take invalid index:" << index;
return 0;
@@ -5027,21 +5027,20 @@ QCPLayoutElement* QCPLayoutInset::takeAt( int index )
}
/* inherits documentation from base class */
-bool QCPLayoutInset::take( QCPLayoutElement* element )
+bool QCPLayoutInset::take(QCPLayoutElement *element)
{
- if( element )
+ if (element)
{
- for( int i = 0; i < elementCount(); ++i )
+ for (int i=0; irealVisibility() && mElements.at( i )->selectTest( pos, onlySelectable ) >= 0 )
- return mParentPlot->selectionTolerance() * 0.99;
+ if (mElements.at(i)->realVisibility() && mElements.at(i)->selectTest(pos, onlySelectable) >= 0)
+ return mParentPlot->selectionTolerance()*0.99;
}
return -1;
}
@@ -5082,19 +5081,18 @@ double QCPLayoutInset::selectTest( const QPointF& pos, bool onlySelectable, QVar
\see addElement(QCPLayoutElement *element, const QRectF &rect)
*/
-void QCPLayoutInset::addElement( QCPLayoutElement* element, Qt::Alignment alignment )
+void QCPLayoutInset::addElement(QCPLayoutElement *element, Qt::Alignment alignment)
{
- if( element )
+ if (element)
{
- if( element->layout() ) // remove from old layout first
- element->layout()->take( element );
- mElements.append( element );
- mInsetPlacement.append( ipBorderAligned );
- mInsetAlignment.append( alignment );
- mInsetRect.append( QRectF( 0.6, 0.6, 0.4, 0.4 ) );
- adoptElement( element );
- }
- else
+ if (element->layout()) // remove from old layout first
+ element->layout()->take(element);
+ mElements.append(element);
+ mInsetPlacement.append(ipBorderAligned);
+ mInsetAlignment.append(alignment);
+ mInsetRect.append(QRectF(0.6, 0.6, 0.4, 0.4));
+ adoptElement(element);
+ } else
qDebug() << Q_FUNC_INFO << "Can't add null element";
}
@@ -5109,23 +5107,23 @@ void QCPLayoutInset::addElement( QCPLayoutElement* element, Qt::Alignment alignm
\see addElement(QCPLayoutElement *element, Qt::Alignment alignment)
*/
-void QCPLayoutInset::addElement( QCPLayoutElement* element, const QRectF& rect )
+void QCPLayoutInset::addElement(QCPLayoutElement *element, const QRectF &rect)
{
- if( element )
+ if (element)
{
- if( element->layout() ) // remove from old layout first
- element->layout()->take( element );
- mElements.append( element );
- mInsetPlacement.append( ipFree );
- mInsetAlignment.append( Qt::AlignRight | Qt::AlignTop );
- mInsetRect.append( rect );
- adoptElement( element );
- }
- else
+ if (element->layout()) // remove from old layout first
+ element->layout()->take(element);
+ mElements.append(element);
+ mInsetPlacement.append(ipFree);
+ mInsetAlignment.append(Qt::AlignRight|Qt::AlignTop);
+ mInsetRect.append(rect);
+ adoptElement(element);
+ } else
qDebug() << Q_FUNC_INFO << "Can't add null element";
}
/* end of 'src/layout.cpp' */
+
/* including file 'src/lineending.cpp', size 11536 */
/* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */
@@ -5156,23 +5154,29 @@ void QCPLayoutInset::addElement( QCPLayoutElement* element, const QRectF& rect )
/*!
Creates a QCPLineEnding instance with default values (style \ref esNone).
*/
-QCPLineEnding::QCPLineEnding()
- : mStyle( esNone ), mWidth( 8 ), mLength( 10 ), mInverted( false )
+QCPLineEnding::QCPLineEnding() :
+ mStyle(esNone),
+ mWidth(8),
+ mLength(10),
+ mInverted(false)
{
}
/*!
Creates a QCPLineEnding instance with the specified values.
*/
-QCPLineEnding::QCPLineEnding( QCPLineEnding::EndingStyle style, double width, double length, bool inverted )
- : mStyle( style ), mWidth( width ), mLength( length ), mInverted( inverted )
+QCPLineEnding::QCPLineEnding(QCPLineEnding::EndingStyle style, double width, double length, bool inverted) :
+ mStyle(style),
+ mWidth(width),
+ mLength(length),
+ mInverted(inverted)
{
}
/*!
Sets the style of the ending decoration.
*/
-void QCPLineEnding::setStyle( QCPLineEnding::EndingStyle style )
+void QCPLineEnding::setStyle(QCPLineEnding::EndingStyle style)
{
mStyle = style;
}
@@ -5183,7 +5187,7 @@ void QCPLineEnding::setStyle( QCPLineEnding::EndingStyle style )
\see setLength
*/
-void QCPLineEnding::setWidth( double width )
+void QCPLineEnding::setWidth(double width)
{
mWidth = width;
}
@@ -5194,7 +5198,7 @@ void QCPLineEnding::setWidth( double width )
\see setWidth
*/
-void QCPLineEnding::setLength( double length )
+void QCPLineEnding::setLength(double length)
{
mLength = length;
}
@@ -5207,7 +5211,7 @@ void QCPLineEnding::setLength( double length )
discs, this doesn't make a difference. However, asymmetric styles like \ref esHalfBar are
affected by it, which can be used to control to which side the half bar points to.
*/
-void QCPLineEnding::setInverted( bool inverted )
+void QCPLineEnding::setInverted(bool inverted)
{
mInverted = inverted;
}
@@ -5223,23 +5227,24 @@ void QCPLineEnding::setInverted( bool inverted )
*/
double QCPLineEnding::boundingDistance() const
{
- switch( mStyle )
+ switch (mStyle)
{
- case esNone:
- return 0;
+ case esNone:
+ return 0;
+
+ case esFlatArrow:
+ case esSpikeArrow:
+ case esLineArrow:
+ case esSkewedBar:
+ return qSqrt(mWidth*mWidth+mLength*mLength); // items that have width and length
+
+ case esDisc:
+ case esSquare:
+ case esDiamond:
+ case esBar:
+ case esHalfBar:
+ return mWidth*1.42; // items that only have a width -> width*sqrt(2)
- case esFlatArrow:
- case esSpikeArrow:
- case esLineArrow:
- case esSkewedBar:
- return qSqrt( mWidth * mWidth + mLength * mLength ); // items that have width and length
-
- case esDisc:
- case esSquare:
- case esDiamond:
- case esBar:
- case esHalfBar:
- return mWidth * 1.42; // items that only have a width -> width*sqrt(2)
}
return 0;
}
@@ -5257,25 +5262,25 @@ double QCPLineEnding::boundingDistance() const
*/
double QCPLineEnding::realLength() const
{
- switch( mStyle )
+ switch (mStyle)
{
- case esNone:
- case esLineArrow:
- case esSkewedBar:
- case esBar:
- case esHalfBar:
- return 0;
-
- case esFlatArrow:
- return mLength;
-
- case esDisc:
- case esSquare:
- case esDiamond:
- return mWidth * 0.5;
-
- case esSpikeArrow:
- return mLength * 0.8;
+ case esNone:
+ case esLineArrow:
+ case esSkewedBar:
+ case esBar:
+ case esHalfBar:
+ return 0;
+
+ case esFlatArrow:
+ return mLength;
+
+ case esDisc:
+ case esSquare:
+ case esDiamond:
+ return mWidth*0.5;
+
+ case esSpikeArrow:
+ return mLength*0.8;
}
return 0;
}
@@ -5285,121 +5290,124 @@ double QCPLineEnding::realLength() const
Draws the line ending with the specified \a painter at the position \a pos. The direction of the
line ending is controlled with \a dir.
*/
-void QCPLineEnding::draw( QCPPainter* painter, const QCPVector2D& pos, const QCPVector2D& dir ) const
+void QCPLineEnding::draw(QCPPainter *painter, const QCPVector2D &pos, const QCPVector2D &dir) const
{
- if( mStyle == esNone )
+ if (mStyle == esNone)
return;
-
- QCPVector2D lengthVec = dir.normalized() * mLength * ( mInverted ? -1 : 1 );
- if( lengthVec.isNull() )
- lengthVec = QCPVector2D( 1, 0 );
- QCPVector2D widthVec = dir.normalized().perpendicular() * mWidth * 0.5 * ( mInverted ? -1 : 1 );
-
+
+ QCPVector2D lengthVec = dir.normalized() * mLength*(mInverted ? -1 : 1);
+ if (lengthVec.isNull())
+ lengthVec = QCPVector2D(1, 0);
+ QCPVector2D widthVec = dir.normalized().perpendicular() * mWidth*0.5*(mInverted ? -1 : 1);
+
QPen penBackup = painter->pen();
QBrush brushBackup = painter->brush();
QPen miterPen = penBackup;
- miterPen.setJoinStyle( Qt::MiterJoin ); // to make arrow heads spikey
- QBrush brush( painter->pen().color(), Qt::SolidPattern );
- switch( mStyle )
+ miterPen.setJoinStyle(Qt::MiterJoin); // to make arrow heads spikey
+ QBrush brush(painter->pen().color(), Qt::SolidPattern);
+ switch (mStyle)
{
- case esNone:
- break;
- case esFlatArrow:
- {
- QPointF points[3] = {pos.toPointF(),
- ( pos - lengthVec + widthVec ).toPointF(),
- ( pos - lengthVec - widthVec ).toPointF()};
- painter->setPen( miterPen );
- painter->setBrush( brush );
- painter->drawConvexPolygon( points, 3 );
- painter->setBrush( brushBackup );
- painter->setPen( penBackup );
- break;
- }
- case esSpikeArrow:
- {
- QPointF points[4] = {pos.toPointF(),
- ( pos - lengthVec + widthVec ).toPointF(),
- ( pos - lengthVec * 0.8 ).toPointF(),
- ( pos - lengthVec - widthVec ).toPointF()};
- painter->setPen( miterPen );
- painter->setBrush( brush );
- painter->drawConvexPolygon( points, 4 );
- painter->setBrush( brushBackup );
- painter->setPen( penBackup );
- break;
- }
- case esLineArrow:
- {
- QPointF points[3] = {( pos - lengthVec + widthVec ).toPointF(),
- pos.toPointF(),
- ( pos - lengthVec - widthVec ).toPointF()};
- painter->setPen( miterPen );
- painter->drawPolyline( points, 3 );
- painter->setPen( penBackup );
- break;
- }
- case esDisc:
- {
- painter->setBrush( brush );
- painter->drawEllipse( pos.toPointF(), mWidth * 0.5, mWidth * 0.5 );
- painter->setBrush( brushBackup );
- break;
- }
- case esSquare:
- {
- QCPVector2D widthVecPerp = widthVec.perpendicular();
- QPointF points[4] = {( pos - widthVecPerp + widthVec ).toPointF(),
- ( pos - widthVecPerp - widthVec ).toPointF(),
- ( pos + widthVecPerp - widthVec ).toPointF(),
- ( pos + widthVecPerp + widthVec ).toPointF()};
- painter->setPen( miterPen );
- painter->setBrush( brush );
- painter->drawConvexPolygon( points, 4 );
- painter->setBrush( brushBackup );
- painter->setPen( penBackup );
- break;
- }
- case esDiamond:
- {
- QCPVector2D widthVecPerp = widthVec.perpendicular();
- QPointF points[4] = {( pos - widthVecPerp ).toPointF(),
- ( pos - widthVec ).toPointF(),
- ( pos + widthVecPerp ).toPointF(),
- ( pos + widthVec ).toPointF()};
- painter->setPen( miterPen );
- painter->setBrush( brush );
- painter->drawConvexPolygon( points, 4 );
- painter->setBrush( brushBackup );
- painter->setPen( penBackup );
- break;
- }
- case esBar:
- {
- painter->drawLine( ( pos + widthVec ).toPointF(), ( pos - widthVec ).toPointF() );
- break;
- }
- case esHalfBar:
- {
- painter->drawLine( ( pos + widthVec ).toPointF(), pos.toPointF() );
- break;
- }
- case esSkewedBar:
- {
- if( qFuzzyIsNull( painter->pen().widthF() ) && !painter->modes().testFlag( QCPPainter::pmNonCosmetic ) )
+ case esNone: break;
+ case esFlatArrow:
{
- // if drawing with cosmetic pen (perfectly thin stroke, happens only in vector exports), draw bar exactly on tip of line
- painter->drawLine( ( pos + widthVec + lengthVec * 0.2 * ( mInverted ? -1 : 1 ) ).toPointF(),
- ( pos - widthVec - lengthVec * 0.2 * ( mInverted ? -1 : 1 ) ).toPointF() );
+ QPointF points[3] = {pos.toPointF(),
+ (pos-lengthVec+widthVec).toPointF(),
+ (pos-lengthVec-widthVec).toPointF()
+ };
+ painter->setPen(miterPen);
+ painter->setBrush(brush);
+ painter->drawConvexPolygon(points, 3);
+ painter->setBrush(brushBackup);
+ painter->setPen(penBackup);
+ break;
}
- else
+ case esSpikeArrow:
{
- // if drawing with thick (non-cosmetic) pen, shift bar a little in line direction to prevent line from sticking through bar slightly
- painter->drawLine( ( pos + widthVec + lengthVec * 0.2 * ( mInverted ? -1 : 1 ) + dir.normalized() * qMax( 1.0f, (float)painter->pen().widthF() ) * 0.5f ).toPointF(),
- ( pos - widthVec - lengthVec * 0.2 * ( mInverted ? -1 : 1 ) + dir.normalized() * qMax( 1.0f, (float)painter->pen().widthF() ) * 0.5f ).toPointF() );
+ QPointF points[4] = {pos.toPointF(),
+ (pos-lengthVec+widthVec).toPointF(),
+ (pos-lengthVec*0.8).toPointF(),
+ (pos-lengthVec-widthVec).toPointF()
+ };
+ painter->setPen(miterPen);
+ painter->setBrush(brush);
+ painter->drawConvexPolygon(points, 4);
+ painter->setBrush(brushBackup);
+ painter->setPen(penBackup);
+ break;
+ }
+ case esLineArrow:
+ {
+ QPointF points[3] = {(pos-lengthVec+widthVec).toPointF(),
+ pos.toPointF(),
+ (pos-lengthVec-widthVec).toPointF()
+ };
+ painter->setPen(miterPen);
+ painter->drawPolyline(points, 3);
+ painter->setPen(penBackup);
+ break;
+ }
+ case esDisc:
+ {
+ painter->setBrush(brush);
+ painter->drawEllipse(pos.toPointF(), mWidth*0.5, mWidth*0.5);
+ painter->setBrush(brushBackup);
+ break;
+ }
+ case esSquare:
+ {
+ QCPVector2D widthVecPerp = widthVec.perpendicular();
+ QPointF points[4] = {(pos-widthVecPerp+widthVec).toPointF(),
+ (pos-widthVecPerp-widthVec).toPointF(),
+ (pos+widthVecPerp-widthVec).toPointF(),
+ (pos+widthVecPerp+widthVec).toPointF()
+ };
+ painter->setPen(miterPen);
+ painter->setBrush(brush);
+ painter->drawConvexPolygon(points, 4);
+ painter->setBrush(brushBackup);
+ painter->setPen(penBackup);
+ break;
+ }
+ case esDiamond:
+ {
+ QCPVector2D widthVecPerp = widthVec.perpendicular();
+ QPointF points[4] = {(pos-widthVecPerp).toPointF(),
+ (pos-widthVec).toPointF(),
+ (pos+widthVecPerp).toPointF(),
+ (pos+widthVec).toPointF()
+ };
+ painter->setPen(miterPen);
+ painter->setBrush(brush);
+ painter->drawConvexPolygon(points, 4);
+ painter->setBrush(brushBackup);
+ painter->setPen(penBackup);
+ break;
+ }
+ case esBar:
+ {
+ painter->drawLine((pos+widthVec).toPointF(), (pos-widthVec).toPointF());
+ break;
+ }
+ case esHalfBar:
+ {
+ painter->drawLine((pos+widthVec).toPointF(), pos.toPointF());
+ break;
+ }
+ case esSkewedBar:
+ {
+ if (qFuzzyIsNull(painter->pen().widthF()) && !painter->modes().testFlag(QCPPainter::pmNonCosmetic))
+ {
+ // if drawing with cosmetic pen (perfectly thin stroke, happens only in vector exports), draw bar exactly on tip of line
+ painter->drawLine((pos+widthVec+lengthVec*0.2*(mInverted?-1:1)).toPointF(),
+ (pos-widthVec-lengthVec*0.2*(mInverted?-1:1)).toPointF());
+ } else
+ {
+ // if drawing with thick (non-cosmetic) pen, shift bar a little in line direction to prevent line from sticking through bar slightly
+ painter->drawLine((pos+widthVec+lengthVec*0.2*(mInverted?-1:1)+dir.normalized()*qMax(1.0f, (float)painter->pen().widthF())*0.5f).toPointF(),
+ (pos-widthVec-lengthVec*0.2*(mInverted?-1:1)+dir.normalized()*qMax(1.0f, (float)painter->pen().widthF())*0.5f).toPointF());
+ }
+ break;
}
- break;
- }
}
}
@@ -5408,12 +5416,13 @@ void QCPLineEnding::draw( QCPPainter* painter, const QCPVector2D& pos, const QCP
Draws the line ending. The direction is controlled with the \a angle parameter in radians.
*/
-void QCPLineEnding::draw( QCPPainter* painter, const QCPVector2D& pos, double angle ) const
+void QCPLineEnding::draw(QCPPainter *painter, const QCPVector2D &pos, double angle) const
{
- draw( painter, pos, QCPVector2D( qCos( angle ), qSin( angle ) ) );
+ draw(painter, pos, QCPVector2D(qCos(angle), qSin(angle)));
}
/* end of 'src/lineending.cpp' */
+
/* including file 'src/axis/axisticker.cpp', size 18664 */
/* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */
@@ -5477,20 +5486,23 @@ void QCPLineEnding::draw( QCPPainter* painter, const QCPVector2D& pos, double an
Constructs the ticker and sets reasonable default values. Axis tickers are commonly created
managed by a QSharedPointer, which then can be passed to QCPAxis::setTicker.
*/
-QCPAxisTicker::QCPAxisTicker()
- : mTickStepStrategy( tssReadability ), mTickCount( 5 ), mTickOrigin( 0 )
+QCPAxisTicker::QCPAxisTicker() :
+ mTickStepStrategy(tssReadability),
+ mTickCount(5),
+ mTickOrigin(0)
{
}
QCPAxisTicker::~QCPAxisTicker()
{
+
}
/*!
Sets which strategy the axis ticker follows when choosing the size of the tick step. For the
available strategies, see \ref TickStepStrategy.
*/
-void QCPAxisTicker::setTickStepStrategy( QCPAxisTicker::TickStepStrategy strategy )
+void QCPAxisTicker::setTickStepStrategy(QCPAxisTicker::TickStepStrategy strategy)
{
mTickStepStrategy = strategy;
}
@@ -5503,9 +5515,9 @@ void QCPAxisTicker::setTickStepStrategy( QCPAxisTicker::TickStepStrategy strateg
Whether the readability has priority over meeting the requested \a count can be specified with
\ref setTickStepStrategy.
*/
-void QCPAxisTicker::setTickCount( int count )
+void QCPAxisTicker::setTickCount(int count)
{
- if( count > 0 )
+ if (count > 0)
mTickCount = count;
else
qDebug() << Q_FUNC_INFO << "tick count must be greater than zero:" << count;
@@ -5519,7 +5531,7 @@ void QCPAxisTicker::setTickCount( int count )
step is five. If \a origin is now set to 1 instead, the correspondingly generated ticks would be
{-4, 1, 6, 11, 16,...}.
*/
-void QCPAxisTicker::setTickOrigin( double origin )
+void QCPAxisTicker::setTickOrigin(double origin)
{
mTickOrigin = origin;
}
@@ -5537,30 +5549,29 @@ void QCPAxisTicker::setTickOrigin( double origin )
and are respectively filled with sub tick coordinates, and tick label strings belonging to \a
ticks by index.
*/
-void QCPAxisTicker::generate( const QCPRange& range, const QLocale& locale, QChar formatChar, int precision, QVector& ticks, QVector* subTicks, QVector* tickLabels )
+void QCPAxisTicker::generate(const QCPRange &range, const QLocale &locale, QChar formatChar, int precision, QVector &ticks, QVector *subTicks, QVector *tickLabels)
{
// generate (major) ticks:
- double tickStep = getTickStep( range );
- ticks = createTickVector( tickStep, range );
- trimTicks( range, ticks, true ); // trim ticks to visible range plus one outer tick on each side (incase a subclass createTickVector creates more)
-
+ double tickStep = getTickStep(range);
+ ticks = createTickVector(tickStep, range);
+ trimTicks(range, ticks, true); // trim ticks to visible range plus one outer tick on each side (incase a subclass createTickVector creates more)
+
// generate sub ticks between major ticks:
- if( subTicks )
+ if (subTicks)
{
- if( ticks.size() > 0 )
+ if (ticks.size() > 0)
{
- *subTicks = createSubTickVector( getSubTickCount( tickStep ), ticks );
- trimTicks( range, *subTicks, false );
- }
- else
+ *subTicks = createSubTickVector(getSubTickCount(tickStep), ticks);
+ trimTicks(range, *subTicks, false);
+ } else
*subTicks = QVector();
}
-
+
// finally trim also outliers (no further clipping happens in axis drawing):
- trimTicks( range, ticks, false );
+ trimTicks(range, ticks, false);
// generate labels for visible ticks if requested:
- if( tickLabels )
- *tickLabels = createLabelVector( ticks, locale, formatChar, precision );
+ if (tickLabels)
+ *tickLabels = createLabelVector(ticks, locale, formatChar, precision);
}
/*! \internal
@@ -5573,10 +5584,10 @@ void QCPAxisTicker::generate( const QCPRange& range, const QLocale& locale, QCha
implementation, it should reimplement this method. See \ref cleanMantissa for a possible helper
function.
*/
-double QCPAxisTicker::getTickStep( const QCPRange& range )
+double QCPAxisTicker::getTickStep(const QCPRange &range)
{
- double exactStep = range.size() / (double)( mTickCount + 1e-10 ); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers
- return cleanMantissa( exactStep );
+ double exactStep = range.size()/(double)(mTickCount+1e-10); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers
+ return cleanMantissa(exactStep);
}
/*! \internal
@@ -5586,92 +5597,55 @@ double QCPAxisTicker::getTickStep( const QCPRange& range )
Note that a returned sub tick count of e.g. 4 will split each tick interval into 5 sections.
*/
-int QCPAxisTicker::getSubTickCount( double tickStep )
+int QCPAxisTicker::getSubTickCount(double tickStep)
{
- int result = 1; // default to 1, if no proper value can be found
-
+ int result = 1; // default to 1, if no proper value can be found
+
// separate integer and fractional part of mantissa:
double epsilon = 0.01;
double intPartf;
int intPart;
- double fracPart = modf( getMantissa( tickStep ), &intPartf );
+ double fracPart = modf(getMantissa(tickStep), &intPartf);
intPart = intPartf;
-
+
// handle cases with (almost) integer mantissa:
- if( fracPart < epsilon || 1.0 - fracPart < epsilon )
+ if (fracPart < epsilon || 1.0-fracPart < epsilon)
{
- if( 1.0 - fracPart < epsilon )
+ if (1.0-fracPart < epsilon)
++intPart;
- switch( intPart )
+ switch (intPart)
{
- case 1:
- result = 4;
- break; // 1.0 -> 0.2 substep
- case 2:
- result = 3;
- break; // 2.0 -> 0.5 substep
- case 3:
- result = 2;
- break; // 3.0 -> 1.0 substep
- case 4:
- result = 3;
- break; // 4.0 -> 1.0 substep
- case 5:
- result = 4;
- break; // 5.0 -> 1.0 substep
- case 6:
- result = 2;
- break; // 6.0 -> 2.0 substep
- case 7:
- result = 6;
- break; // 7.0 -> 1.0 substep
- case 8:
- result = 3;
- break; // 8.0 -> 2.0 substep
- case 9:
- result = 2;
- break; // 9.0 -> 3.0 substep
+ case 1: result = 4; break; // 1.0 -> 0.2 substep
+ case 2: result = 3; break; // 2.0 -> 0.5 substep
+ case 3: result = 2; break; // 3.0 -> 1.0 substep
+ case 4: result = 3; break; // 4.0 -> 1.0 substep
+ case 5: result = 4; break; // 5.0 -> 1.0 substep
+ case 6: result = 2; break; // 6.0 -> 2.0 substep
+ case 7: result = 6; break; // 7.0 -> 1.0 substep
+ case 8: result = 3; break; // 8.0 -> 2.0 substep
+ case 9: result = 2; break; // 9.0 -> 3.0 substep
}
- }
- else
+ } else
{
// handle cases with significantly fractional mantissa:
- if( qAbs( fracPart - 0.5 ) < epsilon ) // *.5 mantissa
+ if (qAbs(fracPart-0.5) < epsilon) // *.5 mantissa
{
- switch( intPart )
+ switch (intPart)
{
- case 1:
- result = 2;
- break; // 1.5 -> 0.5 substep
- case 2:
- result = 4;
- break; // 2.5 -> 0.5 substep
- case 3:
- result = 4;
- break; // 3.5 -> 0.7 substep
- case 4:
- result = 2;
- break; // 4.5 -> 1.5 substep
- case 5:
- result = 4;
- break; // 5.5 -> 1.1 substep (won't occur with default getTickStep from here on)
- case 6:
- result = 4;
- break; // 6.5 -> 1.3 substep
- case 7:
- result = 2;
- break; // 7.5 -> 2.5 substep
- case 8:
- result = 4;
- break; // 8.5 -> 1.7 substep
- case 9:
- result = 4;
- break; // 9.5 -> 1.9 substep
+ case 1: result = 2; break; // 1.5 -> 0.5 substep
+ case 2: result = 4; break; // 2.5 -> 0.5 substep
+ case 3: result = 4; break; // 3.5 -> 0.7 substep
+ case 4: result = 2; break; // 4.5 -> 1.5 substep
+ case 5: result = 4; break; // 5.5 -> 1.1 substep (won't occur with default getTickStep from here on)
+ case 6: result = 4; break; // 6.5 -> 1.3 substep
+ case 7: result = 2; break; // 7.5 -> 2.5 substep
+ case 8: result = 4; break; // 8.5 -> 1.7 substep
+ case 9: result = 4; break; // 9.5 -> 1.9 substep
}
}
// if mantissa fraction isn't 0.0 or 0.5, don't bother finding good sub tick marks, leave default
}
-
+
return result;
}
@@ -5686,9 +5660,9 @@ int QCPAxisTicker::getSubTickCount( double tickStep )
be formatted accordingly using multiplication symbol and superscript during rendering of the
label automatically.
*/
-QString QCPAxisTicker::getTickLabel( double tick, const QLocale& locale, QChar formatChar, int precision )
+QString QCPAxisTicker::getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision)
{
- return locale.toString( tick, formatChar.toLatin1(), precision );
+ return locale.toString(tick, formatChar.toLatin1(), precision);
}
/*! \internal
@@ -5700,18 +5674,18 @@ QString QCPAxisTicker::getTickLabel( double tick, const QLocale& locale, QChar f
reimplement this method. Depending on the purpose of the subclass it doesn't necessarily need to
base its result on \a subTickCount or \a ticks.
*/
-QVector QCPAxisTicker::createSubTickVector( int subTickCount, const QVector& ticks )
+QVector QCPAxisTicker::createSubTickVector(int subTickCount, const QVector &ticks)
{
QVector result;
- if( subTickCount <= 0 || ticks.size() < 2 )
+ if (subTickCount <= 0 || ticks.size() < 2)
return result;
-
- result.reserve( ( ticks.size() - 1 ) * subTickCount );
- for( int i = 1; i < ticks.size(); ++i )
+
+ result.reserve((ticks.size()-1)*subTickCount);
+ for (int i=1; i QCPAxisTicker::createSubTickVector( int subTickCount, const QVec
result on \a tickStep, e.g. when the ticks are spaced unequally like in the case of
QCPAxisTickerLog.
*/
-QVector QCPAxisTicker::createTickVector( double tickStep, const QCPRange& range )
+QVector QCPAxisTicker::createTickVector(double tickStep, const QCPRange &range)
{
QVector result;
// Generate tick positions according to tickStep:
- qint64 firstStep = floor( ( range.lower - mTickOrigin ) / tickStep ); // do not use qFloor here, or we'll lose 64 bit precision
- qint64 lastStep = ceil( ( range.upper - mTickOrigin ) / tickStep ); // do not use qCeil here, or we'll lose 64 bit precision
- int tickcount = lastStep - firstStep + 1;
- if( tickcount < 0 )
- tickcount = 0;
- result.resize( tickcount );
- for( int i = 0; i < tickcount; ++i )
- result[i] = mTickOrigin + ( firstStep + i ) * tickStep;
+ qint64 firstStep = floor((range.lower-mTickOrigin)/tickStep); // do not use qFloor here, or we'll lose 64 bit precision
+ qint64 lastStep = ceil((range.upper-mTickOrigin)/tickStep); // do not use qCeil here, or we'll lose 64 bit precision
+ int tickcount = lastStep-firstStep+1;
+ if (tickcount < 0) tickcount = 0;
+ result.resize(tickcount);
+ for (int i=0; i QCPAxisTicker::createTickVector( double tickStep, const QCPRange
It is possible but uncommon for QCPAxisTicker subclasses to reimplement this method, as
reimplementing \ref getTickLabel often achieves the intended result easier.
*/
-QVector QCPAxisTicker::createLabelVector( const QVector& ticks, const QLocale& locale, QChar formatChar, int precision )
+QVector QCPAxisTicker::createLabelVector(const QVector &ticks, const QLocale &locale, QChar formatChar, int precision)
{
QVector result;
- result.reserve( ticks.size() );
- for( int i = 0; i < ticks.size(); ++i )
- result.append( getTickLabel( ticks.at( i ), locale, formatChar, precision ) );
+ result.reserve(ticks.size());
+ for (int i=0; i QCPAxisTicker::createLabelVector( const QVector& ticks,
The passed \a ticks must be sorted in ascending order.
*/
-void QCPAxisTicker::trimTicks( const QCPRange& range, QVector& ticks, bool keepOneOutlier ) const
+void QCPAxisTicker::trimTicks(const QCPRange &range, QVector &ticks, bool keepOneOutlier) const
{
bool lowFound = false;
bool highFound = false;
int lowIndex = 0;
int highIndex = -1;
-
- for( int i = 0; i < ticks.size(); ++i )
+
+ for (int i=0; i < ticks.size(); ++i)
{
- if( ticks.at( i ) >= range.lower )
+ if (ticks.at(i) >= range.lower)
{
lowFound = true;
lowIndex = i;
break;
}
}
- for( int i = ticks.size() - 1; i >= 0; --i )
+ for (int i=ticks.size()-1; i >= 0; --i)
{
- if( ticks.at( i ) <= range.upper )
+ if (ticks.at(i) <= range.upper)
{
highFound = true;
highIndex = i;
break;
}
}
-
- if( highFound && lowFound )
+
+ if (highFound && lowFound)
{
- int trimFront = qMax( 0, lowIndex - ( keepOneOutlier ? 1 : 0 ) );
- int trimBack = qMax( 0, ticks.size() - ( keepOneOutlier ? 2 : 1 ) - highIndex );
- if( trimFront > 0 || trimBack > 0 )
- ticks = ticks.mid( trimFront, ticks.size() - trimFront - trimBack );
- }
- else // all ticks are either all below or all above the range
+ int trimFront = qMax(0, lowIndex-(keepOneOutlier ? 1 : 0));
+ int trimBack = qMax(0, ticks.size()-(keepOneOutlier ? 2 : 1)-highIndex);
+ if (trimFront > 0 || trimBack > 0)
+ ticks = ticks.mid(trimFront, ticks.size()-trimFront-trimBack);
+ } else // all ticks are either all below or all above the range
ticks.clear();
}
@@ -5814,17 +5786,17 @@ void QCPAxisTicker::trimTicks( const QCPRange& range, QVector& ticks, bo
This method assumes \a candidates is not empty and sorted in ascending order.
*/
-double QCPAxisTicker::pickClosest( double target, const QVector& candidates ) const
+double QCPAxisTicker::pickClosest(double target, const QVector &candidates) const
{
- if( candidates.size() == 1 )
+ if (candidates.size() == 1)
return candidates.first();
- QVector::const_iterator it = std::lower_bound( candidates.constBegin(), candidates.constEnd(), target );
- if( it == candidates.constEnd() )
- return *( it - 1 );
- else if( it == candidates.constBegin() )
+ QVector::const_iterator it = std::lower_bound(candidates.constBegin(), candidates.constEnd(), target);
+ if (it == candidates.constEnd())
+ return *(it-1);
+ else if (it == candidates.constBegin())
return *it;
else
- return target - *( it - 1 ) < *it - target ? *( it - 1 ) : *it;
+ return target-*(it-1) < *it-target ? *(it-1) : *it;
}
/*! \internal
@@ -5834,12 +5806,11 @@ double QCPAxisTicker::pickClosest( double target, const QVector& candida
For example, an input of 142.6 will return a mantissa of 1.426 and a magnitude of 100.
*/
-double QCPAxisTicker::getMantissa( double input, double* magnitude ) const
+double QCPAxisTicker::getMantissa(double input, double *magnitude) const
{
- const double mag = qPow( 10.0, qFloor( qLn( input ) / qLn( 10.0 ) ) );
- if( magnitude )
- *magnitude = mag;
- return input / mag;
+ const double mag = qPow(10.0, qFloor(qLn(input)/qLn(10.0)));
+ if (magnitude) *magnitude = mag;
+ return input/mag;
}
/*! \internal
@@ -5848,29 +5819,30 @@ double QCPAxisTicker::getMantissa( double input, double* magnitude ) const
strongly the mantissa is altered, and thus how strong the result deviates from the original \a
input, depends on the current tick step strategy (see \ref setTickStepStrategy).
*/
-double QCPAxisTicker::cleanMantissa( double input ) const
+double QCPAxisTicker::cleanMantissa(double input) const
{
double magnitude;
- const double mantissa = getMantissa( input, &magnitude );
- switch( mTickStepStrategy )
+ const double mantissa = getMantissa(input, &magnitude);
+ switch (mTickStepStrategy)
{
- case tssReadability:
- {
- return pickClosest( mantissa, QVector() << 1.0 << 2.0 << 2.5 << 5.0 << 10.0 ) * magnitude;
- }
- case tssMeetTickCount:
- {
- // this gives effectively a mantissa of 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 8.0, 10.0
- if( mantissa <= 5.0 )
- return (int)( mantissa * 2 ) / 2.0 * magnitude; // round digit after decimal point to 0.5
- else
- return (int)( mantissa / 2.0 ) * 2.0 * magnitude; // round to first digit in multiples of 2
- }
+ case tssReadability:
+ {
+ return pickClosest(mantissa, QVector() << 1.0 << 2.0 << 2.5 << 5.0 << 10.0)*magnitude;
+ }
+ case tssMeetTickCount:
+ {
+ // this gives effectively a mantissa of 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 8.0, 10.0
+ if (mantissa <= 5.0)
+ return (int)(mantissa*2)/2.0*magnitude; // round digit after decimal point to 0.5
+ else
+ return (int)(mantissa/2.0)*2.0*magnitude; // round to first digit in multiples of 2
+ }
}
return input;
}
/* end of 'src/axis/axisticker.cpp' */
+
/* including file 'src/axis/axistickerdatetime.cpp', size 14443 */
/* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */
@@ -5917,10 +5889,12 @@ double QCPAxisTicker::cleanMantissa( double input ) const
Constructs the ticker and sets reasonable default values. Axis tickers are commonly created
managed by a QSharedPointer, which then can be passed to QCPAxis::setTicker.
*/
-QCPAxisTickerDateTime::QCPAxisTickerDateTime()
- : mDateTimeFormat( QLatin1String( "hh:mm:ss\ndd.MM.yy" ) ), mDateTimeSpec( Qt::LocalTime ), mDateStrategy( dsNone )
+QCPAxisTickerDateTime::QCPAxisTickerDateTime() :
+ mDateTimeFormat(QLatin1String("hh:mm:ss\ndd.MM.yy")),
+ mDateTimeSpec(Qt::LocalTime),
+ mDateStrategy(dsNone)
{
- setTickCount( 4 );
+ setTickCount(4);
}
/*!
@@ -5931,7 +5905,7 @@ QCPAxisTickerDateTime::QCPAxisTickerDateTime()
\see setDateTimeSpec
*/
-void QCPAxisTickerDateTime::setDateTimeFormat( const QString& format )
+void QCPAxisTickerDateTime::setDateTimeFormat(const QString &format)
{
mDateTimeFormat = format;
}
@@ -5946,7 +5920,7 @@ void QCPAxisTickerDateTime::setDateTimeFormat( const QString& format )
\see setDateTimeFormat
*/
-void QCPAxisTickerDateTime::setDateTimeSpec( Qt::TimeSpec spec )
+void QCPAxisTickerDateTime::setDateTimeSpec(Qt::TimeSpec spec)
{
mDateTimeSpec = spec;
}
@@ -5960,9 +5934,9 @@ void QCPAxisTickerDateTime::setDateTimeSpec( Qt::TimeSpec spec )
example, If you pass 15. July, 9:45 to this method and the tick interval happens to be one tick
per year, the ticks will end up on 15. July at 9:45 of every year.
*/
-void QCPAxisTickerDateTime::setTickOrigin( double origin )
+void QCPAxisTickerDateTime::setTickOrigin(double origin)
{
- QCPAxisTicker::setTickOrigin( origin );
+ QCPAxisTicker::setTickOrigin(origin);
}
/*!
@@ -5972,9 +5946,9 @@ void QCPAxisTickerDateTime::setTickOrigin( double origin )
example, If you pass 15. July, 9:45 to this method and the tick interval happens to be one tick
per year, the ticks will end up on 15. July at 9:45 of every year.
*/
-void QCPAxisTickerDateTime::setTickOrigin( const QDateTime& origin )
+void QCPAxisTickerDateTime::setTickOrigin(const QDateTime &origin)
{
- setTickOrigin( dateTimeToKey( origin ) );
+ setTickOrigin(dateTimeToKey(origin));
}
/*! \internal
@@ -5990,30 +5964,28 @@ void QCPAxisTickerDateTime::setTickOrigin( const QDateTime& origin )
\seebaseclassmethod
*/
-double QCPAxisTickerDateTime::getTickStep( const QCPRange& range )
+double QCPAxisTickerDateTime::getTickStep(const QCPRange &range)
{
- double result = range.size() / (double)( mTickCount + 1e-10 ); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers
-
+ double result = range.size()/(double)(mTickCount+1e-10); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers
+
mDateStrategy = dsNone;
- if( result < 1 ) // ideal tick step is below 1 second -> use normal clean mantissa algorithm in units of seconds
+ if (result < 1) // ideal tick step is below 1 second -> use normal clean mantissa algorithm in units of seconds
{
- result = cleanMantissa( result );
- }
- else if( result < 86400 * 30.4375 * 12 ) // below a year
+ result = cleanMantissa(result);
+ } else if (result < 86400*30.4375*12) // below a year
{
- result = pickClosest( result, QVector()
- << 1 << 2.5 << 5 << 10 << 15 << 30 << 60 << 2.5 * 60 << 5 * 60 << 10 * 60 << 15 * 60 << 30 * 60 << 60 * 60 // second, minute, hour range
- << 3600 * 2 << 3600 * 3 << 3600 * 6 << 3600 * 12 << 3600 * 24 // hour to day range
- << 86400 * 2 << 86400 * 5 << 86400 * 7 << 86400 * 14 << 86400 * 30.4375 << 86400 * 30.4375 * 2 << 86400 * 30.4375 * 3 << 86400 * 30.4375 * 6 << 86400 * 30.4375 * 12 ); // day, week, month range (avg. days per month includes leap years)
- if( result > 86400 * 30.4375 - 1 ) // month tick intervals or larger
+ result = pickClosest(result, QVector()
+ << 1 << 2.5 << 5 << 10 << 15 << 30 << 60 << 2.5*60 << 5*60 << 10*60 << 15*60 << 30*60 << 60*60 // second, minute, hour range
+ << 3600*2 << 3600*3 << 3600*6 << 3600*12 << 3600*24 // hour to day range
+ << 86400*2 << 86400*5 << 86400*7 << 86400*14 << 86400*30.4375 << 86400*30.4375*2 << 86400*30.4375*3 << 86400*30.4375*6 << 86400*30.4375*12); // day, week, month range (avg. days per month includes leap years)
+ if (result > 86400*30.4375-1) // month tick intervals or larger
mDateStrategy = dsUniformDayInMonth;
- else if( result > 3600 * 24 - 1 ) // day tick intervals or larger
+ else if (result > 3600*24-1) // day tick intervals or larger
mDateStrategy = dsUniformTimeInDay;
- }
- else // more than a year, go back to normal clean mantissa algorithm but in units of years
+ } else // more than a year, go back to normal clean mantissa algorithm but in units of years
{
- const double secondsPerYear = 86400 * 30.4375 * 12; // average including leap years
- result = cleanMantissa( result / secondsPerYear ) * secondsPerYear;
+ const double secondsPerYear = 86400*30.4375*12; // average including leap years
+ result = cleanMantissa(result/secondsPerYear)*secondsPerYear;
mDateStrategy = dsUniformDayInMonth;
}
return result;
@@ -6026,68 +5998,30 @@ double QCPAxisTickerDateTime::getTickStep( const QCPRange& range )
\seebaseclassmethod
*/
-int QCPAxisTickerDateTime::getSubTickCount( double tickStep )
+int QCPAxisTickerDateTime::getSubTickCount(double tickStep)
{
- int result = QCPAxisTicker::getSubTickCount( tickStep );
- switch( qRound( tickStep ) ) // hand chosen subticks for specific minute/hour/day/week/month range (as specified in getTickStep)
+ int result = QCPAxisTicker::getSubTickCount(tickStep);
+ switch (qRound(tickStep)) // hand chosen subticks for specific minute/hour/day/week/month range (as specified in getTickStep)
{
- case 5 * 60:
- result = 4;
- break;
- case 10 * 60:
- result = 1;
- break;
- case 15 * 60:
- result = 2;
- break;
- case 30 * 60:
- result = 1;
- break;
- case 60 * 60:
- result = 3;
- break;
- case 3600 * 2:
- result = 3;
- break;
- case 3600 * 3:
- result = 2;
- break;
- case 3600 * 6:
- result = 1;
- break;
- case 3600 * 12:
- result = 3;
- break;
- case 3600 * 24:
- result = 3;
- break;
- case 86400 * 2:
- result = 1;
- break;
- case 86400 * 5:
- result = 4;
- break;
- case 86400 * 7:
- result = 6;
- break;
- case 86400 * 14:
- result = 1;
- break;
- case(int)( 86400 * 30.4375 + 0.5 ):
- result = 3;
- break;
- case(int)( 86400 * 30.4375 * 2 + 0.5 ):
- result = 1;
- break;
- case(int)( 86400 * 30.4375 * 3 + 0.5 ):
- result = 2;
- break;
- case(int)( 86400 * 30.4375 * 6 + 0.5 ):
- result = 5;
- break;
- case(int)( 86400 * 30.4375 * 12 + 0.5 ):
- result = 3;
- break;
+ case 5*60: result = 4; break;
+ case 10*60: result = 1; break;
+ case 15*60: result = 2; break;
+ case 30*60: result = 1; break;
+ case 60*60: result = 3; break;
+ case 3600*2: result = 3; break;
+ case 3600*3: result = 2; break;
+ case 3600*6: result = 1; break;
+ case 3600*12: result = 3; break;
+ case 3600*24: result = 3; break;
+ case 86400*2: result = 1; break;
+ case 86400*5: result = 4; break;
+ case 86400*7: result = 6; break;
+ case 86400*14: result = 1; break;
+ case (int)(86400*30.4375+0.5): result = 3; break;
+ case (int)(86400*30.4375*2+0.5): result = 1; break;
+ case (int)(86400*30.4375*3+0.5): result = 2; break;
+ case (int)(86400*30.4375*6+0.5): result = 5; break;
+ case (int)(86400*30.4375*12+0.5): result = 3; break;
}
return result;
}
@@ -6099,11 +6033,11 @@ int QCPAxisTickerDateTime::getSubTickCount( double tickStep )
\seebaseclassmethod
*/
-QString QCPAxisTickerDateTime::getTickLabel( double tick, const QLocale& locale, QChar formatChar, int precision )
+QString QCPAxisTickerDateTime::getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision)
{
- Q_UNUSED( precision )
- Q_UNUSED( formatChar )
- return locale.toString( keyToDateTime( tick ).toTimeSpec( mDateTimeSpec ), mDateTimeFormat );
+ Q_UNUSED(precision)
+ Q_UNUSED(formatChar)
+ return locale.toString(keyToDateTime(tick).toTimeSpec(mDateTimeSpec), mDateTimeFormat);
}
/*! \internal
@@ -6113,37 +6047,36 @@ QString QCPAxisTickerDateTime::getTickLabel( double tick, const QLocale& locale,
\seebaseclassmethod
*/
-QVector QCPAxisTickerDateTime::createTickVector( double tickStep, const QCPRange& range )
+QVector QCPAxisTickerDateTime::createTickVector(double tickStep, const QCPRange &range)
{
- QVector result = QCPAxisTicker::createTickVector( tickStep, range );
- if( !result.isEmpty() )
+ QVector result = QCPAxisTicker::createTickVector(tickStep, range);
+ if (!result.isEmpty())
{
- if( mDateStrategy == dsUniformTimeInDay )
+ if (mDateStrategy == dsUniformTimeInDay)
{
- QDateTime uniformDateTime = keyToDateTime( mTickOrigin ); // the time of this datetime will be set for all other ticks, if possible
+ QDateTime uniformDateTime = keyToDateTime(mTickOrigin); // the time of this datetime will be set for all other ticks, if possible
QDateTime tickDateTime;
- for( int i = 0; i < result.size(); ++i )
+ for (int i=0; i 15 ) // with leap years involved, date month may jump backwards or forwards, and needs to be corrected before setting day
- tickDateTime = tickDateTime.addMonths( -1 );
- tickDateTime.setDate( QDate( tickDateTime.date().year(), tickDateTime.date().month(), thisUniformDay ) );
- result[i] = dateTimeToKey( tickDateTime );
+ tickDateTime = keyToDateTime(result.at(i));
+ tickDateTime.setTime(uniformDateTime.time());
+ int thisUniformDay = uniformDateTime.date().day() <= tickDateTime.date().daysInMonth() ? uniformDateTime.date().day() : tickDateTime.date().daysInMonth(); // don't exceed month (e.g. try to set day 31 in February)
+ if (thisUniformDay-tickDateTime.date().day() < -15) // with leap years involved, date month may jump backwards or forwards, and needs to be corrected before setting day
+ tickDateTime = tickDateTime.addMonths(1);
+ else if (thisUniformDay-tickDateTime.date().day() > 15) // with leap years involved, date month may jump backwards or forwards, and needs to be corrected before setting day
+ tickDateTime = tickDateTime.addMonths(-1);
+ tickDateTime.setDate(QDate(tickDateTime.date().year(), tickDateTime.date().month(), thisUniformDay));
+ result[i] = dateTimeToKey(tickDateTime);
}
}
}
@@ -6159,13 +6092,13 @@ QVector QCPAxisTickerDateTime::createTickVector( double tickStep, const
\see dateTimeToKey
*/
-QDateTime QCPAxisTickerDateTime::keyToDateTime( double key )
+QDateTime QCPAxisTickerDateTime::keyToDateTime(double key)
{
-#if QT_VERSION < QT_VERSION_CHECK( 4, 7, 0 )
- return QDateTime::fromTime_t( key ).addMSecs( ( key - (qint64)key ) * 1000 );
-#else
- return QDateTime::fromMSecsSinceEpoch( key * 1000.0 );
-#endif
+# if QT_VERSION < QT_VERSION_CHECK(4, 7, 0)
+ return QDateTime::fromTime_t(key).addMSecs((key-(qint64)key)*1000);
+# else
+ return QDateTime::fromMSecsSinceEpoch(key*1000.0);
+# endif
}
/*! \overload
@@ -6179,13 +6112,13 @@ QDateTime QCPAxisTickerDateTime::keyToDateTime( double key )
\see keyToDateTime
*/
-double QCPAxisTickerDateTime::dateTimeToKey( const QDateTime dateTime )
+double QCPAxisTickerDateTime::dateTimeToKey(const QDateTime dateTime)
{
-#if QT_VERSION < QT_VERSION_CHECK( 4, 7, 0 )
- return dateTime.toTime_t() + dateTime.time().msec() / 1000.0;
-#else
- return dateTime.toMSecsSinceEpoch() / 1000.0;
-#endif
+# if QT_VERSION < QT_VERSION_CHECK(4, 7, 0)
+ return dateTime.toTime_t()+dateTime.time().msec()/1000.0;
+# else
+ return dateTime.toMSecsSinceEpoch()/1000.0;
+# endif
}
/*! \overload
@@ -6196,16 +6129,17 @@ double QCPAxisTickerDateTime::dateTimeToKey( const QDateTime dateTime )
\see keyToDateTime
*/
-double QCPAxisTickerDateTime::dateTimeToKey( const QDate date )
+double QCPAxisTickerDateTime::dateTimeToKey(const QDate date)
{
-#if QT_VERSION < QT_VERSION_CHECK( 4, 7, 0 )
- return QDateTime( date ).toTime_t();
-#else
- return QDateTime( date ).toMSecsSinceEpoch() / 1000.0;
-#endif
+# if QT_VERSION < QT_VERSION_CHECK(4, 7, 0)
+ return QDateTime(date).toTime_t();
+# else
+ return QDateTime(date).toMSecsSinceEpoch()/1000.0;
+# endif
}
/* end of 'src/axis/axistickerdatetime.cpp' */
+
/* including file 'src/axis/axistickertime.cpp', size 11747 */
/* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */
@@ -6252,21 +6186,23 @@ double QCPAxisTickerDateTime::dateTimeToKey( const QDate date )
Constructs the ticker and sets reasonable default values. Axis tickers are commonly created
managed by a QSharedPointer, which then can be passed to QCPAxis::setTicker.
*/
-QCPAxisTickerTime::QCPAxisTickerTime()
- : mTimeFormat( QLatin1String( "%h:%m:%s" ) ), mSmallestUnit( tuSeconds ), mBiggestUnit( tuHours )
+QCPAxisTickerTime::QCPAxisTickerTime() :
+ mTimeFormat(QLatin1String("%h:%m:%s")),
+ mSmallestUnit(tuSeconds),
+ mBiggestUnit(tuHours)
{
- setTickCount( 4 );
+ setTickCount(4);
mFieldWidth[tuMilliseconds] = 3;
mFieldWidth[tuSeconds] = 2;
mFieldWidth[tuMinutes] = 2;
mFieldWidth[tuHours] = 2;
mFieldWidth[tuDays] = 1;
-
- mFormatPattern[tuMilliseconds] = QLatin1String( "%z" );
- mFormatPattern[tuSeconds] = QLatin1String( "%s" );
- mFormatPattern[tuMinutes] = QLatin1String( "%m" );
- mFormatPattern[tuHours] = QLatin1String( "%h" );
- mFormatPattern[tuDays] = QLatin1String( "%d" );
+
+ mFormatPattern[tuMilliseconds] = QLatin1String("%z");
+ mFormatPattern[tuSeconds] = QLatin1String("%s");
+ mFormatPattern[tuMinutes] = QLatin1String("%m");
+ mFormatPattern[tuHours] = QLatin1String("%h");
+ mFormatPattern[tuDays] = QLatin1String("%d");
}
/*!
@@ -6287,21 +6223,21 @@ QCPAxisTickerTime::QCPAxisTickerTime()
other hand %%h is available, the minutes will wrap around to zero after 59 and the time will
carry to the hour digit.
*/
-void QCPAxisTickerTime::setTimeFormat( const QString& format )
+void QCPAxisTickerTime::setTimeFormat(const QString &format)
{
mTimeFormat = format;
-
+
// determine smallest and biggest unit in format, to optimize unit replacement and allow biggest
// unit to consume remaining time of a tick value and grow beyond its modulo (e.g. min > 59)
mSmallestUnit = tuMilliseconds;
mBiggestUnit = tuMilliseconds;
bool hasSmallest = false;
- for( int i = tuMilliseconds; i <= tuDays; ++i )
+ for (int i = tuMilliseconds; i <= tuDays; ++i)
{
- TimeUnit unit = static_cast( i );
- if( mTimeFormat.contains( mFormatPattern.value( unit ) ) )
+ TimeUnit unit = static_cast(i);
+ if (mTimeFormat.contains(mFormatPattern.value(unit)))
{
- if( !hasSmallest )
+ if (!hasSmallest)
{
mSmallestUnit = unit;
hasSmallest = true;
@@ -6318,9 +6254,9 @@ void QCPAxisTickerTime::setTimeFormat( const QString& format )
\see setTimeFormat
*/
-void QCPAxisTickerTime::setFieldWidth( QCPAxisTickerTime::TimeUnit unit, int width )
+void QCPAxisTickerTime::setFieldWidth(QCPAxisTickerTime::TimeUnit unit, int width)
{
- mFieldWidth[unit] = qMax( width, 1 );
+ mFieldWidth[unit] = qMax(width, 1);
}
/*! \internal
@@ -6332,49 +6268,47 @@ void QCPAxisTickerTime::setFieldWidth( QCPAxisTickerTime::TimeUnit unit, int wid
\seebaseclassmethod
*/
-double QCPAxisTickerTime::getTickStep( const QCPRange& range )
+double QCPAxisTickerTime::getTickStep(const QCPRange &range)
{
- double result = range.size() / (double)( mTickCount + 1e-10 ); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers
-
- if( result < 1 ) // ideal tick step is below 1 second -> use normal clean mantissa algorithm in units of seconds
+ double result = range.size()/(double)(mTickCount+1e-10); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers
+
+ if (result < 1) // ideal tick step is below 1 second -> use normal clean mantissa algorithm in units of seconds
{
- if( mSmallestUnit == tuMilliseconds )
- result = qMax( cleanMantissa( result ), 0.001 ); // smallest tick step is 1 millisecond
- else // have no milliseconds available in format, so stick with 1 second tickstep
+ if (mSmallestUnit == tuMilliseconds)
+ result = qMax(cleanMantissa(result), 0.001); // smallest tick step is 1 millisecond
+ else // have no milliseconds available in format, so stick with 1 second tickstep
result = 1.0;
- }
- else if( result < 3600 * 24 ) // below a day
+ } else if (result < 3600*24) // below a day
{
// the filling of availableSteps seems a bit contorted but it fills in a sorted fashion and thus saves a post-fill sorting run
QVector availableSteps;
// seconds range:
- if( mSmallestUnit <= tuSeconds )
+ if (mSmallestUnit <= tuSeconds)
availableSteps << 1;
- if( mSmallestUnit == tuMilliseconds )
- availableSteps << 2.5; // only allow half second steps if milliseconds are there to display it
- else if( mSmallestUnit == tuSeconds )
+ if (mSmallestUnit == tuMilliseconds)
+ availableSteps << 2.5; // only allow half second steps if milliseconds are there to display it
+ else if (mSmallestUnit == tuSeconds)
availableSteps << 2;
- if( mSmallestUnit <= tuSeconds )
+ if (mSmallestUnit <= tuSeconds)
availableSteps << 5 << 10 << 15 << 30;
// minutes range:
- if( mSmallestUnit <= tuMinutes )
- availableSteps << 1 * 60;
- if( mSmallestUnit <= tuSeconds )
- availableSteps << 2.5 * 60; // only allow half minute steps if seconds are there to display it
- else if( mSmallestUnit == tuMinutes )
- availableSteps << 2 * 60;
- if( mSmallestUnit <= tuMinutes )
- availableSteps << 5 * 60 << 10 * 60 << 15 * 60 << 30 * 60;
+ if (mSmallestUnit <= tuMinutes)
+ availableSteps << 1*60;
+ if (mSmallestUnit <= tuSeconds)
+ availableSteps << 2.5*60; // only allow half minute steps if seconds are there to display it
+ else if (mSmallestUnit == tuMinutes)
+ availableSteps << 2*60;
+ if (mSmallestUnit <= tuMinutes)
+ availableSteps << 5*60 << 10*60 << 15*60 << 30*60;
// hours range:
- if( mSmallestUnit <= tuHours )
- availableSteps << 1 * 3600 << 2 * 3600 << 3 * 3600 << 6 * 3600 << 12 * 3600 << 24 * 3600;
+ if (mSmallestUnit <= tuHours)
+ availableSteps << 1*3600 << 2*3600 << 3*3600 << 6*3600 << 12*3600 << 24*3600;
// pick available step that is most appropriate to approximate ideal step:
- result = pickClosest( result, availableSteps );
- }
- else // more than a day, go back to normal clean mantissa algorithm but in units of days
+ result = pickClosest(result, availableSteps);
+ } else // more than a day, go back to normal clean mantissa algorithm but in units of days
{
- const double secondsPerDay = 3600 * 24;
- result = cleanMantissa( result / secondsPerDay ) * secondsPerDay;
+ const double secondsPerDay = 3600*24;
+ result = cleanMantissa(result/secondsPerDay)*secondsPerDay;
}
return result;
}
@@ -6385,41 +6319,21 @@ double QCPAxisTickerTime::getTickStep( const QCPRange& range )
\seebaseclassmethod
*/
-int QCPAxisTickerTime::getSubTickCount( double tickStep )
+int QCPAxisTickerTime::getSubTickCount(double tickStep)
{
- int result = QCPAxisTicker::getSubTickCount( tickStep );
- switch( qRound( tickStep ) ) // hand chosen subticks for specific minute/hour/day range (as specified in getTickStep)
+ int result = QCPAxisTicker::getSubTickCount(tickStep);
+ switch (qRound(tickStep)) // hand chosen subticks for specific minute/hour/day range (as specified in getTickStep)
{
- case 5 * 60:
- result = 4;
- break;
- case 10 * 60:
- result = 1;
- break;
- case 15 * 60:
- result = 2;
- break;
- case 30 * 60:
- result = 1;
- break;
- case 60 * 60:
- result = 3;
- break;
- case 3600 * 2:
- result = 3;
- break;
- case 3600 * 3:
- result = 2;
- break;
- case 3600 * 6:
- result = 1;
- break;
- case 3600 * 12:
- result = 3;
- break;
- case 3600 * 24:
- result = 3;
- break;
+ case 5*60: result = 4; break;
+ case 10*60: result = 1; break;
+ case 15*60: result = 2; break;
+ case 30*60: result = 1; break;
+ case 60*60: result = 3; break;
+ case 3600*2: result = 3; break;
+ case 3600*3: result = 2; break;
+ case 3600*6: result = 1; break;
+ case 3600*12: result = 3; break;
+ case 3600*24: result = 3; break;
}
return result;
}
@@ -6431,32 +6345,31 @@ int QCPAxisTickerTime::getSubTickCount( double tickStep )
\seebaseclassmethod
*/
-QString QCPAxisTickerTime::getTickLabel( double tick, const QLocale& locale, QChar formatChar, int precision )
+QString QCPAxisTickerTime::getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision)
{
- Q_UNUSED( precision )
- Q_UNUSED( formatChar )
- Q_UNUSED( locale )
+ Q_UNUSED(precision)
+ Q_UNUSED(formatChar)
+ Q_UNUSED(locale)
bool negative = tick < 0;
- if( negative )
- tick *= -1;
- double values[tuDays + 1]; // contains the msec/sec/min/... value with its respective modulo (e.g. minute 0..59)
- double restValues[tuDays + 1]; // contains the msec/sec/min/... value as if it's the largest available unit and thus consumes the remaining time
-
- restValues[tuMilliseconds] = tick * 1000;
- values[tuMilliseconds] = modf( restValues[tuMilliseconds] / 1000, &restValues[tuSeconds] ) * 1000;
- values[tuSeconds] = modf( restValues[tuSeconds] / 60, &restValues[tuMinutes] ) * 60;
- values[tuMinutes] = modf( restValues[tuMinutes] / 60, &restValues[tuHours] ) * 60;
- values[tuHours] = modf( restValues[tuHours] / 24, &restValues[tuDays] ) * 24;
+ if (negative) tick *= -1;
+ double values[tuDays+1]; // contains the msec/sec/min/... value with its respective modulo (e.g. minute 0..59)
+ double restValues[tuDays+1]; // contains the msec/sec/min/... value as if it's the largest available unit and thus consumes the remaining time
+
+ restValues[tuMilliseconds] = tick*1000;
+ values[tuMilliseconds] = modf(restValues[tuMilliseconds]/1000, &restValues[tuSeconds])*1000;
+ values[tuSeconds] = modf(restValues[tuSeconds]/60, &restValues[tuMinutes])*60;
+ values[tuMinutes] = modf(restValues[tuMinutes]/60, &restValues[tuHours])*60;
+ values[tuHours] = modf(restValues[tuHours]/24, &restValues[tuDays])*24;
// no need to set values[tuDays] because days are always a rest value (there is no higher unit so it consumes all remaining time)
-
+
QString result = mTimeFormat;
- for( int i = mSmallestUnit; i <= mBiggestUnit; ++i )
+ for (int i = mSmallestUnit; i <= mBiggestUnit; ++i)
{
- TimeUnit iUnit = static_cast( i );
- replaceUnit( result, iUnit, qRound( iUnit == mBiggestUnit ? restValues[iUnit] : values[iUnit] ) );
+ TimeUnit iUnit = static_cast(i);
+ replaceUnit(result, iUnit, qRound(iUnit == mBiggestUnit ? restValues[iUnit] : values[iUnit]));
}
- if( negative )
- result.prepend( QLatin1Char( '-' ) );
+ if (negative)
+ result.prepend(QLatin1Char('-'));
return result;
}
@@ -6465,16 +6378,17 @@ QString QCPAxisTickerTime::getTickLabel( double tick, const QLocale& locale, QCh
Replaces all occurrences of the format pattern belonging to \a unit in \a text with the specified
\a value, using the field width as specified with \ref setFieldWidth for the \a unit.
*/
-void QCPAxisTickerTime::replaceUnit( QString& text, QCPAxisTickerTime::TimeUnit unit, int value ) const
+void QCPAxisTickerTime::replaceUnit(QString &text, QCPAxisTickerTime::TimeUnit unit, int value) const
{
- QString valueStr = QString::number( value );
- while( valueStr.size() < mFieldWidth.value( unit ) )
- valueStr.prepend( QLatin1Char( '0' ) );
-
- text.replace( mFormatPattern.value( unit ), valueStr );
+ QString valueStr = QString::number(value);
+ while (valueStr.size() < mFieldWidth.value(unit))
+ valueStr.prepend(QLatin1Char('0'));
+
+ text.replace(mFormatPattern.value(unit), valueStr);
}
/* end of 'src/axis/axistickertime.cpp' */
+
/* including file 'src/axis/axistickerfixed.cpp', size 5583 */
/* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */
@@ -6505,8 +6419,9 @@ void QCPAxisTickerTime::replaceUnit( QString& text, QCPAxisTickerTime::TimeUnit
Constructs the ticker and sets reasonable default values. Axis tickers are commonly created
managed by a QSharedPointer, which then can be passed to QCPAxis::setTicker.
*/
-QCPAxisTickerFixed::QCPAxisTickerFixed()
- : mTickStep( 1.0 ), mScaleStrategy( ssNone )
+QCPAxisTickerFixed::QCPAxisTickerFixed() :
+ mTickStep(1.0),
+ mScaleStrategy(ssNone)
{
}
@@ -6519,9 +6434,9 @@ QCPAxisTickerFixed::QCPAxisTickerFixed()
step. This will enable the ticker to reduce the number of ticks to a reasonable amount (see \ref
setTickCount).
*/
-void QCPAxisTickerFixed::setTickStep( double step )
+void QCPAxisTickerFixed::setTickStep(double step)
{
- if( step > 0 )
+ if (step > 0)
mTickStep = step;
else
qDebug() << Q_FUNC_INFO << "tick step must be greater than zero:" << step;
@@ -6534,7 +6449,7 @@ void QCPAxisTickerFixed::setTickStep( double step )
The default strategy is \ref ssNone, which means the tick step is absolutely fixed.
*/
-void QCPAxisTickerFixed::setScaleStrategy( QCPAxisTickerFixed::ScaleStrategy strategy )
+void QCPAxisTickerFixed::setScaleStrategy(QCPAxisTickerFixed::ScaleStrategy strategy)
{
mScaleStrategy = strategy;
}
@@ -6549,32 +6464,33 @@ void QCPAxisTickerFixed::setScaleStrategy( QCPAxisTickerFixed::ScaleStrategy str
\seebaseclassmethod
*/
-double QCPAxisTickerFixed::getTickStep( const QCPRange& range )
+double QCPAxisTickerFixed::getTickStep(const QCPRange &range)
{
- switch( mScaleStrategy )
+ switch (mScaleStrategy)
{
- case ssNone:
- {
- return mTickStep;
- }
- case ssMultiples:
- {
- double exactStep = range.size() / (double)( mTickCount + 1e-10 ); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers
- if( exactStep < mTickStep )
+ case ssNone:
+ {
return mTickStep;
- else
- return ( qint64 )( cleanMantissa( exactStep / mTickStep ) + 0.5 ) * mTickStep;
- }
- case ssPowers:
- {
- double exactStep = range.size() / (double)( mTickCount + 1e-10 ); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers
- return qPow( mTickStep, (int)( qLn( exactStep ) / qLn( mTickStep ) + 0.5 ) );
- }
+ }
+ case ssMultiples:
+ {
+ double exactStep = range.size()/(double)(mTickCount+1e-10); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers
+ if (exactStep < mTickStep)
+ return mTickStep;
+ else
+ return (qint64)(cleanMantissa(exactStep/mTickStep)+0.5)*mTickStep;
+ }
+ case ssPowers:
+ {
+ double exactStep = range.size()/(double)(mTickCount+1e-10); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers
+ return qPow(mTickStep, (int)(qLn(exactStep)/qLn(mTickStep)+0.5));
+ }
}
return mTickStep;
}
/* end of 'src/axis/axistickerfixed.cpp' */
+
/* including file 'src/axis/axistickertext.cpp', size 8653 */
/* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */
@@ -6618,8 +6534,8 @@ double QCPAxisTickerFixed::getTickStep( const QCPRange& range )
Constructs the ticker and sets reasonable default values. Axis tickers are commonly created
managed by a QSharedPointer, which then can be passed to QCPAxis::setTicker.
*/
-QCPAxisTickerText::QCPAxisTickerText()
- : mSubTickCount( 0 )
+QCPAxisTickerText::QCPAxisTickerText() :
+ mSubTickCount(0)
{
}
@@ -6633,7 +6549,7 @@ QCPAxisTickerText::QCPAxisTickerText()
\see addTicks, addTick, clear
*/
-void QCPAxisTickerText::setTicks( const QMap& ticks )
+void QCPAxisTickerText::setTicks(const QMap &ticks)
{
mTicks = ticks;
}
@@ -6646,10 +6562,10 @@ void QCPAxisTickerText::setTicks( const QMap& ticks )
\see addTicks, addTick, clear
*/
-void QCPAxisTickerText::setTicks( const QVector& positions, const QVector labels )
+void QCPAxisTickerText::setTicks(const QVector &positions, const QVector labels)
{
clear();
- addTicks( positions, labels );
+ addTicks(positions, labels);
}
/*!
@@ -6657,9 +6573,9 @@ void QCPAxisTickerText::setTicks( const QVector& positions, const QVecto
automatic sub tick count calculation. So if sub ticks are needed, they must be configured with this
method.
*/
-void QCPAxisTickerText::setSubTickCount( int subTicks )
+void QCPAxisTickerText::setSubTickCount(int subTicks)
{
- if( subTicks >= 0 )
+ if (subTicks >= 0)
mSubTickCount = subTicks;
else
qDebug() << Q_FUNC_INFO << "sub tick count can't be negative:" << subTicks;
@@ -6684,9 +6600,9 @@ void QCPAxisTickerText::clear()
\see addTicks, setTicks, clear
*/
-void QCPAxisTickerText::addTick( double position, QString label )
+void QCPAxisTickerText::addTick(double position, QString label)
{
- mTicks.insert( position, label );
+ mTicks.insert(position, label);
}
/*! \overload
@@ -6699,9 +6615,9 @@ void QCPAxisTickerText::addTick( double position, QString label )
\see addTick, setTicks, clear
*/
-void QCPAxisTickerText::addTicks( const QMap& ticks )
+void QCPAxisTickerText::addTicks(const QMap &ticks)
{
- mTicks.unite( ticks );
+ mTicks.unite(ticks);
}
/*! \overload
@@ -6715,13 +6631,13 @@ void QCPAxisTickerText::addTicks( const QMap& ticks )
\see addTick, setTicks, clear
*/
-void QCPAxisTickerText::addTicks( const QVector& positions, const QVector& labels )
+void QCPAxisTickerText::addTicks(const QVector &positions, const QVector &labels)
{
- if( positions.size() != labels.size() )
+ if (positions.size() != labels.size())
qDebug() << Q_FUNC_INFO << "passed unequal length vectors for positions and labels:" << positions.size() << labels.size();
- int n = qMin( positions.size(), labels.size() );
- for( int i = 0; i < n; ++i )
- mTicks.insert( positions.at( i ), labels.at( i ) );
+ int n = qMin(positions.size(), labels.size());
+ for (int i=0; i& positions, const QVecto
\seebaseclassmethod
*/
-double QCPAxisTickerText::getTickStep( const QCPRange& range )
+double QCPAxisTickerText::getTickStep(const QCPRange &range)
{
// text axis ticker has manual tick positions, so doesn't need this method
- Q_UNUSED( range )
+ Q_UNUSED(range)
return 1.0;
}
@@ -6741,9 +6657,9 @@ double QCPAxisTickerText::getTickStep( const QCPRange& range )
\seebaseclassmethod
*/
-int QCPAxisTickerText::getSubTickCount( double tickStep )
+int QCPAxisTickerText::getSubTickCount(double tickStep)
{
- Q_UNUSED( tickStep )
+ Q_UNUSED(tickStep)
return mSubTickCount;
}
@@ -6753,12 +6669,12 @@ int QCPAxisTickerText::getSubTickCount( double tickStep )
\seebaseclassmethod
*/
-QString QCPAxisTickerText::getTickLabel( double tick, const QLocale& locale, QChar formatChar, int precision )
+QString QCPAxisTickerText::getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision)
{
- Q_UNUSED( locale )
- Q_UNUSED( formatChar )
- Q_UNUSED( precision )
- return mTicks.value( tick );
+ Q_UNUSED(locale)
+ Q_UNUSED(formatChar)
+ Q_UNUSED(precision)
+ return mTicks.value(tick);
}
/*!
@@ -6768,27 +6684,26 @@ QString QCPAxisTickerText::getTickLabel( double tick, const QLocale& locale, QCh
\seebaseclassmethod
*/
-QVector QCPAxisTickerText::createTickVector( double tickStep, const QCPRange& range )
+QVector QCPAxisTickerText::createTickVector(double tickStep, const QCPRange &range)
{
- Q_UNUSED( tickStep )
+ Q_UNUSED(tickStep)
QVector result;
- if( mTicks.isEmpty() )
+ if (mTicks.isEmpty())
return result;
-
- QMap::const_iterator start = mTicks.lowerBound( range.lower );
- QMap::const_iterator end = mTicks.upperBound( range.upper );
+
+ QMap::const_iterator start = mTicks.lowerBound(range.lower);
+ QMap::const_iterator end = mTicks.upperBound(range.upper);
// this method should try to give one tick outside of range so proper subticks can be generated:
- if( start != mTicks.constBegin() )
- --start;
- if( end != mTicks.constEnd() )
- ++end;
- for( QMap::const_iterator it = start; it != end; ++it )
- result.append( it.key() );
-
+ if (start != mTicks.constBegin()) --start;
+ if (end != mTicks.constEnd()) ++end;
+ for (QMap::const_iterator it = start; it != end; ++it)
+ result.append(it.key());
+
return result;
}
/* end of 'src/axis/axistickertext.cpp' */
+
/* including file 'src/axis/axistickerpi.cpp', size 11170 */
/* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */
@@ -6815,10 +6730,14 @@ QVector QCPAxisTickerText::createTickVector( double tickStep, const QCPR
Constructs the ticker and sets reasonable default values. Axis tickers are commonly created
managed by a QSharedPointer, which then can be passed to QCPAxis::setTicker.
*/
-QCPAxisTickerPi::QCPAxisTickerPi()
- : mPiSymbol( QLatin1String( " " ) + QChar( 0x03C0 ) ), mPiValue( M_PI ), mPeriodicity( 0 ), mFractionStyle( fsUnicodeFractions ), mPiTickStep( 0 )
+QCPAxisTickerPi::QCPAxisTickerPi() :
+ mPiSymbol(QLatin1String(" ")+QChar(0x03C0)),
+ mPiValue(M_PI),
+ mPeriodicity(0),
+ mFractionStyle(fsUnicodeFractions),
+ mPiTickStep(0)
{
- setTickCount( 4 );
+ setTickCount(4);
}
/*!
@@ -6828,7 +6747,7 @@ QCPAxisTickerPi::QCPAxisTickerPi()
If a space shall appear between the number and the symbol, make sure the space is contained in \a
symbol.
*/
-void QCPAxisTickerPi::setPiSymbol( QString symbol )
+void QCPAxisTickerPi::setPiSymbol(QString symbol)
{
mPiSymbol = symbol;
}
@@ -6839,7 +6758,7 @@ void QCPAxisTickerPi::setPiSymbol( QString symbol )
This will be used to place the appropriate fractions of the symbol at the respective axis
coordinates.
*/
-void QCPAxisTickerPi::setPiValue( double pi )
+void QCPAxisTickerPi::setPiValue(double pi)
{
mPiValue = pi;
}
@@ -6852,16 +6771,16 @@ void QCPAxisTickerPi::setPiValue( double pi )
For example, an axis that identifies 0 with 2pi would set \a multiplesOfPi to two.
*/
-void QCPAxisTickerPi::setPeriodicity( int multiplesOfPi )
+void QCPAxisTickerPi::setPeriodicity(int multiplesOfPi)
{
- mPeriodicity = qAbs( multiplesOfPi );
+ mPeriodicity = qAbs(multiplesOfPi);
}
/*!
Sets how the numerical/fractional part preceding the symbolic constant is displayed in tick
labels. See \ref FractionStyle for the various options.
*/
-void QCPAxisTickerPi::setFractionStyle( QCPAxisTickerPi::FractionStyle style )
+void QCPAxisTickerPi::setFractionStyle(QCPAxisTickerPi::FractionStyle style)
{
mFractionStyle = style;
}
@@ -6874,11 +6793,11 @@ void QCPAxisTickerPi::setFractionStyle( QCPAxisTickerPi::FractionStyle style )
\seebaseclassmethod
*/
-double QCPAxisTickerPi::getTickStep( const QCPRange& range )
+double QCPAxisTickerPi::getTickStep(const QCPRange &range)
{
- mPiTickStep = range.size() / mPiValue / (double)( mTickCount + 1e-10 ); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers
- mPiTickStep = cleanMantissa( mPiTickStep );
- return mPiTickStep * mPiValue;
+ mPiTickStep = range.size()/mPiValue/(double)(mTickCount+1e-10); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers
+ mPiTickStep = cleanMantissa(mPiTickStep);
+ return mPiTickStep*mPiValue;
}
/*! \internal
@@ -6889,9 +6808,9 @@ double QCPAxisTickerPi::getTickStep( const QCPRange& range )
\seebaseclassmethod
*/
-int QCPAxisTickerPi::getSubTickCount( double tickStep )
+int QCPAxisTickerPi::getSubTickCount(double tickStep)
{
- return QCPAxisTicker::getSubTickCount( tickStep / mPiValue );
+ return QCPAxisTicker::getSubTickCount(tickStep/mPiValue);
}
/*! \internal
@@ -6902,33 +6821,32 @@ int QCPAxisTickerPi::getSubTickCount( double tickStep )
\seebaseclassmethod
*/
-QString QCPAxisTickerPi::getTickLabel( double tick, const QLocale& locale, QChar formatChar, int precision )
+QString QCPAxisTickerPi::getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision)
{
- double tickInPis = tick / mPiValue;
- if( mPeriodicity > 0 )
- tickInPis = fmod( tickInPis, mPeriodicity );
-
- if( mFractionStyle != fsFloatingPoint && mPiTickStep > 0.09 && mPiTickStep < 50 )
+ double tickInPis = tick/mPiValue;
+ if (mPeriodicity > 0)
+ tickInPis = fmod(tickInPis, mPeriodicity);
+
+ if (mFractionStyle != fsFloatingPoint && mPiTickStep > 0.09 && mPiTickStep < 50)
{
// simply construct fraction from decimal like 1.234 -> 1234/1000 and then simplify fraction, smaller digits are irrelevant due to mPiTickStep conditional above
int denominator = 1000;
- int numerator = qRound( tickInPis * denominator );
- simplifyFraction( numerator, denominator );
- if( qAbs( numerator ) == 1 && denominator == 1 )
- return ( numerator < 0 ? QLatin1String( "-" ) : QLatin1String( "" ) ) + mPiSymbol.trimmed();
- else if( numerator == 0 )
- return QLatin1String( "0" );
+ int numerator = qRound(tickInPis*denominator);
+ simplifyFraction(numerator, denominator);
+ if (qAbs(numerator) == 1 && denominator == 1)
+ return (numerator < 0 ? QLatin1String("-") : QLatin1String("")) + mPiSymbol.trimmed();
+ else if (numerator == 0)
+ return QLatin1String("0");
else
- return fractionToString( numerator, denominator ) + mPiSymbol;
- }
- else
+ return fractionToString(numerator, denominator) + mPiSymbol;
+ } else
{
- if( qFuzzyIsNull( tickInPis ) )
- return QLatin1String( "0" );
- else if( qFuzzyCompare( qAbs( tickInPis ), 1.0 ) )
- return ( tickInPis < 0 ? QLatin1String( "-" ) : QLatin1String( "" ) ) + mPiSymbol.trimmed();
+ if (qFuzzyIsNull(tickInPis))
+ return QLatin1String("0");
+ else if (qFuzzyCompare(qAbs(tickInPis), 1.0))
+ return (tickInPis < 0 ? QLatin1String("-") : QLatin1String("")) + mPiSymbol.trimmed();
else
- return QCPAxisTicker::getTickLabel( tickInPis, locale, formatChar, precision ) + mPiSymbol;
+ return QCPAxisTicker::getTickLabel(tickInPis, locale, formatChar, precision) + mPiSymbol;
}
}
@@ -6938,14 +6856,14 @@ QString QCPAxisTickerPi::getTickLabel( double tick, const QLocale& locale, QChar
the fraction is in irreducible form, i.e. numerator and denominator don't share any common
factors which could be cancelled.
*/
-void QCPAxisTickerPi::simplifyFraction( int& numerator, int& denominator ) const
+void QCPAxisTickerPi::simplifyFraction(int &numerator, int &denominator) const
{
- if( numerator == 0 || denominator == 0 )
+ if (numerator == 0 || denominator == 0)
return;
-
+
int num = numerator;
int denom = denominator;
- while( denom != 0 ) // euclidean gcd algorithm
+ while (denom != 0) // euclidean gcd algorithm
{
int oldDenom = denom;
denom = num % denom;
@@ -6965,50 +6883,47 @@ void QCPAxisTickerPi::simplifyFraction( int& numerator, int& denominator ) const
simplifies the passed fraction to an irreducible form using \ref simplifyFraction and factors out
any integer parts of the fraction (e.g. "10/4" becomes "2 1/2").
*/
-QString QCPAxisTickerPi::fractionToString( int numerator, int denominator ) const
+QString QCPAxisTickerPi::fractionToString(int numerator, int denominator) const
{
- if( denominator == 0 )
+ if (denominator == 0)
{
qDebug() << Q_FUNC_INFO << "called with zero denominator";
return QString();
}
- if( mFractionStyle == fsFloatingPoint ) // should never be the case when calling this function
+ if (mFractionStyle == fsFloatingPoint) // should never be the case when calling this function
{
qDebug() << Q_FUNC_INFO << "shouldn't be called with fraction style fsDecimal";
- return QString::number( numerator / (double)denominator ); // failsafe
+ return QString::number(numerator/(double)denominator); // failsafe
}
- int sign = numerator * denominator < 0 ? -1 : 1;
- numerator = qAbs( numerator );
- denominator = qAbs( denominator );
-
- if( denominator == 1 )
+ int sign = numerator*denominator < 0 ? -1 : 1;
+ numerator = qAbs(numerator);
+ denominator = qAbs(denominator);
+
+ if (denominator == 1)
{
- return QString::number( sign * numerator );
- }
- else
+ return QString::number(sign*numerator);
+ } else
{
- int integerPart = numerator / denominator;
- int remainder = numerator % denominator;
- if( remainder == 0 )
+ int integerPart = numerator/denominator;
+ int remainder = numerator%denominator;
+ if (remainder == 0)
{
- return QString::number( sign * integerPart );
- }
- else
+ return QString::number(sign*integerPart);
+ } else
{
- if( mFractionStyle == fsAsciiFractions )
+ if (mFractionStyle == fsAsciiFractions)
{
- return QString( QLatin1String( "%1%2%3/%4" ) )
- .arg( sign == -1 ? QLatin1String( "-" ) : QLatin1String( "" ) )
- .arg( integerPart > 0 ? QString::number( integerPart ) + QLatin1String( " " ) : QLatin1String( "" ) )
- .arg( remainder )
- .arg( denominator );
- }
- else if( mFractionStyle == fsUnicodeFractions )
+ return QString(QLatin1String("%1%2%3/%4"))
+ .arg(sign == -1 ? QLatin1String("-") : QLatin1String(""))
+ .arg(integerPart > 0 ? QString::number(integerPart)+QLatin1String(" ") : QLatin1String(""))
+ .arg(remainder)
+ .arg(denominator);
+ } else if (mFractionStyle == fsUnicodeFractions)
{
- return QString( QLatin1String( "%1%2%3" ) )
- .arg( sign == -1 ? QLatin1String( "-" ) : QLatin1String( "" ) )
- .arg( integerPart > 0 ? QString::number( integerPart ) : QLatin1String( "" ) )
- .arg( unicodeFraction( remainder, denominator ) );
+ return QString(QLatin1String("%1%2%3"))
+ .arg(sign == -1 ? QLatin1String("-") : QLatin1String(""))
+ .arg(integerPart > 0 ? QString::number(integerPart) : QLatin1String(""))
+ .arg(unicodeFraction(remainder, denominator));
}
}
}
@@ -7024,9 +6939,9 @@ QString QCPAxisTickerPi::fractionToString( int numerator, int denominator ) cons
This method doesn't use the single-character common fractions but builds each fraction from a
superscript unicode number, the unicode fraction character, and a subscript unicode number.
*/
-QString QCPAxisTickerPi::unicodeFraction( int numerator, int denominator ) const
+QString QCPAxisTickerPi::unicodeFraction(int numerator, int denominator) const
{
- return unicodeSuperscript( numerator ) + QChar( 0x2044 ) + unicodeSubscript( denominator );
+ return unicodeSuperscript(numerator)+QChar(0x2044)+unicodeSubscript(denominator);
}
/*! \internal
@@ -7034,37 +6949,21 @@ QString QCPAxisTickerPi::unicodeFraction( int numerator, int denominator ) const
Returns the unicode string representing \a number as superscript. This is used to build
unicode fractions in \ref unicodeFraction.
*/
-QString QCPAxisTickerPi::unicodeSuperscript( int number ) const
+QString QCPAxisTickerPi::unicodeSuperscript(int number) const
{
- if( number == 0 )
- return QString( QChar( 0x2070 ) );
-
+ if (number == 0)
+ return QString(QChar(0x2070));
+
QString result;
- while( number > 0 )
+ while (number > 0)
{
- const int digit = number % 10;
- switch( digit )
+ const int digit = number%10;
+ switch (digit)
{
- case 1:
- {
- result.prepend( QChar( 0x00B9 ) );
- break;
- }
- case 2:
- {
- result.prepend( QChar( 0x00B2 ) );
- break;
- }
- case 3:
- {
- result.prepend( QChar( 0x00B3 ) );
- break;
- }
- default:
- {
- result.prepend( QChar( 0x2070 + digit ) );
- break;
- }
+ case 1: { result.prepend(QChar(0x00B9)); break; }
+ case 2: { result.prepend(QChar(0x00B2)); break; }
+ case 3: { result.prepend(QChar(0x00B3)); break; }
+ default: { result.prepend(QChar(0x2070+digit)); break; }
}
number /= 10;
}
@@ -7076,21 +6975,22 @@ QString QCPAxisTickerPi::unicodeSuperscript( int number ) const
Returns the unicode string representing \a number as subscript. This is used to build unicode
fractions in \ref unicodeFraction.
*/
-QString QCPAxisTickerPi::unicodeSubscript( int number ) const
+QString QCPAxisTickerPi::unicodeSubscript(int number) const
{
- if( number == 0 )
- return QString( QChar( 0x2080 ) );
-
+ if (number == 0)
+ return QString(QChar(0x2080));
+
QString result;
- while( number > 0 )
+ while (number > 0)
{
- result.prepend( QChar( 0x2080 + number % 10 ) );
+ result.prepend(QChar(0x2080+number%10));
number /= 10;
}
return result;
}
/* end of 'src/axis/axistickerpi.cpp' */
+
/* including file 'src/axis/axistickerlog.cpp', size 7106 */
/* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */
@@ -7121,9 +7021,10 @@ QString QCPAxisTickerPi::unicodeSubscript( int number ) const
Constructs the ticker and sets reasonable default values. Axis tickers are commonly created
managed by a QSharedPointer, which then can be passed to QCPAxis::setTicker.
*/
-QCPAxisTickerLog::QCPAxisTickerLog()
- : mLogBase( 10.0 ), mSubTickCount( 8 ), // generates 10 intervals
- mLogBaseLnInv( 1.0 / qLn( mLogBase ) )
+QCPAxisTickerLog::QCPAxisTickerLog() :
+ mLogBase(10.0),
+ mSubTickCount(8), // generates 10 intervals
+ mLogBaseLnInv(1.0/qLn(mLogBase))
{
}
@@ -7131,14 +7032,13 @@ QCPAxisTickerLog::QCPAxisTickerLog()
Sets the logarithm base used for tick coordinate generation. The ticks will be placed at integer
powers of \a base.
*/
-void QCPAxisTickerLog::setLogBase( double base )
+void QCPAxisTickerLog::setLogBase(double base)
{
- if( base > 0 )
+ if (base > 0)
{
mLogBase = base;
- mLogBaseLnInv = 1.0 / qLn( mLogBase );
- }
- else
+ mLogBaseLnInv = 1.0/qLn(mLogBase);
+ } else
qDebug() << Q_FUNC_INFO << "log base has to be greater than zero:" << base;
}
@@ -7152,9 +7052,9 @@ void QCPAxisTickerLog::setLogBase( double base )
ticks (the default). This means e.g. between the ticks 10 and 100 there will be eight ticks,
namely at 20, 30, 40, 50, 60, 70, 80 and 90.
*/
-void QCPAxisTickerLog::setSubTickCount( int subTicks )
+void QCPAxisTickerLog::setSubTickCount(int subTicks)
{
- if( subTicks >= 0 )
+ if (subTicks >= 0)
mSubTickCount = subTicks;
else
qDebug() << Q_FUNC_INFO << "sub tick count can't be negative:" << subTicks;
@@ -7167,10 +7067,10 @@ void QCPAxisTickerLog::setSubTickCount( int subTicks )
\seebaseclassmethod
*/
-double QCPAxisTickerLog::getTickStep( const QCPRange& range )
+double QCPAxisTickerLog::getTickStep(const QCPRange &range)
{
// Logarithmic axis ticker has unequal tick spacing, so doesn't need this method
- Q_UNUSED( range )
+ Q_UNUSED(range)
return 1.0;
}
@@ -7181,9 +7081,9 @@ double QCPAxisTickerLog::getTickStep( const QCPRange& range )
\seebaseclassmethod
*/
-int QCPAxisTickerLog::getSubTickCount( double tickStep )
+int QCPAxisTickerLog::getSubTickCount(double tickStep)
{
- Q_UNUSED( tickStep )
+ Q_UNUSED(tickStep)
return mSubTickCount;
}
@@ -7196,46 +7096,46 @@ int QCPAxisTickerLog::getSubTickCount( double tickStep )
\seebaseclassmethod
*/
-QVector QCPAxisTickerLog::createTickVector( double tickStep, const QCPRange& range )
+QVector QCPAxisTickerLog::createTickVector(double tickStep, const QCPRange &range)
{
- Q_UNUSED( tickStep )
+ Q_UNUSED(tickStep)
QVector result;
- if( range.lower > 0 && range.upper > 0 ) // positive range
+ if (range.lower > 0 && range.upper > 0) // positive range
{
- double exactPowerStep = qLn( range.upper / range.lower ) * mLogBaseLnInv / (double)( mTickCount + 1e-10 );
- double newLogBase = qPow( mLogBase, qMax( (int)cleanMantissa( exactPowerStep ), 1 ) );
- double currentTick = qPow( newLogBase, qFloor( qLn( range.lower ) / qLn( newLogBase ) ) );
- result.append( currentTick );
- while( currentTick < range.upper && currentTick > 0 ) // currentMag might be zero for ranges ~1e-300, just cancel in that case
+ double exactPowerStep = qLn(range.upper/range.lower)*mLogBaseLnInv/(double)(mTickCount+1e-10);
+ double newLogBase = qPow(mLogBase, qMax((int)cleanMantissa(exactPowerStep), 1));
+ double currentTick = qPow(newLogBase, qFloor(qLn(range.lower)/qLn(newLogBase)));
+ result.append(currentTick);
+ while (currentTick < range.upper && currentTick > 0) // currentMag might be zero for ranges ~1e-300, just cancel in that case
{
currentTick *= newLogBase;
- result.append( currentTick );
+ result.append(currentTick);
}
- }
- else if( range.lower < 0 && range.upper < 0 ) // negative range
+ } else if (range.lower < 0 && range.upper < 0) // negative range
{
- double exactPowerStep = qLn( range.lower / range.upper ) * mLogBaseLnInv / (double)( mTickCount + 1e-10 );
- double newLogBase = qPow( mLogBase, qMax( (int)cleanMantissa( exactPowerStep ), 1 ) );
- double currentTick = -qPow( newLogBase, qCeil( qLn( -range.lower ) / qLn( newLogBase ) ) );
- result.append( currentTick );
- while( currentTick < range.upper && currentTick < 0 ) // currentMag might be zero for ranges ~1e-300, just cancel in that case
+ double exactPowerStep = qLn(range.lower/range.upper)*mLogBaseLnInv/(double)(mTickCount+1e-10);
+ double newLogBase = qPow(mLogBase, qMax((int)cleanMantissa(exactPowerStep), 1));
+ double currentTick = -qPow(newLogBase, qCeil(qLn(-range.lower)/qLn(newLogBase)));
+ result.append(currentTick);
+ while (currentTick < range.upper && currentTick < 0) // currentMag might be zero for ranges ~1e-300, just cancel in that case
{
currentTick /= newLogBase;
- result.append( currentTick );
+ result.append(currentTick);
}
- }
- else // invalid range for logarithmic scale, because lower and upper have different sign
+ } else // invalid range for logarithmic scale, because lower and upper have different sign
{
qDebug() << Q_FUNC_INFO << "Invalid range for logarithmic plot: " << range.lower << ".." << range.upper;
}
-
+
return result;
}
/* end of 'src/axis/axistickerlog.cpp' */
+
/* including file 'src/axis/axis.cpp', size 99397 */
/* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */
+
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// QCPGrid
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -7258,18 +7158,19 @@ QVector QCPAxisTickerLog::createTickVector( double tickStep, const QCPRa
You shouldn't instantiate grids on their own, since every QCPAxis brings its own QCPGrid.
*/
-QCPGrid::QCPGrid( QCPAxis* parentAxis )
- : QCPLayerable( parentAxis->parentPlot(), QString(), parentAxis ), mParentAxis( parentAxis )
+QCPGrid::QCPGrid(QCPAxis *parentAxis) :
+ QCPLayerable(parentAxis->parentPlot(), QString(), parentAxis),
+ mParentAxis(parentAxis)
{
// warning: this is called in QCPAxis constructor, so parentAxis members should not be accessed/called
- setParent( parentAxis );
- setPen( QPen( QColor( 200, 200, 200 ), 0, Qt::DotLine ) );
- setSubGridPen( QPen( QColor( 220, 220, 220 ), 0, Qt::DotLine ) );
- setZeroLinePen( QPen( QColor( 200, 200, 200 ), 0, Qt::SolidLine ) );
- setSubGridVisible( false );
- setAntialiased( false );
- setAntialiasedSubGrid( false );
- setAntialiasedZeroLine( false );
+ setParent(parentAxis);
+ setPen(QPen(QColor(200,200,200), 0, Qt::DotLine));
+ setSubGridPen(QPen(QColor(220,220,220), 0, Qt::DotLine));
+ setZeroLinePen(QPen(QColor(200,200,200), 0, Qt::SolidLine));
+ setSubGridVisible(false);
+ setAntialiased(false);
+ setAntialiasedSubGrid(false);
+ setAntialiasedZeroLine(false);
}
/*!
@@ -7277,7 +7178,7 @@ QCPGrid::QCPGrid( QCPAxis* parentAxis )
\see setSubGridPen
*/
-void QCPGrid::setSubGridVisible( bool visible )
+void QCPGrid::setSubGridVisible(bool visible)
{
mSubGridVisible = visible;
}
@@ -7285,7 +7186,7 @@ void QCPGrid::setSubGridVisible( bool visible )
/*!
Sets whether sub grid lines are drawn antialiased.
*/
-void QCPGrid::setAntialiasedSubGrid( bool enabled )
+void QCPGrid::setAntialiasedSubGrid(bool enabled)
{
mAntialiasedSubGrid = enabled;
}
@@ -7293,7 +7194,7 @@ void QCPGrid::setAntialiasedSubGrid( bool enabled )
/*!
Sets whether zero lines are drawn antialiased.
*/
-void QCPGrid::setAntialiasedZeroLine( bool enabled )
+void QCPGrid::setAntialiasedZeroLine(bool enabled)
{
mAntialiasedZeroLine = enabled;
}
@@ -7301,7 +7202,7 @@ void QCPGrid::setAntialiasedZeroLine( bool enabled )
/*!
Sets the pen with which (major) grid lines are drawn.
*/
-void QCPGrid::setPen( const QPen& pen )
+void QCPGrid::setPen(const QPen &pen)
{
mPen = pen;
}
@@ -7309,7 +7210,7 @@ void QCPGrid::setPen( const QPen& pen )
/*!
Sets the pen with which sub grid lines are drawn.
*/
-void QCPGrid::setSubGridPen( const QPen& pen )
+void QCPGrid::setSubGridPen(const QPen &pen)
{
mSubGridPen = pen;
}
@@ -7320,7 +7221,7 @@ void QCPGrid::setSubGridPen( const QPen& pen )
Zero lines are lines at value coordinate 0 which may be drawn with a different pen than other grid
lines. To disable zero lines and just draw normal grid lines at zero, set \a pen to Qt::NoPen.
*/
-void QCPGrid::setZeroLinePen( const QPen& pen )
+void QCPGrid::setZeroLinePen(const QPen &pen)
{
mZeroLinePen = pen;
}
@@ -7338,9 +7239,9 @@ void QCPGrid::setZeroLinePen( const QPen& pen )
\see setAntialiased
*/
-void QCPGrid::applyDefaultAntialiasingHint( QCPPainter* painter ) const
+void QCPGrid::applyDefaultAntialiasingHint(QCPPainter *painter) const
{
- applyAntialiasingHint( painter, mAntialiased, QCP::aeGrid );
+ applyAntialiasingHint(painter, mAntialiased, QCP::aeGrid);
}
/*! \internal
@@ -7348,17 +7249,13 @@ void QCPGrid::applyDefaultAntialiasingHint( QCPPainter* painter ) const
Draws grid lines and sub grid lines at the positions of (sub) ticks of the parent axis, spanning
over the complete axis rect. Also draws the zero line, if appropriate (\ref setZeroLinePen).
*/
-void QCPGrid::draw( QCPPainter* painter )
+void QCPGrid::draw(QCPPainter *painter)
{
- if( !mParentAxis )
- {
- qDebug() << Q_FUNC_INFO << "invalid parent axis";
- return;
- }
-
- if( mParentAxis->subTicks() && mSubGridVisible )
- drawSubGridLines( painter );
- drawGridLines( painter );
+ if (!mParentAxis) { qDebug() << Q_FUNC_INFO << "invalid parent axis"; return; }
+
+ if (mParentAxis->subTicks() && mSubGridVisible)
+ drawSubGridLines(painter);
+ drawGridLines(painter);
}
/*! \internal
@@ -7367,76 +7264,69 @@ void QCPGrid::draw( QCPPainter* painter )
This is a helper function called by \ref draw.
*/
-void QCPGrid::drawGridLines( QCPPainter* painter ) const
+void QCPGrid::drawGridLines(QCPPainter *painter) const
{
- if( !mParentAxis )
- {
- qDebug() << Q_FUNC_INFO << "invalid parent axis";
- return;
- }
-
+ if (!mParentAxis) { qDebug() << Q_FUNC_INFO << "invalid parent axis"; return; }
+
const int tickCount = mParentAxis->mTickVector.size();
- double t; // helper variable, result of coordinate-to-pixel transforms
- if( mParentAxis->orientation() == Qt::Horizontal )
+ double t; // helper variable, result of coordinate-to-pixel transforms
+ if (mParentAxis->orientation() == Qt::Horizontal)
{
// draw zeroline:
int zeroLineIndex = -1;
- if( mZeroLinePen.style() != Qt::NoPen && mParentAxis->mRange.lower < 0 && mParentAxis->mRange.upper > 0 )
+ if (mZeroLinePen.style() != Qt::NoPen && mParentAxis->mRange.lower < 0 && mParentAxis->mRange.upper > 0)
{
- applyAntialiasingHint( painter, mAntialiasedZeroLine, QCP::aeZeroLine );
- painter->setPen( mZeroLinePen );
- double epsilon = mParentAxis->range().size() * 1E-6; // for comparing double to zero
- for( int i = 0; i < tickCount; ++i )
+ applyAntialiasingHint(painter, mAntialiasedZeroLine, QCP::aeZeroLine);
+ painter->setPen(mZeroLinePen);
+ double epsilon = mParentAxis->range().size()*1E-6; // for comparing double to zero
+ for (int i=0; imTickVector.at( i ) ) < epsilon )
+ if (qAbs(mParentAxis->mTickVector.at(i)) < epsilon)
{
zeroLineIndex = i;
- t = mParentAxis->coordToPixel( mParentAxis->mTickVector.at( i ) ); // x
- painter->drawLine( QLineF( t, mParentAxis->mAxisRect->bottom(), t, mParentAxis->mAxisRect->top() ) );
+ t = mParentAxis->coordToPixel(mParentAxis->mTickVector.at(i)); // x
+ painter->drawLine(QLineF(t, mParentAxis->mAxisRect->bottom(), t, mParentAxis->mAxisRect->top()));
break;
}
}
}
// draw grid lines:
- applyDefaultAntialiasingHint( painter );
- painter->setPen( mPen );
- for( int i = 0; i < tickCount; ++i )
+ applyDefaultAntialiasingHint(painter);
+ painter->setPen(mPen);
+ for (int i=0; icoordToPixel( mParentAxis->mTickVector.at( i ) ); // x
- painter->drawLine( QLineF( t, mParentAxis->mAxisRect->bottom(), t, mParentAxis->mAxisRect->top() ) );
+ if (i == zeroLineIndex) continue; // don't draw a gridline on top of the zeroline
+ t = mParentAxis->coordToPixel(mParentAxis->mTickVector.at(i)); // x
+ painter->drawLine(QLineF(t, mParentAxis->mAxisRect->bottom(), t, mParentAxis->mAxisRect->top()));
}
- }
- else
+ } else
{
// draw zeroline:
int zeroLineIndex = -1;
- if( mZeroLinePen.style() != Qt::NoPen && mParentAxis->mRange.lower < 0 && mParentAxis->mRange.upper > 0 )
+ if (mZeroLinePen.style() != Qt::NoPen && mParentAxis->mRange.lower < 0 && mParentAxis->mRange.upper > 0)
{
- applyAntialiasingHint( painter, mAntialiasedZeroLine, QCP::aeZeroLine );
- painter->setPen( mZeroLinePen );
- double epsilon = mParentAxis->mRange.size() * 1E-6; // for comparing double to zero
- for( int i = 0; i < tickCount; ++i )
+ applyAntialiasingHint(painter, mAntialiasedZeroLine, QCP::aeZeroLine);
+ painter->setPen(mZeroLinePen);
+ double epsilon = mParentAxis->mRange.size()*1E-6; // for comparing double to zero
+ for (int i=0; imTickVector.at( i ) ) < epsilon )
+ if (qAbs(mParentAxis->mTickVector.at(i)) < epsilon)
{
zeroLineIndex = i;
- t = mParentAxis->coordToPixel( mParentAxis->mTickVector.at( i ) ); // y
- painter->drawLine( QLineF( mParentAxis->mAxisRect->left(), t, mParentAxis->mAxisRect->right(), t ) );
+ t = mParentAxis->coordToPixel(mParentAxis->mTickVector.at(i)); // y
+ painter->drawLine(QLineF(mParentAxis->mAxisRect->left(), t, mParentAxis->mAxisRect->right(), t));
break;
}
}
}
// draw grid lines:
- applyDefaultAntialiasingHint( painter );
- painter->setPen( mPen );
- for( int i = 0; i < tickCount; ++i )
+ applyDefaultAntialiasingHint(painter);
+ painter->setPen(mPen);
+ for (int i=0; i