#include "FramePropertiesDock.h"
-FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitch ) :
- QWidget( parent ),
- m_pbIsPlaying( pbMainPlaySwitch )
+FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitch )
+ : QWidget( parent ), m_pbIsPlaying( pbMainPlaySwitch )
{
// -------------- Variables definition --------------
m_pcFrame = NULL;
@@ -38,29 +37,31 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitc
// Histogram area -----------------------------------------------------
- QLabel *channelLabel = new QLabel( tr( "Channel:" ) );
+ QLabel* channelLabel = new QLabel( tr( "Channel:" ) );
channelLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
channelCB = new QComboBox;
channelCB->addItem( tr( "Luminance" ) );
channelCB->setItemIcon( 0, QIcon( ":/images/channel-luma.png" ) );
- channelCB->setWhatsThis( tr( "Select here the histogram channel to display:
"
- "Luminance: Display luminance (perceived brightness).
"
- "Red: Display the red image channel.
"
- "Green: Display the green image channel.
"
- "Blue: Display the blue image channel.
"
- "Alpha: Display the alpha image channel. "
- "This channel corresponds to the transparency value and "
- "is supported by some image formats such as PNG or TIFF.
"
- "Colors: Display all color channel values at "
- "the same time." ) );
+ channelCB->setWhatsThis(
+ tr( "
Select here the histogram channel to display:
"
+ "Luminance: Display luminance (perceived brightness).
"
+ "Red: Display the red image channel.
"
+ "Green: Display the green image channel.
"
+ "Blue: Display the blue image channel.
"
+ "Alpha: Display the alpha image channel. "
+ "This channel corresponds to the transparency value and "
+ "is supported by some image formats such as PNG or TIFF.
"
+ "Colors: Display all color channel values at "
+ "the same time." ) );
- QString scaleWhatsThis( tr( "
Select here the histogram scale.
"
- "If the image's maximal values are small, you can use the "
- "linear scale.
Logarithmic scale can be used when the maximal"
- " values are big; if it is used, all values (small and large) "
- "will be visible on the graph." ) );
+ QString scaleWhatsThis(
+ tr( "
Select here the histogram scale.
"
+ "If the image's maximal values are small, you can use the "
+ "linear scale.
Logarithmic scale can be used when the maximal"
+ " values are big; if it is used, all values (small and large) "
+ "will be visible on the graph." ) );
linHistoButton = new QPushButton;
linHistoButton->setToolTip( tr( "Linear" ) );
@@ -81,7 +82,7 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitc
scaleButtonGroup->addButton( linHistoButton, HistogramWidget::LinScaleHistogram );
scaleButtonGroup->addButton( logHistoButton, HistogramWidget::LogScaleHistogram );
- QHBoxLayout *scaleLayout = new QHBoxLayout;
+ QHBoxLayout* scaleLayout = new QHBoxLayout;
scaleLayout->addWidget( linHistoButton );
scaleLayout->addWidget( logHistoButton );
@@ -92,10 +93,11 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitc
colorsCB->hide();
colorsLabel->hide();
- QString regionWhatsThis( tr( "
Select here from which region the histogram will be computed:"
- "
Full Image: Compute histogram using the full image."
- "
Selection: Compute histogram using the current image "
- "selection." ) );
+ QString regionWhatsThis(
+ tr( "
Select here from which region the histogram will be computed:"
+ "
Full Image: Compute histogram using the full image."
+ "
Selection: Compute histogram using the current image "
+ "selection." ) );
fullImageButton = new QPushButton;
fullImageButton->setToolTip( tr( "Full Image" ) );
@@ -116,11 +118,11 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitc
renderingButtonGroup->addButton( fullImageButton, HistogramWidget::FullImageHistogram );
renderingButtonGroup->addButton( selectionImageButton, HistogramWidget::ImageSelectionHistogram );
- QHBoxLayout *regionLayout = new QHBoxLayout;
+ QHBoxLayout* regionLayout = new QHBoxLayout;
regionLayout->addWidget( fullImageButton );
regionLayout->addWidget( selectionImageButton );
- QGridLayout *mainLayout = new QGridLayout;
+ QGridLayout* mainLayout = new QGridLayout;
mainLayout->addWidget( channelLabel, 1, 0 );
mainLayout->addWidget( channelCB, 1, 1 );
mainLayout->addLayout( scaleLayout, 1, 3 );
@@ -132,10 +134,11 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitc
// -------------------------------------------------------------
histogramWidget = new HistogramWidget( 100, 100 );
- histogramWidget->setWhatsThis( tr( "
This is the histogram drawing of "
- "the selected image channel" ) );
+ histogramWidget->setWhatsThis(
+ tr( "
This is the histogram drawing of "
+ "the selected image channel" ) );
- QVBoxLayout *histogramLayout = new QVBoxLayout;
+ QVBoxLayout* histogramLayout = new QVBoxLayout;
histogramLayout->setSpacing( 1 );
histogramLayout->addWidget( histogramWidget );
@@ -143,24 +146,26 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitc
// -------------------------------------------------------------
- QLabel *rangeSelectionLabel = new QLabel( tr( "Range:" ) );
+ 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 "
- "value of the histogram selection." ) );
+ 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"
- " of the histogram selection." ) );
+ minInterv->setWhatsThis(
+ tr( "
Select here the maximal intensity value"
+ " of the histogram selection." ) );
- QHBoxLayout *rangeLayout = new QHBoxLayout;
+ QHBoxLayout* rangeLayout = new QHBoxLayout;
rangeLayout->addWidget( rangeSelectionLabel );
rangeLayout->addWidget( minInterv );
rangeLayout->addWidget( maxInterv );
@@ -169,43 +174,43 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitc
// ----------------- GUI definition -----------------
- QLabel *pixelsLabel = new QLabel( tr( "Pixels:" ) );
+ QLabel* pixelsLabel = new QLabel( tr( "Pixels:" ) );
pixelsLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
labelPixelsValue = new QLabel;
labelPixelsValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
- QLabel *countLabel = new QLabel( tr( "Selected:" ) );
+ QLabel* countLabel = new QLabel( tr( "Selected:" ) );
countLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
labelCountValue = new QLabel;
labelCountValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
- QLabel *rangeLabel = new QLabel( tr( "Range:" ) );
+ QLabel* rangeLabel = new QLabel( tr( "Range:" ) );
rangeLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
labelRangeValue = new QLabel;
labelRangeValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
- QLabel *meanLabel = new QLabel( tr( "Mean:" ) );
+ QLabel* meanLabel = new QLabel( tr( "Mean:" ) );
meanLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
labelMeanValue = new QLabel;
labelMeanValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
- QLabel *stdDevLabel = new QLabel( tr( "Std. deviation:" ) );
+ QLabel* stdDevLabel = new QLabel( tr( "Std. deviation:" ) );
stdDevLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
labelStdDevValue = new QLabel;
labelStdDevValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
- QLabel *medianLabel = new QLabel( tr( "Median:" ) );
+ QLabel* medianLabel = new QLabel( tr( "Median:" ) );
medianLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
labelMedianValue = new QLabel;
labelMedianValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
- QLabel *percentileLabel = new QLabel( tr( "Percentile:" ) );
+ QLabel* percentileLabel = new QLabel( tr( "Percentile:" ) );
percentileLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
labelPercentileValue = new QLabel;
labelPercentileValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
Int gridRow = 0;
- QGridLayout *statisticsLayout = new QGridLayout;
+ QGridLayout* statisticsLayout = new QGridLayout;
statisticsLayout->addWidget( pixelsLabel, gridRow, 0 );
statisticsLayout->addWidget( labelPixelsValue, gridRow++, 1 );
statisticsLayout->addWidget( countLabel, gridRow, 0 );
@@ -218,14 +223,15 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitc
statisticsLayout->addWidget( labelStdDevValue, gridRow++, 1 );
statisticsLayout->addWidget( medianLabel, gridRow, 0 );
statisticsLayout->addWidget( labelMedianValue, gridRow++, 1 );
-// statisticsLayout->addWidget( percentileLabel, 5, 0 );
-// statisticsLayout->addWidget( labelPercentileValue, 5, 1 );
+ // statisticsLayout->addWidget( percentileLabel, 5, 0 );
+ // statisticsLayout->addWidget( labelPercentileValue, 5, 1 );
- QGroupBox *statisticsGroup = new QGroupBox( tr( "Statistics" ) );
+ QGroupBox* statisticsGroup = new QGroupBox( tr( "Statistics" ) );
statisticsGroup->setLayout( statisticsLayout );
- statisticsGroup->setWhatsThis( tr( "
Here you can see the statistical results calculated from the "
- "selected histogram part. These values are available for all "
- "channels." ) );
+ statisticsGroup->setWhatsThis(
+ tr( "
Here you can see the statistical results calculated from the "
+ "selected histogram part. These values are available for all "
+ "channels." ) );
mainLayout->addWidget( statisticsGroup, 5, 0, 1, 4 );
@@ -233,17 +239,17 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitc
setLayout( mainLayout );
setEnabled( false );
- connect( channelCB, SIGNAL( activated(int) ), this, SLOT( slotChannelChanged(int) ) );
- 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( 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( channelCB, SIGNAL( activated( int ) ), this, SLOT( slotChannelChanged( int ) ) );
+ 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( 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 ) ) );
}
FramePropertiesDock::~FramePropertiesDock()
@@ -314,10 +320,11 @@ Void FramePropertiesDock::setFrame( PlaYUVerFrame* pcFrame )
colorsCB->addItem( "Green" );
colorsCB->addItem( "Blue" );
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.
"
- "Green: Draw the Green image channel in the foreground.
"
- "Blue: Draw the Blue image channel in the foreground.
" ) );
+ colorsCB->setWhatsThis(
+ tr( "
Select here the main color displayed with Colors Channel mode:"
+ "
Red: Draw the Red image channel in the foreground.
"
+ "Green: Draw the Green image channel in the foreground.
"
+ "Blue: Draw the Blue image channel in the foreground.
" ) );
colorsCB->show();
colorsLabel->show();
}
@@ -334,10 +341,11 @@ Void FramePropertiesDock::setFrame( PlaYUVerFrame* pcFrame )
colorsCB->addItem( "Chroma U" );
colorsCB->addItem( "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 foreground.
"
- "Chroma U: Draw the Chroma U channel in the foreground.
"
- "Chroma V: Draw the Chroma V channel in the foreground.
" ) );
+ colorsCB->setWhatsThis(
+ tr( "
Select here the main color displayed with Colors Channel mode:"
+ "
Luminance: DraupdateDataw the Luminance channel in the foreground.
"
+ "Chroma U: Draw the Chroma U channel in the foreground.
"
+ "Chroma V: Draw the Chroma V channel in the foreground.
" ) );
colorsCB->show();
colorsLabel->show();
}
@@ -358,7 +366,7 @@ Void FramePropertiesDock::setFrame( PlaYUVerFrame* pcFrame )
}
}
-Void FramePropertiesDock::setSelection( const QRect &selectionArea )
+Void FramePropertiesDock::setSelection( const QRect& selectionArea )
{
if( m_pcFrame )
{
@@ -378,7 +386,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 PlaYUVerFrame( m_pcFrame, selectionArea.x(), selectionArea.y(), selectionArea.width(),
+ selectionArea.height() );
}
updateDataHistogram();
selectionImageButton->click();
@@ -445,21 +454,21 @@ Void FramePropertiesDock::updateStatistiques()
if( frame )
{
-
- QString rangeText = "[" + QString::number( frame->getMin( channel ) ) + ":" + QString::number( frame->getMax( channel ) ) + "]";
+ QString rangeText =
+ "[" + QString::number( frame->getMin( channel ) ) + ":" + QString::number( frame->getMax( channel ) ) + "]";
labelRangeValue->setText( rangeText );
double mean = frame->getMean( channel, min, max );
labelMeanValue->setText( value.setNum( mean, 'f', 1 ) );
double pixels = frame->getPixels();
- labelPixelsValue->setText( value.setNum( ( float )pixels, 'f', 0 ) );
+ labelPixelsValue->setText( value.setNum( (float)pixels, 'f', 0 ) );
double stddev = frame->getStdDev( channel, min, max );
labelStdDevValue->setText( value.setNum( stddev, 'f', 1 ) );
double counts = frame->getCount( channel, min, max );
- labelCountValue->setText( value.setNum( ( float )counts, 'f', 0 ) );
+ labelCountValue->setText( value.setNum( (float)counts, 'f', 0 ) );
double median = frame->getMedian( channel, min, max );
labelMedianValue->setText( value.setNum( median, 'f', 1 ) );
@@ -515,31 +524,31 @@ Void FramePropertiesDock::slotChannelChanged( Int channel )
switch( channel )
{
- case FirstChannel:
- histogramWidget->m_channelType = HistogramWidget::FirstChannelHistogram;
- colorsCB->setEnabled( false );
- break;
- case SecondChannel:
- histogramWidget->m_channelType = HistogramWidget::SecondChannelHistogram;
- colorsCB->setEnabled( false );
- break;
- case ThirdChannel:
- histogramWidget->m_channelType = HistogramWidget::ThirdChannelHistogram;
- colorsCB->setEnabled( false );
- break;
- case AlphaChannel:
- histogramWidget->m_channelType = HistogramWidget::AlphaChannelHistogram;
- colorsCB->setEnabled( false );
- break;
- case ColorChannels:
- histogramWidget->m_channelType = HistogramWidget::ColorChannelsHistogram;
- colorsCB->setEnabled( true );
- break;
- default: // Luminance.
- //histogramWidget->m_channelType = HistogramWidget::LumaHistogram;
- histogramWidget->m_channelType = HistogramWidget::FirstChannelHistogram;
- colorsCB->setEnabled( false );
- break;
+ case FirstChannel:
+ histogramWidget->m_channelType = HistogramWidget::FirstChannelHistogram;
+ colorsCB->setEnabled( false );
+ break;
+ case SecondChannel:
+ histogramWidget->m_channelType = HistogramWidget::SecondChannelHistogram;
+ colorsCB->setEnabled( false );
+ break;
+ case ThirdChannel:
+ histogramWidget->m_channelType = HistogramWidget::ThirdChannelHistogram;
+ colorsCB->setEnabled( false );
+ break;
+ case AlphaChannel:
+ histogramWidget->m_channelType = HistogramWidget::AlphaChannelHistogram;
+ colorsCB->setEnabled( false );
+ break;
+ case ColorChannels:
+ histogramWidget->m_channelType = HistogramWidget::ColorChannelsHistogram;
+ colorsCB->setEnabled( true );
+ break;
+ default: // Luminance.
+ // histogramWidget->m_channelType = HistogramWidget::LumaHistogram;
+ histogramWidget->m_channelType = HistogramWidget::FirstChannelHistogram;
+ colorsCB->setEnabled( false );
+ break;
}
histogramWidget->update();
updateStatistiques();
@@ -555,15 +564,15 @@ Void FramePropertiesDock::slotColorsChanged( Int color )
{
switch( color )
{
- case AllColorsGreen:
- histogramWidget->m_colorType = HistogramWidget::SecondChannelColor;
- break;
- case AllColorsBlue:
- histogramWidget->m_colorType = HistogramWidget::ThirdChannelColor;
- break;
- default: // Red.
- histogramWidget->m_colorType = HistogramWidget::FirstChannelColor;
- break;
+ case AllColorsGreen:
+ histogramWidget->m_colorType = HistogramWidget::SecondChannelColor;
+ break;
+ case AllColorsBlue:
+ histogramWidget->m_colorType = HistogramWidget::ThirdChannelColor;
+ break;
+ default: // Red.
+ histogramWidget->m_colorType = HistogramWidget::FirstChannelColor;
+ break;
}
histogramWidget->update();
@@ -625,4 +634,3 @@ Void FramePropertiesDock::slotUpdateIntervRange( Int range )
maxInterv->setMaximum( range );
maxInterv->blockSignals( false );
}
-
diff --git a/app/FramePropertiesDock.h b/app/FramePropertiesDock.h
index 2a490fd..fe777bc 100644
--- a/app/FramePropertiesDock.h
+++ b/app/FramePropertiesDock.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -37,21 +37,21 @@
#include "lib/PlaYUVerFrame.h"
#include "HistogramWidget.h"
-class FramePropertiesDock: public QWidget
+class FramePropertiesDock : public QWidget
{
-Q_OBJECT
- public:
+ Q_OBJECT
+ public:
FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitch );
~FramePropertiesDock();
QSize sizeHint() const;
Void setFrame( PlaYUVerFrame* m_pcFrame );
- Void setSelection( const QRect &selectionArea );
+ Void setSelection( const QRect& selectionArea );
Void reset();
Void stopHistogram();
-private:
+ private:
enum ColorChannel
{
LuminosityChannel = 0,
@@ -69,45 +69,45 @@ private:
AllColorsBlue
};
- PlaYUVerFrame *m_pcFrame;
- PlaYUVerFrame *m_pcSelectedFrame;
+ PlaYUVerFrame* m_pcFrame;
+ PlaYUVerFrame* m_pcSelectedFrame;
Int m_iLastFrameType;
Bool* m_pbIsPlaying;
- QComboBox *channelCB;
- QComboBox *colorsCB;
- QComboBox *renderingCB;
+ QComboBox* channelCB;
+ QComboBox* colorsCB;
+ QComboBox* renderingCB;
- QPushButton *linHistoButton;
- QPushButton *logHistoButton;
- QPushButton *fullImageButton;
- QPushButton *selectionImageButton;
+ QPushButton* linHistoButton;
+ QPushButton* logHistoButton;
+ QPushButton* fullImageButton;
+ QPushButton* selectionImageButton;
- QButtonGroup *scaleButtonGroup;
- QButtonGroup *renderingButtonGroup;
+ QButtonGroup* scaleButtonGroup;
+ QButtonGroup* renderingButtonGroup;
- QSpinBox *minInterv;
- QSpinBox *maxInterv;
+ QSpinBox* minInterv;
+ QSpinBox* maxInterv;
- QLabel *labelPixelsValue;
- QLabel *labelCountValue;
- QLabel *labelRangeValue;
- QLabel *labelMeanValue;
- QLabel *labelStdDevValue;
- QLabel *labelMedianValue;
- QLabel *labelPercentileValue;
+ QLabel* labelPixelsValue;
+ QLabel* labelCountValue;
+ QLabel* labelRangeValue;
+ QLabel* labelMeanValue;
+ QLabel* labelStdDevValue;
+ QLabel* labelMedianValue;
+ QLabel* labelPercentileValue;
- QLabel *colorsLabel;
+ QLabel* colorsLabel;
QRect m_cSelectionArea;
- HistogramWidget *histogramWidget;
+ HistogramWidget* histogramWidget;
Void updateStatistiques();
Void updateDataHistogram();
-private Q_SLOTS:
+ private Q_SLOTS:
void slotRefreshOptions( int range );
void slotHistogramComputationFailed( void );
void slotChannelChanged( int channel );
@@ -119,7 +119,6 @@ private Q_SLOTS:
void slotUpdateInterval( int min, int max );
void slotUpdateIntervRange( int range );
-
};
-#endif // __FRAMEPROPERTIESDOCK_H__
+#endif // __FRAMEPROPERTIESDOCK_H__
diff --git a/app/GridManager.cpp b/app/GridManager.cpp
index ba4b1a3..68c4ffa 100644
--- a/app/GridManager.cpp
+++ b/app/GridManager.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -47,10 +47,10 @@ GridManager::GridManager()
////////////////////////////////////////////////////////////////////////////////
// Grid Drawer
////////////////////////////////////////////////////////////////////////////////
-void GridManager::drawGrid( QPixmap &image, const QRect& area, QPainter *painter )
+void GridManager::drawGrid( QPixmap& image, const QRect& area, QPainter* painter )
{
- int offsetx = 0; // Grid offset doesn't applies to SCODE
- int offsety = 0; // project for now...
+ int offsetx = 0; // Grid offset doesn't applies to SCODE
+ int offsety = 0; // project for now...
int imageWidth = image.width();
int imageHeight = image.height();
@@ -65,82 +65,82 @@ void GridManager::drawGrid( QPixmap &image, const QRect& area, QPainter *painter
style = Solid;
switch( style )
{
- case IntersectionDot:
+ case IntersectionDot:
case IntersectionCross:
{
- painter->setPen( mainPen );
- // Draw crosses or dots on intersections
- for( int x = offsetx; x <= area.right(); x += hSpacing )
- {
- if( x >= imageWidth )
- break;
+ painter->setPen( mainPen );
+ // Draw crosses or dots on intersections
+ for( int x = offsetx; x <= area.right(); x += hSpacing )
+ {
+ if( x >= imageWidth )
+ break;
+ for( int y = offsety; y <= area.bottom(); y += vSpacing )
+ {
+ if( y >= imageHeight )
+ break;
+
+ if( x >= area.x() && y >= area.y() )
+ {
+ if( style == IntersectionDot )
+ painter->drawPoint( x, y ); // Dot
+ else
+ { // Crosses:
+ painter->drawLine( x, y - 1, x, y + 1 ); // Ver.line
+ painter->drawLine( x - 1, y, x + 1, y ); // Hor.line
+ }
+ }
+ }
+ }
+ break;
+ }
+ case Dashed:
+ {
+ // Change pen to the dashed line
+ mainPen.setStyle( Qt::DashLine );
+ }
+ default: // Solid:
+ {
+ painter->setPen( mainPen );
+
+ // Draw vertical line
+ for( int x = offsetx; x <= area.right(); x += hSpacing )
+ {
+ if( x >= imageWidth )
+ break;
+
+ if( x >= area.x() )
+ {
+ // Always draw the full line otherwise the line stippling
+ // varies with the location of view area and we get glitchy
+ // patterns.
+ painter->drawLine( x, 0, x, imageHeight - 1 );
+ }
+ }
+ // Draw horizontal line
for( int y = offsety; y <= area.bottom(); y += vSpacing )
{
if( y >= imageHeight )
break;
- if( x >= area.x() && y >= area.y() )
+ if( y >= area.y() )
{
- if( style == IntersectionDot )
- painter->drawPoint( x, y ); // Dot
- else
- { // Crosses:
- painter->drawLine( x, y - 1, x, y + 1 ); // Ver.line
- painter->drawLine( x - 1, y, x + 1, y ); // Hor.line
- }
+ painter->drawLine( 0, y, imageWidth - 1, y );
}
}
+ break;
}
- break;
- }
- case Dashed:
- {
- // Change pen to the dashed line
- mainPen.setStyle( Qt::DashLine );
- }
- default: // Solid:
- {
- painter->setPen( mainPen );
-
- // Draw vertical line
- for( int x = offsetx; x <= area.right(); x += hSpacing )
- {
- if( x >= imageWidth )
- break;
-
- if( x >= area.x() )
- {
- // Always draw the full line otherwise the line stippling
- // varies with the location of view area and we get glitchy
- // patterns.
- painter->drawLine( x, 0, x, imageHeight - 1 );
- }
- }
- // Draw horizontal line
- for( int y = offsety; y <= area.bottom(); y += vSpacing )
- {
- if( y >= imageHeight )
- break;
-
- if( y >= area.y() )
- {
- painter->drawLine( 0, y, imageWidth - 1, y );
- }
- }
- break;
- }
}
}
////////////////////////////////////////////////////////////////////////////////
-QRect GridManager::rectContains( const QPoint &pos ) const
- {
+QRect GridManager::rectContains( const QPoint& pos ) const
+{
return rectContains( pos.x(), pos.y() );
}
QRect GridManager::rectContains( int x, int y ) const
- {
+{
QRect rect;
QPoint pos;
int multiPosX;
@@ -242,8 +242,8 @@ bool GridManager::isNear( int x, int y )
{
for( int i = 0; i < 2; i++ )
{
- gx = ( int )( multiPosX * hSpacing + i * hSpacing );
- gy = ( int )( multiPosY * vSpacing + j * vSpacing );
+ gx = (int)( multiPosX * hSpacing + i * hSpacing );
+ gy = (int)( multiPosY * vSpacing + j * vSpacing );
gridPoint.setX( gx );
gridPoint.setY( gy );
rect.moveCenter( gridPoint );
@@ -259,7 +259,7 @@ bool GridManager::isNear( int x, int y )
return false;
}
-bool GridManager::isNear( const QPoint &pos )
+bool GridManager::isNear( const QPoint& pos )
{
return isNear( pos.x(), pos.y() );
}
diff --git a/app/GridManager.h b/app/GridManager.h
index 3291151..f68a439 100644
--- a/app/GridManager.h
+++ b/app/GridManager.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -41,8 +41,7 @@ class QPainter;
*/
class GridManager
{
-public:
-
+ public:
enum Style
{
IntersectionDot = 0,
@@ -53,7 +52,7 @@ public:
GridManager();
- void drawGrid( QPixmap &image, const QRect& area, QPainter *painter );
+ void drawGrid( QPixmap& image, const QRect& area, QPainter* painter );
/**
* @returns a QRect defined by the grid that contains the point (x, y).
@@ -64,7 +63,7 @@ public:
* This is an overloaded member function, provided for convenience.
* @returns a QRect defined by the grid that contains the QPoint pos.
*/
- QRect rectContains( const QPoint &pos ) const;
+ QRect rectContains( const QPoint& pos ) const;
/**
* @returns @c true if the point (x, y) is over a grid crossing, otherwise
@@ -84,7 +83,7 @@ public:
* returns @c false.
* @see @p nearPos()
*/
- bool isNear( const QPoint &pos );
+ bool isNear( const QPoint& pos );
/**
* @returns the grid crossing position that is near the point (x,y). If
@@ -93,8 +92,7 @@ public:
*/
QPoint nearPos( int x = -1, int y = -1 );
-private:
-
+ private:
UInt m_uiHSpace;
UInt m_uiVSpace;
QColor m_cGridColor;
@@ -102,4 +100,4 @@ private:
QPoint m_nearPos;
};
-#endif // __GRIDMANAGER_H__
+#endif // __GRIDMANAGER_H__
diff --git a/app/HistogramWidget.cpp b/app/HistogramWidget.cpp
index a2a89dc..c36abf2 100644
--- a/app/HistogramWidget.cpp
+++ b/app/HistogramWidget.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -23,7 +23,7 @@
* Based on the work of Ricardo N. Rocha Sardo in SCode project
*/
-//TODO:
+// TODO:
// - Optimizar paintEvent. Parece haver codigo redundante !!
#include "config.h"
#include
@@ -31,14 +31,13 @@
#include
#include "HistogramWidget.h"
-class HistogramWorker: public QThread
+class HistogramWorker : public QThread
{
-private:
+ private:
QObject* m_parent;
PlaYUVerFrame* m_pcFrame;
-public:
-
+ public:
HistogramWorker( QObject* parent )
{
m_pcFrame = NULL;
@@ -54,18 +53,18 @@ public:
{
if( m_pcFrame && m_parent )
{
- EventData *eventData = new EventData();
-// eventDm_imageHistogramata->starting = true;
-// eventData->success = false;
-// eventData->histogram = m_histogram;
-// QCoreApplication::postEvent( m_parent, eventData );
+ EventData* eventData = new EventData();
+ // eventDm_imageHistogramata->starting = true;
+ // eventData->success = false;
+ // eventData->histogram = m_histogram;
+ // QCoreApplication::postEvent( m_parent, eventData );
eventData->starting = true;
m_pcFrame->calcHistogram();
eventData->starting = false;
-// eventData->success = m_pcFrame->getHasHistogram();
+ // eventData->success = m_pcFrame->getHasHistogram();
eventData->success = true;
eventData->frame = m_pcFrame;
QCoreApplication::postEvent( m_parent, eventData );
@@ -75,13 +74,10 @@ public:
/**
* Custom Event
*/
- class EventData: public QEvent
+ class EventData : public QEvent
{
-
- public:
-
- EventData() :
- QEvent( QEvent::User )
+ public:
+ EventData() : QEvent( QEvent::User )
{
starting = false;
success = false;
@@ -90,37 +86,34 @@ public:
bool starting;
bool success;
- PlaYUVerFrame *frame;
+ PlaYUVerFrame* frame;
};
-
};
-const QBrush g_eColorPallet[][3] =
+const QBrush g_eColorPallet[][3] = {
{
- {
- Qt::darkGray, // Luma
- Qt::blue, // Cb
- Qt::red, // Cr
- },
- {
- Qt::red, // Channel Red
- Qt::green, // Channel Green
- Qt::blue, // Channel Blue
- },
- };
+ Qt::darkGray, // Luma
+ Qt::blue, // Cb
+ Qt::red, // Cr
+ },
+ {
+ Qt::red, // Channel Red
+ Qt::green, // Channel Green
+ Qt::blue, // Channel Blue
+ },
+};
class HistogramWidgetPrivate
{
-public:
-
+ public:
enum RepaintType
{
- HistogramNone = 0, // No current histogram values calculation.
- HistogramDataLoading, // The image is being loaded
- HistogramStarted, // Histogram values calculation started.
- HistogramCompleted, // Histogram values calculation completed.
- HistogramSkipped, // Skip histogram while playing
- HistogramFailed // Histogram values calculation failed.
+ HistogramNone = 0, // No current histogram values calculation.
+ HistogramDataLoading, // The image is being loaded
+ HistogramStarted, // Histogram values calculation started.
+ HistogramCompleted, // Histogram values calculation completed.
+ HistogramSkipped, // Skip histogram while playing
+ HistogramFailed // Histogram values calculation failed.
};
HistogramWidgetPrivate()
@@ -142,7 +135,7 @@ public:
double xminOrg;
double xmax;
Int range;
- Int clearFlag; // Clear drawing zone with message.
+ Int clearFlag; // Clear drawing zone with message.
// Image informations
Int imageChannels;
@@ -152,17 +145,17 @@ public:
bool guideVisible; // Display color guide.
bool statisticsVisible; // Display tooltip histogram statistics.
bool inSelected;
- bool selectMode; // If true, a part of the histogram can be
- // selected !
+ bool selectMode; // If true, a part of the histogram can be
+ // selected !
bool blinkFlag;
- bool blinkComputation; // If true, a message will be displayed during
- // histogram computation, else nothing (limit
- // flicker effect in widget especially for small
- // image/computation time).
- bool lumaChannel; // Compute luminance channel if true.
+ bool blinkComputation; // If true, a message will be displayed during
+ // histogram computation, else nothing (limit
+ // flicker effect in widget especially for small
+ // image/computation time).
+ bool lumaChannel; // Compute luminance channel if true.
bool inInitialRepaintWait;
- QTimer *blinkTimer;
+ QTimer* blinkTimer;
QColor colorGuide;
};
@@ -171,15 +164,14 @@ public:
// Constructors
////////////////////////////////////////////////////////////////////////////////
-//Constructor without image data
-HistogramWidget::HistogramWidget( Int width, Int height, QWidget *parent ) :
- QWidget( parent )
+// Constructor without image data
+HistogramWidget::HistogramWidget( Int width, Int height, QWidget* parent ) : QWidget( parent )
{
setAttribute( Qt::WA_DeleteOnClose );
d = new HistogramWidgetPrivate;
-// m_channelType = LumaHistogram;
+ // m_channelType = LumaHistogram;
m_channelType = FirstChannelHistogram;
m_scaleType = LogScaleHistogram;
m_colorType = FirstChannelColor;
@@ -210,11 +202,11 @@ HistogramWidget::~HistogramWidget()
{
d->blinkTimer->stop();
-// if( m_imageHistogram )
-// delete m_imageHistogram;
-//
-// if( m_selectionHistogram )
-// delete m_selectionHistogram;
+ // if( m_imageHistogram )
+ // delete m_imageHistogram;
+ //
+ // if( m_selectionHistogram )
+ // delete m_selectionHistogram;
delete m_imageWorker;
delete m_selectionWorker;
@@ -227,10 +219,10 @@ HistogramWidget::~HistogramWidget()
Void HistogramWidget::setOptions( HistogramOptions options )
{
- d->statisticsVisible = ( bool )( options & ShowStatistics );
- d->selectMode = ( bool )( options & SelectMode );
- d->blinkComputation = ( bool )( options & BlinkComputation );
- d->lumaChannel = ( bool )( options & ShowLumaChannel );
+ d->statisticsVisible = (bool)( options & ShowStatistics );
+ d->selectMode = (bool)( options & SelectMode );
+ d->blinkComputation = (bool)( options & BlinkComputation );
+ d->lumaChannel = (bool)( options & ShowLumaChannel );
}
Void HistogramWidget::setHistogramGuideByColor( QColor color )
@@ -254,14 +246,14 @@ Void HistogramWidget::reset()
// Custom Event Handler
////////////////////////////////////////////////////////////////////////////////
-Void HistogramWidget::customEvent( QEvent *event )
+Void HistogramWidget::customEvent( QEvent* event )
{
if( !event )
{
return;
}
- HistogramWorker::EventData *ed = ( HistogramWorker::EventData* )event;
+ HistogramWorker::EventData* ed = (HistogramWorker::EventData*)event;
if( !ed )
{
@@ -326,21 +318,21 @@ Void HistogramWidget::customEvent( QEvent *event )
// Remove old histogram data from memory.
m_fullImage = NULL;
m_selectionImage = NULL;
-// if( m_imageHistogram )
-// {
-// delete m_imageHistogram;
-// m_imageHistogram = 0;
-// }
-// if( m_selectionHistogram )
-// {
-// delete m_selectionHistogram;
-// m_selectionHistogram = 0;
-// }
+ // if( m_imageHistogram )
+ // {
+ // delete m_imageHistogram;
+ // m_imageHistogram = 0;
+ // }
+ // if( m_selectionHistogram )
+ // {
+ // delete m_selectionHistogram;
+ // m_selectionHistogram = 0;
+ // }
emit signalHistogramComputationFailed();
}
}
- //delete ed;
+ // delete ed;
}
////////////////////////////////////////////////////////////////////////////////
// Data Loading Functions
@@ -382,11 +374,11 @@ Void HistogramWidget::setLoadingFailed()
Void HistogramWidget::stopHistogramComputation()
{
-// if( m_imageHistogram )
-// m_imageHistogram->setRunningFlag( false );
-//
-// if( m_selectionHistogram )
-// m_selectionHistogram->setRunningFlag( false );
+ // if( m_imageHistogram )
+ // m_imageHistogram->setRunningFlag( false );
+ //
+ // if( m_selectionHistogram )
+ // m_selectionHistogram->setRunningFlag( false );
d->blinkTimer->stop();
}
@@ -395,7 +387,7 @@ Void HistogramWidget::stopHistogramComputation()
// Update Data Methods
////////////////////////////////////////////////////////////////////////////////
-Void HistogramWidget::updateData( PlaYUVerFrame *pcFrame, PlaYUVerFrame *pcFrameSelection )
+Void HistogramWidget::updateData( PlaYUVerFrame* pcFrame, PlaYUVerFrame* pcFrameSelection )
{
d->imageBits = pcFrame->getBitsPel();
d->imageColorSpace = pcFrame->getColorSpace();
@@ -416,7 +408,6 @@ Void HistogramWidget::updateData( PlaYUVerFrame *pcFrame, PlaYUVerFrame *pcFrame
m_selectionImage = pcFrameSelection;
m_selectionWorker->setup( pcFrameSelection );
-
}
////////////////////////////////////////////////////////////////////////////////
@@ -433,7 +424,7 @@ Void HistogramWidget::slotBlinkTimerDone()
// Paint Event
////////////////////////////////////////////////////////////////////////////////
-Void HistogramWidget::paintEvent( QPaintEvent * )
+Void HistogramWidget::paintEvent( QPaintEvent* )
{
int maxX = size().width() - 1;
int maxY = size().height() - 1;
@@ -441,8 +432,9 @@ Void HistogramWidget::paintEvent( QPaintEvent * )
// Widget is disabled, not initialized,
// or loading, but no message shall be drawn:
// Drawing grayed frame.
- if( !isEnabled() || d->clearFlag == HistogramWidgetPrivate::HistogramNone
- || ( !d->blinkComputation && ( d->clearFlag == HistogramWidgetPrivate::HistogramStarted || d->clearFlag == HistogramWidgetPrivate::HistogramDataLoading ) ) )
+ if( !isEnabled() || d->clearFlag == HistogramWidgetPrivate::HistogramNone ||
+ ( !d->blinkComputation && ( d->clearFlag == HistogramWidgetPrivate::HistogramStarted ||
+ d->clearFlag == HistogramWidgetPrivate::HistogramDataLoading ) ) )
{
QPainter p1( this );
@@ -454,7 +446,8 @@ Void HistogramWidget::paintEvent( QPaintEvent * )
}
// Image data is loading or histogram is being computed:
// Draw message.
- else if( d->blinkComputation && ( d->clearFlag == HistogramWidgetPrivate::HistogramStarted || d->clearFlag == HistogramWidgetPrivate::HistogramDataLoading ) )
+ else if( d->blinkComputation && ( d->clearFlag == HistogramWidgetPrivate::HistogramStarted ||
+ d->clearFlag == HistogramWidgetPrivate::HistogramDataLoading ) )
{
QPainter p1( this );
@@ -480,7 +473,7 @@ Void HistogramWidget::paintEvent( QPaintEvent * )
p1.fillRect( 0, 0, maxX, maxY, Qt::white );
p1.setPen( Qt::darkGreen );
p1.drawText( 0, 0, maxX, maxY, Qt::AlignCenter, tr( "Histogram\ncalculation\nskipped." ) );
- //bitBlt(this, 0, 0, &pm);
+ // bitBlt(this, 0, 0, &pm);
return;
}
// Histogram computation failed:
@@ -491,16 +484,16 @@ Void HistogramWidget::paintEvent( QPaintEvent * )
p1.fillRect( 0, 0, maxX, maxY, Qt::white );
p1.setPen( Qt::red );
p1.drawText( 0, 0, maxX, maxY, Qt::AlignCenter, tr( "Histogram\ncalculation\nfailed." ) );
- //bitBlt(this, 0, 0, &pm);
+ // bitBlt(this, 0, 0, &pm);
return;
}
int x, y;
- int yr, yg, yb; // For all color channels.
+ int yr, yg, yb; // For all color channels.
int wWidth = width() - 1;
int wHeight = height() - 1;
double max;
- PlaYUVerFrame *frame;
+ PlaYUVerFrame* frame;
if( m_renderingType == ImageSelectionHistogram && m_selectionImage )
frame = m_selectionImage;
@@ -519,38 +512,38 @@ Void HistogramWidget::paintEvent( QPaintEvent * )
switch( m_channelType )
{
- case HistogramWidget::FirstChannelHistogram: // Y channel.
- max = frame->getMaximum( LUMA );
- break;
- case HistogramWidget::SecondChannelHistogram: // Cb channel.
- max = frame->getMaximum( CHROMA_U );
- break;
- case HistogramWidget::ThirdChannelHistogram: // Cr channel.
- max = frame->getMaximum( CHROMA_V );
- break;
- case HistogramWidget::AlphaChannelHistogram: // Alpha channel.
- max = frame->getMaximum( COLOR_A );
- break;
+ case HistogramWidget::FirstChannelHistogram: // Y channel.
+ max = frame->getMaximum( LUMA );
+ break;
+ case HistogramWidget::SecondChannelHistogram: // Cb channel.
+ max = frame->getMaximum( CHROMA_U );
+ break;
+ case HistogramWidget::ThirdChannelHistogram: // Cr channel.
+ max = frame->getMaximum( CHROMA_V );
+ break;
+ case HistogramWidget::AlphaChannelHistogram: // Alpha channel.
+ max = frame->getMaximum( COLOR_A );
+ break;
- case HistogramWidget::ColorChannelsHistogram: // All color channels.
- max = qMax( qMax( frame->getMaximum( LUMA ), frame->getMaximum( CHROMA_U ) ), frame->getMaximum( CHROMA_V ) );
- break;
-// case HistogramWidget::LumaHistogram: // Luminance.
-// max = frame->getMaximum( LUMA );
-// break;
+ case HistogramWidget::ColorChannelsHistogram: // All color channels.
+ max = qMax( qMax( frame->getMaximum( LUMA ), frame->getMaximum( CHROMA_U ) ), frame->getMaximum( CHROMA_V ) );
+ break;
+ // case HistogramWidget::LumaHistogram: // Luminance.
+ // max = frame->getMaximum( LUMA );
+ // break;
}
switch( m_scaleType )
{
- case HistogramWidget::LinScaleHistogram:
- break;
+ case HistogramWidget::LinScaleHistogram:
+ break;
- case HistogramWidget::LogScaleHistogram:
- if( max > 0.0 )
- max = log( max );
- else
- max = 1.0;
- break;
+ case HistogramWidget::LogScaleHistogram:
+ if( max > 0.0 )
+ max = log( max );
+ else
+ max = 1.0;
+ break;
}
// From Qt 4.0, QWidget automatically double-buffers its painting,
@@ -573,7 +566,7 @@ Void HistogramWidget::paintEvent( QPaintEvent * )
do
{
double v;
- double vr, vg, vb; // For all color channels.
+ double vr, vg, vb; // For all color channels.
v = 0.0;
vr = 0.0;
@@ -582,27 +575,26 @@ Void HistogramWidget::paintEvent( QPaintEvent * )
switch( m_channelType )
{
- case HistogramWidget::FirstChannelHistogram: // Y channel.
- v = frame->getHistogramValue( LUMA, i++ );
- break;
- case HistogramWidget::SecondChannelHistogram: // Cb channel.
- v = frame->getHistogramValue( CHROMA_U, i++ );
- break;
- case HistogramWidget::ThirdChannelHistogram: // Cr channel.
- v = frame->getHistogramValue( CHROMA_V, i++ );
- break;
- case HistogramWidget::AlphaChannelHistogram: // Alpha channel.
- v = frame->getHistogramValue( COLOR_A, i++ );
- break;
- case HistogramWidget::ColorChannelsHistogram: // All color.
- vr = frame->getHistogramValue( LUMA, i );
- vg = frame->getHistogramValue( CHROMA_U, i );
- vb = frame->getHistogramValue( CHROMA_V, i++ );
- break;
-// case HistogramWidget::LumaHistogram: // Luminance.
-// v = frame->getHistogramValue( LUMA, i++ );
-// break;
-
+ case HistogramWidget::FirstChannelHistogram: // Y channel.
+ v = frame->getHistogramValue( LUMA, i++ );
+ break;
+ case HistogramWidget::SecondChannelHistogram: // Cb channel.
+ v = frame->getHistogramValue( CHROMA_U, i++ );
+ break;
+ case HistogramWidget::ThirdChannelHistogram: // Cr channel.
+ v = frame->getHistogramValue( CHROMA_V, i++ );
+ break;
+ case HistogramWidget::AlphaChannelHistogram: // Alpha channel.
+ v = frame->getHistogramValue( COLOR_A, i++ );
+ break;
+ case HistogramWidget::ColorChannelsHistogram: // All color.
+ vr = frame->getHistogramValue( LUMA, i );
+ vg = frame->getHistogramValue( CHROMA_U, i );
+ vb = frame->getHistogramValue( CHROMA_V, i++ );
+ break;
+ // case HistogramWidget::LumaHistogram: // Luminance.
+ // v = frame->getHistogramValue( LUMA, i++ );
+ // break;
}
if( m_channelType != HistogramWidget::ColorChannelsHistogram )
@@ -619,55 +611,54 @@ Void HistogramWidget::paintEvent( QPaintEvent * )
if( vb > value_b )
value_b = vb;
}
- }
- while( i < j );
+ } while( i < j );
if( m_channelType != HistogramWidget::ColorChannelsHistogram )
{
switch( m_scaleType )
{
- case HistogramWidget::LinScaleHistogram:
- y = ( int )( ( wHeight * value ) / max );
- break;
+ case HistogramWidget::LinScaleHistogram:
+ y = (int)( ( wHeight * value ) / max );
+ break;
- case HistogramWidget::LogScaleHistogram:
- if( value <= 0.0 )
- value = 1.0;
- y = ( int )( ( wHeight * log( value ) ) / max );
- break;
+ case HistogramWidget::LogScaleHistogram:
+ if( value <= 0.0 )
+ value = 1.0;
+ y = (int)( ( wHeight * log( value ) ) / max );
+ break;
- default:
- y = 0;
- break;
+ default:
+ y = 0;
+ break;
}
}
else
{
switch( m_scaleType )
{
- case HistogramWidget::LinScaleHistogram:
- yr = ( int )( ( wHeight * value_r ) / max );
- yg = ( int )( ( wHeight * value_g ) / max );
- yb = ( int )( ( wHeight * value_b ) / max );
- break;
+ case HistogramWidget::LinScaleHistogram:
+ yr = (int)( ( wHeight * value_r ) / max );
+ yg = (int)( ( wHeight * value_g ) / max );
+ yb = (int)( ( wHeight * value_b ) / max );
+ break;
- case HistogramWidget::LogScaleHistogram:
- if( value_r <= 0.0 )
- value_r = 1.0;
- if( value_g <= 0.0 )
- value_g = 1.0;
- if( value_b <= 0.0 )
- value_b = 1.0;
- yr = ( int )( ( wHeight * log( value_r ) ) / max );
- yg = ( int )( ( wHeight * log( value_g ) ) / max );
- yb = ( int )( ( wHeight * log( value_b ) ) / max );
- break;
+ case HistogramWidget::LogScaleHistogram:
+ if( value_r <= 0.0 )
+ value_r = 1.0;
+ if( value_g <= 0.0 )
+ value_g = 1.0;
+ if( value_b <= 0.0 )
+ value_b = 1.0;
+ yr = (int)( ( wHeight * log( value_r ) ) / max );
+ yg = (int)( ( wHeight * log( value_g ) ) / max );
+ yb = (int)( ( wHeight * log( value_b ) ) / max );
+ break;
- default:
- yr = 0;
- yg = 0;
- yb = 0;
- break;
+ default:
+ yr = 0;
+ yg = 0;
+ yb = 0;
+ break;
}
}
@@ -675,9 +666,9 @@ Void HistogramWidget::paintEvent( QPaintEvent * )
if( m_channelType != HistogramWidget::ColorChannelsHistogram )
{
- if( d->selectMode == true ) // Selection mode enable ?
+ if( d->selectMode == true ) // Selection mode enable ?
{
- if( x >= ( int )( d->xmin * wWidth ) && x <= ( int )( d->xmax * wWidth ) )
+ if( x >= (int)( d->xmin * wWidth ) && x <= (int)( d->xmax * wWidth ) )
{
p1.setPen( QPen( Qt::black, 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, 0 );
@@ -712,11 +703,11 @@ Void HistogramWidget::paintEvent( QPaintEvent * )
}
}
}
- else // All colors channel
+ else // All colors channel
{
- if( d->selectMode == true ) // Histogram selection mode enable ?
+ if( d->selectMode == true ) // Histogram selection mode enable ?
{
- if( x >= ( int )( d->xmin * wWidth ) && x <= ( int )( d->xmax * wWidth ) )
+ if( x >= (int)( d->xmin * wWidth ) && x <= (int)( d->xmax * wWidth ) )
{
p1.setPen( QPen( Qt::black, 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, 0 );
@@ -726,17 +717,17 @@ Void HistogramWidget::paintEvent( QPaintEvent * )
// colors channel mode?
switch( m_colorType )
{
- case HistogramWidget::FirstChannelColor:
- p1.drawLine( x, wHeight, x, wHeight - yr );
- break;
+ case HistogramWidget::FirstChannelColor:
+ p1.drawLine( x, wHeight, x, wHeight - yr );
+ break;
- case HistogramWidget::SecondChannelColor:
- p1.drawLine( x, wHeight, x, wHeight - yg );
- break;
+ case HistogramWidget::SecondChannelColor:
+ p1.drawLine( x, wHeight, x, wHeight - yg );
+ break;
- default:
- p1.drawLine( x, wHeight, x, wHeight - yb );
- break;
+ default:
+ p1.drawLine( x, wHeight, x, wHeight - yb );
+ break;
}
}
else
@@ -745,56 +736,56 @@ Void HistogramWidget::paintEvent( QPaintEvent * )
// colors channel mode?
switch( m_colorType )
{
- case HistogramWidget::FirstChannelColor:
- p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight, x, wHeight - yg );
- p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight, x, wHeight - yb );
- p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight, x, wHeight - yr );
+ case HistogramWidget::FirstChannelColor:
+ p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight, x, wHeight - yg );
+ p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight, x, wHeight - yb );
+ p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight, x, wHeight - yr );
- p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
- p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
- p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
- p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
+ p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
+ p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
+ p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
+ p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
- break;
+ break;
- case HistogramWidget::SecondChannelColor:
- p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight, x, wHeight - yb );
- p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight, x, wHeight - yr );
- p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight, x, wHeight - yg );
+ case HistogramWidget::SecondChannelColor:
+ p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight, x, wHeight - yb );
+ p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight, x, wHeight - yr );
+ p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight, x, wHeight - yg );
- p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
- p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
- p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
- p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
+ p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
+ p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
+ p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
+ p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
- break;
+ break;
- default:
- p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight, x, wHeight - yr );
- p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight, x, wHeight - yg );
- p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight, x, wHeight - yb );
+ default:
+ p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight, x, wHeight - yr );
+ p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight, x, wHeight - yg );
+ p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight, x, wHeight - yb );
- p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
- p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
- p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
- p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
+ p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
+ p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
+ p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
+ p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
- break;
+ break;
}
if( x == wWidth / 4 || x == wWidth / 2 || x == 3 * wWidth / 4 )
@@ -810,65 +801,65 @@ Void HistogramWidget::paintEvent( QPaintEvent * )
// colors channel mode?
switch( m_colorType )
{
- case HistogramWidget::FirstChannelColor:
- p1.setPen( QPen( Qt::green, 1, Qt::SolidLine ) );
- p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight, x, wHeight - yg );
- p1.setPen( QPen( Qt::blue, 1, Qt::SolidLine ) );
- p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight, x, wHeight - yb );
- p1.setPen( QPen( Qt::red, 1, Qt::SolidLine ) );
- p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight, x, wHeight - yr );
+ case HistogramWidget::FirstChannelColor:
+ p1.setPen( QPen( Qt::green, 1, Qt::SolidLine ) );
+ p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight, x, wHeight - yg );
+ p1.setPen( QPen( Qt::blue, 1, Qt::SolidLine ) );
+ p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight, x, wHeight - yb );
+ p1.setPen( QPen( Qt::red, 1, Qt::SolidLine ) );
+ p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight, x, wHeight - yr );
- p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
- p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
- p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
- p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
+ p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
+ p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
+ p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
+ p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
- break;
+ break;
- case HistogramWidget::SecondChannelColor:
- p1.setPen( QPen( Qt::blue, 1, Qt::SolidLine ) );
- p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight, x, wHeight - yb );
- p1.setPen( QPen( Qt::red, 1, Qt::SolidLine ) );
- p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight, x, wHeight - yr );
- p1.setPen( QPen( Qt::green, 1, Qt::SolidLine ) );
- p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight, x, wHeight - yg );
+ case HistogramWidget::SecondChannelColor:
+ p1.setPen( QPen( Qt::blue, 1, Qt::SolidLine ) );
+ p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight, x, wHeight - yb );
+ p1.setPen( QPen( Qt::red, 1, Qt::SolidLine ) );
+ p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight, x, wHeight - yr );
+ p1.setPen( QPen( Qt::green, 1, Qt::SolidLine ) );
+ p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight, x, wHeight - yg );
- p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
- p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
- p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
- p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
+ p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
+ p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
+ p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
+ p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
- break;
+ break;
- default:
- p1.setPen( QPen( Qt::red, 1, Qt::SolidLine ) );
- p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight, x, wHeight - yr );
- p1.setPen( QPen( Qt::green, 1, Qt::SolidLine ) );
- p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight, x, wHeight - yg );
- p1.setPen( QPen( Qt::blue, 1, Qt::SolidLine ) );
- p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight, x, wHeight - yb );
+ default:
+ p1.setPen( QPen( Qt::red, 1, Qt::SolidLine ) );
+ p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight, x, wHeight - yr );
+ p1.setPen( QPen( Qt::green, 1, Qt::SolidLine ) );
+ p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight, x, wHeight - yg );
+ p1.setPen( QPen( Qt::blue, 1, Qt::SolidLine ) );
+ p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight, x, wHeight - yb );
- p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
- p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
- p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
- p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
- p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
+ p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
+ p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
+ p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
+ p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
+ p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
- break;
+ break;
}
if( x == wWidth / 4 || x == wWidth / 2 || x == 3 * wWidth / 4 )
@@ -889,25 +880,25 @@ Void HistogramWidget::paintEvent( QPaintEvent * )
{
switch( m_channelType )
{
- case HistogramWidget::FirstChannelHistogram:
- guidePos = d->colorGuide.red();
- break;
+ case HistogramWidget::FirstChannelHistogram:
+ guidePos = d->colorGuide.red();
+ break;
- case HistogramWidget::SecondChannelHistogram:
- guidePos = d->colorGuide.green();
- break;
+ case HistogramWidget::SecondChannelHistogram:
+ guidePos = d->colorGuide.green();
+ break;
- case HistogramWidget::ThirdChannelHistogram:
- guidePos = d->colorGuide.blue();
- break;
+ case HistogramWidget::ThirdChannelHistogram:
+ guidePos = d->colorGuide.blue();
+ break;
-// case HistogramWidget::LumaHistogram:
-// guidePos = qMax( qMax( d->colorGuide.red(), d->colorGuide.green() ), d->colorGuide.blue() );
-// break;
+ // case HistogramWidget::LumaHistogram:
+ // guidePos = qMax( qMax( d->colorGuide.red(), d->colorGuide.green() ), d->colorGuide.blue() );
+ // break;
- default: // Alpha.
- guidePos = -1;
- break;
+ default: // Alpha.
+ guidePos = -1;
+ break;
}
if( guidePos != -1 )
@@ -954,7 +945,7 @@ Void HistogramWidget::paintEvent( QPaintEvent * )
tipText += cellBeg + tr( "Pixels:" ) + cellMid;
double pixels = frame->getPixels();
- tipText += value.setNum( ( float )pixels, 'f', 0 ) + cellEnd;
+ tipText += value.setNum( (float)pixels, 'f', 0 ) + cellEnd;
tipText += cellBeg + tr( "Std dev.:" ) + cellMid;
double stddev = frame->getStdDev( m_channelType, 0, frame->getHistogramSegment() - 1 );
@@ -962,7 +953,7 @@ Void HistogramWidget::paintEvent( QPaintEvent * )
tipText += cellBeg + tr( "Selected:" ) + cellMid;
double counts = frame->getCount( m_channelType, 0, frame->getHistogramSegment() - 1 );
- tipText += value.setNum( ( float )counts, 'f', 0 ) + cellEnd;
+ tipText += value.setNum( (float)counts, 'f', 0 ) + cellEnd;
tipText += cellBeg + tr( "Median:" ) + cellMid;
double median = frame->getMedian( m_channelType, 0, frame->getHistogramSegment() - 1 );
@@ -982,14 +973,14 @@ Void HistogramWidget::paintEvent( QPaintEvent * )
p1.setPen( QPen( Qt::black, 1, Qt::SolidLine ) );
p1.drawRect( 0, 0, maxX, maxY );
- //bitBlt(this, 0, 0, &pm);
+ // bitBlt(this, 0, 0, &pm);
}
////////////////////////////////////////////////////////////////////////////////
// Mouse Events
////////////////////////////////////////////////////////////////////////////////
-Void HistogramWidget::mousePressEvent( QMouseEvent * e )
+Void HistogramWidget::mousePressEvent( QMouseEvent* e )
{
if( d->selectMode == true && d->clearFlag == HistogramWidgetPrivate::HistogramCompleted )
{
@@ -999,15 +990,15 @@ Void HistogramWidget::mousePressEvent( QMouseEvent * e )
update();
}
- d->xmin = ( ( double )e->pos().x() ) / ( ( double )width() );
+ d->xmin = ( (double)e->pos().x() ) / ( (double)width() );
d->xminOrg = d->xmin;
notifyValuesChanged();
- //emit signalValuesChanged( (int)(d->xmin * d->range), );
+ // emit signalValuesChanged( (int)(d->xmin * d->range), );
d->xmax = 0.0;
}
}
-Void HistogramWidget::mouseReleaseEvent( QMouseEvent * )
+Void HistogramWidget::mouseReleaseEvent( QMouseEvent* )
{
if( d->selectMode == true && d->clearFlag == HistogramWidgetPrivate::HistogramCompleted )
@@ -1017,15 +1008,15 @@ Void HistogramWidget::mouseReleaseEvent( QMouseEvent * )
if( d->xmax == 0.0 )
{
d->xmin = 0.0;
- //emit signalMinValueChanged( 0 );
- //emit signalMaxValueChanged( d->range );
+ // emit signalMinValueChanged( 0 );
+ // emit signalMaxValueChanged( d->range );
notifyValuesChanged();
update();
}
}
}
-Void HistogramWidget::mouseMoveEvent( QMouseEvent * e )
+Void HistogramWidget::mouseMoveEvent( QMouseEvent* e )
{
if( d->selectMode == true && d->clearFlag == HistogramWidgetPrivate::HistogramCompleted )
{
@@ -1033,14 +1024,14 @@ Void HistogramWidget::mouseMoveEvent( QMouseEvent * e )
if( d->inSelected )
{
- double max = ( ( double )e->pos().x() ) / ( ( double )width() );
- //int max = (int)(e->pos().x()*((float)m_imageHistogram->getHistogramSegment()/(float)width()));
+ double max = ( (double)e->pos().x() ) / ( (double)width() );
+ // int max = (int)(e->pos().x()*((float)m_imageHistogram->getHistogramSegment()/(float)width()));
if( max < d->xminOrg )
{
d->xmax = d->xminOrg;
d->xmin = max;
- //emit signalMinValueChanged( (int)(d->xmin * d->range) );
+ // emit signalMinValueChanged( (int)(d->xmin * d->range) );
}
else
{
@@ -1049,7 +1040,7 @@ Void HistogramWidget::mouseMoveEvent( QMouseEvent * e )
}
notifyValuesChanged();
- //emit signalMaxValueChanged( d->xmax == 0.0 ? d->range : (int)(d->xmax * d->range) );
+ // emit signalMaxValueChanged( d->xmax == 0.0 ? d->range : (int)(d->xmax * d->range) );
update();
}
@@ -1060,7 +1051,7 @@ Void HistogramWidget::mouseMoveEvent( QMouseEvent * e )
Void HistogramWidget::notifyValuesChanged()
{
- emit signalIntervalChanged( ( int )( d->xmin * d->range ), d->xmax == 0.0 ? d->range : ( int )( d->xmax * d->range ) );
+ emit signalIntervalChanged( (int)( d->xmin * d->range ), d->xmax == 0.0 ? d->range : (int)( d->xmax * d->range ) );
}
Void HistogramWidget::slotMinValueChanged( int min )
@@ -1075,7 +1066,7 @@ Void HistogramWidget::slotMinValueChanged( int min )
}
if( min >= 0 && min < d->range )
{
- d->xmin = ( ( double )min ) / d->range;
+ d->xmin = ( (double)min ) / d->range;
}
update();
}
@@ -1093,9 +1084,8 @@ Void HistogramWidget::slotMaxValueChanged( int max )
}
else if( max > 0 && max <= d->range )
{
- d->xmax = ( ( double )max ) / d->range;
+ d->xmax = ( (double)max ) / d->range;
}
update();
}
}
-
diff --git a/app/HistogramWidget.h b/app/HistogramWidget.h
index a10a0d1..23104a5 100644
--- a/app/HistogramWidget.h
+++ b/app/HistogramWidget.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -37,16 +37,15 @@ class QEvent;
class HistogramWorker;
class HistogramWidgetPrivate;
-class HistogramWidget: public QWidget
+class HistogramWidget : public QWidget
{
-Q_OBJECT
-
-public:
+ Q_OBJECT
+ public:
enum HistogramChannel
{
/** Luminance */
- //LumaHistogram = 0,
+ // LumaHistogram = 0,
/** Channels */
FirstChannelHistogram = 0,
SecondChannelHistogram,
@@ -93,10 +92,10 @@ public:
ShowLumaChannel = 0x8,
/** Set all the options */
AllOptions = BlinkComputation | ShowStatistics | SelectMode | ShowLumaChannel
- };Q_DECLARE_FLAGS( HistogramOptions, HistogramOption )
-
-public :
+ };
+ Q_DECLARE_FLAGS( HistogramOptions, HistogramOption )
+ public:
/**
* Constructor without image data. Needed to use @p updateData() method
* after to create instance.
@@ -104,7 +103,7 @@ public :
* @param height of the widget
* @param parent the histogram widget parent
*/
- HistogramWidget( Int width, Int height, QWidget *parent = 0 );
+ HistogramWidget( Int width, Int height, QWidget* parent = 0 );
~HistogramWidget();
@@ -112,7 +111,7 @@ public :
Void stopHistogramComputation();
/** Update full image histogram data. */
- Void updateData( PlaYUVerFrame *pcFrame, PlaYUVerFrame *pcFrameSelection );
+ Void updateData( PlaYUVerFrame* pcFrame, PlaYUVerFrame* pcFrameSelection );
/** @see @p HistogramOption */
Void setOptions( HistogramOptions options = AllOptions );
@@ -123,7 +122,7 @@ public :
Void reset();
-public:
+ public:
/** Channel type to draw */
Int m_channelType;
/** Scale to use for drawing */
@@ -135,40 +134,40 @@ public:
/** Full image */
HistogramWorker* m_imageWorker;
- //PlaYUVerFrameStats* m_imageHistogram;
+ // PlaYUVerFrameStats* m_imageHistogram;
PlaYUVerFrame* m_fullImage;
/** Histogram area selection */
HistogramWorker* m_selectionWorker;
- //PlaYUVerFrameStats* m_selectionHistogram;
+ // PlaYUVerFrameStats* m_selectionHistogram;
PlaYUVerFrame* m_selectionImage;
- Q_SIGNALS:
+ Q_SIGNALS:
void signalIntervalChanged( int min, int max );
void signalMaximumValueChanged( int );
void signalHistogramComputationDone( int );
void signalHistogramComputationFailed( void );
-public Q_SLOTS:
+ public Q_SLOTS:
void slotMinValueChanged( int min );
void slotMaxValueChanged( int max );
-protected slots:
+ protected slots:
void slotBlinkTimerDone( void );
-protected:
- Void paintEvent( QPaintEvent * );
- Void mousePressEvent( QMouseEvent * e );
- Void mouseReleaseEvent( QMouseEvent * e );
- Void mouseMoveEvent( QMouseEvent * e );
+ protected:
+ Void paintEvent( QPaintEvent* );
+ Void mousePressEvent( QMouseEvent* e );
+ Void mouseReleaseEvent( QMouseEvent* e );
+ Void mouseMoveEvent( QMouseEvent* e );
-private:
- Void customEvent( QEvent *event );
+ private:
+ Void customEvent( QEvent* event );
Void notifyValuesChanged();
-private:
+ private:
HistogramWidgetPrivate* d;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( HistogramWidget::HistogramOptions )
-#endif // __HISTOGRAMWIDGET_H__
+#endif // __HISTOGRAMWIDGET_H__
diff --git a/app/ModuleHandleDock.cpp b/app/ModuleHandleDock.cpp
index e39fab2..ca2cc6a 100644
--- a/app/ModuleHandleDock.cpp
+++ b/app/ModuleHandleDock.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -27,9 +27,8 @@
#include "PlaYUVerAppModuleIf.h"
#include "ModulesHandle.h"
-ModuleHandleDock::ModuleHandleDock( QWidget* parent, PlaYUVerAppModuleIf* moduleIf ) :
- QWidget( parent ),
- m_pcCurrModuleIf( moduleIf )
+ModuleHandleDock::ModuleHandleDock( QWidget* parent, PlaYUVerAppModuleIf* moduleIf )
+ : QWidget( parent ), m_pcCurrModuleIf( moduleIf )
{
// ----------------- Dock definition -----------------
@@ -42,7 +41,7 @@ ModuleHandleDock::ModuleHandleDock( QWidget* parent, PlaYUVerAppModuleIf* module
labelModulueReturnValue = new QLabel;
labelModulueReturnValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
- QGridLayout *modulesPropertiesLayout = new QGridLayout;
+ QGridLayout* modulesPropertiesLayout = new QGridLayout;
Int layout_line = 0;
modulesPropertiesLayout->addWidget( labelModulueValueLabel, layout_line, 0 );
modulesPropertiesLayout->addWidget( labelModulueReturnValue, layout_line, 1 );
@@ -52,12 +51,10 @@ ModuleHandleDock::ModuleHandleDock( QWidget* parent, PlaYUVerAppModuleIf* module
setLayout( modulesPropertiesLayout );
setEnabled( true );
-
}
ModuleHandleDock::~ModuleHandleDock()
{
-
}
Void ModuleHandleDock::setModulueReturnValue( Double value )
@@ -86,4 +83,3 @@ QSize ModuleHandleDock::sizeHint() const
else
return currSize;
}
-
diff --git a/app/ModuleHandleDock.h b/app/ModuleHandleDock.h
index 0103451..f86a7a0 100644
--- a/app/ModuleHandleDock.h
+++ b/app/ModuleHandleDock.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -36,10 +36,10 @@
class PlaYUVerAppModuleIf;
-class ModuleHandleDock: public QWidget
+class ModuleHandleDock : public QWidget
{
Q_OBJECT
- public:
+ public:
ModuleHandleDock( QWidget* parent, PlaYUVerAppModuleIf* moduleIf );
~ModuleHandleDock();
@@ -47,17 +47,15 @@ class ModuleHandleDock: public QWidget
QSize sizeHint() const;
-private:
-
+ private:
PlaYUVerAppModuleIf* m_pcCurrModuleIf;
Bool m_bIsVisible;
QLabel* labelModulueValueLabel;
QLabel* labelModulueReturnValue;
-public Q_SLOTS:
+ public Q_SLOTS:
void visibilityChangedSlot( bool );
-
};
-#endif // __MODULEHANDLEDOCK_H__
+#endif // __MODULEHANDLEDOCK_H__
diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp
index c6798b7..f430c9f 100644
--- a/app/ModulesHandle.cpp
+++ b/app/ModulesHandle.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -32,11 +32,8 @@
#include "ModulesHandleOptDialog.h"
#include "modules/PlaYUVerModuleFactory.h"
-ModulesHandle::ModulesHandle( QWidget* parent, PlaYUVerSubWindowHandle *windowManager, VideoHandle *moduleVideo ) :
- QWidget( parent ),
- m_pcParent( parent ),
- m_pcMainWindowManager( windowManager ),
- m_appModuleVideo( moduleVideo )
+ModulesHandle::ModulesHandle( QWidget* parent, PlaYUVerSubWindowHandle* windowManager, VideoHandle* moduleVideo )
+ : QWidget( parent ), m_pcParent( parent ), m_pcMainWindowManager( windowManager ), m_appModuleVideo( moduleVideo )
{
setParent( m_pcParent );
}
@@ -50,7 +47,7 @@ Void ModulesHandle::createActions()
m_arrayActions.resize( MODULES_TOTAL_ACT );
m_pcActionMapper = new QSignalMapper( this );
- connect( m_pcActionMapper, SIGNAL( mapped(int) ), this, SLOT( processOpt(int) ) );
+ connect( m_pcActionMapper, SIGNAL( mapped( int ) ), this, SLOT( processOpt( int ) ) );
// m_arrayActions[FORCE_PLAYING_REFRESH_ACT] = new QAction( "Refresh while playing", parent() );
// m_arrayActions[FORCE_PLAYING_REFRESH_ACT]->setStatusTip( "Force module refreshing while playing" );
@@ -77,9 +74,9 @@ Void ModulesHandle::createActions()
connect( m_arrayActions[DISABLE_ALL_ACT], SIGNAL( triggered() ), this, SLOT( destroyAllModulesIf() ) );
m_arrayActions[FORCE_NEW_WINDOW_ACT] = new QAction( "Use New Window", parent() );
- m_arrayActions[FORCE_NEW_WINDOW_ACT]->setStatusTip( "Show module result in a new window. Some modules already force this feature" );
+ m_arrayActions[FORCE_NEW_WINDOW_ACT]->setStatusTip(
+ "Show module result in a new window. Some modules already force this feature" );
m_arrayActions[FORCE_NEW_WINDOW_ACT]->setCheckable( true );
-
}
QMenu* ModulesHandle::createMenu()
@@ -155,7 +152,7 @@ Void ModulesHandle::buildMenu()
Void ModulesHandle::updateMenus()
{
- VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
+ VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
Bool hasSubWindow = pcSubWindow ? true : false;
QAction* currModuleAction;
@@ -209,7 +206,7 @@ Void ModulesHandle::writeSettings()
Void ModulesHandle::processOpt( Int index )
{
- VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
+ VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
if( pcSubWindow )
{
PlaYUVerAppModuleIf* pcCurrentModule = pcSubWindow->getDisplayModule();
@@ -218,16 +215,16 @@ Void ModulesHandle::processOpt( Int index )
PlaYUVerAppModuleIf* pcCurrModule = pcCurrentModule;
switch( index )
{
- case INVALID_OPT:
- break;
- case SWAP_FRAMES_ACT:
- swapModulesWindowsIf( pcCurrModule );
- break;
- case APPLY_ALL_ACT:
- applyAllModuleIf( pcCurrModule );
- break;
- default:
- Q_ASSERT( 0 );
+ case INVALID_OPT:
+ break;
+ case SWAP_FRAMES_ACT:
+ swapModulesWindowsIf( pcCurrModule );
+ break;
+ case APPLY_ALL_ACT:
+ applyAllModuleIf( pcCurrModule );
+ break;
+ default:
+ Q_ASSERT( 0 );
}
}
emit changed();
@@ -241,10 +238,9 @@ Void ModulesHandle::loadExternalModule()
QStringList formatsList;
formatsList << "Shared Libraries (*.so)";
QStringList filter;
- filter << supported
- << formatsList
- << tr( "All Files (*)" );
- QStringList fileNames = QFileDialog::getOpenFileNames( m_pcParent, tr( "Open File" ), QString(), filter.join( ";;" ) );
+ filter << supported << formatsList << tr( "All Files (*)" );
+ QStringList fileNames =
+ QFileDialog::getOpenFileNames( m_pcParent, tr( "Open File" ), QString(), filter.join( ";;" ) );
for( Int i = 0; i < fileNames.size(); i++ )
{
@@ -256,11 +252,11 @@ Void ModulesHandle::loadExternalModule()
Void ModulesHandle::activateModule()
{
- QAction *pcAction = qobject_cast( sender() );
+ QAction* pcAction = qobject_cast( sender() );
Qt::KeyboardModifiers keyModifiers = QApplication::keyboardModifiers();
Bool bTmpForceNewWindow = false;
- VideoSubWindow* pcVideoSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
+ VideoSubWindow* pcVideoSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
if( !pcVideoSubWindow )
{
return;
@@ -272,7 +268,8 @@ Void ModulesHandle::activateModule()
}
QString ModuleIfName = pcAction->data().toString();
- PlaYUVerModuleIf* pcCurrModuleIf = PlaYUVerModuleFactory::Get()->CreateModule( ModuleIfName.toLocal8Bit().constData() );
+ PlaYUVerModuleIf* pcCurrModuleIf =
+ PlaYUVerModuleFactory::Get()->CreateModule( ModuleIfName.toLocal8Bit().constData() );
PlaYUVerAppModuleIf* pcCurrAppModuleIf = new PlaYUVerAppModuleIf( this, pcAction, pcCurrModuleIf );
QList videoSubWindowList;
@@ -286,10 +283,11 @@ Void ModulesHandle::activateModule()
minNumFrames = 0;
maxNumFrames = 255;
}
- DialogSubWindowSelector dialogWindowsSelection( m_pcParent, m_pcMainWindowManager, SubWindowAbstract::VIDEO_SUBWINDOW, minNumFrames, maxNumFrames );
+ DialogSubWindowSelector dialogWindowsSelection( m_pcParent, m_pcMainWindowManager,
+ SubWindowAbstract::VIDEO_SUBWINDOW, minNumFrames, maxNumFrames );
QList windowsList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
- if( windowsList.size() == minNumFrames && windowsList.size() == maxNumFrames )
+ if( windowsList.size() == minNumFrames && windowsList.size() == maxNumFrames )
{
for( Int i = 0; i < windowsList.size(); i++ )
{
@@ -311,7 +309,7 @@ Void ModulesHandle::activateModule()
}
if( dialogWindowsSelection.exec() == QDialog::Accepted )
{
- VideoSubWindow *videoSubWindow;
+ VideoSubWindow* videoSubWindow;
QList subWindowList = dialogWindowsSelection.getSelectedWindows();
for( Int i = 0; i < subWindowList.size(); i++ )
{
@@ -342,7 +340,8 @@ Void ModulesHandle::activateModule()
if( videoSubWindowList.size() == 0 )
{
- qobject_cast( m_pcParent )->printMessage( "Error! There is no windows to apply the module", LOG_ERROR );
+ qobject_cast( m_pcParent )
+ ->printMessage( "Error! There is no windows to apply the module", LOG_ERROR );
destroyModuleIf( pcCurrAppModuleIf );
return;
}
@@ -370,16 +369,19 @@ Void ModulesHandle::activateModule()
VideoSubWindow* pcModuleSubWindow = NULL;
if( pcCurrAppModuleIf->m_pcModule->m_iModuleType == FRAME_PROCESSING_MODULE )
{
- if( ( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow )
+ if( ( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) ||
+ bShowModulesNewWindow )
{
pcModuleSubWindow = new VideoSubWindow( VideoSubWindow::MODULE_SUBWINDOW );
windowName.append( QStringLiteral( "Module " ) );
windowName.append( pcCurrAppModuleIf->m_pcModule->m_pchModuleName );
- connect( pcModuleSubWindow->getViewArea(), SIGNAL( selectionChanged( QRect ) ), m_appModuleVideo, SLOT( updateSelectionArea( QRect ) ) );
+ connect( pcModuleSubWindow->getViewArea(), SIGNAL( selectionChanged( QRect ) ), m_appModuleVideo,
+ SLOT( updateSelectionArea( QRect ) ) );
connect( pcModuleSubWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), m_appModuleVideo,
- SLOT( zoomToFactorAll( double, QPoint ) ) );
- connect( pcModuleSubWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), m_appModuleVideo, SLOT( moveAllScrollBars( const QPoint ) ) );
+ SLOT( zoomToFactorAll( double, QPoint ) ) );
+ connect( pcModuleSubWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), m_appModuleVideo,
+ SLOT( moveAllScrollBars( const QPoint ) ) );
pcCurrAppModuleIf->m_pcDisplaySubWindow = pcModuleSubWindow;
}
@@ -395,7 +397,8 @@ Void ModulesHandle::activateModule()
pcCurrAppModuleIf->m_pcDockWidget->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
pcCurrAppModuleIf->m_pcDockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
pcCurrAppModuleIf->m_pcDockWidget->setWidget( pcCurrAppModuleIf->m_pcModuleDock );
- qobject_cast( m_pcParent )->addDockWidget( Qt::RightDockWidgetArea, pcCurrAppModuleIf->m_pcDockWidget );
+ qobject_cast( m_pcParent )
+ ->addDockWidget( Qt::RightDockWidgetArea, pcCurrAppModuleIf->m_pcDockWidget );
}
// Associate module with subwindows
@@ -459,7 +462,7 @@ Void ModulesHandle::activateModule()
emit changed();
}
-Void ModulesHandle::destroyModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
+Void ModulesHandle::destroyModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf )
{
if( pcCurrModuleIf )
{
@@ -469,7 +472,7 @@ Void ModulesHandle::destroyModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
Void ModulesHandle::destroyWindowModules()
{
- VideoSubWindow* pcVideoSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
+ VideoSubWindow* pcVideoSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
if( pcVideoSubWindow )
{
pcVideoSubWindow->disableModule();
@@ -494,7 +497,7 @@ Void ModulesHandle::applyModuleIf( QList pcCurrModuleIfLis
}
}
-Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
+Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf )
{
if( pcCurrModuleIf )
{
@@ -521,9 +524,7 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
supported.append( " )" );
QStringList filter;
- filter << supported
- << formatsList
- << tr( "All Files (*)" );
+ filter << supported << formatsList << tr( "All Files (*)" );
QString fileName = QFileDialog::getSaveFileName( m_pcParent, tr( "Open File" ), QString(), filter.join( ";;" ) );
@@ -534,7 +535,8 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
FrameRate = pcCurrModuleIf->m_pcSubWindow[0]->getInputStream()->getFrameRate();
pcCurrModuleIf->m_pcModuleStream = new PlaYUVerStream;
- if( !pcCurrModuleIf->m_pcModuleStream->open( fileName.toStdString(), Width, Height, InputFormat, BitsPixel, PLAYUVER_LITTLE_ENDIAN, FrameRate, false ) )
+ if( !pcCurrModuleIf->m_pcModuleStream->open( fileName.toStdString(), Width, Height, InputFormat, BitsPixel,
+ PLAYUVER_LITTLE_ENDIAN, FrameRate, false ) )
{
delete pcCurrModuleIf->m_pcModuleStream;
pcCurrModuleIf->m_pcModuleStream = NULL;
@@ -574,7 +576,7 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
}
}
-Void ModulesHandle::swapModulesWindowsIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
+Void ModulesHandle::swapModulesWindowsIf( PlaYUVerAppModuleIf* pcCurrModuleIf )
{
if( pcCurrModuleIf->m_pcModule->m_uiNumberOfFrames == MODULE_REQUIRES_TWO_FRAMES )
{
@@ -585,16 +587,15 @@ Void ModulesHandle::swapModulesWindowsIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
}
}
-Void ModulesHandle::customEvent( QEvent *event )
+Void ModulesHandle::customEvent( QEvent* event )
{
if( !event )
{
return;
}
- PlaYUVerAppModuleIf::EventData *eventData = ( PlaYUVerAppModuleIf::EventData* )event;
+ PlaYUVerAppModuleIf::EventData* eventData = (PlaYUVerAppModuleIf::EventData*)event;
if( eventData->m_bSuccess )
{
eventData->m_pcModule->show();
}
}
-
diff --git a/app/ModulesHandle.h b/app/ModulesHandle.h
index 9b98540..aebd565 100644
--- a/app/ModulesHandle.h
+++ b/app/ModulesHandle.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -44,16 +44,16 @@ class PlaYUVerSubWindowHandle;
class PlaYUVerAppModuleIf;
class SubWindowHandle;
-class ModulesHandle: public QWidget
+class ModulesHandle : public QWidget
{
-Q_OBJECT
- public:
+ Q_OBJECT
+ public:
ModulesHandle( QWidget*, PlaYUVerSubWindowHandle*, VideoHandle* );
~ModulesHandle();
Void createActions();
QMenu* createMenu();
- //QDockWidget* createDock();
+ // QDockWidget* createDock();
Void buildMenu();
Void updateMenus();
@@ -61,9 +61,11 @@ Q_OBJECT
Void writeSettings();
static Void destroyModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf );
- static Void applyModuleIf( QList pcCurrModuleIfList, Bool isPlaying = false, Bool disableThreads = false );
+ static Void applyModuleIf( QList pcCurrModuleIfList,
+ Bool isPlaying = false,
+ Bool disableThreads = false );
-private:
+ private:
QWidget* m_pcParent;
PlaYUVerSubWindowHandle* m_pcMainWindowManager;
VideoHandle* m_appModuleVideo;
@@ -84,7 +86,7 @@ private:
enum MODULES_ACTION_LIST
{
LOAD_EXTERNAL_ACT,
- //FORCE_PLAYING_REFRESH_ACT,
+ // FORCE_PLAYING_REFRESH_ACT,
APPLY_ALL_ACT,
SWAP_FRAMES_ACT,
DISABLE_ACT,
@@ -97,21 +99,19 @@ private:
Void enableModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf );
Void applyAllModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf );
- Void swapModulesWindowsIf( PlaYUVerAppModuleIf *pcCurrModuleIf );
+ Void swapModulesWindowsIf( PlaYUVerAppModuleIf* pcCurrModuleIf );
- Void customEvent( QEvent *event );
+ Void customEvent( QEvent* event );
-Q_SIGNALS:
+ Q_SIGNALS:
void changed();
-private Q_SLOTS:
+ private Q_SLOTS:
void loadExternalModule();
void activateModule();
void processOpt( int index );
void destroyWindowModules();
void destroyAllModulesIf();
-
};
-#endif // __MODULESHANDLE_H__
-
+#endif // __MODULESHANDLE_H__
diff --git a/app/ModulesHandleOptDialog.cpp b/app/ModulesHandleOptDialog.cpp
index 94a9530..fecb4fe 100644
--- a/app/ModulesHandleOptDialog.cpp
+++ b/app/ModulesHandleOptDialog.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -32,9 +32,9 @@
#include "lib/PlaYUVerOptions.h"
-class OpionConfiguration: public QWidget
+class OpionConfiguration : public QWidget
{
-public:
+ public:
OpionConfiguration( OptionBase* option )
{
m_pcChecked = NULL;
@@ -67,20 +67,16 @@ public:
}
return m_pcValue->text();
}
- const String& getName()
- {
- return m_cName;
- }
-private:
+ const String& getName() { return m_cName; }
+ private:
QLineEdit* m_pcValue;
QCheckBox* m_pcChecked;
QLabel* m_pcDescription;
String m_cName;
};
-ModulesHandleOptDialog::ModulesHandleOptDialog( QWidget *parent, PlaYUVerAppModuleIf *pcCurrModuleIf ) :
- QDialog( parent ),
- m_pcCurrModuleIf( pcCurrModuleIf )
+ModulesHandleOptDialog::ModulesHandleOptDialog( QWidget* parent, PlaYUVerAppModuleIf* pcCurrModuleIf )
+ : QDialog( parent ), m_pcCurrModuleIf( pcCurrModuleIf )
{
resize( 400, 10 );
setWindowTitle( "Select module parameters" );
@@ -145,4 +141,3 @@ Int ModulesHandleOptDialog::runConfiguration()
}
return QDialog::Accepted;
}
-
diff --git a/app/ModulesHandleOptDialog.h b/app/ModulesHandleOptDialog.h
index e20ca7f..48973ca 100644
--- a/app/ModulesHandleOptDialog.h
+++ b/app/ModulesHandleOptDialog.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -36,16 +36,17 @@ class OpionConfiguration;
/**
*
*/
-class ModulesHandleOptDialog: public QDialog
+class ModulesHandleOptDialog : public QDialog
{
-Q_OBJECT
+ Q_OBJECT
-public:
- ModulesHandleOptDialog( QWidget *parent, PlaYUVerAppModuleIf *pcCurrModuleIf );
+ public:
+ ModulesHandleOptDialog( QWidget* parent, PlaYUVerAppModuleIf* pcCurrModuleIf );
Int runConfiguration();
- private:
- PlaYUVerAppModuleIf *m_pcCurrModuleIf;
+
+ private:
+ PlaYUVerAppModuleIf* m_pcCurrModuleIf;
QVector m_apcOptionList;
};
-#endif // __MODULEHANDLEOPTDIALOG_H__
+#endif // __MODULEHANDLEOPTDIALOG_H__
diff --git a/app/PlaYUVerApp.cpp b/app/PlaYUVerApp.cpp
index ad25214..6b018c7 100644
--- a/app/PlaYUVerApp.cpp
+++ b/app/PlaYUVerApp.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -46,16 +46,12 @@
#define SYNCHRONISED_ZOON 1
-PlaYUVerApp::PlaYUVerApp() :
- m_pcCurrentSubWindow( NULL ),
- m_pcCurrentVideoSubWindow( NULL ),
- m_pcAboutDialog( NULL )
+PlaYUVerApp::PlaYUVerApp() : m_pcCurrentSubWindow( NULL ), m_pcCurrentVideoSubWindow( NULL ), m_pcAboutDialog( NULL )
{
-
setWindowModality( Qt::ApplicationModal );
setWindowModality( Qt::NonModal );
- // DBus
+// DBus
#ifdef USE_QTDBUS
m_pDBusAdaptor = new PlaYUVerAppAdaptor( this );
#endif
@@ -87,10 +83,9 @@ PlaYUVerApp::PlaYUVerApp() :
connect( m_appModuleVideo, SIGNAL( changed() ), this, SLOT( update() ) );
connect( m_appModuleQuality, SIGNAL( changed() ), this, SLOT( update() ) );
connect( m_appModuleExtensions, SIGNAL( changed() ), this, SLOT( update() ) );
-
}
-Bool PlaYUVerApp::parseArgs( Int argc, Char *argv[] )
+Bool PlaYUVerApp::parseArgs( Int argc, Char* argv[] )
{
Bool bRet = false;
PlaYUVerOptions pcCmdParser;
@@ -99,10 +94,10 @@ Bool PlaYUVerApp::parseArgs( Int argc, Char *argv[] )
String strResolution( "" );
String strPelFmt( "" );
- pcCmdParser.addOptions()/**/
- ( "input,i", m_apcInputs, "input file" ) /**/
- ( "size,s", strResolution, "size (WxH)" ) /**/
- ( "pel_fmt", strPelFmt, "pixel format" );
+ pcCmdParser.addOptions() /**/
+ ( "input,i", m_apcInputs, "input file" ) /**/
+ ( "size,s", strResolution, "size (WxH)" ) /**/
+ ( "pel_fmt", strPelFmt, "pixel format" );
if( !pcCmdParser.parse( argc, argv ) )
{
@@ -139,7 +134,7 @@ Void PlaYUVerApp::about()
m_pcAboutDialog->exec();
}
-Void PlaYUVerApp::closeEvent( QCloseEvent *event )
+Void PlaYUVerApp::closeEvent( QCloseEvent* event )
{
Int mayCloseAll = true;
Int msgBoxCloseRet = QMessageBox::Yes;
@@ -147,35 +142,36 @@ Void PlaYUVerApp::closeEvent( QCloseEvent *event )
QList subWindowList = m_pcWindowHandle->findSubWindow();
if( subWindowList.size() >= 1 )
{
- QMessageBox msgBoxClose( QMessageBox::Question, "PlaYUVer", "There are open files!", QMessageBox::Yes | QMessageBox::No, this );
+ QMessageBox msgBoxClose( QMessageBox::Question, "PlaYUVer", "There are open files!",
+ QMessageBox::Yes | QMessageBox::No, this );
msgBoxClose.setDefaultButton( QMessageBox::No );
msgBoxClose.setInformativeText( "Close all?" );
msgBoxCloseRet = msgBoxClose.exec();
}
switch( msgBoxCloseRet )
{
- case QMessageBox::Yes:
- mayCloseAll = true;
- for( Int i = 0; i < subWindowList.size(); i++ )
- {
- mayCloseAll &= subWindowList.at( i )->mayClose();
- }
+ case QMessageBox::Yes:
+ mayCloseAll = true;
+ for( Int i = 0; i < subWindowList.size(); i++ )
+ {
+ mayCloseAll &= subWindowList.at( i )->mayClose();
+ }
- if( mayCloseAll )
- {
- //m_pcPlayingTimer->stop();
- closeAll();
- writeSettings();
- event->accept();
- }
- else
- {
- event->ignore();
- }
- break;
- case QMessageBox::No:
+ if( mayCloseAll )
+ {
+ // m_pcPlayingTimer->stop();
+ closeAll();
+ writeSettings();
+ event->accept();
+ }
+ else
+ {
+ event->ignore();
+ }
+ break;
+ case QMessageBox::No:
default:
- event->ignore();
+ event->ignore();
}
}
@@ -191,18 +187,18 @@ Void PlaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo )
printMessage( "File " + fileName + " do not exist!", LOG_ERROR );
return;
}
- VideoSubWindow *videoSubWindow = PlaYUVerApp::findVideoStreamSubWindow( m_pcWindowHandle, fileName );
+ VideoSubWindow* videoSubWindow = PlaYUVerApp::findVideoStreamSubWindow( m_pcWindowHandle, fileName );
if( videoSubWindow )
{
m_pcWindowHandle->setActiveSubWindow( videoSubWindow );
return;
}
- videoSubWindow = new VideoSubWindow( VideoSubWindow::VIDEO_STREAM_SUBWINDOW ); //createSubWindow();
- SubWindowAbstract *subWindow = videoSubWindow;
+ videoSubWindow = new VideoSubWindow( VideoSubWindow::VIDEO_STREAM_SUBWINDOW ); // createSubWindow();
+ SubWindowAbstract* subWindow = videoSubWindow;
if( !pStreamInfo )
{
Int idx = findPlaYUVerStreamInfo( m_aRecentFileStreamInfo, fileName );
- pStreamInfo = ( PlaYUVerStreamInfo* )( idx >= 0 ? &m_aRecentFileStreamInfo.at( idx ) : NULL );
+ pStreamInfo = (PlaYUVerStreamInfo*)( idx >= 0 ? &m_aRecentFileStreamInfo.at( idx ) : NULL );
}
try
@@ -220,9 +216,12 @@ Void PlaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo )
m_pcWindowHandle->addSubWindow( videoSubWindow );
videoSubWindow->show();
- connect( subWindow, SIGNAL( aboutToClose( SubWindowAbstract* ) ), m_appModuleVideo, SLOT( closeSubWindow( SubWindowAbstract* ) ) );
- connect( subWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), m_appModuleVideo, SLOT( zoomToFactorAll( double, QPoint ) ) );
- connect( subWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), m_appModuleVideo, SLOT( moveAllScrollBars( const QPoint ) ) );
+ connect( subWindow, SIGNAL( aboutToClose( SubWindowAbstract* ) ), m_appModuleVideo,
+ SLOT( closeSubWindow( SubWindowAbstract* ) ) );
+ connect( subWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), m_appModuleVideo,
+ SLOT( zoomToFactorAll( double, QPoint ) ) );
+ connect( subWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), m_appModuleVideo,
+ SLOT( moveAllScrollBars( const QPoint ) ) );
videoSubWindow->zoomToFit();
updateZoomFactorSBox();
@@ -242,7 +241,8 @@ Void PlaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo )
catch( PlaYUVerFailure& e )
{
videoSubWindow->close();
- QString warningMsg = "Cannot open file " + QFileInfo( fileName ).fileName() + " with the following error: \n" + e.what();
+ QString warningMsg =
+ "Cannot open file " + QFileInfo( fileName ).fileName() + " with the following error: \n" + e.what();
QMessageBox::warning( this, QApplication::applicationName(), warningMsg );
printMessage( warningMsg, LOG_ERROR );
}
@@ -270,11 +270,10 @@ Void PlaYUVerApp::open()
supported.append( " )" );
QStringList filter;
- filter << supported
- << formatsList
- << tr( "All Files (*)" );
+ filter << supported << formatsList << tr( "All Files (*)" );
- QStringList fileNameList = QFileDialog::getOpenFileNames( this, tr( "Open File" ), m_cLastOpenPath, filter.join( ";;" ) );
+ QStringList fileNameList =
+ QFileDialog::getOpenFileNames( this, tr( "Open File" ), m_cLastOpenPath, filter.join( ";;" ) );
for( Int i = 0; i < fileNameList.size(); i++ )
{
@@ -287,7 +286,7 @@ Void PlaYUVerApp::open()
Void PlaYUVerApp::openRecent()
{
- QAction *action = qobject_cast( sender() );
+ QAction* action = qobject_cast( sender() );
PlaYUVerStreamInfo recentFile = action->data().value();
if( action )
loadFile( recentFile.m_cFilename, &recentFile );
@@ -297,7 +296,7 @@ Void PlaYUVerApp::save()
{
if( m_pcCurrentVideoSubWindow )
{
- VideoSubWindow *saveWindow = m_pcCurrentVideoSubWindow;
+ VideoSubWindow* saveWindow = m_pcCurrentVideoSubWindow;
QString supported = tr( "Supported Files (" );
QStringList formatsList;
@@ -316,9 +315,7 @@ Void PlaYUVerApp::save()
supported.append( " )" );
QStringList filter;
- filter << supported
- << formatsList
- << tr( "All Files (*)" );
+ filter << supported << formatsList << tr( "All Files (*)" );
QString fileName = QFileDialog::getSaveFileName( this, tr( "Open File" ), m_cLastOpenPath, filter.join( ";;" ) );
@@ -332,7 +329,8 @@ Void PlaYUVerApp::save()
catch( PlaYUVerFailure& e )
{
QApplication::restoreOverrideCursor();
- QString warningMsg = "Cannot save file " + QFileInfo( fileName ).fileName() + " with the following error: \n" + e.what();
+ QString warningMsg =
+ "Cannot save file " + QFileInfo( fileName ).fileName() + " with the following error: \n" + e.what();
QMessageBox::warning( this, QApplication::applicationName(), warningMsg );
printMessage( warningMsg, LOG_ERROR );
return;
@@ -355,10 +353,11 @@ Void PlaYUVerApp::format()
}
catch( PlaYUVerFailure& e )
{
- QString warningMsg = "Cannot change format of " + QFileInfo( pcVideoSubWindow->getCurrentFileName() ).fileName() + " with the following error: \n" + e.what();
+ QString warningMsg = "Cannot change format of " + QFileInfo( pcVideoSubWindow->getCurrentFileName() ).fileName() +
+ " with the following error: \n" + e.what();
QMessageBox::warning( this, QApplication::applicationName(), warningMsg );
printMessage( warningMsg, LOG_ERROR );
- qDebug( ) << warningMsg;
+ qDebug() << warningMsg;
m_pcCurrentSubWindow->close();
}
m_pcCurrentSubWindow = NULL;
@@ -378,12 +377,10 @@ Void PlaYUVerApp::reload()
Void PlaYUVerApp::reloadAll()
{
- UInt windowCategoryOrder[] =
- {
- SubWindowAbstract::VIDEO_STREAM_SUBWINDOW,
- SubWindowAbstract::MODULE_SUBWINDOW,
- SubWindowAbstract::MODULE_SUBWINDOW,
- };
+ UInt windowCategoryOrder[] = {
+ SubWindowAbstract::VIDEO_STREAM_SUBWINDOW, SubWindowAbstract::MODULE_SUBWINDOW,
+ SubWindowAbstract::MODULE_SUBWINDOW,
+ };
for( UInt c = 0; c < 3; c++ )
{
@@ -429,13 +426,12 @@ Void PlaYUVerApp::zoomToFit()
Void PlaYUVerApp::zoomToFitAll()
{
- VideoSubWindow *videoSubWindow;
+ VideoSubWindow* videoSubWindow;
QList subWindowList = m_pcWindowHandle->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
for( Int i = 0; i < subWindowList.size(); i++ )
{
videoSubWindow = qobject_cast( subWindowList.at( i ) );
videoSubWindow->zoomToFit();
-
}
if( m_pcCurrentSubWindow )
updateZoomFactorSBox();
@@ -452,7 +448,7 @@ Void PlaYUVerApp::scaleFrame( int ratio )
Void PlaYUVerApp::zoomFromSBox( double zoom )
{
- SubWindowAbstract *activeSubWindow = m_pcWindowHandle->activeSubWindow();
+ SubWindowAbstract* activeSubWindow = m_pcWindowHandle->activeSubWindow();
Double factor = zoom / 100;
if( activeSubWindow )
{
@@ -472,16 +468,16 @@ Void PlaYUVerApp::updateZoomFactorSBox()
// ----------------------- Drag and drop functions ----------------------
-Void PlaYUVerApp::dragEnterEvent( QDragEnterEvent *event )
+Void PlaYUVerApp::dragEnterEvent( QDragEnterEvent* event )
{
- //setText(tr(""));
- //mdiArea->setBackgroundRole( QPalette::Highlight );
+ // setText(tr(""));
+ // mdiArea->setBackgroundRole( QPalette::Highlight );
event->acceptProposedAction();
}
-Void PlaYUVerApp::dropEvent( QDropEvent *event )
+Void PlaYUVerApp::dropEvent( QDropEvent* event )
{
- const QMimeData *mimeData = event->mimeData();
+ const QMimeData* mimeData = event->mimeData();
QList urlList = mimeData->urls();
if( urlList.size() == 1 )
{
@@ -493,7 +489,8 @@ Void PlaYUVerApp::dropEvent( QDropEvent *event )
// ----------------------- Sub Window Functions -----------------------
-VideoSubWindow* PlaYUVerApp::findVideoStreamSubWindow( const PlaYUVerSubWindowHandle* windowManager, const QString& fileName )
+VideoSubWindow* PlaYUVerApp::findVideoStreamSubWindow( const PlaYUVerSubWindowHandle* windowManager,
+ const QString& fileName )
{
QString canonicalFilePath = QFileInfo( fileName ).canonicalFilePath();
VideoSubWindow* pcSubWindow;
@@ -511,9 +508,9 @@ VideoSubWindow* PlaYUVerApp::findVideoStreamSubWindow( const PlaYUVerSubWindowHa
Void PlaYUVerApp::update()
{
- SubWindowAbstract *activeSubWindow = m_pcWindowHandle->activeSubWindow();
+ SubWindowAbstract* activeSubWindow = m_pcWindowHandle->activeSubWindow();
QCoreApplication::processEvents();
-//if( activeSubWindow() != m_pcCurrentSubWindow )
+ // if( activeSubWindow() != m_pcCurrentSubWindow )
{
m_pcCurrentSubWindow = NULL;
m_pcCurrentVideoSubWindow = NULL;
@@ -656,7 +653,7 @@ Void PlaYUVerApp::createActions()
// ------------ View ------------
mapperZoom = new QSignalMapper( this );
- connect( mapperZoom, SIGNAL( mapped(int) ), this, SLOT( scaleFrame(int) ) );
+ connect( mapperZoom, SIGNAL( mapped( int ) ), this, SLOT( scaleFrame( int ) ) );
m_arrayActions[ZOOM_IN_ACT] = new QAction( tr( "Zoom &In (+25%)" ), this );
m_arrayActions[ZOOM_IN_ACT]->setIcon( QIcon::fromTheme( "zoom-in", QIcon( ":/images/zoomin.png" ) ) );
@@ -684,7 +681,8 @@ Void PlaYUVerApp::createActions()
connect( m_arrayActions[ZOOM_FIT_ACT], SIGNAL( triggered() ), this, SLOT( zoomToFit() ) );
m_arrayActions[ZOOM_FIT_ALL_ACT] = new QAction( tr( "Zoom to Fit All" ), this );
-//m_arrayActions[ZOOM_FIT_ALL_ACT]->setIcon( QIcon::fromTheme( "zoom-fit-best", QIcon( ":/images/fittowindow.png" ) ) );
+ // m_arrayActions[ZOOM_FIT_ALL_ACT]->setIcon( QIcon::fromTheme( "zoom-fit-best", QIcon( ":/images/fittowindow.png" ) )
+ // );
m_arrayActions[ZOOM_FIT_ALL_ACT]->setStatusTip( tr( "Apply zoom to fit to all windows" ) );
connect( m_arrayActions[ZOOM_FIT_ALL_ACT], SIGNAL( triggered() ), this, SLOT( zoomToFitAll() ) );
@@ -698,7 +696,8 @@ Void PlaYUVerApp::createActions()
#ifdef USE_FERVOR
m_arrayActions[UPDATE_ACT] = new QAction( tr( "&Update" ), this );
m_arrayActions[UPDATE_ACT]->setStatusTip( tr( "Check for updates" ) );
- connect( m_arrayActions[UPDATE_ACT], SIGNAL( triggered() ), FvUpdater::sharedUpdater(), SLOT( CheckForUpdatesNotSilent() ) );
+ connect( m_arrayActions[UPDATE_ACT], SIGNAL( triggered() ), FvUpdater::sharedUpdater(),
+ SLOT( CheckForUpdatesNotSilent() ) );
#endif
m_arrayActions[ABOUT_ACT] = new QAction( tr( "&About" ), this );
@@ -742,12 +741,12 @@ Void PlaYUVerApp::createMenus()
m_arrayMenu[VIEW_MENU]->addSeparator();
-// createPopupMenu() Returns a popup menu containing checkable entries for
-// the toolbars and dock widgets present in the main window.
+ // createPopupMenu() Returns a popup menu containing checkable entries for
+ // the toolbars and dock widgets present in the main window.
m_arrayMenu[DOCK_VIEW_MENU] = createPopupMenu();
if( m_arrayMenu[DOCK_VIEW_MENU] )
{
- QAction *actionPopupMenu = m_arrayMenu[VIEW_MENU]->addMenu( m_arrayMenu[DOCK_VIEW_MENU] );
+ QAction* actionPopupMenu = m_arrayMenu[VIEW_MENU]->addMenu( m_arrayMenu[DOCK_VIEW_MENU] );
actionPopupMenu->setText( tr( "&Toolbars/Docks" ) );
}
@@ -769,7 +768,6 @@ Void PlaYUVerApp::createMenus()
m_arrayMenu[ABOUT_MENU]->addSeparator();
m_arrayMenu[ABOUT_MENU]->addAction( m_arrayActions[ABOUT_ACT] );
m_arrayMenu[ABOUT_MENU]->addAction( m_arrayActions[ABOUTQT_ACT] );
-
}
Void PlaYUVerApp::createToolBars()
@@ -793,7 +791,7 @@ Void PlaYUVerApp::createToolBars()
m_pcZoomFactorSBox->setSingleStep( 10.0 );
m_pcZoomFactorSBox->setValue( 100.0 );
m_pcZoomFactorSBox->setSuffix( "%" );
- connect( m_pcZoomFactorSBox, SIGNAL( valueChanged(double) ), this, SLOT( zoomFromSBox(double) ) );
+ connect( m_pcZoomFactorSBox, SIGNAL( valueChanged( double ) ), this, SLOT( zoomFromSBox( double ) ) );
m_arrayToolBars[VIEW_TOOLBAR]->addWidget( m_pcZoomFactorSBox );
m_arrayToolBars[VIEW_TOOLBAR]->addAction( m_arrayActions[ZOOM_IN_ACT] );
m_arrayToolBars[VIEW_TOOLBAR]->addAction( m_arrayActions[ZOOM_OUT_ACT] );
@@ -804,12 +802,11 @@ Void PlaYUVerApp::createToolBars()
addToolBar( Qt::TopToolBarArea, m_arrayToolBars[VIEW_TOOLBAR] );
addToolBar( Qt::TopToolBarArea, m_appModuleVideo->createToolBar() );
-
}
Void PlaYUVerApp::createDockWidgets()
{
-// Properties Dock Window
+ // Properties Dock Window
m_arraySideBars.resize( TOTAL_DOCK );
addDockWidget( Qt::RightDockWidgetArea, m_appModuleVideo->createDock() );
addDockWidget( Qt::RightDockWidgetArea, m_appModuleQuality->createDock() );
@@ -844,7 +841,8 @@ Void PlaYUVerApp::updateRecentFileActions()
m_arrayRecentFilesActions.at( actionIdx )->setText( QFileInfo( text ).fileName() );
m_arrayRecentFilesActions.at( actionIdx )->setToolTip( "Open File " + text );
m_arrayRecentFilesActions.at( actionIdx )->setStatusTip( "Open File " + text );
- m_arrayRecentFilesActions.at( actionIdx )->setData( QVariant::fromValue( m_aRecentFileStreamInfo.at( actionIdx ) ) );
+ m_arrayRecentFilesActions.at( actionIdx )
+ ->setData( QVariant::fromValue( m_aRecentFileStreamInfo.at( actionIdx ) ) );
m_arrayRecentFilesActions.at( actionIdx )->setVisible( true );
actionIdx++;
}
@@ -918,4 +916,3 @@ Void PlaYUVerApp::writeSettings()
m_appModuleExtensions->writeSettings();
m_pcWindowHandle->writeSettings();
}
-
diff --git a/app/PlaYUVerApp.h b/app/PlaYUVerApp.h
index 6030c42..996ea2e 100644
--- a/app/PlaYUVerApp.h
+++ b/app/PlaYUVerApp.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -65,23 +65,23 @@ class VideoSubWindow;
class SubWindowAbstract;
class AboutDialog;
-class PlaYUVerApp: public QMainWindow
+class PlaYUVerApp : public QMainWindow
{
-Q_OBJECT
+ Q_OBJECT
-public:
+ public:
PlaYUVerApp();
- Bool parseArgs( Int argc, Char *argv[] );
+ Bool parseArgs( Int argc, Char* argv[] );
Void loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo = NULL );
-public Q_SLOTS:
+ public Q_SLOTS:
void printMessage( const QString& msg );
void printMessage( const QString& msg, UInt logLevel );
-protected:
- Void closeEvent( QCloseEvent *event );
+ protected:
+ Void closeEvent( QCloseEvent* event );
-private Q_SLOTS:
+ private Q_SLOTS:
void about();
@@ -108,14 +108,13 @@ private Q_SLOTS:
void zoomToFit();
void zoomToFitAll();
- void dragEnterEvent( QDragEnterEvent *event );
- void dropEvent( QDropEvent *event );
+ void dragEnterEvent( QDragEnterEvent* event );
+ void dropEvent( QDropEvent* event );
void update();
void updateZoomFactorSBox();
-private:
-
+ private:
PlaYUVerAppAdaptor* m_pDBusAdaptor;
PlaYUVerOptions* m_pcCmdParser;
/**
@@ -126,7 +125,8 @@ private:
QString m_cLastOpenPath;
- static VideoSubWindow* findVideoStreamSubWindow( const PlaYUVerSubWindowHandle* windowManager, const QString& fileName );
+ static VideoSubWindow* findVideoStreamSubWindow( const PlaYUVerSubWindowHandle* windowManager,
+ const QString& fileName );
Void updateMenus();
@@ -143,10 +143,10 @@ private:
Void readSettings();
Void writeSettings();
- QDoubleSpinBox *m_pcZoomFactorSBox;
+ QDoubleSpinBox* m_pcZoomFactorSBox;
- QSignalMapper *mapperZoom;
- QSignalMapper *mapperWindow;
+ QSignalMapper* mapperZoom;
+ QSignalMapper* mapperWindow;
/**
* App modules
@@ -156,7 +156,7 @@ private:
*/
VideoHandle* m_appModuleVideo;
QualityHandle* m_appModuleQuality;
- ModulesHandle *m_appModuleExtensions;
+ ModulesHandle* m_appModuleExtensions;
PlaYUVerSubWindowHandle* m_pcWindowHandle;
/**
@@ -234,5 +234,4 @@ private:
AboutDialog* m_pcAboutDialog;
};
-#endif // __PLAYUVERAPP_H__
-
+#endif // __PLAYUVERAPP_H__
diff --git a/app/PlaYUVerAppAdaptor.cpp b/app/PlaYUVerAppAdaptor.cpp
index dd5b795..806089a 100644
--- a/app/PlaYUVerAppAdaptor.cpp
+++ b/app/PlaYUVerAppAdaptor.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -26,12 +26,11 @@
#include "PlaYUVerAppAdaptor.h"
#include "PlaYUVerApp.h"
-PlaYUVerAppAdaptor::PlaYUVerAppAdaptor( PlaYUVerApp *app ) :
- QDBusAbstractAdaptor( app ),
- m_app( app )
+PlaYUVerAppAdaptor::PlaYUVerAppAdaptor( PlaYUVerApp* app ) : QDBusAbstractAdaptor( app ), m_app( app )
{
// application dbus interface
- QDBusConnection::sessionBus().registerObject( QStringLiteral( PLAYUVER_DBUS_PATH ), this, QDBusConnection::ExportAllSlots );
+ QDBusConnection::sessionBus().registerObject( QStringLiteral( PLAYUVER_DBUS_PATH ), this,
+ QDBusConnection::ExportAllSlots );
}
PlaYUVerAppAdaptor::~PlaYUVerAppAdaptor()
@@ -46,12 +45,11 @@ void PlaYUVerAppAdaptor::activate()
return;
}
m_app->raise();
-
}
QString PlaYUVerAppAdaptor::activeSession()
{
- //return m_app->sessionManager()->activeSession()->name();
+ // return m_app->sessionManager()->activeSession()->name();
return QString( "PlaYUVer" );
}
@@ -60,4 +58,3 @@ bool PlaYUVerAppAdaptor::loadFile( const QString& filename )
m_app->loadFile( filename );
return true;
}
-
diff --git a/app/PlaYUVerAppAdaptor.h b/app/PlaYUVerAppAdaptor.h
index a4e9779..8853485 100644
--- a/app/PlaYUVerAppAdaptor.h
+++ b/app/PlaYUVerAppAdaptor.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -37,20 +37,20 @@
class PlaYUVerApp;
-class PlaYUVerAppAdaptor: public QDBusAbstractAdaptor
+class PlaYUVerAppAdaptor : public QDBusAbstractAdaptor
{
-Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "org.pixlra.PlaYUVer.application")
-Q_PROPERTY(QString activeSession READ activeSession)
-public:
- PlaYUVerAppAdaptor( PlaYUVerApp *app );
+ Q_OBJECT
+ Q_CLASSINFO( "D-Bus Interface", "org.pixlra.PlaYUVer.application" )
+ Q_PROPERTY( QString activeSession READ activeSession )
+ public:
+ PlaYUVerAppAdaptor( PlaYUVerApp* app );
~PlaYUVerAppAdaptor();
/**
* emit the exiting signal
*/
- //void emitExiting();
- //void emitDocumentClosed(const QString &token);
-public Q_SLOTS:
+ // void emitExiting();
+ // void emitDocumentClosed(const QString &token);
+ public Q_SLOTS:
/**
* open a file with given url and encoding
* will get view created
@@ -65,18 +65,18 @@ public Q_SLOTS:
*/
void activate();
-Q_SIGNALS:
+ Q_SIGNALS:
/**
* Notify the world that this kate instance is exiting.
* All apps should stop using the dbus interface of this instance after this signal got emitted.
*/
- //void exiting();
- //void documentClosed(const QString &token);
-public:
+ // void exiting();
+ // void documentClosed(const QString &token);
+ public:
QString activeSession();
- private:
- PlaYUVerApp *m_app;
+
+ private:
+ PlaYUVerApp* m_app;
};
-#endif // __PlaYUVerAppAdaptor_H__
-
+#endif // __PlaYUVerAppAdaptor_H__
diff --git a/app/PlaYUVerAppDefs.h b/app/PlaYUVerAppDefs.h
index 48a86af..656ce56 100644
--- a/app/PlaYUVerAppDefs.h
+++ b/app/PlaYUVerAppDefs.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -35,7 +35,7 @@
// fallback, return a temporary QString
// source code is assumed to be encoded in UTF-8
-# define QStringLiteral(str) QString::fromUtf8("" str "", sizeof(str) - 1)
+#define QStringLiteral( str ) QString::fromUtf8( "" str "", sizeof( str ) - 1 )
#endif
-#endif // __PLAYUVERAPPDEFS_H__
+#endif // __PLAYUVERAPPDEFS_H__
diff --git a/app/PlaYUVerAppModuleIf.cpp b/app/PlaYUVerAppModuleIf.cpp
index fb4d85e..5d334a6 100644
--- a/app/PlaYUVerAppModuleIf.cpp
+++ b/app/PlaYUVerAppModuleIf.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -26,16 +26,16 @@
#include "VideoSubWindow.h"
#include "VideoSubWindow.h"
-PlaYUVerAppModuleIf::PlaYUVerAppModuleIf( QObject* parent, QAction* action, PlaYUVerModuleIf* module ) :
- m_bIsRunning( false ),
- m_pcModuleAction( action ),
- m_pcModule( module ),
- m_pcDisplaySubWindow( NULL ),
- m_pcDockWidget( NULL ),
- m_pcModuleDock( NULL ),
- m_pcModuleStream( NULL ),
- m_pcProcessedFrame( NULL ),
- m_dMeasurementResult( 0 )
+PlaYUVerAppModuleIf::PlaYUVerAppModuleIf( QObject* parent, QAction* action, PlaYUVerModuleIf* module )
+ : m_bIsRunning( false ),
+ m_pcModuleAction( action ),
+ m_pcModule( module ),
+ m_pcDisplaySubWindow( NULL ),
+ m_pcDockWidget( NULL ),
+ m_pcModuleDock( NULL ),
+ m_pcModuleStream( NULL ),
+ m_pcProcessedFrame( NULL ),
+ m_dMeasurementResult( 0 )
{
setParent( parent );
for( Int i = 0; i < MODULE_REQUIRES_MAX_NUM_FRAMES; i++ )
@@ -139,9 +139,9 @@ Void PlaYUVerAppModuleIf::run()
m_bSuccess = true;
m_bIsRunning = false;
#ifdef PLAYUVER_THREADED_MODULES
- EventData *eventData = new EventData( m_bSuccess, this );
+ EventData* eventData = new EventData( m_bSuccess, this );
if( parent() )
- QCoreApplication::postEvent( parent(), eventData );
+ QCoreApplication::postEvent( parent(), eventData );
#endif
return;
}
@@ -150,23 +150,23 @@ Void PlaYUVerAppModuleIf::show()
{
switch( m_pcModule->m_iModuleType )
{
- case FRAME_PROCESSING_MODULE:
- if( m_pcDisplaySubWindow )
- {
- m_pcDisplaySubWindow->setCurrFrame( m_pcProcessedFrame );
- m_pcDisplaySubWindow->setFillWindow( false );
- m_pcDisplaySubWindow->clearWindowBusy();
- }
- else
- {
- m_pcSubWindow[0]->setCurrFrame( m_pcProcessedFrame );
- m_pcSubWindow[0]->setFillWindow( false );
- m_pcSubWindow[0]->clearWindowBusy();
- }
- break;
- case FRAME_MEASUREMENT_MODULE:
- m_pcModuleDock->setModulueReturnValue( m_dMeasurementResult );
- break;
+ case FRAME_PROCESSING_MODULE:
+ if( m_pcDisplaySubWindow )
+ {
+ m_pcDisplaySubWindow->setCurrFrame( m_pcProcessedFrame );
+ m_pcDisplaySubWindow->setFillWindow( false );
+ m_pcDisplaySubWindow->clearWindowBusy();
+ }
+ else
+ {
+ m_pcSubWindow[0]->setCurrFrame( m_pcProcessedFrame );
+ m_pcSubWindow[0]->setFillWindow( false );
+ m_pcSubWindow[0]->clearWindowBusy();
+ }
+ break;
+ case FRAME_MEASUREMENT_MODULE:
+ m_pcModuleDock->setModulueReturnValue( m_dMeasurementResult );
+ break;
}
}
@@ -214,6 +214,4 @@ Void PlaYUVerAppModuleIf::destroy()
m_pcModule->Delete();
m_pcModule = NULL;
}
-
}
-
diff --git a/app/PlaYUVerAppModuleIf.h b/app/PlaYUVerAppModuleIf.h
index 7536f18..c5dbc9a 100644
--- a/app/PlaYUVerAppModuleIf.h
+++ b/app/PlaYUVerAppModuleIf.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -42,7 +42,7 @@ class QAction;
class VideoSubWindow;
class PlaYUVerAppModuleIf
- #ifdef PLAYUVER_THREADED_MODULES
+#ifdef PLAYUVER_THREADED_MODULES
: public QThread
#else
: public QObject
@@ -52,8 +52,7 @@ class PlaYUVerAppModuleIf
friend class ModuleHandleDock;
friend class ModulesHandleOptDialog;
-private:
-
+ private:
Bool m_bIsRunning;
Bool m_bSuccess;
@@ -71,12 +70,11 @@ private:
PlaYUVerFrame* m_pcProcessedFrame;
Double m_dMeasurementResult;
-public:
- class EventData: public QEvent
+ public:
+ class EventData : public QEvent
{
- public:
- EventData( bool success, PlaYUVerAppModuleIf* module ) :
- QEvent( QEvent::User )
+ public:
+ EventData( bool success, PlaYUVerAppModuleIf* module ) : QEvent( QEvent::User )
{
m_bSuccess = success;
m_pcModule = module;
@@ -86,10 +84,7 @@ public:
};
PlaYUVerAppModuleIf( QObject* parent, QAction* action, PlaYUVerModuleIf* module );
- virtual ~PlaYUVerAppModuleIf()
- {
- }
-
+ virtual ~PlaYUVerAppModuleIf() {}
QList getSubWindowList()
{
QList arraySubWindows;
@@ -99,23 +94,15 @@ public:
return arraySubWindows;
}
- PlaYUVerModuleIf* getModule()
- {
- return m_pcModule;
- }
-
- UInt getModuleRequirements()
- {
- return m_pcModule->m_uiModuleRequirements;
- }
-
+ PlaYUVerModuleIf* getModule() { return m_pcModule; }
+ UInt getModuleRequirements() { return m_pcModule->m_uiModuleRequirements; }
Void update();
Bool apply( Bool isPlaying = false, Bool disableThreads = false );
Void show();
Void destroy();
- protected:
+
+ protected:
virtual void run();
};
-#endif // __PLAYUVERAPPMODULESIF_H__
-
+#endif // __PLAYUVERAPPMODULESIF_H__
diff --git a/app/PlaYUVerMdiSubWindow.cpp b/app/PlaYUVerMdiSubWindow.cpp
index d30c06f..efac05e 100644
--- a/app/PlaYUVerMdiSubWindow.cpp
+++ b/app/PlaYUVerMdiSubWindow.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -26,8 +26,7 @@
#include "PlaYUVerMdiSubWindow.h"
#include "SubWindowAbstract.h"
-PlaYUVerMdiSubWindow::PlaYUVerMdiSubWindow( QWidget *parent ) :
- QMdiSubWindow( parent )
+PlaYUVerMdiSubWindow::PlaYUVerMdiSubWindow( QWidget* parent ) : QMdiSubWindow( parent )
{
setAttribute( Qt::WA_DeleteOnClose );
setBackgroundRole( QPalette::Background );
@@ -42,9 +41,8 @@ QSize PlaYUVerMdiSubWindow::sizeHint() const
return sizeHint;
}
-Void PlaYUVerMdiSubWindow::closeEvent( QCloseEvent *event )
+Void PlaYUVerMdiSubWindow::closeEvent( QCloseEvent* event )
{
emit aboutToClose( this );
event->accept();
}
-
diff --git a/app/PlaYUVerMdiSubWindow.h b/app/PlaYUVerMdiSubWindow.h
index 440225a..6a74a4a 100644
--- a/app/PlaYUVerMdiSubWindow.h
+++ b/app/PlaYUVerMdiSubWindow.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -29,20 +29,19 @@
#include "PlaYUVerAppDefs.h"
#include
-class PlaYUVerMdiSubWindow: public QMdiSubWindow
+class PlaYUVerMdiSubWindow : public QMdiSubWindow
{
-Q_OBJECT
+ Q_OBJECT
-public:
- PlaYUVerMdiSubWindow( QWidget *parent = 0 );
+ public:
+ PlaYUVerMdiSubWindow( QWidget* parent = 0 );
-Q_SIGNALS:
+ Q_SIGNALS:
void aboutToClose( PlaYUVerMdiSubWindow* );
-protected:
+ protected:
QSize sizeHint() const;
- void closeEvent( QCloseEvent *event );
+ void closeEvent( QCloseEvent* event );
};
-#endif // __PLAYUVERMDISUBWINDOW_H__
-
+#endif // __PLAYUVERMDISUBWINDOW_H__
diff --git a/app/PlaYUVerSubWindowHandle.cpp b/app/PlaYUVerSubWindowHandle.cpp
index 78850ce..e351e12 100644
--- a/app/PlaYUVerSubWindowHandle.cpp
+++ b/app/PlaYUVerSubWindowHandle.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -40,12 +40,10 @@
#include "PlaYUVerMdiSubWindow.h"
#include "SubWindowAbstract.h"
-class PlaYUVerMdiArea: public QMdiArea
+class PlaYUVerMdiArea : public QMdiArea
{
-public:
- PlaYUVerMdiArea( QWidget *parent = 0 ) :
- QMdiArea( parent ),
- m_pixmapLogo( ":/images/playuver-backgroud-logo.png" )
+ public:
+ PlaYUVerMdiArea( QWidget* parent = 0 ) : QMdiArea( parent ), m_pixmapLogo( ":/images/playuver-backgroud-logo.png" )
{
setBackgroundRole( QPalette::Background );
}
@@ -57,8 +55,9 @@ public:
m_acLogMessages.remove( m_acLogMessages.size() - 1 );
update();
}
-protected:
- void paintEvent( QPaintEvent *event )
+
+ protected:
+ void paintEvent( QPaintEvent* event )
{
QMdiArea::paintEvent( event );
QPainter painter( viewport() );
@@ -68,19 +67,19 @@ protected:
int y = height() / 2 - pixFinalLogo.height() / 2;
painter.drawPixmap( x, y, pixFinalLogo );
-// for( Int i = 0; i < m_acLogMessages.size(); i++ )
-// {
-// painter.drawText( 5, height() - 5 - i * 15, m_acLogMessages.at( i ) );
-// }
-// QPoint bottomLeftCorner( 0, viewport()->height() );
+ // for( Int i = 0; i < m_acLogMessages.size(); i++ )
+ // {
+ // painter.drawText( 5, height() - 5 - i * 15, m_acLogMessages.at( i ) );
+ // }
+ // QPoint bottomLeftCorner( 0, viewport()->height() );
}
-private:
+
+ private:
QVector m_acLogMessages;
QPixmap m_pixmapLogo;
};
-PlaYUVerSubWindowHandle::PlaYUVerSubWindowHandle( QWidget *parent ) :
- QWidget( parent )
+PlaYUVerSubWindowHandle::PlaYUVerSubWindowHandle( QWidget* parent ) : QWidget( parent )
{
m_iWindowMode = -1;
m_pcWindowManagerLayout = NULL;
@@ -90,7 +89,7 @@ PlaYUVerSubWindowHandle::PlaYUVerSubWindowHandle( QWidget *parent ) :
m_apcMdiSubWindowList.clear();
m_pcApp = qobject_cast( parentWidget() );
- //setWindowMode( DETACHEDSUBWINDOWMODE );
+ // setWindowMode( DETACHEDSUBWINDOWMODE );
setWindowMode( MDISUBWINDOWMODE );
}
@@ -108,7 +107,6 @@ Void PlaYUVerSubWindowHandle::resetWindowMode()
if( m_iWindowMode == DETACHEDSUBWINDOWMODE )
{
-
}
if( m_iWindowMode == MDISUBWINDOWMODE )
{
@@ -120,7 +118,8 @@ Void PlaYUVerSubWindowHandle::resetWindowMode()
}
for( Int i = 0; i < m_apcMdiSubWindowList.size(); i++ )
{
- disconnect( m_apcMdiSubWindowList.at( i ), SIGNAL( aboutToClose( PlaYUVerMdiSubWindow* ) ), this, SLOT( removeMdiSubWindow( PlaYUVerMdiSubWindow* ) ) );
+ disconnect( m_apcMdiSubWindowList.at( i ), SIGNAL( aboutToClose( PlaYUVerMdiSubWindow* ) ), this,
+ SLOT( removeMdiSubWindow( PlaYUVerMdiSubWindow* ) ) );
m_apcMdiSubWindowList.at( i )->close();
}
m_apcMdiSubWindowList.clear();
@@ -129,7 +128,6 @@ Void PlaYUVerSubWindowHandle::resetWindowMode()
m_pcMdiArea = NULL;
if( m_pcWindowManagerLayout )
delete m_pcWindowManagerLayout;
-
}
}
@@ -163,7 +161,7 @@ Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode )
setVisible( true );
m_pcMdiArea = new PlaYUVerMdiArea;
m_pcMdiArea->setActivationOrder( QMdiArea::ActivationHistoryOrder );
- connect( m_pcMdiArea, SIGNAL( subWindowActivated(QMdiSubWindow*) ), this, SLOT( updateActiveSubWindow() ) );
+ connect( m_pcMdiArea, SIGNAL( subWindowActivated( QMdiSubWindow* ) ), this, SLOT( updateActiveSubWindow() ) );
m_pcWindowManagerLayout = new QHBoxLayout( this );
m_pcWindowManagerLayout->addWidget( m_pcMdiArea );
setLayout( m_pcWindowManagerLayout );
@@ -172,20 +170,20 @@ Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode )
addMdiSubWindow( m_apcSubWindowList.at( i ) );
m_apcSubWindowList.at( i )->resize( m_apcSubWindowList.at( i )->sizeHint() );
}
- //m_pcApp->move( m_cMdiModeWindowPosition );
- //m_pcApp->resize( m_cMdiModeWindowSize );
+ // m_pcApp->move( m_cMdiModeWindowPosition );
+ // m_pcApp->resize( m_cMdiModeWindowSize );
if( m_pcActiveWindow )
{
m_pcApp->setWindowTitle( QApplication::applicationName() + " :: " + m_pcActiveWindow->getWindowName() );
}
}
m_iWindowMode = iWindowMode;
- //tileSubWindows();
- //parentWidget()->update();
- //qApp->processEvents();
+ // tileSubWindows();
+ // parentWidget()->update();
+ // qApp->processEvents();
}
-Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowAbstract *window )
+Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowAbstract* window )
{
if( m_iWindowMode == DETACHEDSUBWINDOWMODE )
{
@@ -217,26 +215,30 @@ Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowAbstract *window )
}
}
-Void PlaYUVerSubWindowHandle::addMdiSubWindow( SubWindowAbstract *window )
+Void PlaYUVerSubWindowHandle::addMdiSubWindow( SubWindowAbstract* window )
{
PlaYUVerMdiSubWindow* mdiSubWindow = new PlaYUVerMdiSubWindow;
mdiSubWindow->setWidget( window );
m_pcMdiArea->addSubWindow( mdiSubWindow );
m_apcMdiSubWindowList.append( mdiSubWindow );
window->setSubWindow( mdiSubWindow );
- connect( mdiSubWindow, SIGNAL( aboutToClose( PlaYUVerMdiSubWindow* ) ), this, SLOT( removeMdiSubWindow( PlaYUVerMdiSubWindow* ) ) );
+ connect( mdiSubWindow, SIGNAL( aboutToClose( PlaYUVerMdiSubWindow* ) ), this,
+ SLOT( removeMdiSubWindow( PlaYUVerMdiSubWindow* ) ) );
}
-Void PlaYUVerSubWindowHandle::addSubWindow( SubWindowAbstract *window, Qt::WindowFlags flags )
+Void PlaYUVerSubWindowHandle::addSubWindow( SubWindowAbstract* window, Qt::WindowFlags flags )
{
if( window )
{
connect( window, SIGNAL( updateStatusBar( const QString& ) ), m_pcApp, SLOT( printMessage( const QString& ) ) );
- connect( window, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), m_pcApp, SLOT( updateZoomFactorSBox() ) );
+ connect( window, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), m_pcApp,
+ SLOT( updateZoomFactorSBox() ) );
if( m_iWindowMode == DETACHEDSUBWINDOWMODE )
{
- connect( window, SIGNAL( aboutToActivate( SubWindowAbstract* ) ), this, SLOT( updateActiveSubWindow( SubWindowAbstract* ) ) );
- connect( window, SIGNAL( aboutToClose( SubWindowAbstract* ) ), this, SLOT( removeSubWindow( SubWindowAbstract* ) ) );
+ connect( window, SIGNAL( aboutToActivate( SubWindowAbstract* ) ), this,
+ SLOT( updateActiveSubWindow( SubWindowAbstract* ) ) );
+ connect( window, SIGNAL( aboutToClose( SubWindowAbstract* ) ), this,
+ SLOT( removeSubWindow( SubWindowAbstract* ) ) );
}
if( m_iWindowMode == MDISUBWINDOWMODE )
{
@@ -304,7 +306,7 @@ SubWindowAbstract* PlaYUVerSubWindowHandle::activeSubWindow() const
}
QList PlaYUVerSubWindowHandle::findSubWindow( const UInt uiCategory ) const
- {
+{
QList apcSubWindowList;
if( uiCategory == 0 )
{
@@ -321,8 +323,9 @@ QList PlaYUVerSubWindowHandle::findSubWindow( const UInt uiC
return apcSubWindowList;
}
-QList PlaYUVerSubWindowHandle::findSubWindow( const QString &windowName, const UInt uiCategory ) const
- {
+QList PlaYUVerSubWindowHandle::findSubWindow( const QString& windowName,
+ const UInt uiCategory ) const
+{
QList subWindowList = findSubWindow( uiCategory );
QList apcSubWindowList;
if( !windowName.isEmpty() )
@@ -337,7 +340,7 @@ QList PlaYUVerSubWindowHandle::findSubWindow( const QString
}
SubWindowAbstract* PlaYUVerSubWindowHandle::findSubWindow( const SubWindowAbstract* subWindow ) const
- {
+{
QList subWindowList = findSubWindow();
for( Int i = 0; i < subWindowList.size(); i++ )
{
@@ -347,12 +350,12 @@ SubWindowAbstract* PlaYUVerSubWindowHandle::findSubWindow( const SubWindowAbstra
return 0;
}
-Void PlaYUVerSubWindowHandle::setActiveSubWindow( QWidget *window )
+Void PlaYUVerSubWindowHandle::setActiveSubWindow( QWidget* window )
{
if( !window )
return;
- m_pcActiveWindow = qobject_cast( window );
+ m_pcActiveWindow = qobject_cast( window );
if( m_iWindowMode == DETACHEDSUBWINDOWMODE )
{
@@ -384,7 +387,7 @@ Void PlaYUVerSubWindowHandle::tileSubWindows()
m_pcApp->resize( screenSize.width(), 5 );
QSize appSize = m_pcApp->size();
QPoint topLeftCornerWindow( 0, appSize.height() );
- //Select the arrangement based on the number of windows
+ // Select the arrangement based on the number of windows
if( numberOfWindows % 2 != 0 && numberOfWindows > minWindowsInRow )
{
@@ -429,7 +432,6 @@ Void PlaYUVerSubWindowHandle::tileSubWindows()
{
m_pcMdiArea->tileSubWindows();
}
-
}
Void PlaYUVerSubWindowHandle::cascadeSubWindows()
@@ -443,7 +445,7 @@ Void PlaYUVerSubWindowHandle::cascadeSubWindows()
Void PlaYUVerSubWindowHandle::createActions()
{
m_mapperWindow = new QSignalMapper( this );
- connect( m_mapperWindow, SIGNAL( mapped(QWidget*) ), this, SLOT( setActiveSubWindow(QWidget*) ) );
+ connect( m_mapperWindow, SIGNAL( mapped( QWidget* ) ), this, SLOT( setActiveSubWindow( QWidget* ) ) );
m_arrayActions.resize( TOTAL_ACT );
@@ -452,7 +454,7 @@ Void PlaYUVerSubWindowHandle::createActions()
m_actionGroupWindowMode->setExclusive( true );
m_mapperWindowMode = new QSignalMapper( this );
- connect( m_mapperWindowMode, SIGNAL( mapped(int) ), this, SLOT( setWindowMode(int) ) );
+ connect( m_mapperWindowMode, SIGNAL( mapped( int ) ), this, SLOT( setWindowMode( int ) ) );
m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT] = new QAction( tr( "&Detached SubWindows" ), this );
m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT]->setCheckable( true );
@@ -486,7 +488,7 @@ Void PlaYUVerSubWindowHandle::createActions()
m_arrayActions[TILE_WINDOWS_ACT]->setIcon( QIcon( ":images/windowstile.png" ) );
m_arrayActions[TILE_WINDOWS_ACT]->setStatusTip( tr( "Tile the windows" ) );
m_arrayActions[TILE_WINDOWS_ACT]->setShortcut( tr( "Ctrl+T" ) );
-//connect( m_arrayActions[TILE_WINDOWS_ACT], SIGNAL( triggered() ), mdiArea, SLOT( tileSubWindows() ) );
+ // connect( m_arrayActions[TILE_WINDOWS_ACT], SIGNAL( triggered() ), mdiArea, SLOT( tileSubWindows() ) );
connect( m_arrayActions[TILE_WINDOWS_ACT], SIGNAL( triggered() ), this, SLOT( tileSubWindows() ) );
m_arrayActions[CASCADE_WINDOWS_ACT] = new QAction( tr( "Cascade" ), this );
@@ -498,17 +500,16 @@ Void PlaYUVerSubWindowHandle::createActions()
m_arrayActions[NEXT_WINDOWS_ACT]->setShortcuts( QKeySequence::NextChild );
m_arrayActions[NEXT_WINDOWS_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_ArrowRight ) ) );
m_arrayActions[NEXT_WINDOWS_ACT]->setStatusTip( tr( "Move the focus to the next window" ) );
-// connect( m_arrayActions[NEXT_WINDOWS_ACT], SIGNAL( triggered() ), this, SLOT( activateNextSubWindow() ) );
+ // connect( m_arrayActions[NEXT_WINDOWS_ACT], SIGNAL( triggered() ), this, SLOT( activateNextSubWindow() ) );
m_arrayActions[PREVIOUS_WINDOWS_ACT] = new QAction( tr( "Pre&vious" ), this );
m_arrayActions[PREVIOUS_WINDOWS_ACT]->setShortcuts( QKeySequence::PreviousChild );
m_arrayActions[PREVIOUS_WINDOWS_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_ArrowLeft ) ) );
m_arrayActions[PREVIOUS_WINDOWS_ACT]->setStatusTip( tr( "Move the focus to the previous window" ) );
-// connect( m_arrayActions[PREVIOUS_WINDOWS_ACT], SIGNAL( triggered() ), this, SLOT( activatePreviousSubWindow() ) );
+ // connect( m_arrayActions[PREVIOUS_WINDOWS_ACT], SIGNAL( triggered() ), this, SLOT( activatePreviousSubWindow() ) );
m_arrayActions[SEPARATOR_ACT] = new QAction( this );
m_arrayActions[SEPARATOR_ACT]->setSeparator( true );
-
}
QMenu* PlaYUVerSubWindowHandle::createMenu()
@@ -531,9 +532,9 @@ Void PlaYUVerSubWindowHandle::updateMenu()
m_pcMenuWindow->addAction( m_arrayActions[TILE_WINDOWS_ACT] );
m_pcMenuWindow->addAction( m_arrayActions[CASCADE_WINDOWS_ACT] );
m_pcMenuWindow->addSeparator();
-// m_pcMenuWindow->addAction( m_arrayActions[NEXT_WINDOWS_ACT] );
-// m_pcMenuWindow->addAction( m_arrayActions[PREVIOUS_WINDOWS_ACT] );
-// m_pcMenuWindow->addSeparator();
+ // m_pcMenuWindow->addAction( m_arrayActions[NEXT_WINDOWS_ACT] );
+ // m_pcMenuWindow->addAction( m_arrayActions[PREVIOUS_WINDOWS_ACT] );
+ // m_pcMenuWindow->addSeparator();
Int number_windows = m_apcSubWindowList.size();
if( number_windows > 1 )
@@ -551,7 +552,7 @@ Void PlaYUVerSubWindowHandle::updateMenu()
for( Int i = 0; i < number_windows; ++i )
{
- SubWindowAbstract *subWindow = m_apcSubWindowList.at( i );
+ SubWindowAbstract* subWindow = m_apcSubWindowList.at( i );
QString text;
if( i < 9 )
@@ -562,7 +563,7 @@ Void PlaYUVerSubWindowHandle::updateMenu()
{
text = tr( "%1 %2" ).arg( i + 1 ).arg( subWindow->getWindowName() );
}
- QAction *action = m_pcMenuWindow->addAction( text );
+ QAction* action = m_pcMenuWindow->addAction( text );
action->setCheckable( true );
action->setChecked( subWindow == activeSubWindow() );
connect( action, SIGNAL( triggered() ), m_mapperWindow, SLOT( map() ) );
@@ -587,4 +588,3 @@ Void PlaYUVerSubWindowHandle::writeSettings()
appSettings.setValue( "SubWindowManager/LastMdiSize", m_cMdiModeWindowSize );
appSettings.setValue( "SubWindowManager/SubWindowMode", m_iWindowMode );
}
-
diff --git a/app/PlaYUVerSubWindowHandle.h b/app/PlaYUVerSubWindowHandle.h
index de36a61..240f160 100644
--- a/app/PlaYUVerSubWindowHandle.h
+++ b/app/PlaYUVerSubWindowHandle.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -42,21 +42,21 @@ class SubWindowAbstract;
class PlaYUVerMdiArea;
class PlaYUVerMdiSubWindow;
-class PlaYUVerSubWindowHandle: public QWidget
+class PlaYUVerSubWindowHandle : public QWidget
{
-Q_OBJECT
+ Q_OBJECT
-public:
- PlaYUVerSubWindowHandle( QWidget *parent );
+ public:
+ PlaYUVerSubWindowHandle( QWidget* parent );
Void processLogMsg( const QString& msg );
- Void addSubWindow( SubWindowAbstract *widget, Qt::WindowFlags flags = 0 );
+ Void addSubWindow( SubWindowAbstract* widget, Qt::WindowFlags flags = 0 );
- SubWindowAbstract *activeSubWindow() const;
+ SubWindowAbstract* activeSubWindow() const;
QList findSubWindow( const UInt uiCategory = 0 ) const;
- QList findSubWindow( const QString &aName, const UInt uiCategory = 0 ) const;
+ QList findSubWindow( const QString& aName, const UInt uiCategory = 0 ) const;
SubWindowAbstract* findSubWindow( const SubWindowAbstract* subWindow ) const;
Void createActions();
@@ -71,7 +71,7 @@ public:
MDISUBWINDOWMODE = 1,
};
-private:
+ private:
PlaYUVerApp* m_pcApp;
Int m_iWindowMode;
QList m_apcSubWindowList;
@@ -107,15 +107,15 @@ private:
/**
* Internal functions
*/
- Void addMdiSubWindow( SubWindowAbstract *window );
+ Void addMdiSubWindow( SubWindowAbstract* window );
Void resetWindowMode();
Void removeSubWindow( Int windowIdx );
-public Q_SLOTS:
+ public Q_SLOTS:
void setWindowMode( int iWindowMode );
- void updateActiveSubWindow( SubWindowAbstract *window = 0 );
- void setActiveSubWindow( QWidget *window );
- void removeSubWindow( SubWindowAbstract *window );
+ void updateActiveSubWindow( SubWindowAbstract* window = 0 );
+ void setActiveSubWindow( QWidget* window );
+ void removeSubWindow( SubWindowAbstract* window );
void removeMdiSubWindow( PlaYUVerMdiSubWindow* window );
void removeActiveSubWindow();
void removeAllSubWindow();
@@ -123,10 +123,9 @@ public Q_SLOTS:
void cascadeSubWindows();
void updateMenu();
-Q_SIGNALS:
+ Q_SIGNALS:
void changed();
void windowActivated();
-
};
-#endif // __PLAYUVERSUBWINDOWHANDLE_H__
+#endif // __PLAYUVERSUBWINDOWHANDLE_H__
diff --git a/app/PlotSubWindow.cpp b/app/PlotSubWindow.cpp
index ddd7411..9cfb771 100644
--- a/app/PlotSubWindow.cpp
+++ b/app/PlotSubWindow.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -44,10 +44,9 @@ Void PlotSubWindow::definePlotColors()
m_arrayColorList.append( Qt::darkYellow );
}
-PlotSubWindow::PlotSubWindow( const QString& windowTitle, QWidget * parent ) :
- SubWindowAbstract( parent, SubWindowAbstract::PLOT_SUBWINDOW )
+PlotSubWindow::PlotSubWindow( const QString& windowTitle, QWidget* parent )
+ : SubWindowAbstract( parent, SubWindowAbstract::PLOT_SUBWINDOW )
{
-
definePlotColors();
m_iNumberPlots = 0;
m_dScaleFactor = 1;
@@ -94,10 +93,10 @@ PlotSubWindow::PlotSubWindow( const QString& windowTitle, QWidget * parent ) :
m_cPlotArea->yAxis2->setVisible( true );
m_cPlotArea->yAxis2->setTickLabels( false );
// make left and bottom axes always transfer their ranges to right and top axes:
- connect( m_cPlotArea->xAxis, SIGNAL( rangeChanged(QCPRange) ), m_cPlotArea->xAxis2, SLOT( setRange(QCPRange) ) );
- connect( m_cPlotArea->yAxis, SIGNAL( rangeChanged(QCPRange) ), m_cPlotArea->yAxis2, SLOT( setRange(QCPRange) ) );
+ connect( m_cPlotArea->xAxis, SIGNAL( rangeChanged( QCPRange ) ), m_cPlotArea->xAxis2, SLOT( setRange( QCPRange ) ) );
+ connect( m_cPlotArea->yAxis, SIGNAL( rangeChanged( QCPRange ) ), m_cPlotArea->yAxis2, SLOT( setRange( QCPRange ) ) );
- QFont legendFont = font(); // start out with MainWindow's font..
+ QFont legendFont = font(); // start out with MainWindow's font..
legendFont.setPointSize( 9 ); // and make a bit smaller for legend
m_cPlotArea->legend->setFont( legendFont );
m_cPlotArea->legend->setBrush( backgroundBrush );
@@ -105,7 +104,7 @@ PlotSubWindow::PlotSubWindow( const QString& windowTitle, QWidget * parent ) :
m_cPlotArea->legend->setBorderPen( QPen( palette().brush( QPalette::Active, QPalette::Shadow ), 1 ) );
m_cPlotArea->legend->setVisible( false );
- m_cPlotArea->setInteractions( QCP::iRangeZoom | QCP::iRangeDrag ); //QCP::iSelectPlottables
+ m_cPlotArea->setInteractions( QCP::iRangeZoom | QCP::iRangeDrag ); // QCP::iSelectPlottables
m_cPlotPen.setStyle( Qt::SolidLine );
m_cPlotPen.setColor( Qt::black );
@@ -134,7 +133,6 @@ Void PlotSubWindow::zoomToFit()
Void PlotSubWindow::zoomToFactor( Double factor, QPoint center )
{
-
}
Void PlotSubWindow::scaleView( Double scale, QPoint center )
@@ -144,14 +142,14 @@ Void PlotSubWindow::scaleView( Double scale, QPoint center )
scale += 1;
m_dScaleFactor *= scale;
-//
-// UInt aNewAxisRange[2][2];
-// for( UInt axis = 0; axis < 2; axis++ )
-// for( UInt dim = 0; dim < 2; dim++ )
-// aNewAxisRange[axis][dim] = m_aAxisRange[axis][dim] / m_dScaleFactor;
-//
-// m_cPlotArea->xAxis->setRange( aNewAxisRange[HORIZONTAL][0], aNewAxisRange[HORIZONTAL][1] );
-// m_cPlotArea->yAxis->setRange( aNewAxisRange[VERTICAL][0], aNewAxisRange[VERTICAL][1] );
+ //
+ // UInt aNewAxisRange[2][2];
+ // for( UInt axis = 0; axis < 2; axis++ )
+ // for( UInt dim = 0; dim < 2; dim++ )
+ // aNewAxisRange[axis][dim] = m_aAxisRange[axis][dim] / m_dScaleFactor;
+ //
+ // m_cPlotArea->xAxis->setRange( aNewAxisRange[HORIZONTAL][0], aNewAxisRange[HORIZONTAL][1] );
+ // m_cPlotArea->yAxis->setRange( aNewAxisRange[VERTICAL][0], aNewAxisRange[VERTICAL][1] );
m_cPlotArea->xAxis->scaleRange( scale, 0 );
m_cPlotArea->yAxis->scaleRange( scale, 0 );
@@ -161,7 +159,7 @@ Void PlotSubWindow::scaleView( Double scale, QPoint center )
QSize PlotSubWindow::sizeHint() const
{
QSize maxSize;
- QWidget *p = parentWidget();
+ QWidget* p = parentWidget();
if( p )
{
maxSize = p->size();
@@ -173,8 +171,8 @@ QSize PlotSubWindow::sizeHint() const
return sizeHint( maxSize );
}
-QSize PlotSubWindow::sizeHint( const QSize & maxSize ) const
- {
+QSize PlotSubWindow::sizeHint( const QSize& maxSize ) const
+{
return maxSize * 2 / 3;
}
@@ -195,23 +193,23 @@ Void PlotSubWindow::setAxisRange( PlotSubWindow::Axis eAxis, const Int& axisStar
if( eAxis == HORIZONTAL )
{
m_cPlotArea->xAxis->setRange( axisStart, axisEnd );
- //horizontalScrollBar()->setRange( axisStart * 100, axisEnd * 100 );
+ // horizontalScrollBar()->setRange( axisStart * 100, axisEnd * 100 );
m_aAxisRange[HORIZONTAL][0] = axisStart;
m_aAxisRange[HORIZONTAL][1] = axisEnd;
}
if( eAxis == VERTICAL )
{
m_cPlotArea->yAxis->setRange( axisStart, axisEnd );
- //verticalScrollBar()->setRange( axisStart * 100, axisEnd * 100 );
+ // verticalScrollBar()->setRange( axisStart * 100, axisEnd * 100 );
m_aAxisRange[VERTICAL][0] = axisStart;
m_aAxisRange[VERTICAL][1] = axisEnd;
}
m_cPlotArea->replot();
}
-Void PlotSubWindow::addPlot( const QVector &arrayX, const QVector &arrayY, const QString& key )
+Void PlotSubWindow::addPlot( const QVector& arrayX, const QVector& arrayY, const QString& key )
{
- QCPGraph *newPlot = m_cPlotArea->addGraph();
+ QCPGraph* newPlot = m_cPlotArea->addGraph();
QColor plotColor = m_arrayColorList.at( 0 );
if( m_iNumberPlots < m_arrayColorList.size() )
{
@@ -237,4 +235,3 @@ Void PlotSubWindow::addPlot( const QVector &arrayX, const QVector m_arrayColorList;
@@ -55,18 +55,13 @@ private:
Double m_dScaleFactor;
Int m_iNumberPlots;
-public:
-
- PlotSubWindow( const QString& windowTitle, QWidget * parent = NULL );
+ public:
+ PlotSubWindow( const QString& windowTitle, QWidget* parent = NULL );
~PlotSubWindow();
Void definePlotColors();
- Void refreshSubWindow()
- {
-
- }
-
+ Void refreshSubWindow() {}
/**
* Virtual functions from SubWindowAbstract
*/
@@ -75,16 +70,12 @@ public:
Void zoomToFactor( Double factor, QPoint center = QPoint() );
Void scaleView( Double scale, QPoint center = QPoint() );
- Double getScaleFactor()
- {
- return m_dScaleFactor;
- }
-
+ Double getScaleFactor() { return m_dScaleFactor; }
/**
* Size related functions
*/
QSize sizeHint() const;
- QSize sizeHint( const QSize & ) const;
+ QSize sizeHint( const QSize& ) const;
Void setAxisName( const QString& nameAxisX, const QString& nameAxisY );
@@ -93,9 +84,7 @@ public:
Void setKey( const QString& key );
- Void addPlot( const QVector &arrayX, const QVector &arrayY, const QString& key = QString() );
-
+ Void addPlot( const QVector& arrayX, const QVector& arrayY, const QString& key = QString() );
};
-#endif // __PLOTWINDOWHANDLE_H__
-
+#endif // __PLOTWINDOWHANDLE_H__
diff --git a/app/ProgressBar.cpp b/app/ProgressBar.cpp
index 9240dca..b37c06d 100644
--- a/app/ProgressBar.cpp
+++ b/app/ProgressBar.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -29,10 +29,8 @@
#include
#include
-ProgressBar::ProgressBar( QWidget *parent, UInt maxValue ) :
- QWidget( parent ),
- m_uiTotalProgress( maxValue ),
- m_uiProgress( 0 )
+ProgressBar::ProgressBar( QWidget* parent, UInt maxValue )
+ : QWidget( parent ), m_uiTotalProgress( maxValue ), m_uiProgress( 0 )
{
QVBoxLayout* mainLayout = new QVBoxLayout( this );
m_pcProgressBar = new QProgressBar;
@@ -42,8 +40,8 @@ ProgressBar::ProgressBar( QWidget *parent, UInt maxValue ) :
setLayout( mainLayout );
setWindowTitle( QStringLiteral( "Progress" ) );
-// QSize appSize = QApplication::desktop()->availableGeometry().size();
-// QPoint appCenter = QApplication::desktop()->availableGeometry().center();
+ // QSize appSize = QApplication::desktop()->availableGeometry().size();
+ // QPoint appCenter = QApplication::desktop()->availableGeometry().center();
QSize appSize = parent->size();
QPoint appPos = parent->pos();
QPoint appCenter = QPoint( appPos.x() + appSize.width() / 2, appPos.y() + appSize.height() / 2 );
@@ -58,4 +56,3 @@ Void ProgressBar::incrementProgress( UInt increment )
m_pcProgressBar->setValue( m_uiProgress );
update();
}
-
diff --git a/app/ProgressBar.h b/app/ProgressBar.h
index 4cbe919..7a10a21 100644
--- a/app/ProgressBar.h
+++ b/app/ProgressBar.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -31,19 +31,19 @@
class QProgressBar;
-class ProgressBar: public QWidget
+class ProgressBar : public QWidget
{
-Q_OBJECT
+ Q_OBJECT
-public:
- ProgressBar( QWidget *parent, UInt maxValue );
+ public:
+ ProgressBar( QWidget* parent, UInt maxValue );
Void incrementProgress( UInt );
-private:
+ private:
UInt m_uiTotalProgress;
UInt m_uiProgress;
QProgressBar* m_pcProgressBar;
};
-#endif // __PROGRESSBAR_H__
+#endif // __PROGRESSBAR_H__
diff --git a/app/QualityHandle.cpp b/app/QualityHandle.cpp
index d9fd426..03f6dbe 100644
--- a/app/QualityHandle.cpp
+++ b/app/QualityHandle.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -34,16 +34,13 @@
#include "QtConcurrent/qtconcurrentrun.h"
#endif
-QualityHandle::QualityHandle( QWidget* parent, PlaYUVerSubWindowHandle* windowManager ) :
- m_pcParet( parent ),
- m_pcMainWindowManager( windowManager )
+QualityHandle::QualityHandle( QWidget* parent, PlaYUVerSubWindowHandle* windowManager )
+ : m_pcParet( parent ), m_pcMainWindowManager( windowManager )
{
-
}
QualityHandle::~QualityHandle()
{
-
}
Void QualityHandle::createActions()
@@ -93,8 +90,9 @@ QDockWidget* QualityHandle::createDock()
m_pcQualityHandleDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
m_pcQualityHandleDock->setWidget( m_pcQualityHandleSideBar );
- connect( m_pcQualityHandleSideBar, SIGNAL( signalQualityMetricChanged(int) ), this, SLOT( slotQualityMetricChanged(int) ) );
- connect( m_mapperQualityMetric, SIGNAL( mapped(int) ), this, SLOT( slotQualityMetricChanged(int) ) );
+ connect( m_pcQualityHandleSideBar, SIGNAL( signalQualityMetricChanged( int ) ), this,
+ SLOT( slotQualityMetricChanged( int ) ) );
+ connect( m_mapperQualityMetric, SIGNAL( mapped( int ) ), this, SLOT( slotQualityMetricChanged( int ) ) );
slotQualityMetricChanged( 0 );
@@ -103,7 +101,7 @@ QDockWidget* QualityHandle::createDock()
Void QualityHandle::updateMenus()
{
- VideoSubWindow* pcCurrentVideoSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
+ VideoSubWindow* pcCurrentVideoSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
Bool hasSubWindow = pcCurrentVideoSubWindow ? true : false;
Bool hasReference = false;
Bool isReference = false;
@@ -114,10 +112,11 @@ Void QualityHandle::updateMenus()
if( hasSubWindow && !hasReference )
{
VideoSubWindow* pcVideoSubWindow;
- QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
+ QList subWindowList =
+ m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
for( Int i = 0; i < subWindowList.size(); i++ )
{
- pcVideoSubWindow = qobject_cast( subWindowList.at( i ) );
+ pcVideoSubWindow = qobject_cast( subWindowList.at( i ) );
if( pcVideoSubWindow->getRefSubWindow() == pcCurrentVideoSubWindow )
{
isReference = true;
@@ -186,7 +185,7 @@ Void QualityHandle::measureQuality( QVector apcWindowList )
ProgressBar* pcProgressBar = new ProgressBar( m_pcParet, numberOfFrames );
- padQualityValues = new QVector [numberOfWindows + 1];
+ padQualityValues = new QVector[ numberOfWindows + 1 ];
PlaYUVerFrame* pcReferenceFrame;
PlaYUVerFrame* pcCurrFrame;
@@ -215,7 +214,8 @@ Void QualityHandle::measureQuality( QVector apcWindowList )
plotWindowTitle += " - " + apcWindowList.at( 0 )->getWindowName();
}
PlotSubWindow* pcPlotWindow = new PlotSubWindow( plotWindowTitle );
- pcPlotWindow->setAxisName( "Frame Number", QString::fromStdString( PlaYUVerFrame::supportedQualityMetricsList()[m_iQualityMetricIdx] ) );
+ pcPlotWindow->setAxisName(
+ "Frame Number", QString::fromStdString( PlaYUVerFrame::supportedQualityMetricsList()[m_iQualityMetricIdx] ) );
if( apcWindowList.size() > 1 )
{
@@ -235,7 +235,6 @@ Void QualityHandle::measureQuality( QVector apcWindowList )
pcPlotWindow->show();
pcProgressBar->close();
-
}
Void QualityHandle::slotQualityMetricChanged( Int idx )
@@ -252,7 +251,8 @@ Void QualityHandle::slotSelectCurrentAsReference()
if( pcRefSubWindow )
{
VideoSubWindow* pcVideoSubWindow;
- QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
+ QList subWindowList =
+ m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
for( Int i = 0; i < subWindowList.size(); i++ )
{
pcVideoSubWindow = qobject_cast( subWindowList.at( i ) );
@@ -267,7 +267,7 @@ Void QualityHandle::slotSelectCurrentAsReference()
Void QualityHandle::slotPlotQualitySingle()
{
- VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
+ VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
if( pcSubWindow )
{
if( pcSubWindow->getRefSubWindow() )
@@ -275,14 +275,14 @@ Void QualityHandle::slotPlotQualitySingle()
QVector apcWindowList;
apcWindowList.append( pcSubWindow );
-//#ifndef QT_NO_CONCURRENT
-// m_cMeasurementResult.waitForFinished();
-// m_cMeasurementResult = QtConcurrent::run( this, &QualityHandle::measureQuality, apcWindowList );
-//#else
+ //#ifndef QT_NO_CONCURRENT
+ // m_cMeasurementResult.waitForFinished();
+ // m_cMeasurementResult = QtConcurrent::run( this, &QualityHandle::measureQuality, apcWindowList );
+ //#else
QApplication::setOverrideCursor( Qt::WaitCursor );
measureQuality( apcWindowList );
QApplication::restoreOverrideCursor();
-//#endif
+ //#endif
emit changed();
}
}
@@ -290,7 +290,7 @@ Void QualityHandle::slotPlotQualitySingle()
Void QualityHandle::slotPlotQualitySeveral()
{
- VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
+ VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
if( pcSubWindow )
{
QVector apcWindowList;
@@ -302,10 +302,11 @@ Void QualityHandle::slotPlotQualitySeveral()
}
VideoSubWindow* pcVideoSubWindow;
- QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
+ QList subWindowList =
+ m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
for( Int i = 0; i < subWindowList.size(); i++ )
{
- pcVideoSubWindow = qobject_cast( subWindowList.at( i ) );
+ pcVideoSubWindow = qobject_cast( subWindowList.at( i ) );
if( pcVideoSubWindow->getRefSubWindow() == pcRefSubWindow )
{
apcWindowList.append( pcVideoSubWindow );
@@ -314,16 +315,15 @@ Void QualityHandle::slotPlotQualitySeveral()
if( apcWindowList.size() > 0 )
{
-//#ifndef QT_NO_CONCURRENT
-// m_cMeasurementResult.waitForFinished();
-// m_cMeasurementResult = QtConcurrent::run( this, &QualityHandle::measureQuality, apcWindowList );
-//#else
+ //#ifndef QT_NO_CONCURRENT
+ // m_cMeasurementResult.waitForFinished();
+ // m_cMeasurementResult = QtConcurrent::run( this, &QualityHandle::measureQuality, apcWindowList );
+ //#else
QApplication::setOverrideCursor( Qt::WaitCursor );
measureQuality( apcWindowList );
QApplication::restoreOverrideCursor();
-//#endif
+ //#endif
emit changed();
}
}
}
-
diff --git a/app/QualityHandle.h b/app/QualityHandle.h
index 7df0c03..9b14912 100644
--- a/app/QualityHandle.h
+++ b/app/QualityHandle.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -39,11 +39,11 @@
class PlaYUVerSubWindowHandle;
class VideoSubWindow;
-class QualityHandle: public QWidget
+class QualityHandle : public QWidget
{
-Q_OBJECT
- public:
- QualityHandle( QWidget*, PlaYUVerSubWindowHandle * );
+ Q_OBJECT
+ public:
+ QualityHandle( QWidget*, PlaYUVerSubWindowHandle* );
~QualityHandle();
Void createActions();
@@ -56,7 +56,7 @@ Q_OBJECT
Void update( VideoSubWindow* currSubWindow );
-private:
+ private:
QWidget* m_pcParet;
PlaYUVerSubWindowHandle* m_pcMainWindowManager;
@@ -81,14 +81,14 @@ private:
QFuture m_cMeasurementResult;
Void measureQuality( QVector apcWindowList );
-Q_SIGNALS:
+ Q_SIGNALS:
void changed();
-private Q_SLOTS:
+ private Q_SLOTS:
void slotQualityMetricChanged( int );
void slotSelectCurrentAsReference();
void slotPlotQualitySingle();
void slotPlotQualitySeveral();
};
-#endif // __QUALITYMEASUREMENTSIDEBAR_H__
+#endif // __QUALITYMEASUREMENTSIDEBAR_H__
diff --git a/app/QualityMeasurementSidebar.cpp b/app/QualityMeasurementSidebar.cpp
index b96cb4a..2e72f0f 100644
--- a/app/QualityMeasurementSidebar.cpp
+++ b/app/QualityMeasurementSidebar.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -27,21 +27,18 @@
#include "QualityMeasurementSidebar.h"
#include "VideoSubWindow.h"
-QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, PlaYUVerSubWindowHandle *windowManager ) :
- QWidget( parent ),
- m_pcMainWindowManager( windowManager ),
- m_pcCurrentVideoSubWindow( NULL )
+QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, PlaYUVerSubWindowHandle* windowManager )
+ : QWidget( parent ), m_pcMainWindowManager( windowManager ), m_pcCurrentVideoSubWindow( NULL )
{
-
// Side bar area -----------------------------------------------------
- QLabel *MetricLabel = new QLabel( tr( "Metric:" ) );
+ QLabel* MetricLabel = new QLabel( tr( "Metric:" ) );
MetricLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
- QLabel *RefLabel = new QLabel( tr( "Ref:" ) );
+ QLabel* RefLabel = new QLabel( tr( "Ref:" ) );
RefLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
- QLabel *RecLabel = new QLabel( tr( "Rec:" ) );
+ QLabel* RecLabel = new QLabel( tr( "Rec:" ) );
RecLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
m_comboBoxMetric = new QComboBox;
@@ -58,7 +55,7 @@ QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, PlaYUVerS
m_comboBoxRef->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
updateSubWindowList();
- QGridLayout *mainLayout = new QGridLayout;
+ QGridLayout* mainLayout = new QGridLayout;
mainLayout->addWidget( MetricLabel, 0, 0, Qt::AlignLeft );
mainLayout->addWidget( m_comboBoxMetric, 0, 1, Qt::AlignLeft );
mainLayout->addItem( spaceQuality, 0, 2, Qt::AlignRight );
@@ -80,7 +77,7 @@ QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, PlaYUVerS
m_ppcLabelQualityValue[CHROMA_V] = new QLabel;
m_ppcLabelQualityValue[CHROMA_V]->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
- QGridLayout *qualityResultsLayout = new QGridLayout;
+ 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 );
@@ -88,25 +85,24 @@ QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, PlaYUVerS
qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[CHROMA_V], 2, 0 );
qualityResultsLayout->addWidget( m_ppcLabelQualityValue[CHROMA_V], 2, 1 );
- //QGroupBox *statisticsGroup = new QGroupBox( tr( "Quality" ) );
- QGroupBox *statisticsGroup = new QGroupBox;
+ // QGroupBox *statisticsGroup = new QGroupBox( tr( "Quality" ) );
+ QGroupBox* statisticsGroup = new QGroupBox;
statisticsGroup->setLayout( qualityResultsLayout );
- statisticsGroup->setWhatsThis( tr( "Here you can see the quality results calculated for the "
- "selected windows." ) );
+ statisticsGroup->setWhatsThis(
+ tr( "
Here you can see the quality results calculated for the "
+ "selected windows." ) );
mainLayout->addWidget( statisticsGroup, 4, 0, 3, 3 );
mainLayout->setRowStretch( 8, 10 );
setLayout( mainLayout );
- connect( m_comboBoxRef, SIGNAL( activated(int) ), this, SLOT( slotReferenceChanged(int) ) );
- connect( m_comboBoxMetric, SIGNAL( currentIndexChanged(int) ), this, SLOT( slotQualityMetricChanged(int) ) );
-
+ connect( m_comboBoxRef, SIGNAL( activated( int ) ), this, SLOT( slotReferenceChanged( int ) ) );
+ connect( m_comboBoxMetric, SIGNAL( currentIndexChanged( int ) ), this, SLOT( slotQualityMetricChanged( int ) ) );
}
QualityMeasurementSidebar::~QualityMeasurementSidebar()
{
-
}
QSize QualityMeasurementSidebar::sizeHint() const
@@ -163,10 +159,10 @@ Void QualityMeasurementSidebar::updateSubWindowList()
m_comboBoxRef->setCurrentIndex( index );
}
}
-// m_comboBoxRef->setSizeAdjustPolicy( QComboBox::AdjustToContents );
+ // m_comboBoxRef->setSizeAdjustPolicy( QComboBox::AdjustToContents );
}
-Void QualityMeasurementSidebar::updateCurrentWindow( VideoSubWindow *subWindow )
+Void QualityMeasurementSidebar::updateCurrentWindow( VideoSubWindow* subWindow )
{
m_pcCurrentVideoSubWindow = subWindow;
if( m_pcCurrentVideoSubWindow )
@@ -216,7 +212,6 @@ Void QualityMeasurementSidebar::updateSidebarData()
{
m_ppcLabelQualityValue[component]->setText( zeroValue );
}
-
}
Void QualityMeasurementSidebar::updateQualityMetric( Int idx )
@@ -233,7 +228,7 @@ Void QualityMeasurementSidebar::slotReferenceChanged( Int index )
{
if( index > -1 && m_pcCurrentVideoSubWindow )
{
- VideoSubWindow *pcRefSubWindow = m_pcVideoWindowList.at( index );
+ VideoSubWindow* pcRefSubWindow = m_pcVideoWindowList.at( index );
if( pcRefSubWindow )
{
if( m_pcCurrentVideoSubWindow->getCurrFrame()->haveSameFmt( pcRefSubWindow->getCurrFrame() ) )
@@ -254,6 +249,5 @@ Void QualityMeasurementSidebar::slotReferenceChanged( Int index )
Void QualityMeasurementSidebar::slotQualityMetricChanged( Int idx )
{
emit signalQualityMetricChanged( idx );
- //updateQualityMetric( idx );
+ // updateQualityMetric( idx );
}
-
diff --git a/app/QualityMeasurementSidebar.h b/app/QualityMeasurementSidebar.h
index 8785507..9fb4e1b 100644
--- a/app/QualityMeasurementSidebar.h
+++ b/app/QualityMeasurementSidebar.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -40,11 +40,11 @@
class PlaYUVerSubWindowHandle;
class VideoSubWindow;
-class QualityMeasurementSidebar: public QWidget
+class QualityMeasurementSidebar : public QWidget
{
-Q_OBJECT
- public:
- QualityMeasurementSidebar( QWidget*, PlaYUVerSubWindowHandle * );
+ Q_OBJECT
+ public:
+ QualityMeasurementSidebar( QWidget*, PlaYUVerSubWindowHandle* );
~QualityMeasurementSidebar();
QSize sizeHint() const;
@@ -52,36 +52,35 @@ Q_OBJECT
Void updateSideBar( Bool hasSubWindow );
Void updateSubWindowList();
- Void updateCurrentWindow( VideoSubWindow * );
+ Void updateCurrentWindow( VideoSubWindow* );
Void updateSidebarData();
Void updateQualityMetric( Int );
-private:
+ private:
PlaYUVerSubWindowHandle* m_pcMainWindowManager;
QVector m_pcVideoWindowList;
QStringList m_pcWindowListNames;
QStringList m_pcSelectedWindowListNames;
- VideoSubWindow *m_pcCurrentVideoSubWindow;
+ VideoSubWindow* m_pcCurrentVideoSubWindow;
- QComboBox *m_comboBoxMetric;
+ QComboBox* m_comboBoxMetric;
- QComboBox *m_comboBoxRef;
- QComboBox *m_comboBoxRec;
+ QComboBox* m_comboBoxRef;
+ QComboBox* m_comboBoxRec;
QLabel* m_ppcLabelQualityLabel[3];
QLabel* m_ppcLabelQualityValue[3];
- HistogramWidget *histogramWidget;
+ HistogramWidget* histogramWidget;
-Q_SIGNALS:
+ Q_SIGNALS:
void signalQualityMetricChanged( int );
-private Q_SLOTS:
+ private Q_SLOTS:
void slotReferenceChanged( int );
void slotQualityMetricChanged( int );
-
};
-#endif // __QUALITYMEASUREMENTSIDEBAR_H__
+#endif // __QUALITYMEASUREMENTSIDEBAR_H__
diff --git a/app/SeekStreamDialog.cpp b/app/SeekStreamDialog.cpp
index 31b1f72..f165cfb 100644
--- a/app/SeekStreamDialog.cpp
+++ b/app/SeekStreamDialog.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -30,11 +30,9 @@
#include
#include
-SeekStreamDialog::SeekStreamDialog( PlaYUVerStream *pcCurrStream, QWidget *parent ) :
- QDialog( parent, Qt::Dialog | Qt::WindowTitleHint ),
- m_iSelectedFrameNum()
+SeekStreamDialog::SeekStreamDialog( PlaYUVerStream* pcCurrStream, QWidget* parent )
+ : QDialog( parent, Qt::Dialog | Qt::WindowTitleHint ), m_iSelectedFrameNum()
{
-
m_iSelectedFrameNum = pcCurrStream->getCurrFrameNum();
setWindowModality( Qt::ApplicationModal );
@@ -79,4 +77,3 @@ Int SeekStreamDialog::runDialog()
m_iSelectedFrameNum = m_spinFrameNum->value();
return m_iSelectedFrameNum;
}
-
diff --git a/app/SeekStreamDialog.h b/app/SeekStreamDialog.h
index 6542605..b74bb5d 100644
--- a/app/SeekStreamDialog.h
+++ b/app/SeekStreamDialog.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -34,16 +34,17 @@
/**
*
*/
-class SeekStreamDialog: public QDialog
+class SeekStreamDialog : public QDialog
{
-Q_OBJECT
+ Q_OBJECT
-public:
- SeekStreamDialog( PlaYUVerStream *pcCurrStream, QWidget *parent = 0 );
+ public:
+ SeekStreamDialog( PlaYUVerStream* pcCurrStream, QWidget* parent = 0 );
Int runDialog();
- private:
+
+ private:
QSpinBox* m_spinFrameNum;
Int m_iSelectedFrameNum;
};
-#endif // __MODULEHANDLEOPTDIALOG_H__
+#endif // __MODULEHANDLEOPTDIALOG_H__
diff --git a/app/SubWindowAbstract.cpp b/app/SubWindowAbstract.cpp
index d4832ea..e58b559 100644
--- a/app/SubWindowAbstract.cpp
+++ b/app/SubWindowAbstract.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -30,20 +30,18 @@
#include "SubWindowAbstract.h"
#include "PlaYUVerMdiSubWindow.h"
-SubWindowAbstract::SubWindowAbstract( QWidget * parent, UInt category ) :
- QWidget( parent ),
- m_cSubWindow( NULL )
+SubWindowAbstract::SubWindowAbstract( QWidget* parent, UInt category ) : QWidget( parent ), m_cSubWindow( NULL )
{
setParent( parent );
setVisible( false );
- //setFocusPolicy( Qt::WheelFocus );
+ // setFocusPolicy( Qt::WheelFocus );
setFocusPolicy( Qt::StrongFocus );
setAttribute( Qt::WA_DeleteOnClose );
setBackgroundRole( QPalette::Background );
setWindowIcon( QIcon( ":/images/playuver.png" ) );
- //setWidgetResizable( true );
+ // setWidgetResizable( true );
m_pcLayout = NULL;
m_uiCategory = category;
m_cWindowName = QString( " " );
@@ -58,7 +56,7 @@ SubWindowAbstract::~SubWindowAbstract()
Void SubWindowAbstract::setWidget( QWidget* widget )
{
- QGridLayout *layout = new QGridLayout( this );
+ QGridLayout* layout = new QGridLayout( this );
layout->setContentsMargins( 0, 0, 0, 0 );
layout->addWidget( widget, 0, 0 );
}
@@ -89,17 +87,17 @@ QSize SubWindowAbstract::sizeHint() const
return QSize();
}
-QSize SubWindowAbstract::sizeHint( const QSize & ) const
- {
+QSize SubWindowAbstract::sizeHint( const QSize& ) const
+{
return QSize();
}
-Void SubWindowAbstract::focusInEvent( QFocusEvent * event )
+Void SubWindowAbstract::focusInEvent( QFocusEvent* event )
{
emit aboutToActivate( this );
}
-Void SubWindowAbstract::closeEvent( QCloseEvent *event )
+Void SubWindowAbstract::closeEvent( QCloseEvent* event )
{
emit aboutToClose( this );
event->accept();
@@ -111,4 +109,3 @@ Void SubWindowAbstract::closeSubWindow()
if( m_cSubWindow )
m_cSubWindow->close();
}
-
diff --git a/app/SubWindowAbstract.h b/app/SubWindowAbstract.h
index 3d2ea4f..04b06cc 100644
--- a/app/SubWindowAbstract.h
+++ b/app/SubWindowAbstract.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -50,18 +50,18 @@ class QCloseEvent;
class PlaYUVerMdiSubWindow;
-class SubWindowAbstract: public QWidget
+class SubWindowAbstract : public QWidget
{
-Q_OBJECT
+ Q_OBJECT
-private:
+ private:
QHBoxLayout* m_pcLayout;
UInt m_uiCategory;
QString m_cWindowName;
PlaYUVerMdiSubWindow* m_cSubWindow;
-public:
+ public:
enum SubWindowCategory
{
SUBWINDOW = 0,
@@ -69,9 +69,10 @@ public:
VIDEO_STREAM_SUBWINDOW = 2,
MODULE_SUBWINDOW = 4,
PLOT_SUBWINDOW = 8,
- };Q_DECLARE_FLAGS( SubWindowCategories, SubWindowCategory )
+ };
+ Q_DECLARE_FLAGS( SubWindowCategories, SubWindowCategory )
-SubWindowAbstract ( QWidget *, UInt );
+ SubWindowAbstract( QWidget*, UInt );
~SubWindowAbstract();
/**
@@ -104,7 +105,7 @@ SubWindowAbstract ( QWidget *, UInt );
* Size related functions
*/
virtual QSize sizeHint() const;
- virtual QSize sizeHint( const QSize & ) const;
+ virtual QSize sizeHint( const QSize& ) const;
/**
* Window name
@@ -121,36 +122,24 @@ SubWindowAbstract ( QWidget *, UInt );
* @note This function should be used with enum SubWindowCategories
* with an & operation and it may belong to several categories
*/
- UInt getCategory()
- {
- return m_uiCategory;
- }
-
+ UInt getCategory() { return m_uiCategory; }
/**
* Check category of the SubWindow
* @param checkCateory SubWindow category to check against;
* it should be enum SubWindowCategories type
* @return true when SubWindow belong to checkCateory
*/
- Bool checkCategory( UInt checkCateory )
- {
- return m_uiCategory & checkCateory;
- }
-
- Void setSubWindow( PlaYUVerMdiSubWindow* subWindow )
- {
- m_cSubWindow = subWindow;
- }
-
+ Bool checkCategory( UInt checkCateory ) { return m_uiCategory & checkCateory; }
+ Void setSubWindow( PlaYUVerMdiSubWindow* subWindow ) { m_cSubWindow = subWindow; }
Void closeSubWindow();
-protected:
+ protected:
void focusInEvent( QFocusEvent* event );
void closeEvent( QCloseEvent* event );
Void setWidget( QWidget* widget );
- Q_SIGNALS:
+ Q_SIGNALS:
/**
* Notify that zoom factor was changed by internal event (e.g. by mouse wheel)
*/
@@ -167,10 +156,8 @@ protected:
void aboutToActivate( SubWindowAbstract* );
void aboutToClose( SubWindowAbstract* );
-public Q_SLOTS:
+ public Q_SLOTS:
void onDestroyed();
-
};
-#endif // __SUBWINDOWABSTRACT_H__
-
+#endif // __SUBWINDOWABSTRACT_H__
diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp
index 098e5db..a7dcd08 100644
--- a/app/VideoHandle.cpp
+++ b/app/VideoHandle.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -41,9 +41,8 @@
#include
#endif
-VideoHandle::VideoHandle( QWidget* parent, PlaYUVerSubWindowHandle* windowManager ) :
- m_pcParet( parent ),
- m_pcMainWindowManager( windowManager )
+VideoHandle::VideoHandle( QWidget* parent, PlaYUVerSubWindowHandle* windowManager )
+ : m_pcParet( parent ), m_pcMainWindowManager( windowManager )
{
m_pcCurrentVideoSubWindow = NULL;
m_bIsPlaying = false;
@@ -57,7 +56,6 @@ VideoHandle::VideoHandle( QWidget* parent, PlaYUVerSubWindowHandle* windowManage
VideoHandle::~VideoHandle()
{
-
}
Void VideoHandle::createActions()
@@ -75,7 +73,7 @@ Void VideoHandle::createActions()
connect( m_arrayActions[STOP_ACT], SIGNAL( triggered() ), this, SLOT( stop() ) );
m_mapperVideoSeek = new QSignalMapper( this );
- connect( m_mapperVideoSeek, SIGNAL( mapped(int) ), this, SLOT( seekEvent(int) ) );
+ connect( m_mapperVideoSeek, SIGNAL( mapped( int ) ), this, SLOT( seekEvent( int ) ) );
m_arrayActions[VIDEO_BACKWARD_ACT] = new QAction( "Video Backward", this );
m_arrayActions[VIDEO_BACKWARD_ACT]->setStatusTip( "Seek backward" );
@@ -119,14 +117,14 @@ Void VideoHandle::createActions()
m_pcFrameSlider->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ) );
m_pcFrameSlider->setEnabled( false );
m_pcFrameSlider->setTracking( false );
- connect( m_pcFrameSlider, SIGNAL( valueChanged(int) ), this, SLOT( seekSliderEvent(int) ) );
+ connect( m_pcFrameSlider, SIGNAL( valueChanged( int ) ), this, SLOT( seekSliderEvent( int ) ) );
// ------------ Tools ------------
actionGroupTools = new QActionGroup( this );
actionGroupTools->setExclusive( true );
m_mapperTools = new QSignalMapper( this );
- connect( m_mapperTools, SIGNAL( mapped(int) ), this, SLOT( setTool(int) ) );
+ connect( m_mapperTools, SIGNAL( mapped( int ) ), this, SLOT( setTool( int ) ) );
m_uiViewTool = ViewArea::NavigationView;
@@ -157,7 +155,7 @@ Void VideoHandle::createActions()
m_arrayActions[SHOW_GRID_ACT] = new QAction( "Show grid", this );
m_arrayActions[SHOW_GRID_ACT]->setCheckable( true );
m_arrayActions[SHOW_GRID_ACT]->setChecked( false );
- connect( m_arrayActions[SHOW_GRID_ACT], SIGNAL( toggled(bool) ), this, SLOT( toggleGrid(bool) ) );
+ connect( m_arrayActions[SHOW_GRID_ACT], SIGNAL( toggled( bool ) ), this, SLOT( toggleGrid( bool ) ) );
}
QMenu* VideoHandle::createVideoMenu()
@@ -214,7 +212,7 @@ QDockWidget* VideoHandle::createDock()
m_pcFramePropertiesDock = new QDockWidget( tr( "Frame Information" ), this );
m_pcFramePropertiesDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
m_pcFramePropertiesDock->setWidget( m_pcFramePropertiesSideBar );
- connect( m_pcFramePropertiesDock, SIGNAL( visibilityChanged(bool) ), this, SLOT( update() ) );
+ connect( m_pcFramePropertiesDock, SIGNAL( visibilityChanged( bool ) ), this, SLOT( update() ) );
return m_pcFramePropertiesDock;
}
@@ -245,11 +243,11 @@ QWidget* VideoHandle::createStatusBarMessage()
Void VideoHandle::updateMenus()
{
- VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
+ VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
Bool hasSubWindow = pcSubWindow ? true : false;
m_arrayActions[PLAY_ACT]->setEnabled( hasSubWindow );
- //m_arrayActions[PAUSE_ACT]->setEnabled( hasSubWindow );
+ // m_arrayActions[PAUSE_ACT]->setEnabled( hasSubWindow );
m_arrayActions[STOP_ACT]->setEnabled( hasSubWindow );
m_arrayActions[VIDEO_BACKWARD_ACT]->setEnabled( hasSubWindow );
m_arrayActions[VIDEO_FORWARD_ACT]->setEnabled( hasSubWindow );
@@ -385,7 +383,7 @@ Void VideoHandle::openSubWindow( VideoSubWindow* subWindow )
Void VideoHandle::closeSubWindow( SubWindowAbstract* subWindow )
{
- VideoSubWindow* videoSubWindow = qobject_cast( subWindow );
+ VideoSubWindow* videoSubWindow = qobject_cast( subWindow );
if( m_acPlayingSubWindows.contains( videoSubWindow ) )
{
@@ -405,11 +403,11 @@ Void VideoHandle::zoomToFactorAll( const Double scale, const QPoint center )
if( m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->isChecked() )
{
-
factor = m_pcCurrentVideoSubWindow->getScaleFactor();
- SubWindowAbstract *subWindow;
- QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
+ SubWindowAbstract* subWindow;
+ QList subWindowList =
+ m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
for( Int i = 0; i < subWindowList.size(); i++ )
{
subWindow = subWindowList.at( i );
@@ -428,10 +426,11 @@ Void VideoHandle::moveAllScrollBars( const QPoint offset )
QPoint newOffset = offset;
if( m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->isChecked() && m_pcCurrentVideoSubWindow )
{
- VideoSubWindow *videoSubWindow;
- QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
+ VideoSubWindow* videoSubWindow;
+ QList subWindowList =
+ m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
- QScrollBar *scrollBar;
+ QScrollBar* scrollBar;
scrollBar = m_pcCurrentVideoSubWindow->getScroll()->horizontalScrollBar();
// Do not move other images, if current image reached maximum or minimum scroll position
@@ -448,7 +447,7 @@ Void VideoHandle::moveAllScrollBars( const QPoint offset )
for( Int i = 0; i < subWindowList.size(); i++ )
{
- videoSubWindow = qobject_cast( subWindowList.at( i ) );
+ videoSubWindow = qobject_cast( subWindowList.at( i ) );
if( m_pcCurrentVideoSubWindow == videoSubWindow )
continue;
else
@@ -512,10 +511,7 @@ Void VideoHandle::setTimerStatus()
#if( _CONTROL_PLAYING_TIME_ == 1 )
if( m_pcPlayControlTimer && m_pcPlayingTimer->interval() > 0 )
{
- qDebug( ) << "Desired Fps: "
- << 1000 / m_pcPlayingTimer->interval()
- << "Real Fps: "
- << 1000 / m_dAverageFps;
+ qDebug() << "Desired Fps: " << 1000 / m_pcPlayingTimer->interval() << "Real Fps: " << 1000 / m_dAverageFps;
delete m_pcPlayControlTimer;
m_pcPlayControlTimer = NULL;
@@ -574,7 +570,7 @@ Void VideoHandle::play()
}
setTimerStatus();
emit changed();
- //update();
+ // update();
}
Void VideoHandle::stop()
@@ -603,7 +599,8 @@ Void VideoHandle::playEvent()
{
Bool bEndOfSequence = false;
#if( _CONTROL_PLAYING_TIME_ == 1 )
- m_dAverageFps = Double( m_dAverageFps * m_uiNumberPlayedFrames + m_pcPlayControlTimer->elapsed() ) / Double( m_uiNumberPlayedFrames + 1 );
+ m_dAverageFps = Double( m_dAverageFps * m_uiNumberPlayedFrames + m_pcPlayControlTimer->elapsed() ) /
+ Double( m_uiNumberPlayedFrames + 1 );
m_uiNumberPlayedFrames++;
m_pcPlayControlTimer->restart();
#endif
@@ -622,12 +619,13 @@ Void VideoHandle::playEvent()
m_acPlayingSubWindows.at( i )->seekAbsoluteEvent( 0 );
}
}
- catch( const char *msg )
+ catch( const char* msg )
{
- QString warningMsg = "Error while playing " + QFileInfo( m_pcCurrentVideoSubWindow->getCurrentFileName() ).fileName() + " with the following error: \n"
- + msg;
+ QString warningMsg = "Error while playing " +
+ QFileInfo( m_pcCurrentVideoSubWindow->getCurrentFileName() ).fileName() +
+ " with the following error: \n" + msg;
QMessageBox::warning( this, QApplication::applicationName(), warningMsg );
- qDebug( ) << warningMsg;
+ qDebug() << warningMsg;
stop();
m_pcCurrentVideoSubWindow->close();
}
@@ -640,7 +638,8 @@ Void VideoHandle::seekEvent( Int direction )
{
if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) )
{
- if( !( ( UInt )( m_pcCurrentVideoSubWindow->getInputStream()->getCurrFrameNum() + 1 ) >= getMaxFrameNumber() && direction > 0 ) )
+ if( !( ( UInt )( m_pcCurrentVideoSubWindow->getInputStream()->getCurrFrameNum() + 1 ) >= getMaxFrameNumber() &&
+ direction > 0 ) )
{
for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ )
{
@@ -653,7 +652,7 @@ Void VideoHandle::seekEvent( Int direction )
m_pcCurrentVideoSubWindow->seekRelativeEvent( direction > 0 ? true : false );
}
emit changed();
- //update();
+ // update();
}
}
@@ -671,12 +670,12 @@ Void VideoHandle::seekVideo()
{
for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ )
{
- m_acPlayingSubWindows.at( i )->seekAbsoluteEvent( ( UInt )newFrameNum );
+ m_acPlayingSubWindows.at( i )->seekAbsoluteEvent( (UInt)newFrameNum );
}
}
else
{
- m_pcCurrentVideoSubWindow->seekAbsoluteEvent( ( UInt )newFrameNum );
+ m_pcCurrentVideoSubWindow->seekAbsoluteEvent( (UInt)newFrameNum );
}
emit changed();
}
@@ -692,26 +691,27 @@ Void VideoHandle::seekSliderEvent( Int new_frame_num )
{
for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ )
{
- m_acPlayingSubWindows.at( i )->seekAbsoluteEvent( ( UInt )new_frame_num );
+ m_acPlayingSubWindows.at( i )->seekAbsoluteEvent( (UInt)new_frame_num );
}
}
else
{
- m_pcCurrentVideoSubWindow->seekAbsoluteEvent( ( UInt )new_frame_num );
+ m_pcCurrentVideoSubWindow->seekAbsoluteEvent( (UInt)new_frame_num );
}
emit changed();
- //update();
+ // update();
}
}
Void VideoHandle::videoSelectionButtonEvent()
{
- VideoSubWindow *videoSubWindow;
+ VideoSubWindow* videoSubWindow;
Qt::KeyboardModifiers keyModifiers = QApplication::keyboardModifiers();
if( keyModifiers & Qt::ControlModifier )
{
- QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
+ QList subWindowList =
+ m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
for( Int i = 0; i < subWindowList.size(); i++ )
{
videoSubWindow = qobject_cast( subWindowList.at( i ) );
@@ -720,7 +720,8 @@ Void VideoHandle::videoSelectionButtonEvent()
}
else
{
- DialogSubWindowSelector dialogWindowsSelection( this, m_pcMainWindowManager, SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
+ DialogSubWindowSelector dialogWindowsSelection( this, m_pcMainWindowManager,
+ SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
QStringList cWindowListNames;
for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ )
{
@@ -783,4 +784,3 @@ Void VideoHandle::toggleGrid( Bool checked )
qobject_cast( subWindowList.at( i ) )->getViewArea()->setGridVisible( checked );
}
}
-
diff --git a/app/VideoHandle.h b/app/VideoHandle.h
index 81d5285..9add246 100644
--- a/app/VideoHandle.h
+++ b/app/VideoHandle.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -48,11 +48,11 @@ class VideoSubWindow;
class FramePropertiesDock;
class WidgetFrameNumber;
-class VideoHandle: public QWidget
+class VideoHandle : public QWidget
{
-Q_OBJECT
- public:
- VideoHandle( QWidget*, PlaYUVerSubWindowHandle * );
+ Q_OBJECT
+ public:
+ VideoHandle( QWidget*, PlaYUVerSubWindowHandle* );
~VideoHandle();
Void createActions();
@@ -70,7 +70,7 @@ Q_OBJECT
Void openSubWindow( VideoSubWindow* subWindow );
-private:
+ private:
QWidget* m_pcParet;
PlaYUVerSubWindowHandle* m_pcMainWindowManager;
enum
@@ -97,8 +97,8 @@ private:
WidgetFrameNumber* m_pcFrameNumInfo;
// Tools Actions;
- QActionGroup *actionGroupTools;
- QSignalMapper *m_mapperTools;
+ QActionGroup* actionGroupTools;
+ QSignalMapper* m_mapperTools;
UInt m_uiViewTool;
QMenu* m_pcMenuVideo;
@@ -114,7 +114,7 @@ private:
VideoSubWindow* m_pcCurrentVideoSubWindow;
QVector m_acPlayingSubWindows;
- QTimer *m_pcPlayingTimer;
+ QTimer* m_pcPlayingTimer;
Bool m_bIsPlaying;
#if( _CONTROL_PLAYING_TIME_ == 1 )
@@ -126,10 +126,10 @@ private:
UInt64 getMaxFrameNumber();
Void setTimerStatus();
-Q_SIGNALS:
+ Q_SIGNALS:
void changed();
-private Q_SLOTS:
+ private Q_SLOTS:
void update();
void updateSelectionArea( QRect area );
void closeSubWindow( SubWindowAbstract* subWindow );
@@ -144,7 +144,6 @@ private Q_SLOTS:
void videoSelectionButtonEvent();
void setTool( int tool );
void toggleGrid( bool checked );
-
};
-#endif // __VIDEOHANDLE_H__
+#endif // __VIDEOHANDLE_H__
diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp
index 2a0bf15..1fc9474 100644
--- a/app/VideoSubWindow.cpp
+++ b/app/VideoSubWindow.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -43,14 +43,8 @@ QDataStream& operator<<( QDataStream& out, const PlaYUVerStreamInfoVector& array
for( Int i = 0; i < array.size(); i++ )
{
d = array.at( i );
- out << d.m_cFilename
- << d.m_uiWidth
- << d.m_uiHeight
- << d.m_iPelFormat
- << d.m_uiBitsPelPixel
- << d.m_iEndianness
- << d.m_uiFrameRate
- << d.m_uiFileSize;
+ out << d.m_cFilename << d.m_uiWidth << d.m_uiHeight << d.m_iPelFormat << d.m_uiBitsPelPixel << d.m_iEndianness
+ << d.m_uiFrameRate << d.m_uiFileSize;
}
return out;
}
@@ -88,17 +82,16 @@ Int findPlaYUVerStreamInfo( PlaYUVerStreamInfoVector array, QString filename )
* \brief Shows information about video sub window
*/
-class VideoInformation: public QWidget
+class VideoInformation : public QWidget
{
-private:
+ private:
QList m_cTopLeftTextList;
QFont m_cTopLeftTextFont;
QFont m_cCenterTextFont;
Bool m_bBusyWindow;
- public:
- VideoInformation( QWidget *parent ) :
- QWidget( parent ),
- m_bBusyWindow( false )
+
+ public:
+ VideoInformation( QWidget* parent ) : QWidget( parent ), m_bBusyWindow( false )
{
setPalette( Qt::transparent );
setAttribute( Qt::WA_TransparentForMouseEvents );
@@ -113,12 +106,9 @@ private:
m_cTopLeftTextList.append( textLines.at( i ) );
}
}
- Void setBusyWindow( Bool bFlag )
- {
- m_bBusyWindow = bFlag;
- }
-protected:
- void paintEvent( QPaintEvent *event )
+ Void setBusyWindow( Bool bFlag ) { m_bBusyWindow = bFlag; }
+ protected:
+ void paintEvent( QPaintEvent* event )
{
QPainter painter( this );
painter.setFont( m_cTopLeftTextFont );
@@ -140,31 +130,35 @@ protected:
}
};
-VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget * parent ) :
- SubWindowAbstract( parent, SubWindowAbstract::VIDEO_SUBWINDOW | category ),
- m_bWindowBusy( false ),
- m_pCurrStream( NULL ),
- m_pcCurrFrame( NULL ),
- m_pcCurrentDisplayModule( NULL ),
- m_pcReferenceSubWindow( NULL ),
- m_bIsPlaying( false )
+VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget* parent )
+ : SubWindowAbstract( parent, SubWindowAbstract::VIDEO_SUBWINDOW | category ),
+ m_bWindowBusy( false ),
+ m_pCurrStream( NULL ),
+ m_pcCurrFrame( NULL ),
+ m_pcCurrentDisplayModule( NULL ),
+ m_pcReferenceSubWindow( NULL ),
+ m_bIsPlaying( false )
{
-
// Create a new scroll area inside the sub-window
m_pcScrollArea = new QScrollArea;
- connect( m_pcScrollArea->horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValues() ) );
- connect( m_pcScrollArea->verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValues() ) );
+ connect( m_pcScrollArea->horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this,
+ SLOT( updateCurScrollValues() ) );
+ connect( m_pcScrollArea->verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this,
+ SLOT( updateCurScrollValues() ) );
// Create a new interface to show images
m_cViewArea = new ViewArea;
- connect( m_cViewArea, SIGNAL( zoomFactorChanged_byWheel( double , QPoint) ), this, SLOT( adjustScrollBarByScale( double, QPoint ) ) );
- connect( m_cViewArea, SIGNAL( zoomFactorChanged_byWheel( double , QPoint) ), this, SIGNAL( zoomFactorChanged_SWindow( double, QPoint ) ) );
+ connect( m_cViewArea, SIGNAL( zoomFactorChanged_byWheel( double, QPoint ) ), this,
+ SLOT( adjustScrollBarByScale( double, QPoint ) ) );
+ connect( m_cViewArea, SIGNAL( zoomFactorChanged_byWheel( double, QPoint ) ), this,
+ SIGNAL( zoomFactorChanged_SWindow( double, QPoint ) ) );
connect( m_cViewArea, SIGNAL( scrollBarMoved( QPoint ) ), this, SLOT( adjustScrollBarByOffset( QPoint ) ) );
connect( m_cViewArea, SIGNAL( scrollBarMoved( QPoint ) ), this, SIGNAL( scrollBarMoved_SWindow( QPoint ) ) );
connect( m_cViewArea, SIGNAL( selectionChanged( QRect ) ), this, SLOT( updateSelectedArea( QRect ) ) );
- connect( m_cViewArea, SIGNAL( positionChanged( const QPoint & ) ), this, SLOT( updatePixelValueStatusBar( const QPoint & ) ) );
+ connect( m_cViewArea, SIGNAL( positionChanged( const QPoint& ) ), this,
+ SLOT( updatePixelValueStatusBar( const QPoint& ) ) );
m_pcScrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
m_pcScrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
@@ -209,18 +203,18 @@ Void VideoSubWindow::keyPressEvent( QKeyEvent* event )
Bool bRet = false;
switch( event->key() )
{
- case Qt::Key_A:
- bRet = m_pcCurrentDisplayModule->getModule()->keyPressed( MODULE_KEY_LEFT );
- break;
- case Qt::Key_D:
- bRet = m_pcCurrentDisplayModule->getModule()->keyPressed( MODULE_KEY_RIGHT );
- break;
- case Qt::Key_W:
- bRet = m_pcCurrentDisplayModule->getModule()->keyPressed( MODULE_KEY_UP );
- break;
- case Qt::Key_S:
- bRet = m_pcCurrentDisplayModule->getModule()->keyPressed( MODULE_KEY_DOWN );
- break;
+ case Qt::Key_A:
+ bRet = m_pcCurrentDisplayModule->getModule()->keyPressed( MODULE_KEY_LEFT );
+ break;
+ case Qt::Key_D:
+ bRet = m_pcCurrentDisplayModule->getModule()->keyPressed( MODULE_KEY_RIGHT );
+ break;
+ case Qt::Key_W:
+ bRet = m_pcCurrentDisplayModule->getModule()->keyPressed( MODULE_KEY_UP );
+ break;
+ case Qt::Key_S:
+ bRet = m_pcCurrentDisplayModule->getModule()->keyPressed( MODULE_KEY_DOWN );
+ break;
}
if( bRet )
{
@@ -245,7 +239,7 @@ QSize VideoSubWindow::sizeHint() const
{
QSize maxSize;
- QWidget *p = parentWidget();
+ QWidget* p = parentWidget();
if( p )
{
maxSize = p->size();
@@ -257,16 +251,16 @@ QSize VideoSubWindow::sizeHint() const
return sizeHint( maxSize );
}
-QSize VideoSubWindow::sizeHint( const QSize & maxSize ) const
- {
+QSize VideoSubWindow::sizeHint( const QSize& maxSize ) const
+{
QSize isize;
if( m_pcCurrFrame )
isize = QSize( m_pcCurrFrame->getWidth() + 50, m_pcCurrFrame->getHeight() + 50 );
else if( m_pCurrStream )
isize = QSize( m_pCurrStream->getWidth() + 50, m_pCurrStream->getHeight() + 50 );
-// If the VideoSubWindow needs more space that the avaiable, we'll give
-// to the subwindow a reasonable size preserving the image aspect ratio.
+ // If the VideoSubWindow needs more space that the avaiable, we'll give
+ // to the subwindow a reasonable size preserving the image aspect ratio.
if( !( isize.width() < maxSize.width() && isize.height() < maxSize.height() ) )
{
isize.scale( maxSize, Qt::KeepAspectRatio );
@@ -296,7 +290,7 @@ Void VideoSubWindow::refreshSubWindow()
close();
return;
}
- //seekAbsoluteEvent( currFrameNum );
+ // seekAbsoluteEvent( currFrameNum );
}
updateVideoWindowInfo();
refreshFrame();
@@ -319,8 +313,8 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
if( guessFormat( cFilename, Width, Height, InputFormat, BitsPel, Endianness ) || bForceDialog )
{
- if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel, Endianness, FrameRate )
- == QDialog::Rejected )
+ if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel,
+ Endianness, FrameRate ) == QDialog::Rejected )
{
return false;
}
@@ -332,8 +326,8 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
}
catch( ... )
{
- if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel, Endianness, FrameRate )
- == QDialog::Rejected )
+ if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel,
+ Endianness, FrameRate ) == QDialog::Rejected )
{
return false;
}
@@ -367,8 +361,9 @@ Bool VideoSubWindow::loadFile( PlaYUVerStreamInfo* streamInfo )
m_pCurrStream = new PlaYUVerStream;
}
- if( !m_pCurrStream->open( streamInfo->m_cFilename.toStdString(), streamInfo->m_uiWidth, streamInfo->m_uiHeight, streamInfo->m_iPelFormat,
- streamInfo->m_uiBitsPelPixel, streamInfo->m_iEndianness, streamInfo->m_uiFrameRate, true ) )
+ if( !m_pCurrStream->open( streamInfo->m_cFilename.toStdString(), streamInfo->m_uiWidth, streamInfo->m_uiHeight,
+ streamInfo->m_iPelFormat, streamInfo->m_uiBitsPelPixel, streamInfo->m_iEndianness,
+ streamInfo->m_uiFrameRate, true ) )
{
return false;
}
@@ -403,7 +398,7 @@ Void VideoSubWindow::updateVideoWindowInfo()
}
}
}
- //qDebug( ) << sourceWindowList;
+ // qDebug( ) << sourceWindowList;
if( sourceWindowList.size() > 0 )
{
m_pcVideoInfo->setInformationTopLeft( sourceWindowList );
@@ -415,20 +410,25 @@ Void VideoSubWindow::updateVideoWindowInfo()
QString m_cCodedName = QString::fromStdString( m_pCurrStream->getCodecName() );
m_cStreamInformation = m_cFormatName + " | " + m_cCodedName;
}
-//#if 0
+ //#if 0
if( m_pcCurrFrame )
{
QString m_cPelFmtName = QString::fromStdString( m_pcCurrFrame->getPelFmtName() );
m_cStreamInformation += " | " + m_cPelFmtName;
}
-//#endif
+ //#endif
if( m_cStreamInformation.isEmpty() )
{
m_cStreamInformation = " ";
}
}
-Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPixel, Int& rEndianness )
+Bool VideoSubWindow::guessFormat( QString filename,
+ UInt& rWidth,
+ UInt& rHeight,
+ Int& rInputFormat,
+ UInt& rBitsPerPixel,
+ Int& rEndianness )
{
std::vector stdResList = PlaYUVerStream::stdResolutionSizes();
Bool bGuessed = true;
@@ -504,7 +504,8 @@ Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight,
Int count = 0, module, frame_bytes, match;
for( UInt i = 0; i < stdResList.size(); i++ )
{
- frame_bytes = PlaYUVerFrame::getBytesPerFrame( stdResList[i].uiWidth, stdResList[i].uiHeight, rInputFormat, 8 );
+ frame_bytes =
+ PlaYUVerFrame::getBytesPerFrame( stdResList[i].uiWidth, stdResList[i].uiHeight, rInputFormat, 8 );
module = uiFileSize % frame_bytes;
if( module == 0 )
{
@@ -521,7 +522,7 @@ Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight,
}
}
- // Guess bits per pixel - match %dbpp
+// Guess bits per pixel - match %dbpp
#if( QT_VERSION_PLAYUVER == 5 )
QRegularExpressionMatch BppMatch = QRegularExpression( "_\\d*bpp" ).match( FilenameShort );
if( BppMatch.hasMatch() )
@@ -668,7 +669,7 @@ Void VideoSubWindow::refreshFrame( Bool bThreaded )
m_cRefreshResult = QtConcurrent::run( this, &VideoSubWindow::refreshFrameOperation );
}
else
- #endif
+#endif
{
refreshFrameOperation();
}
@@ -682,7 +683,8 @@ Bool VideoSubWindow::save( QString filename )
PlaYUVerFrame* saveFrame = m_pcCurrFrame;
if( m_cSelectedArea.isValid() )
{
- saveFrame = new PlaYUVerFrame( m_pcCurrFrame, m_cSelectedArea.x(), m_cSelectedArea.y(), m_cSelectedArea.width(), m_cSelectedArea.height() );
+ saveFrame = new PlaYUVerFrame( m_pcCurrFrame, m_cSelectedArea.x(), m_cSelectedArea.y(), m_cSelectedArea.width(),
+ m_cSelectedArea.height() );
}
if( !saveFrame )
{
@@ -792,7 +794,7 @@ Void VideoSubWindow::adjustScrollBarByOffset( QPoint Offset )
valueY = scrollBarV->minimum();
m_cCurrScroll.setY( valueY );
-// Update window scroll
+ // Update window scroll
scrollBarH->setValue( m_cCurrScroll.x() );
scrollBarV->setValue( m_cCurrScroll.y() );
}
@@ -836,15 +838,14 @@ Void VideoSubWindow::adjustScrollBarByScale( Double scale, QPoint center )
m_cCurrScroll.setY( value );
}
-// Update window scroll
+ // Update window scroll
scrollBarH->setValue( m_cCurrScroll.x() );
scrollBarV->setValue( m_cCurrScroll.y() );
-
}
Void VideoSubWindow::updateCurScrollValues()
{
- QScrollBar *scrollBar = m_pcScrollArea->horizontalScrollBar();
+ QScrollBar* scrollBar = m_pcScrollArea->horizontalScrollBar();
m_cCurrScroll.setX( scrollBar->value() );
scrollBar = m_pcScrollArea->verticalScrollBar();
m_cCurrScroll.setY( scrollBar->value() );
@@ -852,7 +853,7 @@ Void VideoSubWindow::updateCurScrollValues()
Void VideoSubWindow::setCurScrollValues()
{
- QScrollBar *scrollBar = m_pcScrollArea->horizontalScrollBar();
+ QScrollBar* scrollBar = m_pcScrollArea->horizontalScrollBar();
scrollBar->setValue( m_cCurrScroll.x() );
scrollBar = m_pcScrollArea->verticalScrollBar();
scrollBar->setValue( m_cCurrScroll.y() );
@@ -872,7 +873,7 @@ Void VideoSubWindow::normalSize()
Void VideoSubWindow::zoomToFit()
{
-// Scale to a smaller size that the real to a nicer look
+ // Scale to a smaller size that the real to a nicer look
scaleView( getScrollSize() );
}
@@ -899,7 +900,7 @@ Void VideoSubWindow::scaleView( Double scale, QPoint center )
}
}
-Void VideoSubWindow::scaleView( const QSize & size, QPoint center )
+Void VideoSubWindow::scaleView( const QSize& size, QPoint center )
{
QSize imgViewSize;
if( m_pcCurrFrame )
@@ -909,13 +910,13 @@ Void VideoSubWindow::scaleView( const QSize & size, QPoint center )
QSize newSize = imgViewSize;
newSize.scale( size, Qt::KeepAspectRatio );
-// Calc the zoom factor
+ // Calc the zoom factor
Double wfactor = 1;
Double hfactor = 1;
Double factor;
- wfactor = ( Double )newSize.width() / imgViewSize.width();
- hfactor = ( Double )newSize.height() / imgViewSize.height();
+ wfactor = (Double)newSize.width() / imgViewSize.width();
+ hfactor = (Double)newSize.height() / imgViewSize.height();
if( wfactor < hfactor )
factor = wfactor;
@@ -957,13 +958,15 @@ Void VideoSubWindow::updatePixelValueStatusBar( const QPoint& pos )
if( ColorSpace == PlaYUVerPixel::COLOR_YUV )
{
sPixelValue = m_pcCurrFrame->getPixelValue( pos.x(), pos.y() );
- strStatus.append( QString( "Y: %1 U: %2 V: %3" ).arg( sPixelValue.Y() ).arg( sPixelValue.Cb() ).arg( sPixelValue.Cr() ) );
+ strStatus.append(
+ QString( "Y: %1 U: %2 V: %3" ).arg( sPixelValue.Y() ).arg( sPixelValue.Cb() ).arg( sPixelValue.Cr() ) );
}
if( ( ColorSpace == PlaYUVerPixel::COLOR_RGB ) )
{
sPixelValue = m_pcCurrFrame->getPixelValue( pos.x(), pos.y() );
- strStatus.append( QString( "R: %1 G: %2 B: %3" ).arg( sPixelValue.R() ).arg( sPixelValue.G() ).arg( sPixelValue.B() ) );
+ strStatus.append(
+ QString( "R: %1 G: %2 B: %3" ).arg( sPixelValue.R() ).arg( sPixelValue.G() ).arg( sPixelValue.B() ) );
}
emit updateStatusBar( strStatus );
}
diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h
index badbb44..78d1f39 100644
--- a/app/VideoSubWindow.h
+++ b/app/VideoSubWindow.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -59,12 +59,11 @@ QDataStream& operator<<( QDataStream& out, const PlaYUVerStreamInfoVector& d );
QDataStream& operator>>( QDataStream& in, PlaYUVerStreamInfoVector& d );
Int findPlaYUVerStreamInfo( PlaYUVerStreamInfoVector array, QString filename );
-class VideoSubWindow: public SubWindowAbstract
+class VideoSubWindow : public SubWindowAbstract
{
-Q_OBJECT
-
-private:
+ Q_OBJECT
+ private:
Bool m_bWindowBusy;
QScrollArea* m_pcScrollArea;
@@ -88,7 +87,7 @@ private:
VideoSubWindow* m_pcReferenceSubWindow;
- //QString m_cWindowShortName;
+ // QString m_cWindowShortName;
QString m_cCurrFileName;
Bool m_bIsPlaying;
@@ -103,24 +102,29 @@ private:
Void refreshFrameOperation();
- static Bool guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPixel, Int& rEndianness );
+ static Bool guessFormat( QString filename,
+ UInt& rWidth,
+ UInt& rHeight,
+ Int& rInputFormat,
+ UInt& rBitsPerPixel,
+ Int& rEndianness );
/**
* Private zoom function to handle
* zoom to fit
*/
- Void scaleView( const QSize & size, QPoint center = QPoint() );
+ Void scaleView( const QSize& size, QPoint center = QPoint() );
Void updateVideoWindowInfo();
QSize getScrollSize();
-public:
+ public:
enum VideoSubWindowCategories
{
VIDEO_STREAM_SUBWINDOW = SubWindowAbstract::VIDEO_STREAM_SUBWINDOW,
MODULE_SUBWINDOW = SubWindowAbstract::MODULE_SUBWINDOW,
};
- VideoSubWindow( enum VideoSubWindowCategories category, QWidget * parent = 0 );
+ VideoSubWindow( enum VideoSubWindowCategories category, QWidget* parent = 0 );
~VideoSubWindow();
Bool loadFile( QString cFilename, Bool bForceDialog = false );
@@ -136,49 +140,19 @@ public:
Bool playEvent();
Void stop();
- Bool isPlaying()
- {
- return m_bIsPlaying;
- }
-
+ Bool isPlaying() { return m_bIsPlaying; }
Void seekAbsoluteEvent( UInt new_frame_num );
Void seekRelativeEvent( Bool bIsFoward );
Void setCurrFrame( PlaYUVerFrame* pcCurrFrame );
- QScrollArea* getScroll()
- {
- return m_pcScrollArea;
- }
- PlaYUVerStreamInfo getStreamInfo()
- {
- return m_sStreamInfo;
- }
- QString getStreamInformation()
- {
- return m_cStreamInformation;
- }
-
- PlaYUVerStream* getInputStream()
- {
- return m_pCurrStream;
- }
-
- PlaYUVerStream* getCurrStream()
- {
- return m_pCurrStream;
- }
-
- PlaYUVerFrame* getCurrFrame()
- {
- return m_pcCurrFrame;
- }
-
- ViewArea* getViewArea()
- {
- return m_cViewArea;
- }
-
+ QScrollArea* getScroll() { return m_pcScrollArea; }
+ PlaYUVerStreamInfo getStreamInfo() { return m_sStreamInfo; }
+ QString getStreamInformation() { return m_cStreamInformation; }
+ PlaYUVerStream* getInputStream() { return m_pCurrStream; }
+ PlaYUVerStream* getCurrStream() { return m_pCurrStream; }
+ PlaYUVerFrame* getCurrFrame() { return m_pcCurrFrame; }
+ ViewArea* getViewArea() { return m_cViewArea; }
Void setRefSubWindow( VideoSubWindow* subWindow )
{
m_pcReferenceSubWindow = NULL;
@@ -187,11 +161,7 @@ public:
m_pcReferenceSubWindow = subWindow;
}
- VideoSubWindow* getRefSubWindow()
- {
- return m_pcReferenceSubWindow;
- }
-
+ VideoSubWindow* getRefSubWindow() { return m_pcReferenceSubWindow; }
/**
* Functions to enable a module in the
* current SubWindow
@@ -200,11 +170,7 @@ public:
Void disableModule( PlaYUVerAppModuleIf* pcModule = NULL );
Void associateModule( PlaYUVerAppModuleIf* pcModule );
- PlaYUVerAppModuleIf* getDisplayModule()
- {
- return m_pcCurrentDisplayModule;
- }
-
+ PlaYUVerAppModuleIf* getDisplayModule() { return m_pcCurrentDisplayModule; }
QList getModuleArray()
{
QList apcModulesArray;
@@ -222,40 +188,24 @@ public:
Void scaleView( Double scale, QPoint center = QPoint() );
Void zoomToFactor( Double factor, QPoint center = QPoint() );
- Double getScaleFactor()
- {
- return m_cViewArea->getZoomFactor();
- }
-
+ Double getScaleFactor() { return m_cViewArea->getZoomFactor(); }
/**
* Size related functions
*/
QSize sizeHint() const;
- QSize sizeHint( const QSize & ) const;
-
- QString getCurrentFileName()
- {
- return m_cFilename;
- }
-
- Bool getIsModule()
- {
- return getCategory() | SubWindowAbstract::MODULE_SUBWINDOW;
- }
-
- Void clearWindowBusy()
- {
- m_bWindowBusy = false;
- }
+ QSize sizeHint( const QSize& ) const;
+ QString getCurrentFileName() { return m_cFilename; }
+ Bool getIsModule() { return getCategory() | SubWindowAbstract::MODULE_SUBWINDOW; }
+ Void clearWindowBusy() { m_bWindowBusy = false; }
Void setFillWindow( Bool bFlag );
-protected:
+ protected:
Void keyPressEvent( QKeyEvent* event );
Void resizeEvent( QResizeEvent* event );
- //void closeEvent( QCloseEvent *event );
+ // void closeEvent( QCloseEvent *event );
-public Q_SLOTS:
+ public Q_SLOTS:
void updateWindowOnTimeout();
void adjustScrollBarByScale( double scale, QPoint center );
void adjustScrollBarByOffset( QPoint Offset );
@@ -268,5 +218,4 @@ public Q_SLOTS:
Q_DECLARE_METATYPE( PlaYUVerStreamInfo );
Q_DECLARE_METATYPE( PlaYUVerStreamInfoVector );
-#endif // __VIDEOSUBWINDOW_H__
-
+#endif // __VIDEOSUBWINDOW_H__
diff --git a/app/ViewArea.cpp b/app/ViewArea.cpp
index de6428d..397802b 100644
--- a/app/ViewArea.cpp
+++ b/app/ViewArea.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -43,8 +43,7 @@ static const QColor selectionColor = Qt::cyan;
static const QColor imageMaskColor = Qt::green;
static const QColor eraserColor = Qt::red;
-ViewArea::ViewArea( QWidget *parent ) :
- QWidget( parent )
+ViewArea::ViewArea( QWidget* parent ) : QWidget( parent )
{
setMouseTracking( true );
@@ -73,11 +72,12 @@ Void ViewArea::setImage( PlaYUVerFrame* pcFrame )
m_pcCurrFrame = pcFrame;
m_uiPixelHalfScale = 1 << ( m_pcCurrFrame->getBitsPel() - 1 );
m_pcCurrFrame->fillRGBBuffer();
- QImage qimg = QImage( m_pcCurrFrame->getRGBBuffer(), m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight(), QImage::Format_RGB32 );
+ QImage qimg = QImage( m_pcCurrFrame->getRGBBuffer(), m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight(),
+ QImage::Format_RGB32 );
setImage( QPixmap::fromImage( qimg ) );
}
-Void ViewArea::setImage( const QPixmap &pixmap )
+Void ViewArea::setImage( const QPixmap& pixmap )
{
m_pixmap = pixmap;
m_mask = QBitmap( pixmap.width(), pixmap.height() );
@@ -103,21 +103,21 @@ Void ViewArea::setTool( UInt view )
{
switch( view )
{
- case NavigationView:
- m_eTool = NavigationTool;
- m_snapToGrid = false;
- m_blockTrackEnable = false;
- break;
- case NormalSelectionView:
- m_eTool = SelectionTool;
- m_snapToGrid = false;
- m_blockTrackEnable = false;
- break;
- case BlockSelectionView:
- m_eTool = SelectionTool;
- m_snapToGrid = true;
- m_blockTrackEnable = false;
- break;
+ case NavigationView:
+ m_eTool = NavigationTool;
+ m_snapToGrid = false;
+ m_blockTrackEnable = false;
+ break;
+ case NormalSelectionView:
+ m_eTool = SelectionTool;
+ m_snapToGrid = false;
+ m_blockTrackEnable = false;
+ break;
+ case BlockSelectionView:
+ m_eTool = SelectionTool;
+ m_snapToGrid = true;
+ m_blockTrackEnable = false;
+ break;
}
if( m_eTool != SelectionTool )
@@ -225,7 +225,7 @@ Double ViewArea::scaleZoomFactor( Double scale, QPoint center, QSize minimumSize
return new_scale;
}
-//Void ViewArea::setMode( Int mode )
+// Void ViewArea::setMode( Int mode )
//{
// if( m_mode == mode )
// return;
@@ -234,44 +234,44 @@ Double ViewArea::scaleZoomFactor( Double scale, QPoint center, QSize minimumSize
// update();
//}
//
-//Void ViewArea::setNormalMode()
+// Void ViewArea::setNormalMode()
//{
// setMode( NormalMode );
//}
//
-//Void ViewArea::setMaskMode()
+// Void ViewArea::setMaskMode()
//{
// setMode( MaskMode );
//}
//
-//Void ViewArea::setMaskColor( const QColor &color )
+// Void ViewArea::setMaskColor( const QColor &color )
//{
// m_maskColor = color;
// update();
//}
//
-//Void ViewArea::setMaskTool()
+// Void ViewArea::setMaskTool()
//{
// setMode( MaskMode );
// setTool( MaskTool );
// m_blockTrackEnable = true;
//}
//
-//Void ViewArea::setEraserTool()
+// Void ViewArea::setEraserTool()
//{
// setMode( MaskMode );
// setTool( EraserTool );
// m_blockTrackEnable = true;
//}
//
-//Void ViewArea::setSelectionTool()
+// Void ViewArea::setSelectionTool()
//{
// setMode( NormalMode );
// setTool( SelectionTool );
// m_blockTrackEnable = false;
//}
//
-//Void ViewArea::setBlockSelectionTool()
+// Void ViewArea::setBlockSelectionTool()
//{
// setMode( NormalMode );
// setTool( BlockSelectionTool );
@@ -283,7 +283,7 @@ Void ViewArea::setSnapToGrid( Bool enable )
m_snapToGrid = enable;
}
-//Void ViewArea::setSelectedArea( QRect &rect )
+// Void ViewArea::setSelectedArea( QRect &rect )
//{
// if( rect.isNull() )
// {
@@ -323,33 +323,33 @@ Void ViewArea::initZoomWinRect()
if( iHorizontalImg )
{
- dSizeRatio = ( double )m_pixmap.width() / ( double )m_pixmap.height();
+ dSizeRatio = (double)m_pixmap.width() / (double)m_pixmap.height();
}
else
{
- dSizeRatio = ( double )m_pixmap.height() / ( double )m_pixmap.width();
+ dSizeRatio = (double)m_pixmap.height() / (double)m_pixmap.width();
}
if( dSizeRatio > 5.0 )
{
if( iHorizontalImg )
{
- dWinZoomRatio = ( double )( m_pixmap.width() * 1024 / iMaxX ) / 1000.0;
+ dWinZoomRatio = (double)( m_pixmap.width() * 1024 / iMaxX ) / 1000.0;
}
else
{
- dWinZoomRatio = ( double )( m_pixmap.height() * 1024 / iMaxY ) / 1000.0;
+ dWinZoomRatio = (double)( m_pixmap.height() * 1024 / iMaxY ) / 1000.0;
}
}
else
{
if( iHorizontalImg )
{
- dWinZoomRatio = ( double )( m_pixmap.height() * 1024 / iMinY ) / 1000.0;
+ dWinZoomRatio = (double)( m_pixmap.height() * 1024 / iMinY ) / 1000.0;
}
else
{
- dWinZoomRatio = ( double )( m_pixmap.width() * 1024 / iMinX ) / 1000.0;
+ dWinZoomRatio = (double)( m_pixmap.width() * 1024 / iMinX ) / 1000.0;
}
}
@@ -365,7 +365,7 @@ Void ViewArea::updateSize()
Int h = m_pixmap.height() * m_dZoomFactor;
setMinimumSize( w, h );
- QWidget *p = parentWidget();
+ QWidget* p = parentWidget();
if( p )
{
// If the parent size is bigger than the minimum area to view the
@@ -401,7 +401,7 @@ Void ViewArea::updateOffset()
////////////////////////////////////////////////////////////////////////////////
// Resize Event
////////////////////////////////////////////////////////////////////////////////
-Void ViewArea::resizeEvent( QResizeEvent *event )
+Void ViewArea::resizeEvent( QResizeEvent* event )
{
if( size().isEmpty() || m_pixmap.isNull() )
return;
@@ -414,7 +414,7 @@ Void ViewArea::resizeEvent( QResizeEvent *event )
// PaInt Event
////////////////////////////////////////////////////////////////////////////////
-Void ViewArea::paintEvent( QPaintEvent *event )
+Void ViewArea::paintEvent( QPaintEvent* event )
{
QRect winRect = event->rect();
@@ -471,7 +471,8 @@ Void ViewArea::paintEvent( QPaintEvent *event )
/* if( m_xOffset || m_yOffset )
{
paInter.setPen( Qt::black );
- paInter.drawRect( m_xOffset - 1, m_yOffset - 1, m_pixmap.width() * m_dZoomFactor + 1, m_pixmap.height() * m_dZoomFactor + 1 );
+ paInter.drawRect( m_xOffset - 1, m_yOffset - 1, m_pixmap.width() * m_dZoomFactor + 1, m_pixmap.height() *
+ m_dZoomFactor + 1 );
}*/
// Draw pixel values in grid
@@ -507,9 +508,9 @@ Void ViewArea::paintEvent( QPaintEvent *event )
else
paInter.setPen( QColor( Qt::black ) );
- paInter.drawText( pixelRect, Qt::AlignCenter,
- "Y: " + QString::number( sPixelValue.Y() ) + "\n" + "U: " + QString::number( sPixelValue.Cb() ) + "\n" + "V: "
- + QString::number( sPixelValue.Cr() ) );
+ paInter.drawText( pixelRect, Qt::AlignCenter, "Y: " + QString::number( sPixelValue.Y() ) + "\n" + "U: " +
+ QString::number( sPixelValue.Cb() ) + "\n" + "V: " +
+ QString::number( sPixelValue.Cr() ) );
}
if( frFormat == PlaYUVerPixel::COLOR_GRAY )
{
@@ -532,9 +533,9 @@ Void ViewArea::paintEvent( QPaintEvent *event )
else
paInter.setPen( QColor( Qt::black ) );
- paInter.drawText( pixelRect, Qt::AlignCenter,
- "R: " + QString::number( sPixelValue.R() ) + "\n" + "G: " + QString::number( sPixelValue.G() ) + "\n" + "B: "
- + QString::number( sPixelValue.B() ) );
+ paInter.drawText( pixelRect, Qt::AlignCenter, "R: " + QString::number( sPixelValue.R() ) + "\n" + "G: " +
+ QString::number( sPixelValue.G() ) + "\n" + "B: " +
+ QString::number( sPixelValue.B() ) );
}
}
}
@@ -558,7 +559,7 @@ Void ViewArea::paintEvent( QPaintEvent *event )
}
}
- // VISIBLE ZOOM RECT
+// VISIBLE ZOOM RECT
#if 0
if( m_visibleZoomRect && m_zoomWinTimer.isActive() )
{
@@ -626,7 +627,7 @@ Void ViewArea::paintEvent( QPaintEvent *event )
paInter.setPen( Qt::darkCyan );
-// paInter.drawRect( sr/*m_selectedArea*/ );
+ // paInter.drawRect( sr/*m_selectedArea*/ );
}
else
{
@@ -641,18 +642,17 @@ Void ViewArea::paintEvent( QPaintEvent *event )
QRect imgr = viewToWindow( QRect( 0, 0, m_pixmap.width(), m_pixmap.height() ) );
myPath.addRect( imgr );
- myPath.addRect( sr ); //m_selectedArea
+ myPath.addRect( sr ); // m_selectedArea
paInter.drawPath( myPath );
// 2) Draw the selection rectangle
paInter.setBrush( Qt::NoBrush );
paInter.setPen( Qt::darkCyan );
-// paInter.drawRect( sr/*m_selectedArea*/ );
+ // paInter.drawRect( sr/*m_selectedArea*/ );
}
if( !ir.isNull() )
- paInter.drawRect( sr/*m_selectedArea*/);
-
+ paInter.drawRect( sr /*m_selectedArea*/ );
}
// Mask Mode ----------------------------------------------------------
@@ -684,22 +684,22 @@ Void ViewArea::paintEvent( QPaintEvent *event )
{
switch( tool() )
{
- case MaskTool:
+ case MaskTool:
{
- if( m_maskColor.isValid() )
- color = m_maskColor;
- else
- color = imageMaskColor;
+ if( m_maskColor.isValid() )
+ color = m_maskColor;
+ else
+ color = imageMaskColor;
- break;
- }
- case EraserTool:
+ break;
+ }
+ case EraserTool:
{
- color = eraserColor;
- break;
- }
- default:
- color = selectionColor; // ?Problems!
+ color = eraserColor;
+ break;
+ }
+ default:
+ color = selectionColor; // ?Problems!
}
color.setAlpha( 120 );
@@ -720,7 +720,7 @@ Void ViewArea::paintEvent( QPaintEvent *event )
////////////////////////////////////////////////////////////////////////////////
// Mouse Events
////////////////////////////////////////////////////////////////////////////////
-Void ViewArea::wheelEvent( QWheelEvent *event )
+Void ViewArea::wheelEvent( QWheelEvent* event )
{
Double scale;
Double usedScale;
@@ -733,7 +733,7 @@ Void ViewArea::wheelEvent( QWheelEvent *event )
else
scale = 0.8;
- QWidget *p = parentWidget();
+ QWidget* p = parentWidget();
QSize minimumSize = QSize( p->size().width() - 5, p->size().height() - 5 );
usedScale = scaleZoomFactor( scale, event->pos(), minimumSize );
if( usedScale != 1.0 )
@@ -743,7 +743,7 @@ Void ViewArea::wheelEvent( QWheelEvent *event )
}
}
-Void ViewArea::mousePressEvent( QMouseEvent *event )
+Void ViewArea::mousePressEvent( QMouseEvent* event )
{
event->accept();
@@ -751,7 +751,6 @@ Void ViewArea::mousePressEvent( QMouseEvent *event )
if( event->button() == Qt::MidButton )
{
-
}
if( event->button() == Qt::LeftButton )
{
@@ -802,7 +801,7 @@ Void ViewArea::mousePressEvent( QMouseEvent *event )
}
// Block selection
-// m_selectedArea = m_grid.rectContains( m_lastPos );
+ // m_selectedArea = m_grid.rectContains( m_lastPos );
QRect updateRect = viewToWindow( m_selectedArea );
updateRect.adjust( 0, 0, 1, 1 );
@@ -810,15 +809,15 @@ Void ViewArea::mousePressEvent( QMouseEvent *event )
}
}
-Void ViewArea::mouseMoveEvent( QMouseEvent *event )
+Void ViewArea::mouseMoveEvent( QMouseEvent* event )
{
event->accept();
#ifndef _MSC_VER
// Add this code line to aVoid slow navigation with some specific mouses
// This seems to always appear on windows
- if( qApp->hasPendingEvents())
- return;
+ if( qApp->hasPendingEvents() )
+ return;
#endif
QPoint actualPos = windowToView( event->pos() );
@@ -866,7 +865,7 @@ Void ViewArea::mouseMoveEvent( QMouseEvent *event )
// From left to right
if( m_lastPos.x() < actualPos.x() )
{
- QPoint bottomR = actualPos; // - QPoint( 1, 1 );
+ QPoint bottomR = actualPos; // - QPoint( 1, 1 );
m_selectedArea = QRect( m_lastPos, bottomR );
}
// From right to left
@@ -891,7 +890,7 @@ Void ViewArea::mouseMoveEvent( QMouseEvent *event )
// From right to left
else
{
- QPoint bottomR = m_lastPos; // - QPoint( 1, 1 );
+ QPoint bottomR = m_lastPos; // - QPoint( 1, 1 );
m_selectedArea = QRect( actualPos, bottomR );
}
}
@@ -917,15 +916,15 @@ Void ViewArea::mouseMoveEvent( QMouseEvent *event )
m_selectedArea &= QRect( 0, 0, m_pixmap.width(), m_pixmap.height() );
// Update only the united area
-// updateRect = updateRect.united( viewToWindow( m_selectedArea ) );
+ // updateRect = updateRect.united( viewToWindow( m_selectedArea ) );
// "When rendering with a one pixel wide pen the QRect's
// boundary line will be rendered to the right and below the
// mathematical rectangle's boundary line.", in QT4 doc.
// Our selection pen width is 1, let's adjust the rendering area.
-// updateRect.adjust( 0, 0, 1, 1 );
+ // updateRect.adjust( 0, 0, 1, 1 );
-// update( updateRect.normalized() );
+ // update( updateRect.normalized() );
update();
}
return;
@@ -952,7 +951,7 @@ Void ViewArea::mouseMoveEvent( QMouseEvent *event )
}
}
-Void ViewArea::mouseReleaseEvent( QMouseEvent *event )
+Void ViewArea::mouseReleaseEvent( QMouseEvent* event )
{
event->accept();
@@ -974,7 +973,6 @@ Void ViewArea::mouseReleaseEvent( QMouseEvent *event )
m_selectedArea = QRect();
}
emit selectionChanged( m_selectedArea );
-
}
// Mask Mode -----------------------------------------------------------
@@ -997,9 +995,8 @@ Void ViewArea::mouseReleaseEvent( QMouseEvent *event )
////////////////////////////////////////////////////////////////////////////////
-Bool ViewArea::isPosValid( const QPoint &pos ) const
- {
-
+Bool ViewArea::isPosValid( const QPoint& pos ) const
+{
if( pos.x() < 0 || pos.y() < 0 || pos.x() >= m_pixmap.width() || pos.y() >= m_pixmap.height() )
return false;
else
@@ -1009,7 +1006,7 @@ Bool ViewArea::isPosValid( const QPoint &pos ) const
////////////////////////////////////////////////////////////////////////////////
QPoint ViewArea::windowToView( const QPoint& pt ) const
- {
+{
QPoint p;
p.setX( static_cast( ( pt.x() - m_xOffset ) / m_dZoomFactor ) );
p.setY( static_cast( ( pt.y() - m_yOffset ) / m_dZoomFactor ) );
@@ -1018,20 +1015,20 @@ QPoint ViewArea::windowToView( const QPoint& pt ) const
}
QRect ViewArea::windowToView( const QRect& rc ) const
- {
+{
QRect r;
r.setTopLeft( windowToView( rc.topLeft() ) );
-// r.setRight ( (Int)( ceil(( rc.right() - m_xOffset)/m_dZoomFactor )));
-// r.setBottom( (Int)( ceil(( rc.bottom()- m_yOffset)/m_dZoomFactor )));
-// r.setRight ( static_cast(( rc.right() - m_xOffset ) / m_dZoomFactor +1));
-// r.setBottom( static_cast(( rc.bottom() - m_xOffset ) / m_dZoomFactor+1));
+ // r.setRight ( (Int)( ceil(( rc.right() - m_xOffset)/m_dZoomFactor )));
+ // r.setBottom( (Int)( ceil(( rc.bottom()- m_yOffset)/m_dZoomFactor )));
+ // r.setRight ( static_cast(( rc.right() - m_xOffset ) / m_dZoomFactor +1));
+ // r.setBottom( static_cast(( rc.bottom() - m_xOffset ) / m_dZoomFactor+1));
r.setBottomRight( windowToView( rc.bottomRight() ) );
return r;
}
QPoint ViewArea::viewToWindow( const QPoint& pt ) const
- {
+{
QPoint p;
p.setX( static_cast( pt.x() * m_dZoomFactor + m_xOffset ) );
@@ -1041,17 +1038,17 @@ QPoint ViewArea::viewToWindow( const QPoint& pt ) const
}
QRect ViewArea::viewToWindow( const QRect& rc ) const
- {
+{
QRect r;
r.setTopLeft( viewToWindow( rc.topLeft() ) );
-// r.setRight ( (Int)( ceil(( rc.right() +1+m_xOffset )*m_dZoomFactor ) - 1 ));
-// r.setBottom( (Int)( ceil(( rc.bottom()+1+m_yOffset )*m_dZoomFactor ) - 1 ));
-// r.setRight ( (Int)( ceil(( rc.right()+0.5)*m_dZoomFactor )+ m_xOffset )-1);
-// r.setBottom( (Int)( ceil(( rc.bottom()+0.5)*m_dZoomFactor ) +m_yOffset )-1);
-// qDebug()<<"Right = "<< r.right();
-// r.setRight ( static_cast(( rc.right()+1) * m_dZoomFactor + m_xOffset -1) );
-// r.setBottom( static_cast(( rc.bottom()+1) * m_dZoomFactor + m_yOffset -1));
+ // r.setRight ( (Int)( ceil(( rc.right() +1+m_xOffset )*m_dZoomFactor ) - 1 ));
+ // r.setBottom( (Int)( ceil(( rc.bottom()+1+m_yOffset )*m_dZoomFactor ) - 1 ));
+ // r.setRight ( (Int)( ceil(( rc.right()+0.5)*m_dZoomFactor )+ m_xOffset )-1);
+ // r.setBottom( (Int)( ceil(( rc.bottom()+0.5)*m_dZoomFactor ) +m_yOffset )-1);
+ // qDebug()<<"Right = "<< r.right();
+ // r.setRight ( static_cast(( rc.right()+1) * m_dZoomFactor + m_xOffset -1) );
+ // r.setBottom( static_cast(( rc.bottom()+1) * m_dZoomFactor + m_yOffset -1));
r.setBottomRight( viewToWindow( rc.bottomRight() ) );
return r;
@@ -1060,31 +1057,31 @@ QRect ViewArea::viewToWindow( const QRect& rc ) const
////////////////////////////////////////////////////////////////////////////////
// Masks Management
////////////////////////////////////////////////////////////////////////////////
-Void ViewArea::updateMask( const QRect &rect )
+Void ViewArea::updateMask( const QRect& rect )
{
switch( tool() )
{
- case MaskTool:
+ case MaskTool:
{
- // Add rect to the mask
- QPainter paInter( &m_mask );
- paInter.setBrush( Qt::color1 );
- paInter.setPen( Qt::NoPen );
- paInter.drawRect( rect );
- paInter.end();
- break;
- }
- case EraserTool:
+ // Add rect to the mask
+ QPainter paInter( &m_mask );
+ paInter.setBrush( Qt::color1 );
+ paInter.setPen( Qt::NoPen );
+ paInter.drawRect( rect );
+ paInter.end();
+ break;
+ }
+ case EraserTool:
{
- // Clears rect area in the mask
- QPainter paInter( &m_mask );
- paInter.setBrush( Qt::color0 );
- paInter.setPen( Qt::NoPen );
- paInter.drawRect( rect );
- paInter.end();
- break;
- }
- default: /* Do Nothing */
- ;
+ // Clears rect area in the mask
+ QPainter paInter( &m_mask );
+ paInter.setBrush( Qt::color0 );
+ paInter.setPen( Qt::NoPen );
+ paInter.drawRect( rect );
+ paInter.end();
+ break;
+ }
+ default: /* Do Nothing */
+ ;
}
}
diff --git a/app/ViewArea.h b/app/ViewArea.h
index 31a5e17..1edd931 100644
--- a/app/ViewArea.h
+++ b/app/ViewArea.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -41,12 +41,11 @@ class PlaYUVerStream;
/**
*
*/
-class ViewArea: public QWidget
+class ViewArea : public QWidget
{
-Q_OBJECT
-
-public:
+ Q_OBJECT
+ public:
enum ViewModes
{
NavigationView,
@@ -54,13 +53,13 @@ public:
BlockSelectionView,
};
- ViewArea( QWidget *parent = 0 );
+ ViewArea( QWidget* parent = 0 );
Void setImage( PlaYUVerFrame* pcFrame );
- Void setImage( const QPixmap &pixmap );
+ Void setImage( const QPixmap& pixmap );
Void setMode( Int mode );
- Void setMaskColor( const QColor &color = QColor() );
+ Void setMaskColor( const QColor& color = QColor() );
/**
* Clears any contents.
@@ -79,65 +78,43 @@ public:
*/
Void clearMask();
- QPixmap image() const
- {
- return m_pixmap;
- }
- QBitmap mask() const
- {
- return m_mask;
- }
- QRect selectedArea() const
- {
- return m_selectedArea;
- }
- GridManager gridManager() const
- {
- return m_grid;
- }
-
- QColor maskColor() const
- {
- return m_maskColor;
- }
-
- Double getZoomFactor()
- {
- return m_dZoomFactor;
- }
-
+ QPixmap image() const { return m_pixmap; }
+ QBitmap mask() const { return m_mask; }
+ QRect selectedArea() const { return m_selectedArea; }
+ GridManager gridManager() const { return m_grid; }
+ QColor maskColor() const { return m_maskColor; }
+ Double getZoomFactor() { return m_dZoomFactor; }
// Scale function. Return used scale value (it may change when it touches the min or max zoom value)
Double scaleZoomFactor( Double scale, QPoint center, QSize minimumSize );
-Q_SIGNALS:
- void selectionChanged( const QRect &rect );
- void positionChanged( const QPoint &pos );
+ Q_SIGNALS:
+ void selectionChanged( const QRect& rect );
+ void positionChanged( const QPoint& pos );
void scrollBarMoved( QPoint offset );
void zoomFactorChanged_byWheel( const double factor, const QPoint center );
-public Q_SLOTS:
-// Void setNormalMode();
-// Void setMaskMode();
-// Void setMaskTool();
-// Void setEraserTool();
-// Void setNormalSelectionTool();
-// Void setBlockSelectionTool();
+ public Q_SLOTS:
+ // Void setNormalMode();
+ // Void setMaskMode();
+ // Void setMaskTool();
+ // Void setEraserTool();
+ // Void setNormalSelectionTool();
+ // Void setBlockSelectionTool();
void setSnapToGrid( bool enable );
// void setSelectedArea( QRect &rect );
-protected:
- Void paintEvent( QPaintEvent *event );
- Void resizeEvent( QResizeEvent * event );
- Void mousePressEvent( QMouseEvent *event );
- Void mouseMoveEvent( QMouseEvent *event );
- Void mouseReleaseEvent( QMouseEvent *event );
- Void wheelEvent( QWheelEvent *event );
+ protected:
+ Void paintEvent( QPaintEvent* event );
+ Void resizeEvent( QResizeEvent* event );
+ Void mousePressEvent( QMouseEvent* event );
+ Void mouseMoveEvent( QMouseEvent* event );
+ Void mouseReleaseEvent( QMouseEvent* event );
+ Void wheelEvent( QWheelEvent* event );
Void updateSize();
Void updateOffset();
-private:
-
+ private:
enum ViewMode
{
NormalMode,
@@ -152,22 +129,14 @@ private:
EraserTool
};
- ViewMode mode() const
- {
- return m_mode;
- }
-
- Tool tool() const
- {
- return m_eTool;
- }
-
+ ViewMode mode() const { return m_mode; }
+ Tool tool() const { return m_eTool; }
Void initZoomWinRect();
Void startZoomWinTimer();
Void setZoomFactor( Double );
- Bool isPosValid( const QPoint &pos ) const;
- Void updateMask( const QRect &rect );
+ Bool isPosValid( const QPoint& pos ) const;
+ Void updateMask( const QRect& rect );
QPoint windowToView( const QPoint& pt ) const;
QRect windowToView( const QRect& rc ) const;
@@ -175,7 +144,7 @@ private:
QPoint viewToWindow( const QPoint& pt ) const;
QRect viewToWindow( const QRect& rc ) const;
- PlaYUVerFrame *m_pcCurrFrame;
+ PlaYUVerFrame* m_pcCurrFrame;
Pel m_uiPixelHalfScale;
@@ -202,7 +171,6 @@ private:
Bool m_snapToGrid;
Bool m_cursorInGrid;
Bool m_visibleZoomRect;
-
};
-#endif // __VIEWAREA_H__
+#endif // __VIEWAREA_H__
diff --git a/app/WidgetFrameNumber.cpp b/app/WidgetFrameNumber.cpp
index 81d94ca..4b99e86 100644
--- a/app/WidgetFrameNumber.cpp
+++ b/app/WidgetFrameNumber.cpp
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -31,8 +31,7 @@
#endif
#include "WidgetFrameNumber.h"
-WidgetFrameNumber::WidgetFrameNumber( QWidget *parent ) :
- QWidget( parent )
+WidgetFrameNumber::WidgetFrameNumber( QWidget* parent ) : QWidget( parent )
{
QHBoxLayout* mainlayout = new QHBoxLayout;
m_pcCurrFrameNumLabel = new QLabel;
@@ -40,7 +39,7 @@ WidgetFrameNumber::WidgetFrameNumber( QWidget *parent ) :
m_pcCurrFrameNumLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
m_pcCurrFrameNumLabel->setMinimumWidth( 25 );
m_pcCurrFrameNumLabel->setAlignment( Qt::AlignRight );
- QLabel *forwardslash = new QLabel;
+ QLabel* forwardslash = new QLabel;
forwardslash->setText( "/" );
m_pcTotalFrameNumLabel = new QLabel;
m_pcTotalFrameNumLabel->setText( "-" );
@@ -65,4 +64,3 @@ Void WidgetFrameNumber::clear()
m_pcCurrFrameNumLabel->setText( "-" );
m_pcTotalFrameNumLabel->setText( "-" );
}
-
diff --git a/app/WidgetFrameNumber.h b/app/WidgetFrameNumber.h
index d9af7f9..495f0ef 100644
--- a/app/WidgetFrameNumber.h
+++ b/app/WidgetFrameNumber.h
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
- * Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
+ * Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -34,17 +34,17 @@
#include
#endif
-class WidgetFrameNumber: public QWidget
+class WidgetFrameNumber : public QWidget
{
-public:
- WidgetFrameNumber( QWidget *parent = 0 );
+ public:
+ WidgetFrameNumber( QWidget* parent = 0 );
Void setCurrFrameNum( Int number );
Void setTotalFrameNum( Int number );
Void clear();
- private:
- QLabel *m_pcCurrFrameNumLabel;
- QLabel *m_pcTotalFrameNumLabel;
+ private:
+ QLabel* m_pcCurrFrameNumLabel;
+ QLabel* m_pcTotalFrameNumLabel;
};
-#endif // __WIDGETFRAMENUMBER_H__
+#endif // __WIDGETFRAMENUMBER_H__
diff --git a/app/external/qcustomplot.cpp b/app/external/qcustomplot.cpp
index ad267b6..41905a8 100644
--- a/app/external/qcustomplot.cpp
+++ b/app/external/qcustomplot.cpp
@@ -25,20 +25,17 @@
#include "qcustomplot.h"
-
-
-
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// QCPPainter
////////////////////////////////////////////////////////////////////////////////////////////////////
/*! \class QCPPainter
\brief QPainter subclass used internally
-
+
This QPainter subclass is used to provide some extended functionality e.g. for tweaking position
consistency between antialiased and non-antialiased painting. Further it provides workarounds
for QPainter quirks.
-
+
\warning This class intentionally hides non-virtual functions of QPainter, e.g. setPen, save and
restore. So while it is possible to pass a QCPPainter instance to a function that expects a
QPainter pointer, some of the workarounds and tweaks will be unavailable to the function (because
@@ -48,10 +45,7 @@
/*!
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
@@ -60,17 +54,15 @@ QCPPainter::QCPPainter() :
/*!
Creates a new QCPPainter instance on the specified paint \a device and sets default values. Just
like the analogous QPainter constructor, begins painting on \a device immediately.
-
+
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
}
@@ -81,58 +73,58 @@ QCPPainter::~QCPPainter()
/*!
Sets the pen of the painter and applies certain fixes to it, depending on the mode of this
QCPPainter.
-
+
\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();
}
/*! \overload
-
+
Sets the pen (by color) of the painter and applies certain fixes to it, depending on the mode of
this QCPPainter.
-
+
\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();
}
/*! \overload
-
+
Sets the pen (by style) of the painter and applies certain fixes to it, depending on the mode of
this QCPPainter.
-
+
\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();
}
/*! \overload
-
+
Works around a Qt bug introduced with Qt 4.8 which makes drawing QLineF unpredictable when
antialiasing is disabled. Thus when antialiasing is disabled, it rounds the \a line to
integer coordinates and then passes it to the original drawLine.
-
+
\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() );
}
/*!
@@ -141,18 +133,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 );
}
}
}
@@ -161,7 +153,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;
}
@@ -171,60 +163,61 @@ void QCPPainter::setModes(QCPPainter::PainterModes modes)
device. This is necessary to get cosmetic pen consistency across Qt versions, because since Qt5,
all pens are non-cosmetic by default, and in Qt4 this render hint must be set to get that
behaviour.
-
+
The Constructor \ref QCPPainter(QPaintDevice *device) which directly starts painting also sets
the render hint as appropriate.
-
+
\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;
}
/*! \overload
-
+
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;
}
/*!
Saves the painter (see QPainter::save). Since QCPPainter adds some new internal state to
QPainter, the save/restore functions are reimplemented to also save/restore those members.
-
+
\note this function hides the non-virtual base class implementation.
-
+
\see restore
*/
void QCPPainter::save()
{
- mAntialiasingStack.push(mIsAntialiasing);
+ mAntialiasingStack.push( mIsAntialiasing );
QPainter::save();
}
/*!
Restores the painter (see QPainter::restore). Since QCPPainter adds some new internal state to
QPainter, the save/restore functions are reimplemented to also save/restore those members.
-
+
\note this function hides the non-virtual base class implementation.
-
+
\see save
*/
void QCPPainter::restore()
{
- if (!mAntialiasingStack.isEmpty())
+ if( !mAntialiasingStack.isEmpty() )
mIsAntialiasing = mAntialiasingStack.pop();
else
qDebug() << Q_FUNC_INFO << "Unbalanced save/restore";
@@ -237,32 +230,31 @@ 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 );
}
}
-
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// QCPScatterStyle
////////////////////////////////////////////////////////////////////////////////////////////////////
/*! \class QCPScatterStyle
\brief Represents the visual appearance of scatter points
-
+
This class holds information about shape, color and size of scatter points. In plottables like
QCPGraph it is used to store how scatter points shall be drawn. For example, \ref
QCPGraph::setScatterStyle takes a QCPScatterStyle instance.
-
+
A scatter style consists of a shape (\ref setShape), a line color (\ref setPen) and possibly a
fill (\ref setBrush), if the shape provides a fillable area. Further, the size of the shape can
be controlled with \ref setSize.
\section QCPScatterStyle-defining Specifying a scatter style
-
+
You can set all these configurations either by calling the respective functions on an instance:
\code
QCPScatterStyle myScatter;
@@ -272,22 +264,22 @@ void QCPPainter::makeNonCosmetic()
myScatter.setSize(5);
customPlot->graph(0)->setScatterStyle(myScatter);
\endcode
-
+
Or you can use one of the various constructors that take different parameter combinations, making
it easy to specify a scatter style in a single call, like so:
\code
customPlot->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, Qt::blue, Qt::white, 5));
\endcode
-
+
\section QCPScatterStyle-undefinedpen Leaving the color/pen up to the plottable
-
+
There are two constructors which leave the pen undefined: \ref QCPScatterStyle() and \ref
QCPScatterStyle(ScatterShape shape, double size). If those constructors are used, a call to \ref
isPenDefined will return false. It leads to scatter points that inherit the pen from the
plottable that uses the scatter style. Thus, if such a scatter style is passed to QCPGraph, the line
color of the graph (\ref QCPGraph::setPen) will be used by the scatter points. This makes
it very convenient to set up typical scatter settings:
-
+
\code
customPlot->graph(0)->setScatterStyle(QCPScatterStyle::ssPlus);
\endcode
@@ -297,15 +289,15 @@ void QCPPainter::makeNonCosmetic()
into a QCPScatterStyle instance (that's the \ref QCPScatterStyle(ScatterShape shape, double size)
constructor with a default for \a size). In those cases, C++ allows directly supplying a \ref
ScatterShape, where actually a QCPScatterStyle is expected.
-
+
\section QCPScatterStyle-custompath-and-pixmap Custom shapes and pixmaps
-
+
QCPScatterStyle supports drawing custom shapes and arbitrary pixmaps as scatter points.
For custom shapes, you can provide a QPainterPath with the desired shape to the \ref
setCustomPath function or call the constructor that takes a painter path. The scatter shape will
automatically be set to \ref ssCustom.
-
+
For pixmaps, you call \ref setPixmap with the desired QPixmap. Alternatively you can use the
constructor that takes a QPixmap. The scatter shape will automatically be set to \ref ssPixmap.
Note that \ref setSize does not influence the appearance of the pixmap.
@@ -314,21 +306,21 @@ void QCPPainter::makeNonCosmetic()
/* start documentation of inline functions */
/*! \fn bool QCPScatterStyle::isNone() const
-
+
Returns whether the scatter shape is \ref ssNone.
-
+
\see setShape
*/
/*! \fn bool QCPScatterStyle::isPenDefined() const
-
+
Returns whether a pen has been defined for this scatter style.
-
+
The pen is undefined if a constructor is called that does not carry \a pen as parameter. Those are
\ref QCPScatterStyle() and \ref QCPScatterStyle(ScatterShape shape, double size). If the pen is
left undefined, the scatter color will be inherited from the plottable that uses this scatter
style.
-
+
\see setPen
*/
@@ -336,32 +328,24 @@ void QCPPainter::makeNonCosmetic()
/*!
Creates a new QCPScatterStyle instance with size set to 6. No shape, pen or brush is defined.
-
+
Since the pen is undefined (\ref isPenDefined returns false), the scatter color will be inherited
from the plottable that uses this scatter style.
*/
-QCPScatterStyle::QCPScatterStyle() :
- mSize(6),
- mShape(ssNone),
- mPen(Qt::NoPen),
- mBrush(Qt::NoBrush),
- mPenDefined(false)
+QCPScatterStyle::QCPScatterStyle()
+ : mSize( 6 ), mShape( ssNone ), mPen( Qt::NoPen ), mBrush( Qt::NoBrush ), mPenDefined( false )
{
}
/*!
Creates a new QCPScatterStyle instance with shape set to \a shape and size to \a size. No pen or
brush is defined.
-
+
Since the pen is undefined (\ref isPenDefined returns false), the scatter color will be inherited
from the plottable that uses this scatter style.
*/
-QCPScatterStyle::QCPScatterStyle(ScatterShape shape, double size) :
- mSize(size),
- mShape(shape),
- mPen(Qt::NoPen),
- mBrush(Qt::NoBrush),
- mPenDefined(false)
+QCPScatterStyle::QCPScatterStyle( ScatterShape shape, double size )
+ : mSize( size ), mShape( shape ), mPen( Qt::NoPen ), mBrush( Qt::NoBrush ), mPenDefined( false )
{
}
@@ -369,12 +353,8 @@ QCPScatterStyle::QCPScatterStyle(ScatterShape shape, double size) :
Creates a new QCPScatterStyle instance with shape set to \a shape, the pen color set to \a color,
and size to \a size. No brush is defined, i.e. the scatter point will not be filled.
*/
-QCPScatterStyle::QCPScatterStyle(ScatterShape shape, const QColor &color, double size) :
- mSize(size),
- mShape(shape),
- mPen(QPen(color)),
- mBrush(Qt::NoBrush),
- mPenDefined(true)
+QCPScatterStyle::QCPScatterStyle( ScatterShape shape, const QColor& color, double size )
+ : mSize( size ), mShape( shape ), mPen( QPen( color ) ), mBrush( Qt::NoBrush ), mPenDefined( true )
{
}
@@ -382,19 +362,15 @@ QCPScatterStyle::QCPScatterStyle(ScatterShape shape, const QColor &color, double
Creates a new QCPScatterStyle instance with shape set to \a shape, the pen color set to \a color,
the brush color to \a fill (with a solid pattern), and size to \a size.
*/
-QCPScatterStyle::QCPScatterStyle(ScatterShape shape, const QColor &color, const QColor &fill, double size) :
- mSize(size),
- mShape(shape),
- mPen(QPen(color)),
- mBrush(QBrush(fill)),
- mPenDefined(true)
+QCPScatterStyle::QCPScatterStyle( ScatterShape shape, const QColor& color, const QColor& fill, double size )
+ : mSize( size ), mShape( shape ), mPen( QPen( color ) ), mBrush( QBrush( fill ) ), mPenDefined( true )
{
}
/*!
Creates a new QCPScatterStyle instance with shape set to \a shape, the pen set to \a pen, the
brush to \a brush, and size to \a size.
-
+
\warning In some cases it might be tempting to directly use a pen style like Qt::NoPen as \a pen
and a color like Qt::blue as \a brush. Notice however, that the corresponding call\n
QCPScatterStyle(QCPScatterShape::ssCircle, Qt::NoPen, Qt::blue, 5)\n
@@ -406,12 +382,8 @@ QCPScatterStyle::QCPScatterStyle(ScatterShape shape, const QColor &color, const
instead of just Qt::blue, to clearly point out to the compiler that this constructor is
wanted.
*/
-QCPScatterStyle::QCPScatterStyle(ScatterShape shape, const QPen &pen, const QBrush &brush, double size) :
- mSize(size),
- mShape(shape),
- mPen(pen),
- mBrush(brush),
- mPenDefined(pen.style() != Qt::NoPen)
+QCPScatterStyle::QCPScatterStyle( ScatterShape shape, const QPen& pen, const QBrush& brush, double size )
+ : mSize( size ), mShape( shape ), mPen( pen ), mBrush( brush ), mPenDefined( pen.style() != Qt::NoPen )
{
}
@@ -419,67 +391,57 @@ QCPScatterStyle::QCPScatterStyle(ScatterShape shape, const QPen &pen, const QBru
Creates a new QCPScatterStyle instance which will show the specified \a pixmap. The scatter shape
is set to \ref ssPixmap.
*/
-QCPScatterStyle::QCPScatterStyle(const QPixmap &pixmap) :
- mSize(5),
- mShape(ssPixmap),
- mPen(Qt::NoPen),
- mBrush(Qt::NoBrush),
- mPixmap(pixmap),
- mPenDefined(false)
+QCPScatterStyle::QCPScatterStyle( const QPixmap& pixmap )
+ : mSize( 5 ), mShape( ssPixmap ), mPen( Qt::NoPen ), mBrush( Qt::NoBrush ), mPixmap( pixmap ), mPenDefined( false )
{
}
/*!
Creates a new QCPScatterStyle instance with a custom shape that is defined via \a customPath. The
scatter shape is set to \ref ssCustom.
-
+
The custom shape line will be drawn with \a pen and filled with \a brush. The size has a slightly
different meaning than for built-in scatter points: The custom path will be drawn scaled by a
factor of \a size/6.0. Since the default \a size is 6, the custom path will appear at a its
natural size by default. To double the size of the path for example, set \a size to 12.
*/
-QCPScatterStyle::QCPScatterStyle(const QPainterPath &customPath, const QPen &pen, const QBrush &brush, double size) :
- mSize(size),
- mShape(ssCustom),
- mPen(pen),
- mBrush(brush),
- mCustomPath(customPath),
- mPenDefined(false)
+QCPScatterStyle::QCPScatterStyle( const QPainterPath& customPath, const QPen& pen, const QBrush& brush, double size )
+ : mSize( size ), mShape( ssCustom ), mPen( pen ), mBrush( brush ), mCustomPath( customPath ), mPenDefined( false )
{
}
/*!
Sets the size (pixel diameter) of the drawn scatter points to \a size.
-
+
\see setShape
*/
-void QCPScatterStyle::setSize(double size)
+void QCPScatterStyle::setSize( double size )
{
mSize = size;
}
/*!
Sets the shape to \a shape.
-
+
Note that the calls \ref setPixmap and \ref setCustomPath automatically set the shape to \ref
ssPixmap and \ref ssCustom, respectively.
-
+
\see setSize
*/
-void QCPScatterStyle::setShape(QCPScatterStyle::ScatterShape shape)
+void QCPScatterStyle::setShape( QCPScatterStyle::ScatterShape shape )
{
mShape = shape;
}
/*!
Sets the pen that will be used to draw scatter points to \a pen.
-
+
If the pen was previously undefined (see \ref isPenDefined), the pen is considered defined after
a call to this function, even if \a pen is Qt::NoPen.
-
+
\see setBrush
*/
-void QCPScatterStyle::setPen(const QPen &pen)
+void QCPScatterStyle::setPen( const QPen& pen )
{
mPenDefined = true;
mPen = pen;
@@ -488,212 +450,212 @@ void QCPScatterStyle::setPen(const QPen &pen)
/*!
Sets the brush that will be used to fill scatter points to \a brush. Note that not all scatter
shapes have fillable areas. For example, \ref ssPlus does not while \ref ssCircle does.
-
+
\see setPen
*/
-void QCPScatterStyle::setBrush(const QBrush &brush)
+void QCPScatterStyle::setBrush( const QBrush& brush )
{
mBrush = brush;
}
/*!
Sets the pixmap that will be drawn as scatter point to \a pixmap.
-
+
Note that \ref setSize does not influence the appearance of the pixmap.
-
+
The scatter shape is automatically set to \ref ssPixmap.
*/
-void QCPScatterStyle::setPixmap(const QPixmap &pixmap)
+void QCPScatterStyle::setPixmap( const QPixmap& pixmap )
{
- setShape(ssPixmap);
+ setShape( ssPixmap );
mPixmap = pixmap;
}
/*!
Sets the custom shape that will be drawn as scatter point to \a customPath.
-
+
The scatter shape is automatically set to \ref ssCustom.
*/
-void QCPScatterStyle::setCustomPath(const QPainterPath &customPath)
+void QCPScatterStyle::setCustomPath( const QPainterPath& customPath )
{
- setShape(ssCustom);
+ setShape( ssCustom );
mCustomPath = customPath;
}
/*!
Applies the pen and the brush of this scatter style to \a painter. If this scatter style has an
undefined pen (\ref isPenDefined), sets the pen of \a painter to \a defaultPen instead.
-
+
This function is used by plottables (or any class that wants to draw scatters) just before a
number of scatters with this style shall be drawn with the \a painter.
-
+
\see drawShape
*/
-void QCPScatterStyle::applyTo(QCPPainter *painter, const QPen &defaultPen) const
+void QCPScatterStyle::applyTo( QCPPainter* painter, const QPen& defaultPen ) const
{
- painter->setPen(mPenDefined ? mPen : defaultPen);
- painter->setBrush(mBrush);
+ painter->setPen( mPenDefined ? mPen : defaultPen );
+ painter->setBrush( mBrush );
}
/*!
Draws the scatter shape with \a painter at position \a pos.
-
+
This function does not modify the pen or the brush on the painter, as \ref applyTo is meant to be
called before scatter points are drawn with \ref drawShape.
-
+
\see applyTo
*/
-void QCPScatterStyle::drawShape(QCPPainter *painter, QPointF pos) const
+void QCPScatterStyle::drawShape( QCPPainter* painter, QPointF pos ) const
{
- drawShape(painter, pos.x(), pos.y());
+ drawShape( painter, pos.x(), pos.y() );
}
/*! \overload
Draws the scatter shape with \a painter at position \a x and \a y.
*/
-void QCPScatterStyle::drawShape(QCPPainter *painter, double x, double y) const
+void QCPScatterStyle::drawShape( QCPPainter* painter, double x, double y ) const
{
- double w = mSize/2.0;
- switch (mShape)
+ double w = mSize / 2.0;
+ switch( mShape )
{
- case ssNone: break;
+ case ssNone:
+ break;
case ssDot:
{
- painter->drawLine(QPointF(x, y), QPointF(x+0.0001, y));
+ painter->drawLine( QPointF( x, y ), QPointF( x + 0.0001, y ) );
break;
}
case ssCross:
{
- painter->drawLine(QLineF(x-w, y-w, x+w, y+w));
- painter->drawLine(QLineF(x-w, y+w, x+w, y-w));
+ painter->drawLine( QLineF( x - w, y - w, x + w, y + w ) );
+ painter->drawLine( QLineF( x - w, y + w, x + w, y - w ) );
break;
}
case ssPlus:
{
- painter->drawLine(QLineF(x-w, y, x+w, y));
- painter->drawLine(QLineF( x, y+w, x, y-w));
+ painter->drawLine( QLineF( x - w, y, x + w, y ) );
+ painter->drawLine( QLineF( x, y + w, x, y - w ) );
break;
}
case ssCircle:
{
- painter->drawEllipse(QPointF(x , y), w, w);
+ painter->drawEllipse( QPointF( x, y ), w, w );
break;
}
case ssDisc:
{
QBrush b = painter->brush();
- painter->setBrush(painter->pen().color());
- painter->drawEllipse(QPointF(x , y), w, w);
- painter->setBrush(b);
+ painter->setBrush( painter->pen().color() );
+ painter->drawEllipse( QPointF( x, y ), w, w );
+ painter->setBrush( b );
break;
}
case ssSquare:
{
- painter->drawRect(QRectF(x-w, y-w, mSize, mSize));
+ painter->drawRect( QRectF( x - w, y - w, mSize, mSize ) );
break;
}
case ssDiamond:
{
- painter->drawLine(QLineF(x-w, y, x, y-w));
- painter->drawLine(QLineF( x, y-w, x+w, y));
- painter->drawLine(QLineF(x+w, y, x, y+w));
- painter->drawLine(QLineF( x, y+w, x-w, y));
+ painter->drawLine( QLineF( x - w, y, x, y - w ) );
+ painter->drawLine( QLineF( x, y - w, x + w, y ) );
+ painter->drawLine( QLineF( x + w, y, x, y + w ) );
+ painter->drawLine( QLineF( x, y + w, x - w, y ) );
break;
}
case ssStar:
{
- painter->drawLine(QLineF(x-w, y, x+w, y));
- painter->drawLine(QLineF( x, y+w, x, y-w));
- painter->drawLine(QLineF(x-w*0.707, y-w*0.707, x+w*0.707, y+w*0.707));
- painter->drawLine(QLineF(x-w*0.707, y+w*0.707, x+w*0.707, y-w*0.707));
+ painter->drawLine( QLineF( x - w, y, x + w, y ) );
+ painter->drawLine( QLineF( x, y + w, x, y - w ) );
+ painter->drawLine( QLineF( x - w * 0.707, y - w * 0.707, x + w * 0.707, y + w * 0.707 ) );
+ painter->drawLine( QLineF( x - w * 0.707, y + w * 0.707, x + w * 0.707, y - w * 0.707 ) );
break;
}
case ssTriangle:
{
- painter->drawLine(QLineF(x-w, y+0.755*w, x+w, y+0.755*w));
- painter->drawLine(QLineF(x+w, y+0.755*w, x, y-0.977*w));
- painter->drawLine(QLineF( x, y-0.977*w, x-w, y+0.755*w));
+ painter->drawLine( QLineF( x - w, y + 0.755 * w, x + w, y + 0.755 * w ) );
+ painter->drawLine( QLineF( x + w, y + 0.755 * w, x, y - 0.977 * w ) );
+ painter->drawLine( QLineF( x, y - 0.977 * w, x - w, y + 0.755 * w ) );
break;
}
case ssTriangleInverted:
{
- painter->drawLine(QLineF(x-w, y-0.755*w, x+w, y-0.755*w));
- painter->drawLine(QLineF(x+w, y-0.755*w, x, y+0.977*w));
- painter->drawLine(QLineF( x, y+0.977*w, x-w, y-0.755*w));
+ painter->drawLine( QLineF( x - w, y - 0.755 * w, x + w, y - 0.755 * w ) );
+ painter->drawLine( QLineF( x + w, y - 0.755 * w, x, y + 0.977 * w ) );
+ painter->drawLine( QLineF( x, y + 0.977 * w, x - w, y - 0.755 * w ) );
break;
}
case ssCrossSquare:
{
- painter->drawLine(QLineF(x-w, y-w, x+w*0.95, y+w*0.95));
- painter->drawLine(QLineF(x-w, y+w*0.95, x+w*0.95, y-w));
- painter->drawRect(QRectF(x-w, y-w, mSize, mSize));
+ painter->drawLine( QLineF( x - w, y - w, x + w * 0.95, y + w * 0.95 ) );
+ painter->drawLine( QLineF( x - w, y + w * 0.95, x + w * 0.95, y - w ) );
+ painter->drawRect( QRectF( x - w, y - w, mSize, mSize ) );
break;
}
case ssPlusSquare:
{
- painter->drawLine(QLineF(x-w, y, x+w*0.95, y));
- painter->drawLine(QLineF( x, y+w, x, y-w));
- painter->drawRect(QRectF(x-w, y-w, mSize, mSize));
+ painter->drawLine( QLineF( x - w, y, x + w * 0.95, y ) );
+ painter->drawLine( QLineF( x, y + w, x, y - w ) );
+ painter->drawRect( QRectF( x - w, y - w, mSize, mSize ) );
break;
}
case ssCrossCircle:
{
- painter->drawLine(QLineF(x-w*0.707, y-w*0.707, x+w*0.670, y+w*0.670));
- painter->drawLine(QLineF(x-w*0.707, y+w*0.670, x+w*0.670, y-w*0.707));
- painter->drawEllipse(QPointF(x, y), w, w);
+ painter->drawLine( QLineF( x - w * 0.707, y - w * 0.707, x + w * 0.670, y + w * 0.670 ) );
+ painter->drawLine( QLineF( x - w * 0.707, y + w * 0.670, x + w * 0.670, y - w * 0.707 ) );
+ painter->drawEllipse( QPointF( x, y ), w, w );
break;
}
case ssPlusCircle:
{
- painter->drawLine(QLineF(x-w, y, x+w, y));
- painter->drawLine(QLineF( x, y+w, x, y-w));
- painter->drawEllipse(QPointF(x, y), w, w);
+ painter->drawLine( QLineF( x - w, y, x + w, y ) );
+ painter->drawLine( QLineF( x, y + w, x, y - w ) );
+ painter->drawEllipse( QPointF( x, y ), w, w );
break;
}
case ssPeace:
{
- painter->drawLine(QLineF(x, y-w, x, y+w));
- painter->drawLine(QLineF(x, y, x-w*0.707, y+w*0.707));
- painter->drawLine(QLineF(x, y, x+w*0.707, y+w*0.707));
- painter->drawEllipse(QPointF(x, y), w, w);
+ painter->drawLine( QLineF( x, y - w, x, y + w ) );
+ painter->drawLine( QLineF( x, y, x - w * 0.707, y + w * 0.707 ) );
+ painter->drawLine( QLineF( x, y, x + w * 0.707, y + w * 0.707 ) );
+ painter->drawEllipse( QPointF( x, y ), w, w );
break;
}
case ssPixmap:
{
- painter->drawPixmap(x-mPixmap.width()*0.5, y-mPixmap.height()*0.5, mPixmap);
+ painter->drawPixmap( x - mPixmap.width() * 0.5, y - mPixmap.height() * 0.5, mPixmap );
break;
}
case ssCustom:
{
QTransform oldTransform = painter->transform();
- painter->translate(x, y);
- painter->scale(mSize/6.0, mSize/6.0);
- painter->drawPath(mCustomPath);
- painter->setTransform(oldTransform);
+ painter->translate( x, y );
+ painter->scale( mSize / 6.0, mSize / 6.0 );
+ painter->drawPath( mCustomPath );
+ painter->setTransform( oldTransform );
break;
}
}
}
-
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// QCPLayer
////////////////////////////////////////////////////////////////////////////////////////////////////
/*! \class QCPLayer
\brief A layer that may contain objects, to control the rendering order
-
+
The Layering system of QCustomPlot is the mechanism to control the rendering order of the
elements inside the plot.
-
+
It is based on the two classes QCPLayer and QCPLayerable. QCustomPlot holds an ordered list of
one or more instances of QCPLayer (see QCustomPlot::addLayer, QCustomPlot::layer,
QCustomPlot::moveLayer, etc.). When replotting, QCustomPlot goes through the list of layers
bottom to top and successively draws the layerables of the layers.
-
+
A QCPLayer contains an ordered list of QCPLayerable instances. QCPLayerable is an abstract base
class from which almost all visible objects derive, like axes, grids, graphs, items, etc.
-
+
Initially, QCustomPlot has five layers: "background", "grid", "main", "axes" and "legend" (in
that order). The top two layers "axes" and "legend" contain the default axes and legend, so they
will be drawn on top. In the middle, there is the "main" layer. It is initially empty and set as
@@ -703,21 +665,21 @@ void QCPScatterStyle::drawShape(QCPPainter *painter, double x, double y) const
shall be drawn behind everything else, thus the default QCPAxisRect instance is placed on the
"background" layer. Of course, the layer affiliation of the individual objects can be changed as
required (\ref QCPLayerable::setLayer).
-
+
Controlling the ordering of objects is easy: Create a new layer in the position you want it to
be, e.g. above "main", with QCustomPlot::addLayer. Then set the current layer with
QCustomPlot::setCurrentLayer to that new layer and finally create the objects normally. They will
be placed on the new layer automatically, due to the current layer setting. Alternatively you
could have also ignored the current layer setting and just moved the objects with
QCPLayerable::setLayer to the desired layer after creating them.
-
+
It is also possible to move whole layers. For example, If you want the grid to be shown in front
of all plottables/items on the "main" layer, just move it above "main" with
QCustomPlot::moveLayer.
-
+
The rendering order within one layer is simply by order of creation or insertion. The item
created last (or added last to the layer), is drawn on top of all other objects on that layer.
-
+
When a layer is deleted, the objects on it are not deleted with it, but fall on the layer below
the deleted layer, see QCustomPlot::removeLayer.
*/
@@ -725,16 +687,16 @@ void QCPScatterStyle::drawShape(QCPPainter *painter, double x, double y) const
/* start documentation of inline functions */
/*! \fn QList QCPLayer::children() const
-
+
Returns a list of all layerables on this layer. The order corresponds to the rendering order:
layerables with higher indices are drawn above layerables with lower indices.
*/
/*! \fn int QCPLayer::index() const
-
+
Returns the index this layer has in the QCustomPlot. The index is the integer number by which this layer can be
accessed via \ref QCustomPlot::layer.
-
+
Layers with higher indices will be drawn above layers with lower indices.
*/
@@ -742,18 +704,18 @@ void QCPScatterStyle::drawShape(QCPPainter *painter, double x, double y) const
/*!
Creates a new QCPLayer instance.
-
+
Normally you shouldn't directly instantiate layers, use \ref QCustomPlot::addLayer instead.
-
+
\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)
+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 )
{
// Note: no need to make sure layerName is unique, because layer
// management is done with QCustomPlot functions.
@@ -765,12 +727,13 @@ 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)
- 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.";
+
+ 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.";
}
/*!
@@ -781,76 +744,76 @@ 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;
}
/*! \internal
-
+
Adds the \a layerable to the list of this layer. If \a prepend is set to true, the layerable will
be prepended to the list, i.e. be drawn beneath the other layerables already in the list.
-
+
This function does not change the \a mLayer member of \a layerable to this layer. (Use
QCPLayerable::setLayer to change the layer of an object, not this function.)
-
+
\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);
- } else
- qDebug() << Q_FUNC_INFO << "layerable is already child of this layer" << reinterpret_cast(layerable);
+ mChildren.append( layerable );
+ }
+ else
+ qDebug() << Q_FUNC_INFO << "layerable is already child of this layer" << reinterpret_cast( layerable );
}
/*! \internal
-
+
Removes the \a layerable from the list of this layer.
-
+
This function does not change the \a mLayer member of \a layerable. (Use QCPLayerable::setLayer
to change the layer of an object, not this function.)
-
+
\see addChild
*/
-void QCPLayer::removeChild(QCPLayerable *layerable)
+void QCPLayer::removeChild( QCPLayerable* layerable )
{
- if (!mChildren.removeOne(layerable))
- qDebug() << Q_FUNC_INFO << "layerable is not child of this layer" << reinterpret_cast(layerable);
+ if( !mChildren.removeOne( layerable ) )
+ qDebug() << Q_FUNC_INFO << "layerable is not child of this layer" << reinterpret_cast( layerable );
}
-
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// QCPLayerable
////////////////////////////////////////////////////////////////////////////////////////////////////
/*! \class QCPLayerable
\brief Base class for all drawable objects
-
+
This is the abstract base class most visible objects derive from, e.g. plottables, axes, grid
etc.
Every layerable is on a layer (QCPLayer) which allows controlling the rendering order by stacking
the layers accordingly.
-
+
For details about the layering mechanism, see the QCPLayer documentation.
*/
/* start documentation of inline functions */
/*! \fn QCPLayerable *QCPLayerable::parentLayerable() const
-
+
Returns the parent layerable of this layerable. The parent layerable is used to provide
visibility hierarchies in conjunction with the method \ref realVisibility. This way, layerables
only get drawn if their parent layerables are visible, too.
-
+
Note that a parent layerable is not necessarily also the QObject parent for memory management.
Further, a layerable doesn't always have a parent layerable, so this function may return 0.
-
+
A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be
set manually by the user.
*/
@@ -860,7 +823,7 @@ void QCPLayer::removeChild(QCPLayerable *layerable)
/*! \fn virtual void QCPLayerable::applyDefaultAntialiasingHint(QCPPainter *painter) const = 0
\internal
-
+
This function applies the default antialiasing setting to the specified \a painter, using the
function \ref applyAntialiasingHint. It is the antialiasing state the painter is put in, when
\ref draw is called on the layerable. If the layerable has multiple entities whose antialiasing
@@ -868,7 +831,7 @@ void QCPLayer::removeChild(QCPLayerable *layerable)
most prominent entity. In this case however, the \ref draw function usually calls the specialized
versions of this function before drawing each entity, effectively overriding the setting of the
default antialiasing hint.
-
+
First example: QCPGraph has multiple entities that have an antialiasing setting: The graph
line, fills, scatters and error bars. Those can be configured via QCPGraph::setAntialiased,
QCPGraph::setAntialiasedFill, QCPGraph::setAntialiasedScatters etc. Consequently, there isn't
@@ -876,7 +839,7 @@ void QCPLayer::removeChild(QCPLayerable *layerable)
antialiasing), but specialized ones like QCPGraph::applyFillAntialiasingHint and
QCPGraph::applyScattersAntialiasingHint. So before drawing one of those entities, QCPGraph::draw
calls the respective specialized applyAntialiasingHint function.
-
+
Second example: QCPItemLine consists only of a line so there is only one antialiasing
setting which can be controlled with QCPItemLine::setAntialiased. (This function is inherited by
all layerables. The specialized functions, as seen on QCPGraph, must be added explicitly to the
@@ -889,10 +852,10 @@ void QCPLayer::removeChild(QCPLayerable *layerable)
/*! \fn virtual void QCPLayerable::draw(QCPPainter *painter) const = 0
\internal
-
+
This function draws the layerable with the specified \a painter. It is only called by
QCustomPlot, if the layerable is visible (\ref setVisible).
-
+
Before this function is called, the painter's antialiasing state is set via \ref
applyDefaultAntialiasingHint, see the documentation there. Further, the clipping rectangle was
set to \ref clipRect.
@@ -902,10 +865,10 @@ void QCPLayer::removeChild(QCPLayerable *layerable)
/* start documentation of signals */
/*! \fn void QCPLayerable::layerChanged(QCPLayer *newLayer);
-
+
This signal is emitted when the layer of this layerable changes, i.e. this layerable is moved to
a different layer.
-
+
\see setLayer
*/
@@ -913,44 +876,44 @@ void QCPLayer::removeChild(QCPLayerable *layerable)
/*!
Creates a new QCPLayerable instance.
-
+
Since QCPLayerable is an abstract base class, it can't be instantiated directly. Use one of the
derived classes.
-
+
If \a plot is provided, it automatically places itself on the layer named \a targetLayer. If \a
targetLayer is an empty string, it places itself on the current layer of the plot (see \ref
QCustomPlot::setCurrentLayer).
-
+
It is possible to provide 0 as \a plot. In that case, you should assign a parent plot at a later
time with \ref initializeParentPlot.
-
+
The layerable's parent layerable is set to \a parentLayerable, if provided. Direct layerable parents
are mainly used to control visibility in a hierarchy of layerables. This means a layerable is
only drawn, if all its ancestor layerables are also visible. Note that \a parentLayerable does
not become the QObject-parent (for memory management) of this layerable, \a plot does.
*/
-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;
}
}
@@ -960,7 +923,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;
}
@@ -968,30 +931,31 @@ void QCPLayerable::setVisible(bool on)
/*!
Sets the \a layer of this layerable object. The object will be placed on top of the other objects
already on \a layer.
-
+
Returns true on success, i.e. if \a layer is a valid layer.
*/
-bool QCPLayerable::setLayer(QCPLayer *layer)
+bool QCPLayerable::setLayer( QCPLayer* layer )
{
- return moveToLayer(layer, false);
+ return moveToLayer( layer, false );
}
/*! \overload
Sets the layer of this layerable object by name
-
+
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;
@@ -1000,11 +964,11 @@ bool QCPLayerable::setLayer(const QString &layerName)
/*!
Sets whether this object will be drawn antialiased or not.
-
+
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;
}
@@ -1013,18 +977,19 @@ void QCPLayerable::setAntialiased(bool enabled)
Returns whether this layerable is visible, taking the visibility of the layerable parent and the
visibility of the layer this layerable is on into account. This is the method that is consulted
to decide whether a layerable shall be drawn or not.
-
+
If this layerable has a direct layerable parent (usually set via hierarchies implemented in
subclasses, like in the case of QCPLayoutElement), this function returns true only if this
layerable has its visibility set to true and the parent layerable's \ref realVisibility returns
true.
-
+
If this layerable doesn't have a direct layerable parent, returns the state of this layerable's
visibility.
*/
bool QCPLayerable::realVisibility() const
{
- return mVisible && (!mLayer || mLayer->visible()) && (!mParentLayerable || mParentLayerable.data()->realVisibility());
+ return mVisible && ( !mLayer || mLayer->visible() ) &&
+ ( !mParentLayerable || mParentLayerable.data()->realVisibility() );
}
/*!
@@ -1039,15 +1004,15 @@ bool QCPLayerable::realVisibility() const
click inside the area returns a constant value greater zero (typically the selectionTolerance of
the parent QCustomPlot multiplied by 0.99). If the click lies outside the area, this function
returns -1.0.
-
+
Providing a constant value for area objects allows selecting line objects even when they are
obscured by such area objects, by clicking close to the lines (i.e. closer than
0.99*selectionTolerance).
-
+
The actual setting of the selection state is not done by this function. This is handled by the
parent QCustomPlot when the mouseReleaseEvent occurs, and the finally selected object is notified
via the selectEvent/deselectEvent methods.
-
+
\a details is an optional output parameter. Every layerable subclass may place any information
in \a details. This information will be passed to \ref selectEvent when the parent QCustomPlot
decides on the basis of this selectTest call, that the object was successfully selected. The
@@ -1056,96 +1021,96 @@ bool QCPLayerable::realVisibility() const
is only done once in \ref selectTest. The result (i.e. the actually clicked part) can then be
placed in \a details. So in the subsequent \ref selectEvent, the decision which part was
selected doesn't have to be done a second time for a single selection operation.
-
+
You may pass 0 as \a details to indicate that you are not interested in those selection details.
-
+
\see selectEvent, deselectEvent, 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;
}
/*! \internal
-
+
Sets the parent plot of this layerable. Use this function once to set the parent plot if you have
passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to
another one.
-
+
Note that, unlike when passing a non-null parent plot in the constructor, this function does not
make \a parentPlot the QObject-parent of this layerable. If you want this, call
QObject::setParent(\a parentPlot) in addition to this function.
-
+
Further, you will probably want to set a layer (\ref setLayer) after calling this function, to
make the layerable appear on the QCustomPlot.
-
+
The parent plot change will be propagated to subclasses via a call to \ref parentPlotInitialized
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
-
+
Sets the parent layerable of this layerable to \a parentLayerable. Note that \a parentLayerable does not
become the QObject-parent (for memory management) of this layerable.
-
+
The parent layerable has influence on the return value of the \ref realVisibility method. Only
layerables with a fully visible parent tree will return true for \ref realVisibility, and thus be
drawn.
-
+
\see realVisibility
*/
-void QCPLayerable::setParentLayerable(QCPLayerable *parentLayerable)
+void QCPLayerable::setParentLayerable( QCPLayerable* parentLayerable )
{
mParentLayerable = parentLayerable;
}
/*! \internal
-
+
Moves this layerable object to \a layer. If \a prepend is true, this object will be prepended to
the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is
false, the object will be appended.
-
+
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;
}
@@ -1156,14 +1121,16 @@ 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
@@ -1171,20 +1138,20 @@ void QCPLayerable::applyAntialiasingHint(QCPPainter *painter, bool localAntialia
This function is called by \ref initializeParentPlot, to allow subclasses to react on the setting
of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the
parent plot is set at a later time.
-
+
For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any
QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level
element of the hierarchy gets its parent plot initialized with \ref initializeParentPlot. To
propagate the parent plot to all the children of the hierarchy, the top level element then uses
this function to pass the parent plot on to its child elements.
-
+
The default implementation does nothing.
-
+
\see initializeParentPlot
*/
-void QCPLayerable::parentPlotInitialized(QCustomPlot *parentPlot)
+void QCPLayerable::parentPlotInitialized( QCustomPlot* parentPlot )
{
- Q_UNUSED(parentPlot)
+ Q_UNUSED( parentPlot )
}
/*! \internal
@@ -1192,10 +1159,10 @@ void QCPLayerable::parentPlotInitialized(QCustomPlot *parentPlot)
Returns the selection category this layerable shall belong to. The selection category is used in
conjunction with \ref QCustomPlot::setInteractions to control which objects are selectable and
which aren't.
-
+
Subclasses that don't fit any of the normal \ref QCP::Interaction values can use \ref
QCP::iSelectOther. This is what the default implementation returns.
-
+
\see QCustomPlot::setInteractions
*/
QCP::Interaction QCPLayerable::selectionCategory() const
@@ -1204,33 +1171,33 @@ QCP::Interaction QCPLayerable::selectionCategory() const
}
/*! \internal
-
+
Returns the clipping rectangle of this layerable object. By default, this is the viewport of the
parent QCustomPlot. Specific subclasses may reimplement this function to provide different
clipping rects.
-
+
The returned clipping rect is set on the painter before the draw function of the respective
object is called.
*/
QRect QCPLayerable::clipRect() const
{
- if (mParentPlot)
+ if( mParentPlot )
return mParentPlot->viewport();
else
return QRect();
}
/*! \internal
-
+
This event is called when the layerable shall be selected, as a consequence of a click by the
user. Subclasses should react to it by setting their selection state appropriately. The default
implementation does nothing.
-
+
\a event is the mouse event that caused the selection. \a additive indicates, whether the user
was holding the multi-select-modifier while performing the selection (see \ref
QCustomPlot::setMultiSelectModifier). if \a additive is true, the selection state must be toggled
(i.e. become selected when unselected and unselected when selected).
-
+
Every selectEvent is preceded by a call to \ref selectTest, which has returned positively (i.e.
returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot).
The \a details data you output from \ref selectTest is fed back via \a details here. You may
@@ -1238,51 +1205,53 @@ QRect QCPLayerable::clipRect() const
selectEvent. Usually \a details is used to transfer which part was clicked, if it is a layerable
that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need
to do the calculation again to find out which part was actually clicked.
-
+
\a selectionStateChanged is an output parameter. If the pointer is non-null, this function must
set the value either to true or false, depending on whether the selection state of this layerable
was actually changed. For layerables that only are selectable as a whole and not in parts, this
is simple: if \a additive is true, \a selectionStateChanged must also be set to true, because the
selection toggles. If \a additive is false, \a selectionStateChanged is only set to true, if the
layerable was previously unselected and now is switched to the selected state.
-
+
\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
-
+
This event is called when the layerable shall be deselected, either as consequence of a user
interaction or a call to \ref QCustomPlot::deselectAll. Subclasses should react to it by
unsetting their selection appropriately.
-
+
just as in \ref selectEvent, the output parameter \a selectionStateChanged (if non-null), must
return true or false when the selection state of this layerable has changed or not changed,
respectively.
-
+
\see selectTest, selectEvent
*/
-void QCPLayerable::deselectEvent(bool *selectionStateChanged)
+void QCPLayerable::deselectEvent( bool* selectionStateChanged )
{
- Q_UNUSED(selectionStateChanged)
+ Q_UNUSED( selectionStateChanged )
}
-
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// QCPRange
////////////////////////////////////////////////////////////////////////////////////////////////////
/*! \class QCPRange
\brief Represents the range an axis is encompassing.
-
+
contains a \a lower and \a upper double value and provides convenience input, output and
modification functions.
-
+
\see QCPAxis::setRange
*/
@@ -1307,18 +1276,14 @@ 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 )
{
}
/*! \overload
Constructs a range with the specified \a lower and \a upper values.
*/
-QCPRange::QCPRange(double lower, double upper) :
- lower(lower),
- upper(upper)
+QCPRange::QCPRange( double lower, double upper ) : lower( lower ), upper( upper )
{
normalize();
}
@@ -1328,7 +1293,7 @@ QCPRange::QCPRange(double lower, double upper) :
*/
double QCPRange::size() const
{
- return upper-lower;
+ return upper - lower;
}
/*!
@@ -1336,7 +1301,7 @@ double QCPRange::size() const
*/
double QCPRange::center() const
{
- return (upper+lower)*0.5;
+ return ( upper + lower ) * 0.5;
}
/*!
@@ -1345,37 +1310,36 @@ double QCPRange::center() const
*/
void QCPRange::normalize()
{
- if (lower > upper)
- qSwap(lower, upper);
+ if( lower > upper )
+ qSwap( lower, upper );
}
/*!
Expands this range such that \a otherRange is contained in the new range. It is assumed that both
this range and \a otherRange are normalized (see \ref normalize).
-
+
If \a otherRange is already inside the current range, this function does nothing.
-
+
\see expanded
*/
-void QCPRange::expand(const QCPRange &otherRange)
+void QCPRange::expand( const QCPRange& otherRange )
{
- if (lower > otherRange.lower)
+ if( lower > otherRange.lower )
lower = otherRange.lower;
- if (upper < otherRange.upper)
+ if( upper < otherRange.upper )
upper = otherRange.upper;
}
-
/*!
Returns an expanded range that contains this and \a otherRange. It is assumed that both this
range and \a otherRange are normalized (see \ref normalize).
-
+
\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;
}
@@ -1383,7 +1347,7 @@ QCPRange QCPRange::expanded(const QCPRange &otherRange) const
Returns a sanitized version of the range. Sanitized means for logarithmic scales, that
the range won't span the positive and negative sign domain, i.e. contain zero. Further
\a lower will always be numerically smaller (or equal) to \a upper.
-
+
If the original range does span positive and negative sign domains or contains zero,
the returned range will try to approximate the original range as good as possible.
If the positive interval of the original range is wider than the negative interval, the
@@ -1394,42 +1358,44 @@ QCPRange QCPRange::expanded(const QCPRange &otherRange) 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 (qFuzzyCompare(sanitizedRange.lower+1, 1) && !qFuzzyCompare(sanitizedRange.upper+1, 1))
+ 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= lower && value <= upper;
}
@@ -1463,7 +1429,7 @@ bool QCPRange::contains(double value) const
\li range size above minRange
\li range size below maxRange
*/
-bool QCPRange::validRange(double lower, double upper)
+bool QCPRange::validRange( double lower, double upper )
{
/*
return (lower > -maxRange &&
@@ -1472,10 +1438,8 @@ bool QCPRange::validRange(double lower, double upper)
(lower < -minRange || lower > minRange) &&
(upper < -minRange || upper > minRange));
*/
- return (lower > -maxRange &&
- upper < maxRange &&
- qAbs(lower-upper) > minRange &&
- qAbs(lower-upper) < maxRange);
+ return ( lower > -maxRange && upper < maxRange && qAbs( lower - upper ) > minRange &&
+ qAbs( lower - upper ) < maxRange );
}
/*!
@@ -1487,7 +1451,7 @@ 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 &&
@@ -1497,29 +1461,26 @@ bool QCPRange::validRange(const QCPRange &range)
(range.lower < -minRange || range.lower > minRange) &&
(range.upper < -minRange || range.upper > minRange));
*/
- return (range.lower > -maxRange &&
- range.upper < maxRange &&
- qAbs(range.lower-range.upper) > minRange &&
- qAbs(range.lower-range.upper) < maxRange);
+ return ( range.lower > -maxRange && range.upper < maxRange && qAbs( range.lower - range.upper ) > minRange &&
+ qAbs( range.lower - range.upper ) < maxRange );
}
-
/*! \page thelayoutsystem The Layout System
-
+
The layout system is responsible for positioning and scaling layout elements such as axis rects,
legends and plot titles in a QCustomPlot.
\section layoutsystem-classesandmechanisms Classes and mechanisms
-
+
The layout system is based on the abstract base class \ref QCPLayoutElement. All objects that
take part in the layout system derive from this class, either directly or indirectly.
-
+
Since QCPLayoutElement itself derives from \ref QCPLayerable, a layout element may draw its own
content. However, it is perfectly possible for a layout element to only serve as a structuring
and/or positioning element, not drawing anything on its own.
-
+
\subsection layoutsystem-rects Rects of a layout element
-
+
A layout element is a rectangular object described by two rects: the inner rect (\ref
QCPLayoutElement::rect) and the outer rect (\ref QCPLayoutElement::setOuterRect). The inner rect
is calculated automatically by applying the margin (\ref QCPLayoutElement::setMargins) inward
@@ -1527,9 +1488,9 @@ bool QCPRange::validRange(const QCPRange &range)
left blank or serve for displaying peripheral graphics. For example, \ref QCPAxisRect positions
the four main axes at the sides of the inner rect, so graphs end up inside it and the axis labels
and tick labels are in the margin area.
-
+
\subsection layoutsystem-margins Margins
-
+
Each layout element may provide a mechanism to automatically determine its margins. Internally,
this is realized with the \ref QCPLayoutElement::calculateAutoMargin function which takes a \ref
QCP::MarginSide and returns an integer value which represents the ideal margin for the specified
@@ -1540,15 +1501,15 @@ bool QCPRange::validRange(const QCPRange &range)
margins smaller than desired for a specific situation. If automatic margin calculation is unset
for a specific side, the margin of that side can be controlled directy via \ref
QCPLayoutElement::setMargins.
-
+
If multiple layout ements are arranged next to or beneath each other, it may be desirable to
align their inner rects on certain sides. Since they all might have different automatic margins,
this usually isn't the case. The class \ref QCPMarginGroup and \ref
QCPLayoutElement::setMarginGroup fix this by allowing to synchronize multiple margins. See the
documentation there for details.
-
+
\subsection layoutsystem-layout Layouts
-
+
As mentioned, a QCPLayoutElement may have an arbitrary number of child layout elements and in
princple can have the only purpose to manage/arrange those child elements. This is what the
subclass \ref QCPLayout specializes on. It is a QCPLayoutElement itself but has no visual
@@ -1556,25 +1517,25 @@ bool QCPRange::validRange(const QCPRange &range)
QCPLayout isn't a usable layout though, it's an abstract base class that concrete layouts derive
from, like \ref QCPLayoutGrid which arranges its child elements in a grid and \ref QCPLayoutInset
which allows placing child elements freely inside its rect.
-
+
Since a QCPLayout is a layout element itself, it may be placed inside other layouts. This way,
complex hierarchies may be created, offering very flexible arrangements.
-
- \image html LayoutsystemSketch.png
-
+
+ \image html LayoutsystemSketch.png
+
Above is a sketch of the default \ref QCPLayoutGrid accessible via \ref QCustomPlot::plotLayout.
It shows how two child layout elements are placed inside the grid layout next to each other in
cells (0, 0) and (0, 1).
-
+
\subsection layoutsystem-plotlayout The top level plot layout
-
+
Every QCustomPlot has one top level layout of type \ref QCPLayoutGrid. It is accessible via \ref
QCustomPlot::plotLayout and contains (directly or indirectly via other sub-layouts) all layout
elements in the QCustomPlot. By default, this top level grid layout contains a single cell which
holds the main axis rect.
-
+
\subsection layoutsystem-examples Examples
-
+
Adding a plot title is a typical and simple case to demonstrate basic workings of the layout system.
\code
// first we create and prepare a plot title layout element:
@@ -1615,9 +1576,8 @@ bool QCPRange::validRange(const QCPRange &range)
}
\endcode
\image html layoutsystem-multipleaxisrects.png
-
-*/
+*/
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// QCPMarginGroup
@@ -1625,27 +1585,27 @@ bool QCPRange::validRange(const QCPRange &range)
/*! \class QCPMarginGroup
\brief A margin group allows synchronization of margin sides if working with multiple layout elements.
-
+
QCPMarginGroup allows you to tie a margin side of two or more layout elements together, such that
they will all have the same size, based on the largest required margin in the group.
-
+
\n
\image html QCPMarginGroup.png "Demonstration of QCPMarginGroup"
\n
-
+
In certain situations it is desirable that margins at specific sides are synchronized across
layout elements. For example, if one QCPAxisRect is below another one in a grid layout, it will
provide a cleaner look to the user if the left and right margins of the two axis rects are of the
same size. The left axis of the top axis rect will then be at the same horizontal position as the
left axis of the lower axis rect, making them appear aligned. The same applies for the right
axes. This is what QCPMarginGroup makes possible.
-
+
To add/remove a specific side of a layout element to/from a margin group, use the \ref
QCPLayoutElement::setMarginGroup method. To completely break apart the margin group, either call
\ref clear, or just delete the margin group.
-
+
\section QCPMarginGroup-example Example
-
+
First create a margin group:
\code
QCPMarginGroup *group = new QCPMarginGroup(customPlot);
@@ -1662,7 +1622,7 @@ bool QCPRange::validRange(const QCPRange &range)
/* start documentation of inline functions */
/*! \fn QList QCPMarginGroup::elements(QCP::MarginSide side) const
-
+
Returns a list of all layout elements that have their margin \a side associated with this margin
group.
*/
@@ -1672,14 +1632,12 @@ bool QCPRange::validRange(const QCPRange &range)
/*!
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()
@@ -1693,11 +1651,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;
@@ -1710,89 +1668,91 @@ 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
}
}
/*! \internal
-
+
Returns the synchronized common margin for \a side. This is the margin value that will be used by
the layout element on the respective side, if it is part of this margin group.
-
+
The common margin is calculated by requesting the automatic margin (\ref
QCPLayoutElement::calculateAutoMargin) of each element associated with \a side in this margin
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 = mChildren.value( side );
+ for( int i = 0; i < elements.size(); ++i )
{
- if (!elements.at(i)->autoMargins().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;
}
/*! \internal
-
+
Adds \a element to the internal list of child elements, for the margin \a side.
-
+
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
-
+
Removes \a element from the internal list of child elements, for the margin \a side.
-
+
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
////////////////////////////////////////////////////////////////////////////////////////////////////
/*! \class QCPLayoutElement
\brief The abstract base class for all objects that form \ref thelayoutsystem "the layout system".
-
+
This is an abstract base class. As such, it can't be instantiated directly, rather use one of its subclasses.
-
+
A Layout element is a rectangular object which can be placed in layouts. It has an outer rect
(QCPLayoutElement::outerRect) and an inner rect (\ref QCPLayoutElement::rect). The difference
between outer and inner rect is called its margin. The margin can either be set to automatic or
manual (\ref setAutoMargins) on a per-side basis. If a side is set to manual, that margin can be
set explicitly with \ref setMargins and will stay fixed at that value. If it's set to automatic,
the layout element subclass will control the value itself (via \ref calculateAutoMargin).
-
+
Layout elements can be placed in layouts (base class QCPLayout) like QCPLayoutGrid. The top level
layout is reachable via \ref QCustomPlot::plotLayout, and is a \ref QCPLayoutGrid. Since \ref
QCPLayout itself derives from \ref QCPLayoutElement, layouts can be nested.
-
+
Thus in QCustomPlot one can divide layout elements into two categories: The ones that are
invisible by themselves, because they don't draw anything. Their only purpose is to manage the
position and size of other layout elements. This category of layout elements usually use
@@ -1806,15 +1766,15 @@ void QCPMarginGroup::removeChild(QCP::MarginSide side, QCPLayoutElement *element
/* start documentation of inline functions */
/*! \fn QCPLayout *QCPLayoutElement::layout() const
-
+
Returns the parent layout of this layout element.
*/
/*! \fn QRect QCPLayoutElement::rect() const
-
+
Returns the inner rect of this layout element. The inner rect is the outer rect (\ref
setOuterRect) shrinked by the margins (\ref setMargins, \ref setAutoMargins).
-
+
In some cases, the area between outer and inner rect is left blank. In other cases the margin
area is used to display peripheral graphics while the main content is in the inner rect. This is
where automatic margin calculation becomes interesting because it allows the layout element to
@@ -1824,30 +1784,30 @@ void QCPMarginGroup::removeChild(QCP::MarginSide side, QCPLayoutElement *element
*/
/*! \fn virtual void QCPLayoutElement::mousePressEvent(QMouseEvent *event)
-
+
This event is called, if the mouse was pressed while being inside the outer rect of this layout
element.
*/
/*! \fn virtual void QCPLayoutElement::mouseMoveEvent(QMouseEvent *event)
-
+
This event is called, if the mouse is moved inside the outer rect of this layout element.
*/
/*! \fn virtual void QCPLayoutElement::mouseReleaseEvent(QMouseEvent *event)
-
+
This event is called, if the mouse was previously pressed inside the outer rect of this layout
element and is now released.
*/
/*! \fn virtual void QCPLayoutElement::mouseDoubleClickEvent(QMouseEvent *event)
-
+
This event is called, if the mouse is double-clicked inside the outer rect of this layout
element.
*/
/*! \fn virtual void QCPLayoutElement::wheelEvent(QWheelEvent *event)
-
+
This event is called, if the mouse wheel is scrolled while the cursor is inside the rect of this
layout element.
*/
@@ -1857,44 +1817,46 @@ void QCPMarginGroup::removeChild(QCP::MarginSide side, QCPLayoutElement *element
/*!
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),
- 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 ),
+ 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 );
}
/*!
Sets the outer rect of this layout element. If the layout element is inside a layout, the layout
sets the position and size of this layout element using this function.
-
+
Calling this function externally has no effect, since the layout will overwrite any changes to
the outer rect upon the next replot.
-
+
The layout element will adapt its inner \ref rect by applying the margins inward to the outer rect.
-
+
\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() );
}
}
@@ -1902,34 +1864,34 @@ void QCPLayoutElement::setOuterRect(const QRect &rect)
Sets the margins of this layout element. If \ref setAutoMargins is disabled for some or all
sides, this function is used to manually set the margin on those sides. Sides that are still set
to be handled automatically are ignored and may have any value in \a margins.
-
+
The margin is the distance between the outer rect (controlled by the parent layout via \ref
setOuterRect) and the inner \ref rect (which usually contains the main content of this layout
element).
-
+
\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() );
}
}
/*!
If \ref setAutoMargins is enabled on some or all margins, this function is used to provide
minimum values for those margins.
-
+
The minimum values are not enforced on margin sides that were set to be under manual control via
\ref setAutoMargins.
-
+
\see setAutoMargins
*/
-void QCPLayoutElement::setMinimumMargins(const QMargins &margins)
+void QCPLayoutElement::setMinimumMargins( const QMargins& margins )
{
- if (mMinimumMargins != margins)
+ if( mMinimumMargins != margins )
{
mMinimumMargins = margins;
}
@@ -1939,13 +1901,13 @@ void QCPLayoutElement::setMinimumMargins(const QMargins &margins)
Sets on which sides the margin shall be calculated automatically. If a side is calculated
automatically, a minimum margin value may be provided with \ref setMinimumMargins. If a side is
set to be controlled manually, the value may be specified with \ref setMargins.
-
+
Margin sides that are under automatic control may participate in a \ref QCPMarginGroup (see \ref
setMarginGroup), to synchronize (align) it with other layout elements in the plot.
-
+
\see setMinimumMargins, setMargins
*/
-void QCPLayoutElement::setAutoMargins(QCP::MarginSides sides)
+void QCPLayoutElement::setAutoMargins( QCP::MarginSides sides )
{
mAutoMargins = sides;
}
@@ -1953,89 +1915,94 @@ void QCPLayoutElement::setAutoMargins(QCP::MarginSides sides)
/*!
Sets the minimum size for the inner \ref rect of this layout element. A parent layout tries to
respect the \a size here by changing row/column sizes in the layout accordingly.
-
+
If the parent layout size is not sufficient to satisfy all minimum size constraints of its child
layout elements, the layout may set a size that is actually smaller than \a size. QCustomPlot
propagates the layout's size constraints to the outside by setting its own minimum QWidget size
accordingly, so violations of \a size should be exceptions.
*/
-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();
}
}
/*! \overload
-
+
Sets the minimum size for the inner \ref rect of this layout element.
*/
-void QCPLayoutElement::setMinimumSize(int width, int height)
+void QCPLayoutElement::setMinimumSize( int width, int height )
{
- setMinimumSize(QSize(width, height));
+ setMinimumSize( QSize( width, height ) );
}
/*!
Sets the maximum size for the inner \ref rect of this layout element. A parent layout tries to
respect the \a size here by changing row/column sizes in the layout accordingly.
*/
-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();
}
}
/*! \overload
-
+
Sets the maximum size for the inner \ref rect of this layout element.
*/
-void QCPLayoutElement::setMaximumSize(int width, int height)
+void QCPLayoutElement::setMaximumSize( int width, int height )
{
- setMaximumSize(QSize(width, height));
+ setMaximumSize( QSize( width, height ) );
}
/*!
Sets the margin \a group of the specified margin \a sides.
-
+
Margin groups allow synchronizing specified margins across layout elements, see the documentation
of \ref QCPMarginGroup.
-
+
To unset the margin group of \a sides, set \a group to 0.
-
+
Note that margin groups only work for margin sides that are set to automatic (\ref
setAutoMargins).
*/
-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; 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 );
}
}
}
@@ -2046,42 +2013,49 @@ void QCPLayoutElement::setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *gr
replot by the parent layout element. It is called multiple times, once for every \ref
UpdatePhase. The phases are run through in the order of the enum values. For details about what
happens at the different phases, see the documentation of \ref UpdatePhase.
-
+
Layout elements that have child elements should call the \ref update method of their child
elements, and pass the current \a phase unchanged.
-
+
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:
+ // set the margins of this layout element according to automatic margin calculation, either directly or via a
+ // margin group:
QMargins newMargins = mMargins;
- foreach (QCP::MarginSide side, QList() << QCP::msLeft << QCP::msRight << QCP::msTop << QCP::msBottom)
+ foreach( QCP::MarginSide side, QList() << QCP::msLeft << QCP::msRight << QCP::msTop
+ << QCP::msBottom )
{
- 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 );
}
}
}
/*!
Returns the minimum size this layout element (the inner \ref rect) may be compressed to.
-
+
if a minimum size (\ref setMinimumSize) was not set manually, parent layouts consult this
function to determine the minimum allowed size of this layout element. (A manual minimum size is
considered set if it is non-zero.)
@@ -2093,7 +2067,7 @@ QSize QCPLayoutElement::minimumSizeHint() const
/*!
Returns the maximum size this layout element (the inner \ref rect) may be expanded to.
-
+
if a maximum size (\ref setMaximumSize) was not set manually, parent layouts consult this
function to determine the maximum allowed size of this layout element. (A manual maximum size is
considered set if it is smaller than Qt's QWIDGETSIZE_MAX.)
@@ -2106,13 +2080,13 @@ QSize QCPLayoutElement::maximumSizeHint() const
/*!
Returns a list of all child elements in this layout element. If \a recursive is true, all
sub-child elements are included in the list, too.
-
+
\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();
}
@@ -2121,58 +2095,59 @@ QList QCPLayoutElement::elements(bool recursive) const
rect, this method returns a value corresponding to 0.99 times the parent plot's selection
tolerance. However, layout elements are not selectable by default. So if \a onlySelectable is
true, -1.0 is returned.
-
+
See \ref QCPLayerable::selectTest for a general explanation of this virtual method.
-
+
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;
}
/*! \internal
-
+
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 );
}
}
/*! \internal
-
+
Returns the margin size for this \a side. It is used if automatic margins is enabled for this \a
side (see \ref setAutoMargins). If a minimum margin was set with \ref setMinimumMargins, the
returned value will not be smaller than the specified minimum margin.
-
+
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 ) );
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -2181,23 +2156,23 @@ int QCPLayoutElement::calculateAutoMargin(QCP::MarginSide side)
/*! \class QCPLayout
\brief The abstract base class for layouts
-
+
This is an abstract base class for layout elements whose main purpose is to define the position
and size of other child layout elements. In most cases, layouts don't draw anything themselves
(but there are exceptions to this, e.g. QCPLegend).
-
+
QCPLayout derives from QCPLayoutElement, and thus can itself be nested in other layouts.
-
+
QCPLayout introduces a common interface for accessing and manipulating the child elements. Those
functions are most notably \ref elementCount, \ref elementAt, \ref takeAt, \ref take, \ref
simplify, \ref removeAt, \ref remove and \ref clear. Individual subclasses may add more functions
to this interface which are more specialized to the form of the layout. For example, \ref
QCPLayoutGrid adds functions that take row and column indices to access cells of the layout grid
more conveniently.
-
+
Since this is an abstract base class, you can't instantiate it directly. Rather use one of its
subclasses like QCPLayoutGrid or QCPLayoutInset.
-
+
For a general introduction to the layout system, see the dedicated documentation page \ref
thelayoutsystem "The Layout System".
*/
@@ -2205,44 +2180,44 @@ int QCPLayoutElement::calculateAutoMargin(QCP::MarginSide side)
/* start documentation of pure virtual functions */
/*! \fn virtual int QCPLayout::elementCount() const = 0
-
+
Returns the number of elements/cells in the layout.
-
+
\see elements, elementAt
*/
/*! \fn virtual QCPLayoutElement* QCPLayout::elementAt(int index) const = 0
-
+
Returns the element in the cell with the given \a index. If \a index is invalid, returns 0.
-
+
Note that even if \a index is valid, the respective cell may be empty in some layouts (e.g.
QCPLayoutGrid), so this function may return 0 in those cases. You may use this function to check
whether a cell is empty or not.
-
+
\see elements, elementCount, takeAt
*/
/*! \fn virtual QCPLayoutElement* QCPLayout::takeAt(int index) = 0
-
+
Removes the element with the given \a index from the layout and returns it.
-
+
If the \a index is invalid or the cell with that index is empty, returns 0.
-
+
Note that some layouts don't remove the respective cell right away but leave an empty cell after
successful removal of the layout element. To collapse empty cells, use \ref simplify.
-
+
\see elementAt, take
*/
/*! \fn virtual bool QCPLayout::take(QCPLayoutElement* element) = 0
-
+
Removes the specified \a element from the layout and returns true on success.
-
+
If the \a element isn't in this layout, returns false.
-
+
Note that some layouts don't remove the respective cell right away but leave an empty cell after
successful removal of the layout element. To collapse empty cells, use \ref simplify.
-
+
\see takeAt
*/
@@ -2259,44 +2234,44 @@ QCPLayout::QCPLayout()
/*!
First calls the QCPLayoutElement::update base class implementation to update the margins on this
layout.
-
+
Then calls \ref updateLayout which subclasses reimplement to reposition and resize their cells.
-
+
Finally, \ref update is called on all child elements.
*/
-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; 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; ielements(recursive);
+ if( result.at( i ) )
+ result << result.at( i )->elements( recursive );
}
}
return result;
@@ -2305,7 +2280,7 @@ QList QCPLayout::elements(bool recursive) const
/*!
Simplifies the layout by collapsing empty cells. The exact behavior depends on subclasses, the
default implementation does nothing.
-
+
Not all layouts need simplification. For example, QCPLayoutInset doesn't use explicit
simplification while QCPLayoutGrid does.
*/
@@ -2316,59 +2291,61 @@ void QCPLayout::simplify()
/*!
Removes and deletes the element at the provided \a index. Returns true on success. If \a index is
invalid or points to an empty cell, returns false.
-
+
This function internally uses \ref takeAt to remove the element from the layout and then deletes
the returned element.
-
+
\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;
}
/*!
Removes and deletes the provided \a element. Returns true on success. If \a element is not in the
layout, returns false.
-
+
This function internally uses \ref takeAt to remove the element from the layout and then deletes
the element.
-
+
\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;
}
/*!
Removes and deletes all layout elements in this layout.
-
+
\see remove, removeAt
*/
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();
}
/*!
Subclasses call this method to report changed (minimum/maximum) size constraints.
-
+
If the parent of this layout is again a QCPLayout, forwards the call to the parent's \ref
sizeConstraintsChanged. If the parent is a QWidget (i.e. is the \ref QCustomPlot::plotLayout of
QCustomPlot), calls QWidget::updateGeometry, so if the QCustomPlot widget is inside a Qt QLayout,
@@ -2376,245 +2353,261 @@ 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();
}
/*! \internal
-
+
Subclasses reimplement this method to update the position and sizes of the child elements/cells
via calling their \ref QCPLayoutElement::setOuterRect. The default implementation does nothing.
-
+
The geometry used as a reference is the inner \ref rect of this layout. Child elements should stay
within that rect.
-
+
\ref getSectionSizes may help with the reimplementation of this function.
-
+
\see update
*/
void QCPLayout::updateLayout()
{
}
-
/*! \internal
-
+
Associates \a el with this layout. This is done by setting the \ref QCPLayoutElement::layout, the
\ref QCPLayerable::parentLayerable and the QObject parent to this layout.
-
+
Further, if \a el didn't previously have a parent plot, calls \ref
QCPLayerable::initializeParentPlot on \a el to set the paret plot.
-
+
This method is used by subclass specific methods that add elements to the layout. Note that this
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);
- } else
+ el->setParentLayerable( this );
+ el->setParent( this );
+ if( !el->parentPlot() )
+ el->initializeParentPlot( mParentPlot );
+ }
+ else
qDebug() << Q_FUNC_INFO << "Null element passed";
}
/*! \internal
-
+
Disassociates \a el from this layout. This is done by setting the \ref QCPLayoutElement::layout
and the \ref QCPLayerable::parentLayerable to zero. The QObject parent is set to the parent
QCustomPlot.
-
+
This method is used by subclass specific methods that remove elements from the layout (e.g. \ref
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";
}
/*! \internal
-
+
This is a helper function for the implementation of \ref updateLayout in subclasses.
-
+
It calculates the sizes of one-dimensional sections with provided constraints on maximum section
sizes, minimum section sizes, relative stretch factors and the final total size of all sections.
-
+
The QVector entries refer to the sections. Thus all QVectors must have the same size.
-
+
\a maxSizes gives the maximum allowed size of each section. If there shall be no maximum size
imposed, set all vector values to Qt's QWIDGETSIZE_MAX.
-
+
\a minSizes gives the minimum allowed size of each section. If there shall be no minimum size
imposed, set all vector values to zero. If the \a minSizes entries add up to a value greater than
\a totalSize, sections will be scaled smaller than the proposed minimum sizes. (In other words,
not exceeding the allowed total size is taken to be more important than not going below minimum
section sizes.)
-
+
\a stretchFactors give the relative proportions of the sections to each other. If all sections
shall be scaled equally, set all values equal. If the first section shall be double the size of
each individual other section, set the first number of \a stretchFactors to double the value of
the other individual values (e.g. {2, 1, 1, 1}).
-
+
\a totalSize is the value that the final section sizes will add up to. Due to rounding, the
actual sum may differ slightly. If you want the section sizes to sum up to exactly that value,
you could distribute the remaining difference on the sections.
-
+
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 minimumLockedSections;
QList unfinishedSections;
- for (int i=0; i result(sectionCount);
- for (int i=0; i result( sectionCount );
+ for( int i = 0; i < sectionCount; ++i )
+ result[i] = qRound( sectionSizes.at( i ) );
return result;
}
-
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// QCPLayoutGrid
////////////////////////////////////////////////////////////////////////////////////////////////////
/*! \class QCPLayoutGrid
\brief A layout that arranges child elements in a grid
-
+
Elements are laid out in a grid with configurable stretch factors (\ref setColumnStretchFactor,
\ref setRowStretchFactor) and spacing (\ref setColumnSpacing, \ref setRowSpacing).
-
+
Elements can be added to cells via \ref addElement. The grid is expanded if the specified row or
column doesn't exist yet. Whether a cell contains a valid layout element can be checked with \ref
hasElement, that element can be retrieved with \ref element. If rows and columns that only have
empty cells shall be removed, call \ref simplify. Removal of elements is either done by just
adding the element to a different layout or by using the QCPLayout interface \ref take or \ref
remove.
-
+
Row and column insertion can be performed with \ref insertRow and \ref insertColumn.
*/
/*!
Creates an instance of QCPLayoutGrid and sets default values.
*/
-QCPLayoutGrid::QCPLayoutGrid() :
- mColumnSpacing(5),
- mRowSpacing(5)
+QCPLayoutGrid::QCPLayoutGrid() : mColumnSpacing( 5 ), mRowSpacing( 5 )
{
}
@@ -2627,32 +2620,34 @@ QCPLayoutGrid::~QCPLayoutGrid()
/*!
Returns the element in the cell in \a row and \a column.
-
+
Returns 0 if either the row/column is invalid or if the cell is empty. In those cases, a qDebug
message is printed. To check whether a cell exists and isn't empty, use \ref hasElement.
-
+
\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;
}
/*!
Returns the number of rows in the layout.
-
+
\see columnCount
*/
int QCPLayoutGrid::rowCount() const
@@ -2662,12 +2657,12 @@ int QCPLayoutGrid::rowCount() const
/*!
Returns the number of columns in the layout.
-
+
\see rowCount
*/
int QCPLayoutGrid::columnCount() const
{
- if (mElements.size() > 0)
+ if( mElements.size() > 0 )
return mElements.first().size();
else
return 0;
@@ -2677,27 +2672,29 @@ int QCPLayoutGrid::columnCount() const
Adds the \a element to cell with \a row and \a column. If \a element is already in a layout, it
is first removed from there. If \a row or \a column don't exist yet, the layout is expanded
accordingly.
-
+
Returns true if the element was added successfully, i.e. if the cell at \a row and \a column
didn't already have an element.
-
+
\see element, hasElement, take, remove
*/
-bool QCPLayoutGrid::addElement(int row, int column, QCPLayoutElement *element)
+bool QCPLayoutGrid::addElement( int row, int column, QCPLayoutElement* element )
{
- if (element)
+ if( element )
{
- if (!hasElement(row, column))
+ if( !hasElement( row, column ) )
{
- if (element->layout()) // remove from old layout first
- element->layout()->take(element);
- expandTo(row+1, column+1);
+ if( element->layout() ) // remove from old layout first
+ element->layout()->take( element );
+ expandTo( row + 1, column + 1 );
mElements[row][column] = element;
- adoptElement(element);
+ adoptElement( element );
return true;
- } else
+ }
+ else
qDebug() << Q_FUNC_INFO << "There is already an element in the specified row/column:" << row << column;
- } else
+ }
+ else
qDebug() << Q_FUNC_INFO << "Can't add null element to row/column:" << row << column;
return false;
}
@@ -2705,135 +2702,139 @@ bool QCPLayoutGrid::addElement(int row, int column, QCPLayoutElement *element)
/*!
Returns whether the cell at \a row and \a column exists and contains a valid element, i.e. isn't
empty.
-
+
\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;
}
/*!
Sets the stretch \a factor of \a column.
-
+
Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond
their minimum and maximum widths/heights (\ref QCPLayoutElement::setMinimumSize, \ref
QCPLayoutElement::setMaximumSize), regardless of the stretch factor.
-
+
The default stretch factor of newly created rows/columns is 1.
-
+
\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;
}
/*!
Sets the stretch \a factors of all columns. \a factors must have the size \ref columnCount.
-
+
Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond
their minimum and maximum widths/heights (\ref QCPLayoutElement::setMinimumSize, \ref
QCPLayoutElement::setMaximumSize), regardless of the stretch factor.
-
+
The default stretch factor of newly created rows/columns is 1.
-
+
\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= 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;
}
/*!
Sets the stretch \a factors of all rows. \a factors must have the size \ref rowCount.
-
+
Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond
their minimum and maximum widths/heights (\ref QCPLayoutElement::setMinimumSize, \ref
QCPLayoutElement::setMaximumSize), regardless of the stretch factor.
-
+
The default stretch factor of newly created rows/columns is 1.
-
+
\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.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())
+ if( newIndex > rowCount() )
newIndex = rowCount();
-
- mRowStretchFactors.insert(newIndex, 1);
+
+ mRowStretchFactors.insert( newIndex, 1 );
QList newRow;
- for (int col=0; col columnCount())
+ if( newIndex > columnCount() )
newIndex = columnCount();
-
- mColumnStretchFactors.insert(newIndex, 1);
- for (int row=0; row 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 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 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 ) ) );
}
}
}
@@ -2953,27 +2957,28 @@ void QCPLayoutGrid::updateLayout()
/* inherits documentation from base class */
int QCPLayoutGrid::elementCount() const
{
- return rowCount()*columnCount();
+ return rowCount() * columnCount();
}
/* inherits documentation from base class */
-QCPLayoutElement *QCPLayoutGrid::elementAt(int index) const
+QCPLayoutElement* QCPLayoutGrid::elementAt( int index ) const
{
- if (index >= 0 && index < elementCount())
- return mElements.at(index / columnCount()).at(index % columnCount());
+ if( index >= 0 && index < elementCount() )
+ return mElements.at( index / columnCount() ).at( index % columnCount() );
else
return 0;
}
/* inherits documentation from base class */
-QCPLayoutElement *QCPLayoutGrid::takeAt(int index)
+QCPLayoutElement* QCPLayoutGrid::takeAt( int index )
{
- if (QCPLayoutElement *el = elementAt(index))
+ if( QCPLayoutElement* el = elementAt( index ) )
{
- releaseElement(el);
+ releaseElement( el );
mElements[index / columnCount()][index % columnCount()] = 0;
return el;
- } else
+ }
+ else
{
qDebug() << Q_FUNC_INFO << "Attempt to take invalid index:" << index;
return 0;
@@ -2981,47 +2986,48 @@ 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 QCPLayoutGrid::elements(bool recursive) const
+QList QCPLayoutGrid::elements( bool recursive ) const
{
QList result;
int colC = columnCount();
int rowC = rowCount();
-#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
- result.reserve(colC*rowC);
+#if QT_VERSION >= QT_VERSION_CHECK( 4, 7, 0 )
+ result.reserve( colC * rowC );
#endif
- for (int row=0; rowelements(recursive);
+ if( result.at( i ) )
+ result << result.at( i )->elements( recursive );
}
}
return result;
@@ -3033,43 +3039,44 @@ 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=0; --col)
+ for( int col = columnCount() - 1; col >= 0; --col )
{
bool hasElements = false;
- for (int row=0; row minColWidths, minRowHeights;
- 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 *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( columnCount(), 0 );
+ *minRowHeights = QVector( rowCount(), 0 );
+ for( int row = 0; row < rowCount(); ++row )
{
- for (int col=0; colminimumSizeHint();
- QSize min = mElements.at(row).at(col)->minimumSize();
- QSize final(min.width() > 0 ? min.width() : minHint.width(), min.height() > 0 ? min.height() : minHint.height());
- if (minColWidths->at(col) < final.width())
- (*minColWidths)[col] = final.width();
- if (minRowHeights->at(row) < final.height())
- (*minRowHeights)[row] = final.height();
+ QSize minHint = mElements.at( row ).at( col )->minimumSizeHint();
+ QSize min = mElements.at( row ).at( col )->minimumSize();
+ QSize final( min.width() > 0 ? min.width() : minHint.width(),
+ min.height() > 0 ? min.height() : minHint.height() );
+ if( minColWidths->at( col ) < final.width() )
+ ( *minColWidths )[col] = final.width();
+ if( minRowHeights->at( row ) < final.height() )
+ ( *minRowHeights )[row] = final.height();
}
}
}
}
/*! \internal
-
+
Places the maximum column widths and row heights into \a maxColWidths and \a maxRowHeights
respectively.
-
+
The maximum height of a row is the smallest maximum height of any element in that row. The
maximum width of a column is the smallest maximum width of any element in that column.
-
+
This is a helper function for \ref updateLayout.
-
+
\see getMinimumRowColSizes
*/
-void QCPLayoutGrid::getMaximumRowColSizes(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( columnCount(), QWIDGETSIZE_MAX );
+ *maxRowHeights = QVector( rowCount(), QWIDGETSIZE_MAX );
+ for( int row = 0; row < rowCount(); ++row )
{
- for (int col=0; colmaximumSizeHint();
- QSize max = mElements.at(row).at(col)->maximumSize();
- QSize final(max.width() < QWIDGETSIZE_MAX ? max.width() : maxHint.width(), max.height() < QWIDGETSIZE_MAX ? max.height() : maxHint.height());
- if (maxColWidths->at(col) > final.width())
- (*maxColWidths)[col] = final.width();
- if (maxRowHeights->at(row) > final.height())
- (*maxRowHeights)[row] = final.height();
+ QSize maxHint = mElements.at( row ).at( col )->maximumSizeHint();
+ QSize max = mElements.at( row ).at( col )->maximumSize();
+ QSize final( max.width() < QWIDGETSIZE_MAX ? max.width() : maxHint.width(),
+ max.height() < QWIDGETSIZE_MAX ? max.height() : maxHint.height() );
+ if( maxColWidths->at( col ) > final.width() )
+ ( *maxColWidths )[col] = final.width();
+ if( maxRowHeights->at( row ) > final.height() )
+ ( *maxRowHeights )[row] = final.height();
}
}
}
}
-
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// QCPLayoutInset
////////////////////////////////////////////////////////////////////////////////////////////////////
/*! \class QCPLayoutInset
\brief A layout that places child elements aligned to the border or arbitrarily positioned
-
+
Elements are placed either aligned to the border or at arbitrary position in the area of the
layout. Which placement applies is controlled with the \ref InsetPlacement (\ref
setInsetPlacement).
@@ -3189,16 +3197,16 @@ void QCPLayoutGrid::getMaximumRowColSizes(QVector *maxColWidths, QVectorminimumSizeHint();
- QSize maxSizeHint = mElements.at(i)->maximumSizeHint();
- finalMinSize.setWidth(mElements.at(i)->minimumSize().width() > 0 ? mElements.at(i)->minimumSize().width() : minSizeHint.width());
- finalMinSize.setHeight(mElements.at(i)->minimumSize().height() > 0 ? mElements.at(i)->minimumSize().height() : minSizeHint.height());
- finalMaxSize.setWidth(mElements.at(i)->maximumSize().width() < QWIDGETSIZE_MAX ? mElements.at(i)->maximumSize().width() : maxSizeHint.width());
- finalMaxSize.setHeight(mElements.at(i)->maximumSize().height() < QWIDGETSIZE_MAX ? mElements.at(i)->maximumSize().height() : maxSizeHint.height());
- if (mInsetPlacement.at(i) == ipFree)
+ QSize minSizeHint = mElements.at( i )->minimumSizeHint();
+ QSize maxSizeHint = mElements.at( i )->maximumSizeHint();
+ finalMinSize.setWidth( mElements.at( i )->minimumSize().width() > 0 ? mElements.at( i )->minimumSize().width()
+ : minSizeHint.width() );
+ finalMinSize.setHeight( mElements.at( i )->minimumSize().height() > 0 ? mElements.at( i )->minimumSize().height()
+ : minSizeHint.height() );
+ finalMaxSize.setWidth( mElements.at( i )->maximumSize().width() < QWIDGETSIZE_MAX
+ ? mElements.at( i )->maximumSize().width()
+ : maxSizeHint.width() );
+ finalMaxSize.setHeight( mElements.at( i )->maximumSize().height() < QWIDGETSIZE_MAX
+ ? mElements.at( i )->maximumSize().height()
+ : maxSizeHint.height() );
+ if( mInsetPlacement.at( i ) == ipFree )
{
- 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 = 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() );
}
- mElements.at(i)->setOuterRect(insetRect);
+ 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
+ }
+ mElements.at( i )->setOuterRect( insetRect );
}
}
@@ -3360,26 +3382,27 @@ 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;
@@ -3387,20 +3410,21 @@ 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; 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;
}
@@ -3434,25 +3458,26 @@ double QCPLayoutInset::selectTest(const QPointF &pos, bool onlySelectable, QVari
Adds the specified \a element to the layout as an inset aligned at the border (\ref
setInsetAlignment is initialized with \ref ipBorderAligned). The alignment is set to \a
alignment.
-
+
\a alignment is an or combination of the following alignment flags: Qt::AlignLeft,
Qt::AlignHCenter, Qt::AlighRight, Qt::AlignTop, Qt::AlignVCenter, Qt::AlignBottom. Any other
alignment flags will be ignored.
-
+
\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";
}
@@ -3460,48 +3485,48 @@ void QCPLayoutInset::addElement(QCPLayoutElement *element, Qt::Alignment alignme
Adds the specified \a element to the layout as an inset with free positioning/sizing (\ref
setInsetAlignment is initialized with \ref ipFree). The position and size is set to \a
rect.
-
+
\a rect is given in fractions of the whole inset layout rect. So an inset with rect (0, 0, 1, 1)
will span the entire layout. An inset with rect (0.6, 0.1, 0.35, 0.35) will be in the top right
corner of the layout, with 35% width and height of the parent layout.
-
+
\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";
}
-
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// QCPLineEnding
////////////////////////////////////////////////////////////////////////////////////////////////////
/*! \class QCPLineEnding
\brief Handles the different ending decorations for line-like items
-
+
\image html QCPLineEnding.png "The various ending styles currently supported"
-
+
For every ending a line-like item has, an instance of this class exists. For example, QCPItemLine
has two endings which can be set with QCPItemLine::setHead and QCPItemLine::setTail.
-
+
The styles themselves are defined via the enum QCPLineEnding::EndingStyle. Most decorations can
be modified regarding width and length, see \ref setWidth and \ref setLength. The direction of
the ending decoration (e.g. direction an arrow is pointing) is controlled by the line-like item.
For example, when both endings of a QCPItemLine are set to be arrows, they will point to opposite
directions, e.g. "outward". This can be changed by \ref setInverted, which would make the
respective arrow point inward.
-
+
Note that due to the overloaded QCPLineEnding constructor, you may directly specify a
QCPLineEnding::EndingStyle where actually a QCPLineEnding is expected, e.g. \code
myItemLine->setHead(QCPLineEnding::esSpikeArrow) \endcode
@@ -3510,29 +3535,22 @@ 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;
}
@@ -3540,10 +3558,10 @@ void QCPLineEnding::setStyle(QCPLineEnding::EndingStyle style)
/*!
Sets the width of the ending decoration, if the style supports it. On arrows, for example, the
width defines the size perpendicular to the arrow's pointing direction.
-
+
\see setLength
*/
-void QCPLineEnding::setWidth(double width)
+void QCPLineEnding::setWidth( double width )
{
mWidth = width;
}
@@ -3551,10 +3569,10 @@ void QCPLineEnding::setWidth(double width)
/*!
Sets the length of the ending decoration, if the style supports it. On arrows, for example, the
length defines the size in pointing direction.
-
+
\see setWidth
*/
-void QCPLineEnding::setLength(double length)
+void QCPLineEnding::setLength( double length )
{
mLength = length;
}
@@ -3567,40 +3585,39 @@ 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;
}
/*! \internal
-
+
Returns the maximum pixel radius the ending decoration might cover, starting from the position
the decoration is drawn at (typically a line ending/\ref QCPItemPosition of an item).
-
+
This is relevant for clipping. Only omit painting of the decoration when the position where the
decoration is supposed to be drawn is farther away from the clipping rect than the returned
distance.
*/
double QCPLineEnding::boundingDistance() const
{
- switch (mStyle)
+ switch( mStyle )
{
case esNone:
return 0;
-
+
case esFlatArrow:
case esSpikeArrow:
case esLineArrow:
case esSkewedBar:
- return qSqrt(mWidth*mWidth+mLength*mLength); // items that have width and length
-
+ 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 mWidth * 1.42; // items that only have a width -> width*sqrt(2)
}
return 0;
}
@@ -3608,17 +3625,17 @@ double QCPLineEnding::boundingDistance() const
/*!
Starting from the origin of this line ending (which is style specific), returns the length
covered by the line ending symbol, in backward direction.
-
+
For example, the \ref esSpikeArrow has a shorter real length than a \ref esFlatArrow, even if
both have the same \ref setLength value, because the spike arrow has an inward curved back, which
reduces the length along its center axis (the drawing origin for arrows is at the tip).
-
+
This function is used for precise, style specific placement of line endings, for example in
QCPAxes.
*/
double QCPLineEnding::realLength() const
{
- switch (mStyle)
+ switch( mStyle )
{
case esNone:
case esLineArrow:
@@ -3626,143 +3643,138 @@ double QCPLineEnding::realLength() const
case esBar:
case esHalfBar:
return 0;
-
+
case esFlatArrow:
return mLength;
-
+
case esDisc:
case esSquare:
case esDiamond:
- return mWidth*0.5;
-
+ return mWidth * 0.5;
+
case esSpikeArrow:
- return mLength*0.8;
+ return mLength * 0.8;
}
return 0;
}
/*! \internal
-
+
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 QVector2D &pos, const QVector2D &dir) const
+void QCPLineEnding::draw( QCPPainter* painter, const QVector2D& pos, const QVector2D& dir ) const
{
- if (mStyle == esNone)
+ if( mStyle == esNone )
return;
-
- QVector2D lengthVec(dir.normalized());
- if (lengthVec.isNull())
- lengthVec = QVector2D(1, 0);
- QVector2D widthVec(-lengthVec.y(), lengthVec.x());
- lengthVec *= (float)(mLength*(mInverted ? -1 : 1));
- widthVec *= (float)(mWidth*0.5*(mInverted ? -1 : 1));
-
+
+ QVector2D lengthVec( dir.normalized() );
+ if( lengthVec.isNull() )
+ lengthVec = QVector2D( 1, 0 );
+ QVector2D widthVec( -lengthVec.y(), lengthVec.x() );
+ lengthVec *= (float)( mLength * ( mInverted ? -1 : 1 ) );
+ widthVec *= (float)( 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 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);
+ 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.8f).toPointF(),
- (pos-lengthVec-widthVec).toPointF()
- };
- painter->setPen(miterPen);
- painter->setBrush(brush);
- painter->drawConvexPolygon(points, 4);
- painter->setBrush(brushBackup);
- painter->setPen(penBackup);
+ QPointF points[4] = {pos.toPointF(), ( pos - lengthVec + widthVec ).toPointF(),
+ ( pos - lengthVec * 0.8f ).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);
+ 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);
+ painter->setBrush( brush );
+ painter->drawEllipse( pos.toPointF(), mWidth * 0.5, mWidth * 0.5 );
+ painter->setBrush( brushBackup );
break;
}
case esSquare:
{
- QVector2D widthVecPerp(-widthVec.y(), widthVec.x());
- 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);
+ QVector2D widthVecPerp( -widthVec.y(), widthVec.x() );
+ 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:
{
- QVector2D widthVecPerp(-widthVec.y(), widthVec.x());
- 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);
+ QVector2D widthVecPerp( -widthVec.y(), widthVec.x() );
+ 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());
+ painter->drawLine( ( pos + widthVec ).toPointF(), ( pos - widthVec ).toPointF() );
break;
}
case esHalfBar:
{
- painter->drawLine((pos+widthVec).toPointF(), pos.toPointF());
+ painter->drawLine( ( pos + widthVec ).toPointF(), pos.toPointF() );
break;
}
case esSkewedBar:
{
- if (qFuzzyIsNull(painter->pen().widthF()) && !painter->modes().testFlag(QCPPainter::pmNonCosmetic))
+ 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.2f*(mInverted?-1:1)).toPointF(),
- (pos-widthVec-lengthVec*0.2f*(mInverted?-1:1)).toPointF());
- } else
+ // 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.2f * ( mInverted ? -1 : 1 ) ).toPointF(),
+ ( pos - widthVec - lengthVec * 0.2f * ( 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.2f*(mInverted?-1:1)+dir.normalized()*qMax(1.0f, (float)painter->pen().widthF())*0.5f).toPointF(),
- (pos-widthVec-lengthVec*0.2f*(mInverted?-1:1)+dir.normalized()*qMax(1.0f, (float)painter->pen().widthF())*0.5f).toPointF());
+ // 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.2f * ( mInverted ? -1 : 1 ) +
+ dir.normalized() * qMax( 1.0f, (float)painter->pen().widthF() ) * 0.5f )
+ .toPointF(),
+ ( pos - widthVec - lengthVec * 0.2f * ( mInverted ? -1 : 1 ) +
+ dir.normalized() * qMax( 1.0f, (float)painter->pen().widthF() ) * 0.5f )
+ .toPointF() );
}
break;
}
@@ -3771,26 +3783,25 @@ void QCPLineEnding::draw(QCPPainter *painter, const QVector2D &pos, const QVecto
/*! \internal
\overload
-
+
Draws the line ending. The direction is controlled with the \a angle parameter in radians.
*/
-void QCPLineEnding::draw(QCPPainter *painter, const QVector2D &pos, double angle) const
+void QCPLineEnding::draw( QCPPainter* painter, const QVector2D& pos, double angle ) const
{
- draw(painter, pos, QVector2D(qCos(angle), qSin(angle)));
+ draw( painter, pos, QVector2D( qCos( angle ), qSin( angle ) ) );
}
-
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// QCPGrid
////////////////////////////////////////////////////////////////////////////////////////////////////
/*! \class QCPGrid
\brief Responsible for drawing the grid of a QCPAxis.
-
+
This class is tightly bound to QCPAxis. Every axis owns a grid instance and uses it to draw the
grid lines, sub grid lines and zero-line. You can interact with the grid of an axis via \ref
QCPAxis::grid. Normally, you don't need to create an instance of QCPGrid yourself.
-
+
The axis and grid drawing was split into two classes to allow them to be placed on different
layers (both QCPAxis and QCPGrid inherit from QCPLayerable). Thus it is possible to have the grid
in the background and the axes in the foreground, and any plottables/items in between. This
@@ -3799,30 +3810,29 @@ void QCPLineEnding::draw(QCPPainter *painter, const QVector2D &pos, double angle
/*!
Creates a QCPGrid instance and sets default values.
-
+
You shouldn't instantiate grids on their own, since every QCPAxis brings its own QCPGrid.
*/
-QCPGrid::QCPGrid(QCPAxis *parentAxis) :
- QCPLayerable(parentAxis->parentPlot(), "", parentAxis),
- mParentAxis(parentAxis)
+QCPGrid::QCPGrid( QCPAxis* parentAxis )
+ : QCPLayerable( parentAxis->parentPlot(), "", 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 );
}
/*!
Sets whether grid lines at sub tick marks are drawn.
-
+
\see setSubGridPen
*/
-void QCPGrid::setSubGridVisible(bool visible)
+void QCPGrid::setSubGridVisible( bool visible )
{
mSubGridVisible = visible;
}
@@ -3830,7 +3840,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;
}
@@ -3838,7 +3848,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;
}
@@ -3846,7 +3856,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;
}
@@ -3854,18 +3864,18 @@ 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;
}
/*!
Sets the pen with which zero lines are drawn.
-
+
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;
}
@@ -3876,137 +3886,152 @@ void QCPGrid::setZeroLinePen(const QPen &pen)
before drawing the major grid lines.
This is the antialiasing state the painter passed to the \ref draw method is in by default.
-
+
This function takes into account the local setting of the antialiasing flag as well as the
overrides set with \ref QCustomPlot::setAntialiasedElements and \ref
QCustomPlot::setNotAntialiasedElements.
-
+
\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
-
+
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 (mSubGridVisible)
- drawSubGridLines(painter);
- drawGridLines(painter);
+ if( !mParentAxis )
+ {
+ qDebug() << Q_FUNC_INFO << "invalid parent axis";
+ return;
+ }
+
+ if( mSubGridVisible )
+ drawSubGridLines( painter );
+ drawGridLines( painter );
}
/*! \internal
-
+
Draws the main grid lines and possibly a zero line with the specified 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;
+ }
+
int lowTick = mParentAxis->mLowestVisibleTick;
int highTick = mParentAxis->mHighestVisibleTick;
- 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=lowTick; i <= highTick; ++i)
+ applyAntialiasingHint( painter, mAntialiasedZeroLine, QCP::aeZeroLine );
+ painter->setPen( mZeroLinePen );
+ double epsilon = mParentAxis->range().size() * 1E-6; // for comparing double to zero
+ for( int i = lowTick; i <= highTick; ++i )
{
- if (qAbs(mParentAxis->mTickVector.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=lowTick; i <= highTick; ++i)
+ applyDefaultAntialiasingHint( painter );
+ painter->setPen( mPen );
+ for( int i = lowTick; i <= highTick; ++i )
{
- 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()));
+ 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=lowTick; i <= highTick; ++i)
+ applyAntialiasingHint( painter, mAntialiasedZeroLine, QCP::aeZeroLine );
+ painter->setPen( mZeroLinePen );
+ double epsilon = mParentAxis->mRange.size() * 1E-6; // for comparing double to zero
+ for( int i = lowTick; i <= highTick; ++i )
{
- if (qAbs(mParentAxis->mTickVector.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=lowTick; i <= highTick; ++i)
+ applyDefaultAntialiasingHint( painter );
+ painter->setPen( mPen );
+ for( int i = lowTick; i <= highTick; ++i )
{
- if (i == zeroLineIndex) continue; // don't draw a gridline on top of the zeroline
- t = mParentAxis->coordToPixel(mParentAxis->mTickVector.at(i)); // y
- painter->drawLine(QLineF(mParentAxis->mAxisRect->left(), t, mParentAxis->mAxisRect->right(), t));
+ if( i == zeroLineIndex )
+ continue; // don't draw a gridline on top of the zeroline
+ t = mParentAxis->coordToPixel( mParentAxis->mTickVector.at( i ) ); // y
+ painter->drawLine( QLineF( mParentAxis->mAxisRect->left(), t, mParentAxis->mAxisRect->right(), t ) );
}
}
}
/*! \internal
-
+
Draws the sub grid lines with the specified painter.
-
+
This is a helper function called by \ref draw.
*/
-void QCPGrid::drawSubGridLines(QCPPainter *painter) const
+void QCPGrid::drawSubGridLines( QCPPainter* painter ) const
{
- if (!mParentAxis) { qDebug() << Q_FUNC_INFO << "invalid parent axis"; return; }
-
- applyAntialiasingHint(painter, mAntialiasedSubGrid, QCP::aeSubGrid);
- double t; // helper variable, result of coordinate-to-pixel transforms
- painter->setPen(mSubGridPen);
- if (mParentAxis->orientation() == Qt::Horizontal)
+ if( !mParentAxis )
{
- for (int i=0; imSubTickVector.size(); ++i)
+ qDebug() << Q_FUNC_INFO << "invalid parent axis";
+ return;
+ }
+
+ applyAntialiasingHint( painter, mAntialiasedSubGrid, QCP::aeSubGrid );
+ double t; // helper variable, result of coordinate-to-pixel transforms
+ painter->setPen( mSubGridPen );
+ if( mParentAxis->orientation() == Qt::Horizontal )
+ {
+ for( int i = 0; i < mParentAxis->mSubTickVector.size(); ++i )
{
- t = mParentAxis->coordToPixel(mParentAxis->mSubTickVector.at(i)); // x
- painter->drawLine(QLineF(t, mParentAxis->mAxisRect->bottom(), t, mParentAxis->mAxisRect->top()));
+ t = mParentAxis->coordToPixel( mParentAxis->mSubTickVector.at( i ) ); // x
+ painter->drawLine( QLineF( t, mParentAxis->mAxisRect->bottom(), t, mParentAxis->mAxisRect->top() ) );
}
- } else
+ }
+ else
{
- for (int i=0; imSubTickVector.size(); ++i)
+ for( int i = 0; i < mParentAxis->mSubTickVector.size(); ++i )
{
- t = mParentAxis->coordToPixel(mParentAxis->mSubTickVector.at(i)); // y
- painter->drawLine(QLineF(mParentAxis->mAxisRect->left(), t, mParentAxis->mAxisRect->right(), t));
+ t = mParentAxis->coordToPixel( mParentAxis->mSubTickVector.at( i ) ); // y
+ painter->drawLine( QLineF( mParentAxis->mAxisRect->left(), t, mParentAxis->mAxisRect->right(), t ) );
}
}
}
-
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// QCPAxis
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -4017,12 +4042,12 @@ void QCPGrid::drawSubGridLines(QCPPainter *painter) const
Usually doesn't need to be instantiated externally. Access %QCustomPlot's default four axes via
QCustomPlot::xAxis (bottom), QCustomPlot::yAxis (left), QCustomPlot::xAxis2 (top) and
QCustomPlot::yAxis2 (right).
-
+
Axes are always part of an axis rect, see QCPAxisRect.
\image html AxisNamesOverview.png
Naming convention of axis parts
\n
-
+
\image html AxisRectSpacingOverview.png
Overview of the spacings and paddings that define the geometry of an axis. The dashed gray line
on the left represents the QCustomPlot widget border.
@@ -4032,23 +4057,23 @@ void QCPGrid::drawSubGridLines(QCPPainter *painter) const
/* start of documentation of inline functions */
/*! \fn Qt::Orientation QCPAxis::orientation() const
-
+
Returns the orientation of this axis. The axis orientation (horizontal or vertical) is deduced
from the axis type (left, top, right or bottom).
-
+
\see orientation(AxisType type)
*/
/*! \fn QCPGrid *QCPAxis::grid() const
-
+
Returns the \ref QCPGrid instance belonging to this axis. Access it to set details about the way the
grid is displayed.
*/
/*! \fn static Qt::Orientation QCPAxis::orientation(AxisType type)
-
+
Returns the orientation of the specified axis type
-
+
\see orientation()
*/
@@ -4056,14 +4081,14 @@ void QCPGrid::drawSubGridLines(QCPPainter *painter) const
/* start of documentation of signals */
/*! \fn void QCPAxis::ticksRequest()
-
+
This signal is emitted when \ref setAutoTicks is false and the axis is about to generate tick
labels for a replot.
-
+
Modifying the tick positions can be done with \ref setTickVector. If you also want to control the
tick labels, set \ref setAutoTickLabels to false and also provide the labels with \ref
setTickVectorLabels.
-
+
If you only want static ticks you probably don't need this signal, since you can just set the
tick vector (and possibly tick label vector) once. However, if you want to provide ticks (and
maybe labels) dynamically, e.g. depending on the current axis range, connect a slot to this
@@ -4079,24 +4104,24 @@ void QCPGrid::drawSubGridLines(QCPPainter *painter) const
/*! \fn void QCPAxis::rangeChanged(const QCPRange &newRange, const QCPRange &oldRange)
\overload
-
+
Additionally to the new range, this signal also provides the previous range held by the axis as
\a oldRange.
*/
/*! \fn void QCPAxis::scaleTypeChanged(QCPAxis::ScaleType scaleType);
-
+
This signal is emitted when the scale type changes, by calls to \ref setScaleType
*/
/*! \fn void QCPAxis::selectionChanged(QCPAxis::SelectableParts selection)
-
+
This signal is emitted when the selection state of this axis has changed, either by user interaction
or by a direct call to \ref setSelectedParts.
*/
/*! \fn void QCPAxis::selectableChanged(const QCPAxis::SelectableParts &parts);
-
+
This signal is emitted when the selectability changes, by calls to \ref setSelectableParts
*/
@@ -4106,82 +4131,86 @@ void QCPGrid::drawSubGridLines(QCPPainter *painter) const
Constructs an Axis instance of Type \a type for the axis rect \a parent.
You shouldn't instantiate axes directly, rather use \ref QCPAxisRect::addAxis.
*/
-QCPAxis::QCPAxis(QCPAxisRect *parent, AxisType type) :
- QCPLayerable(parent->parentPlot(), "", parent),
- // axis base:
- mAxisType(type),
- mAxisRect(parent),
- mPadding(5),
- mOrientation(orientation(type)),
- mSelectableParts(spAxis | spTickLabels | spAxisLabel),
- mSelectedParts(spNone),
- mBasePen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
- mSelectedBasePen(QPen(Qt::blue, 2)),
- // axis label:
- mLabel(""),
- mLabelFont(mParentPlot->font()),
- mSelectedLabelFont(QFont(mLabelFont.family(), mLabelFont.pointSize(), QFont::Bold)),
- mLabelColor(Qt::black),
- mSelectedLabelColor(Qt::blue),
- // tick labels:
- mTickLabels(true),
- mAutoTickLabels(true),
- mTickLabelType(ltNumber),
- mTickLabelFont(mParentPlot->font()),
- mSelectedTickLabelFont(QFont(mTickLabelFont.family(), mTickLabelFont.pointSize(), QFont::Bold)),
- mTickLabelColor(Qt::black),
- mSelectedTickLabelColor(Qt::blue),
- mDateTimeFormat("hh:mm:ss\ndd.MM.yy"),
- mDateTimeSpec(Qt::LocalTime),
- mNumberPrecision(6),
- mNumberFormatChar('g'),
- mNumberBeautifulPowers(true),
- // ticks and subticks:
- mTicks(true),
- mTickStep(1),
- mSubTickCount(4),
- mAutoTickCount(6),
- mAutoTicks(true),
- mAutoTickStep(true),
- mAutoSubTicks(true),
- mTickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
- mSelectedTickPen(QPen(Qt::blue, 2)),
- mSubTickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
- mSelectedSubTickPen(QPen(Qt::blue, 2)),
- // scale and range:
- mRange(0, 5),
- mRangeReversed(false),
- mScaleType(stLinear),
- mScaleLogBase(10),
- mScaleLogBaseLogInv(1.0/qLn(mScaleLogBase)),
- // internal members:
- mGrid(new QCPGrid(this)),
- mAxisPainter(new QCPAxisPainterPrivate(parent->parentPlot())),
- mLowestVisibleTick(0),
- mHighestVisibleTick(-1),
- mCachedMarginValid(false),
- mCachedMargin(0)
+QCPAxis::QCPAxis( QCPAxisRect* parent, AxisType type )
+ : QCPLayerable( parent->parentPlot(), "", parent ),
+ // axis base:
+ mAxisType( type ),
+ mAxisRect( parent ),
+ mPadding( 5 ),
+ mOrientation( orientation( type ) ),
+ mSelectableParts( spAxis | spTickLabels | spAxisLabel ),
+ mSelectedParts( spNone ),
+ mBasePen( QPen( Qt::black, 0, Qt::SolidLine, Qt::SquareCap ) ),
+ mSelectedBasePen( QPen( Qt::blue, 2 ) ),
+ // axis label:
+ mLabel( "" ),
+ mLabelFont( mParentPlot->font() ),
+ mSelectedLabelFont( QFont( mLabelFont.family(), mLabelFont.pointSize(), QFont::Bold ) ),
+ mLabelColor( Qt::black ),
+ mSelectedLabelColor( Qt::blue ),
+ // tick labels:
+ mTickLabels( true ),
+ mAutoTickLabels( true ),
+ mTickLabelType( ltNumber ),
+ mTickLabelFont( mParentPlot->font() ),
+ mSelectedTickLabelFont( QFont( mTickLabelFont.family(), mTickLabelFont.pointSize(), QFont::Bold ) ),
+ mTickLabelColor( Qt::black ),
+ mSelectedTickLabelColor( Qt::blue ),
+ mDateTimeFormat( "hh:mm:ss\ndd.MM.yy" ),
+ mDateTimeSpec( Qt::LocalTime ),
+ mNumberPrecision( 6 ),
+ mNumberFormatChar( 'g' ),
+ mNumberBeautifulPowers( true ),
+ // ticks and subticks:
+ mTicks( true ),
+ mTickStep( 1 ),
+ mSubTickCount( 4 ),
+ mAutoTickCount( 6 ),
+ mAutoTicks( true ),
+ mAutoTickStep( true ),
+ mAutoSubTicks( true ),
+ mTickPen( QPen( Qt::black, 0, Qt::SolidLine, Qt::SquareCap ) ),
+ mSelectedTickPen( QPen( Qt::blue, 2 ) ),
+ mSubTickPen( QPen( Qt::black, 0, Qt::SolidLine, Qt::SquareCap ) ),
+ mSelectedSubTickPen( QPen( Qt::blue, 2 ) ),
+ // scale and range:
+ mRange( 0, 5 ),
+ mRangeReversed( false ),
+ mScaleType( stLinear ),
+ mScaleLogBase( 10 ),
+ mScaleLogBaseLogInv( 1.0 / qLn( mScaleLogBase ) ),
+ // internal members:
+ mGrid( new QCPGrid( this ) ),
+ mAxisPainter( new QCPAxisPainterPrivate( parent->parentPlot() ) ),
+ mLowestVisibleTick( 0 ),
+ mHighestVisibleTick( -1 ),
+ mCachedMarginValid( false ),
+ mCachedMargin( 0 )
{
- mGrid->setVisible(false);
- setAntialiased(false);
- setLayer(mParentPlot->currentLayer()); // it's actually on that layer already, but we want it in front of the grid, so we place it on there again
-
- if (type == atTop)
+ mGrid->setVisible( false );
+ setAntialiased( false );
+ setLayer( mParentPlot->currentLayer() ); // it's actually on that layer already, but we want it in front of the grid,
+ // so we place it on there again
+
+ if( type == atTop )
{
- setTickLabelPadding(3);
- setLabelPadding(6);
- } else if (type == atRight)
+ setTickLabelPadding( 3 );
+ setLabelPadding( 6 );
+ }
+ else if( type == atRight )
{
- setTickLabelPadding(7);
- setLabelPadding(12);
- } else if (type == atBottom)
+ setTickLabelPadding( 7 );
+ setLabelPadding( 12 );
+ }
+ else if( type == atBottom )
{
- setTickLabelPadding(3);
- setLabelPadding(3);
- } else if (type == atLeft)
+ setTickLabelPadding( 3 );
+ setLabelPadding( 3 );
+ }
+ else if( type == atLeft )
{
- setTickLabelPadding(5);
- setLabelPadding(10);
+ setTickLabelPadding( 5 );
+ setLabelPadding( 10 );
}
}
@@ -4206,12 +4235,12 @@ double QCPAxis::tickLabelRotation() const
QString QCPAxis::numberFormat() const
{
QString result;
- result.append(mNumberFormatChar);
- if (mNumberBeautifulPowers)
+ result.append( mNumberFormatChar );
+ if( mNumberBeautifulPowers )
{
- result.append("b");
- if (mAxisPainter->numberMultiplyCross)
- result.append("c");
+ result.append( "b" );
+ if( mAxisPainter->numberMultiplyCross )
+ result.append( "c" );
}
return result;
}
@@ -4270,208 +4299,215 @@ QCPLineEnding QCPAxis::upperEnding() const
scaling, major tick marks appear at all powers of the logarithm base. Properties like tick step
(\ref setTickStep) don't apply in logarithmic scaling. If you wish a decimal base but less major
ticks, consider choosing a logarithm base of 100, 1000 or even higher.
-
+
If \a type is \ref stLogarithmic and the number format (\ref setNumberFormat) uses the 'b' option
(beautifully typeset decimal powers), the display usually is "1 [multiplication sign] 10
[superscript] n", which looks unnatural for logarithmic scaling (the "1 [multiplication sign]"
part). To only display the decimal power, set the number precision to zero with
\ref setNumberPrecision.
*/
-void QCPAxis::setScaleType(QCPAxis::ScaleType type)
+void QCPAxis::setScaleType( QCPAxis::ScaleType type )
{
- if (mScaleType != type)
+ if( mScaleType != type )
{
mScaleType = type;
- if (mScaleType == stLogarithmic)
- setRange(mRange.sanitizedForLogScale());
+ if( mScaleType == stLogarithmic )
+ setRange( mRange.sanitizedForLogScale() );
mCachedMarginValid = false;
- emit scaleTypeChanged(mScaleType);
+ emit scaleTypeChanged( mScaleType );
}
}
/*!
If \ref setScaleType is set to \ref stLogarithmic, \a base will be the logarithm base of the
scaling. In logarithmic axis scaling, major tick marks appear at all powers of \a base.
-
+
Properties like tick step (\ref setTickStep) don't apply in logarithmic scaling. If you wish a decimal base but
less major ticks, consider choosing \a base 100, 1000 or even higher.
*/
-void QCPAxis::setScaleLogBase(double base)
+void QCPAxis::setScaleLogBase( double base )
{
- if (base > 1)
+ if( base > 1 )
{
mScaleLogBase = base;
- mScaleLogBaseLogInv = 1.0/qLn(mScaleLogBase); // buffer for faster baseLog() calculation
+ mScaleLogBaseLogInv = 1.0 / qLn( mScaleLogBase ); // buffer for faster baseLog() calculation
mCachedMarginValid = false;
- } else
+ }
+ else
qDebug() << Q_FUNC_INFO << "Invalid logarithmic scale base (must be greater 1):" << base;
}
/*!
Sets the range of the axis.
-
+
This slot may be connected with the \ref rangeChanged signal of another axis so this axis
is always synchronized with the other axis range, when it changes.
-
+
To invert the direction of an axis, use \ref setRangeReversed.
*/
-void QCPAxis::setRange(const QCPRange &range)
+void QCPAxis::setRange( const QCPRange& range )
{
- if (range.lower == mRange.lower && range.upper == mRange.upper)
+ if( range.lower == mRange.lower && range.upper == mRange.upper )
+ return;
+
+ if( !QCPRange::validRange( range ) )
return;
-
- if (!QCPRange::validRange(range)) return;
QCPRange oldRange = mRange;
- if (mScaleType == stLogarithmic)
+ if( mScaleType == stLogarithmic )
{
mRange = range.sanitizedForLogScale();
- } else
+ }
+ else
{
mRange = range.sanitizedForLinScale();
}
mCachedMarginValid = false;
- emit rangeChanged(mRange);
- emit rangeChanged(mRange, oldRange);
+ emit rangeChanged( mRange );
+ emit rangeChanged( mRange, oldRange );
}
/*!
Sets whether the user can (de-)select the parts in \a selectable by clicking on the QCustomPlot surface.
(When \ref QCustomPlot::setInteractions contains iSelectAxes.)
-
+
However, even when \a selectable is set to a value not allowing the selection of a specific part,
it is still possible to set the selection of this part manually, by calling \ref setSelectedParts
directly.
-
+
\see SelectablePart, setSelectedParts
*/
-void QCPAxis::setSelectableParts(const SelectableParts &selectable)
+void QCPAxis::setSelectableParts( const SelectableParts& selectable )
{
- if (mSelectableParts != selectable)
+ if( mSelectableParts != selectable )
{
mSelectableParts = selectable;
- emit selectableChanged(mSelectableParts);
+ emit selectableChanged( mSelectableParts );
}
}
/*!
Sets the selected state of the respective axis parts described by \ref SelectablePart. When a part
is selected, it uses a different pen/font.
-
+
The entire selection mechanism for axes is handled automatically when \ref
QCustomPlot::setInteractions contains iSelectAxes. You only need to call this function when you
wish to change the selection state manually.
-
+
This function can change the selection state of a part, independent of the \ref setSelectableParts setting.
-
+
emits the \ref selectionChanged signal when \a selected is different from the previous selection state.
-
+
\see SelectablePart, setSelectableParts, selectTest, setSelectedBasePen, setSelectedTickPen, setSelectedSubTickPen,
setSelectedTickLabelFont, setSelectedLabelFont, setSelectedTickLabelColor, setSelectedLabelColor
*/
-void QCPAxis::setSelectedParts(const SelectableParts &selected)
+void QCPAxis::setSelectedParts( const SelectableParts& selected )
{
- if (mSelectedParts != selected)
+ if( mSelectedParts != selected )
{
mSelectedParts = selected;
- emit selectionChanged(mSelectedParts);
+ emit selectionChanged( mSelectedParts );
}
}
/*!
\overload
-
+
Sets the lower and upper bound of the axis range.
-
+
To invert the direction of an axis, use \ref setRangeReversed.
-
+
There is also a slot to set a range, see \ref setRange(const QCPRange &range).
*/
-void QCPAxis::setRange(double lower, double upper)
+void QCPAxis::setRange( double lower, double upper )
{
- if (lower == mRange.lower && upper == mRange.upper)
+ if( lower == mRange.lower && upper == mRange.upper )
+ return;
+
+ if( !QCPRange::validRange( lower, upper ) )
return;
-
- if (!QCPRange::validRange(lower, upper)) return;
QCPRange oldRange = mRange;
mRange.lower = lower;
mRange.upper = upper;
- if (mScaleType == stLogarithmic)
+ if( mScaleType == stLogarithmic )
{
mRange = mRange.sanitizedForLogScale();
- } else
+ }
+ else
{
mRange = mRange.sanitizedForLinScale();
}
mCachedMarginValid = false;
- emit rangeChanged(mRange);
- emit rangeChanged(mRange, oldRange);
+ emit rangeChanged( mRange );
+ emit rangeChanged( mRange, oldRange );
}
/*!
\overload
-
+
Sets the range of the axis.
-
+
The \a position coordinate indicates together with the \a alignment parameter, where the new
range will be positioned. \a size defines the size of the new axis range. \a alignment may be
Qt::AlignLeft, Qt::AlignRight or Qt::AlignCenter. This will cause the left border, right border,
or center of the range to be aligned with \a position. Any other values of \a alignment will
default to Qt::AlignCenter.
*/
-void QCPAxis::setRange(double position, double size, Qt::AlignmentFlag alignment)
+void QCPAxis::setRange( double position, double size, Qt::AlignmentFlag alignment )
{
- if (alignment == Qt::AlignLeft)
- setRange(position, position+size);
- else if (alignment == Qt::AlignRight)
- setRange(position-size, position);
- else // alignment == Qt::AlignCenter
- setRange(position-size/2.0, position+size/2.0);
+ if( alignment == Qt::AlignLeft )
+ setRange( position, position + size );
+ else if( alignment == Qt::AlignRight )
+ setRange( position - size, position );
+ else // alignment == Qt::AlignCenter
+ setRange( position - size / 2.0, position + size / 2.0 );
}
/*!
Sets the lower bound of the axis range. The upper bound is not changed.
\see setRange
*/
-void QCPAxis::setRangeLower(double lower)
+void QCPAxis::setRangeLower( double lower )
{
- if (mRange.lower == lower)
+ if( mRange.lower == lower )
return;
-
+
QCPRange oldRange = mRange;
mRange.lower = lower;
- if (mScaleType == stLogarithmic)
+ if( mScaleType == stLogarithmic )
{
mRange = mRange.sanitizedForLogScale();
- } else
+ }
+ else
{
mRange = mRange.sanitizedForLinScale();
}
mCachedMarginValid = false;
- emit rangeChanged(mRange);
- emit rangeChanged(mRange, oldRange);
+ emit rangeChanged( mRange );
+ emit rangeChanged( mRange, oldRange );
}
/*!
Sets the upper bound of the axis range. The lower bound is not changed.
\see setRange
*/
-void QCPAxis::setRangeUpper(double upper)
+void QCPAxis::setRangeUpper( double upper )
{
- if (mRange.upper == upper)
+ if( mRange.upper == upper )
return;
-
+
QCPRange oldRange = mRange;
mRange.upper = upper;
- if (mScaleType == stLogarithmic)
+ if( mScaleType == stLogarithmic )
{
mRange = mRange.sanitizedForLogScale();
- } else
+ }
+ else
{
mRange = mRange.sanitizedForLinScale();
}
mCachedMarginValid = false;
- emit rangeChanged(mRange);
- emit rangeChanged(mRange, oldRange);
+ emit rangeChanged( mRange );
+ emit rangeChanged( mRange, oldRange );
}
/*!
@@ -4483,9 +4519,9 @@ void QCPAxis::setRangeUpper(double upper)
of the \ref setRange interface will still reference the mathematically smaller number than the \a
upper part.
*/
-void QCPAxis::setRangeReversed(bool reversed)
+void QCPAxis::setRangeReversed( bool reversed )
{
- if (mRangeReversed != reversed)
+ if( mRangeReversed != reversed )
{
mRangeReversed = reversed;
mCachedMarginValid = false;
@@ -4495,21 +4531,21 @@ void QCPAxis::setRangeReversed(bool reversed)
/*!
Sets whether the tick positions should be calculated automatically (either from an automatically
generated tick step or a tick step provided manually via \ref setTickStep, see \ref setAutoTickStep).
-
+
If \a on is set to false, you must provide the tick positions manually via \ref setTickVector.
For these manual ticks you may let QCPAxis generate the appropriate labels automatically by
leaving \ref setAutoTickLabels set to true. If you also wish to control the displayed labels
manually, set \ref setAutoTickLabels to false and provide the label strings with \ref
setTickVectorLabels.
-
+
If you need dynamically calculated tick vectors (and possibly tick label vectors), set the
vectors in a slot connected to the \ref ticksRequest signal.
-
+
\see setAutoTickLabels, setAutoSubTicks, setAutoTickCount, setAutoTickStep
*/
-void QCPAxis::setAutoTicks(bool on)
+void QCPAxis::setAutoTicks( bool on )
{
- if (mAutoTicks != on)
+ if( mAutoTicks != on )
{
mAutoTicks = on;
mCachedMarginValid = false;
@@ -4519,23 +4555,24 @@ void QCPAxis::setAutoTicks(bool on)
/*!
When \ref setAutoTickStep is true, \a approximateCount determines how many ticks should be
generated in the visible range, approximately.
-
+
It's not guaranteed that this number of ticks is met exactly, but approximately within a
tolerance of about two.
-
+
Only values greater than zero are accepted as \a approximateCount.
-
+
\see setAutoTickStep, setAutoTicks, setAutoSubTicks
*/
-void QCPAxis::setAutoTickCount(int approximateCount)
+void QCPAxis::setAutoTickCount( int approximateCount )
{
- if (mAutoTickCount != approximateCount)
+ if( mAutoTickCount != approximateCount )
{
- if (approximateCount > 0)
+ if( approximateCount > 0 )
{
mAutoTickCount = approximateCount;
mCachedMarginValid = false;
- } else
+ }
+ else
qDebug() << Q_FUNC_INFO << "approximateCount must be greater than zero:" << approximateCount;
}
}
@@ -4544,20 +4581,20 @@ void QCPAxis::setAutoTickCount(int approximateCount)
Sets whether the tick labels are generated automatically. Depending on the tick label type (\ref
ltNumber or \ref ltDateTime), the labels will either show the coordinate as floating point
number (\ref setNumberFormat), or a date/time formatted according to \ref setDateTimeFormat.
-
+
If \a on is set to false, you should provide the tick labels via \ref setTickVectorLabels. This
is usually used in a combination with \ref setAutoTicks set to false for complete control over
tick positions and labels, e.g. when the ticks should be at multiples of pi and show "2pi", "3pi"
etc. as tick labels.
-
+
If you need dynamically calculated tick vectors (and possibly tick label vectors), set the
vectors in a slot connected to the \ref ticksRequest signal.
-
+
\see setAutoTicks
*/
-void QCPAxis::setAutoTickLabels(bool on)
+void QCPAxis::setAutoTickLabels( bool on )
{
- if (mAutoTickLabels != on)
+ if( mAutoTickLabels != on )
{
mAutoTickLabels = on;
mCachedMarginValid = false;
@@ -4571,14 +4608,14 @@ void QCPAxis::setAutoTickLabels(bool on)
The number of ticks the algorithm aims for within the visible range can be specified with \ref
setAutoTickCount.
-
+
If \a on is set to false, you may set the tick step manually with \ref setTickStep.
-
+
\see setAutoTicks, setAutoSubTicks, setAutoTickCount
*/
-void QCPAxis::setAutoTickStep(bool on)
+void QCPAxis::setAutoTickStep( bool on )
{
- if (mAutoTickStep != on)
+ if( mAutoTickStep != on )
{
mAutoTickStep = on;
mCachedMarginValid = false;
@@ -4589,14 +4626,14 @@ void QCPAxis::setAutoTickStep(bool on)
Sets whether the number of sub ticks in one tick interval is determined automatically. This
works, as long as the tick step mantissa is a multiple of 0.5. When \ref setAutoTickStep is
enabled, this is always the case.
-
+
When \a on is set to false, you may set the sub tick count with \ref setSubTickCount manually.
-
+
\see setAutoTickCount, setAutoTicks, setAutoTickStep
*/
-void QCPAxis::setAutoSubTicks(bool on)
+void QCPAxis::setAutoSubTicks( bool on )
{
- if (mAutoSubTicks != on)
+ if( mAutoSubTicks != on )
{
mAutoSubTicks = on;
mCachedMarginValid = false;
@@ -4609,9 +4646,9 @@ void QCPAxis::setAutoSubTicks(bool on)
Note that setting \a show to false does not imply that tick labels are invisible, too. To achieve
that, see \ref setTickLabels.
*/
-void QCPAxis::setTicks(bool show)
+void QCPAxis::setTicks( bool show )
{
- if (mTicks != show)
+ if( mTicks != show )
{
mTicks = show;
mCachedMarginValid = false;
@@ -4621,9 +4658,9 @@ void QCPAxis::setTicks(bool show)
/*!
Sets whether tick labels are displayed. Tick labels are the numbers drawn next to tick marks.
*/
-void QCPAxis::setTickLabels(bool show)
+void QCPAxis::setTickLabels( bool show )
{
- if (mTickLabels != show)
+ if( mTickLabels != show )
{
mTickLabels = show;
mCachedMarginValid = false;
@@ -4634,9 +4671,9 @@ void QCPAxis::setTickLabels(bool show)
Sets the distance between the axis base line (including any outward ticks) and the tick labels.
\see setLabelPadding, setPadding
*/
-void QCPAxis::setTickLabelPadding(int padding)
+void QCPAxis::setTickLabelPadding( int padding )
{
- if (mAxisPainter->tickLabelPadding != padding)
+ if( mAxisPainter->tickLabelPadding != padding )
{
mAxisPainter->tickLabelPadding = padding;
mCachedMarginValid = false;
@@ -4645,28 +4682,28 @@ void QCPAxis::setTickLabelPadding(int padding)
/*!
Sets whether the tick labels display numbers or dates/times.
-
+
If \a type is set to \ref ltNumber, the format specifications of \ref setNumberFormat apply.
-
+
If \a type is set to \ref ltDateTime, the format specifications of \ref setDateTimeFormat apply.
-
+
In QCustomPlot, date/time coordinates are double numbers representing the seconds since
1970-01-01T00:00:00 UTC. This format can be retrieved from QDateTime objects with the
QDateTime::toTime_t() function. Since this only gives a resolution of one second, there is also
the QDateTime::toMSecsSinceEpoch() function which returns the timespan described above in
milliseconds. Divide its return value by 1000.0 to get a value with the format needed for
date/time plotting, with a resolution of one millisecond.
-
+
Using the toMSecsSinceEpoch function allows dates that go back to 2nd January 4713 B.C.
(represented by a negative number), unlike the toTime_t function, which works with unsigned
integers and thus only goes back to 1st January 1970. So both for range and accuracy, use of
toMSecsSinceEpoch()/1000.0 should be preferred as key coordinate for date/time axes.
-
+
\see setTickLabels
*/
-void QCPAxis::setTickLabelType(LabelType type)
+void QCPAxis::setTickLabelType( LabelType type )
{
- if (mTickLabelType != type)
+ if( mTickLabelType != type )
{
mTickLabelType = type;
mCachedMarginValid = false;
@@ -4675,12 +4712,12 @@ void QCPAxis::setTickLabelType(LabelType type)
/*!
Sets the font of the tick labels.
-
+
\see setTickLabels, setTickLabelColor
*/
-void QCPAxis::setTickLabelFont(const QFont &font)
+void QCPAxis::setTickLabelFont( const QFont& font )
{
- if (font != mTickLabelFont)
+ if( font != mTickLabelFont )
{
mTickLabelFont = font;
mCachedMarginValid = false;
@@ -4689,12 +4726,12 @@ void QCPAxis::setTickLabelFont(const QFont &font)
/*!
Sets the color of the tick labels.
-
+
\see setTickLabels, setTickLabelFont
*/
-void QCPAxis::setTickLabelColor(const QColor &color)
+void QCPAxis::setTickLabelColor( const QColor& color )
{
- if (color != mTickLabelColor)
+ if( color != mTickLabelColor )
{
mTickLabelColor = color;
mCachedMarginValid = false;
@@ -4705,16 +4742,16 @@ void QCPAxis::setTickLabelColor(const QColor &color)
Sets the rotation of the tick labels. If \a degrees is zero, the labels are drawn normally. Else,
the tick labels are drawn rotated by \a degrees clockwise. The specified angle is bound to values
from -90 to 90 degrees.
-
+
If \a degrees is exactly -90, 0 or 90, the tick labels are centered on the tick coordinate. For
other angles, the label is drawn with an offset such that it seems to point toward or away from
the tick mark.
*/
-void QCPAxis::setTickLabelRotation(double degrees)
+void QCPAxis::setTickLabelRotation( double degrees )
{
- if (!qFuzzyIsNull(degrees-mAxisPainter->tickLabelRotation))
+ if( !qFuzzyIsNull( degrees - mAxisPainter->tickLabelRotation ) )
{
- mAxisPainter->tickLabelRotation = qBound(-90.0, degrees, 90.0);
+ mAxisPainter->tickLabelRotation = qBound( -90.0, degrees, 90.0 );
mCachedMarginValid = false;
}
}
@@ -4722,14 +4759,14 @@ void QCPAxis::setTickLabelRotation(double degrees)
/*!
Sets the format in which dates and times are displayed as tick labels, if \ref setTickLabelType is \ref ltDateTime.
for details about the \a format string, see the documentation of QDateTime::toString().
-
+
Newlines can be inserted with "\n".
-
+
\see setDateTimeSpec
*/
-void QCPAxis::setDateTimeFormat(const QString &format)
+void QCPAxis::setDateTimeFormat( const QString& format )
{
- if (mDateTimeFormat != format)
+ if( mDateTimeFormat != format )
{
mDateTimeFormat = format;
mCachedMarginValid = false;
@@ -4743,10 +4780,10 @@ void QCPAxis::setDateTimeFormat(const QString &format)
The default value of QDateTime objects (and also QCustomPlot) is Qt::LocalTime. However,
if the date time values passed to QCustomPlot are given in the UTC spec, set \a
timeSpec to Qt::UTC to get the correct axis labels.
-
+
\see setDateTimeFormat
*/
-void QCPAxis::setDateTimeSpec(const Qt::TimeSpec &timeSpec)
+void QCPAxis::setDateTimeSpec( const Qt::TimeSpec& timeSpec )
{
mDateTimeSpec = timeSpec;
}
@@ -4759,7 +4796,7 @@ void QCPAxis::setDateTimeSpec(const Qt::TimeSpec &timeSpec)
or three characters. The first character is identical to the normal format code used by Qt. In
short, this means: 'e'/'E' scientific format, 'f' fixed format, 'g'/'G' scientific or fixed,
whichever is shorter.
-
+
The second and third characters are optional and specific to QCustomPlot:\n
If the first char was 'e' or 'g', numbers are/might be displayed in the scientific format, e.g.
"5.5e9", which is ugly in a plot. So when the second char of \a formatCode is set to 'b' (for
@@ -4768,13 +4805,13 @@ void QCPAxis::setDateTimeSpec(const Qt::TimeSpec &timeSpec)
If instead a cross should be shown (as is usual in the USA), the third char of \a formatCode can
be set to 'c'. The inserted multiplication signs are the UTF-8 characters 215 (0xD7) for the
cross and 183 (0xB7) for the dot.
-
+
If the scale type (\ref setScaleType) is \ref stLogarithmic and the \a formatCode uses the 'b'
option (beautifully typeset decimal powers), the display usually is "1 [multiplication sign] 10
[superscript] n", which looks unnatural for logarithmic scaling (the "1 [multiplication sign]"
part). To only display the decimal power, set the number precision to zero with \ref
setNumberPrecision.
-
+
Examples for \a formatCode:
\li \c g normal format code behaviour. If number is small, fixed format is used, if number is large,
normal scientific format is used
@@ -4787,55 +4824,60 @@ void QCPAxis::setDateTimeSpec(const Qt::TimeSpec &timeSpec)
\li \c hello illegal format code, since first char is not 'e', 'E', 'f', 'g' or 'G'. Current format
code will not be changed.
*/
-void QCPAxis::setNumberFormat(const QString &formatCode)
+void QCPAxis::setNumberFormat( const QString& formatCode )
{
- if (formatCode.isEmpty())
+ if( formatCode.isEmpty() )
{
qDebug() << Q_FUNC_INFO << "Passed formatCode is empty";
return;
}
mCachedMarginValid = false;
-
+
// interpret first char as number format char:
QString allowedFormatChars = "eEfgG";
- if (allowedFormatChars.contains(formatCode.at(0)))
+ if( allowedFormatChars.contains( formatCode.at( 0 ) ) )
{
- mNumberFormatChar = formatCode.at(0).toLatin1();
- } else
+ mNumberFormatChar = formatCode.at( 0 ).toLatin1();
+ }
+ else
{
qDebug() << Q_FUNC_INFO << "Invalid number format code (first char not in 'eEfgG'):" << formatCode;
return;
}
- if (formatCode.length() < 2)
+ if( formatCode.length() < 2 )
{
mNumberBeautifulPowers = false;
mAxisPainter->numberMultiplyCross = false;
return;
}
-
+
// interpret second char as indicator for beautiful decimal powers:
- if (formatCode.at(1) == 'b' && (mNumberFormatChar == 'e' || mNumberFormatChar == 'g'))
+ if( formatCode.at( 1 ) == 'b' && ( mNumberFormatChar == 'e' || mNumberFormatChar == 'g' ) )
{
mNumberBeautifulPowers = true;
- } else
+ }
+ else
{
- qDebug() << Q_FUNC_INFO << "Invalid number format code (second char not 'b' or first char neither 'e' nor 'g'):" << formatCode;
+ qDebug() << Q_FUNC_INFO
+ << "Invalid number format code (second char not 'b' or first char neither 'e' nor 'g'):" << formatCode;
return;
}
- if (formatCode.length() < 3)
+ if( formatCode.length() < 3 )
{
mAxisPainter->numberMultiplyCross = false;
return;
}
-
+
// interpret third char as indicator for dot or cross multiplication symbol:
- if (formatCode.at(2) == 'c')
+ if( formatCode.at( 2 ) == 'c' )
{
mAxisPainter->numberMultiplyCross = true;
- } else if (formatCode.at(2) == 'd')
+ }
+ else if( formatCode.at( 2 ) == 'd' )
{
mAxisPainter->numberMultiplyCross = false;
- } else
+ }
+ else
{
qDebug() << Q_FUNC_INFO << "Invalid number format code (third char neither 'c' nor 'd'):" << formatCode;
return;
@@ -4853,9 +4895,9 @@ void QCPAxis::setNumberFormat(const QString &formatCode)
scaling (the redundant "1 [multiplication sign]" part). To only display the decimal power "10
[superscript] n", set \a precision to zero.
*/
-void QCPAxis::setNumberPrecision(int precision)
+void QCPAxis::setNumberPrecision( int precision )
{
- if (mNumberPrecision != precision)
+ if( mNumberPrecision != precision )
{
mNumberPrecision = precision;
mCachedMarginValid = false;
@@ -4867,9 +4909,9 @@ void QCPAxis::setNumberPrecision(int precision)
The tick step is the interval between (major) ticks, in plot coordinates.
\see setSubTickCount
*/
-void QCPAxis::setTickStep(double step)
+void QCPAxis::setTickStep( double step )
{
- if (mTickStep != step)
+ if( mTickStep != step )
{
mTickStep = step;
mCachedMarginValid = false;
@@ -4882,14 +4924,14 @@ void QCPAxis::setTickStep(double step)
the provided tick vector will be overwritten with automatically generated tick coordinates upon
replot. The labels of the ticks can be generated automatically when \ref setAutoTickLabels is
left enabled. If it is disabled, you can set the labels manually with \ref setTickVectorLabels.
-
+
\a vec is a vector containing the positions of the ticks, in plot coordinates.
-
+
\warning \a vec must be sorted in ascending order, no additional checks are made to ensure this.
\see setTickVectorLabels
*/
-void QCPAxis::setTickVector(const QVector &vec)
+void QCPAxis::setTickVector( const QVector& vec )
{
// don't check whether mTickVector != vec here, because it takes longer than we would save
mTickVector = vec;
@@ -4901,13 +4943,13 @@ void QCPAxis::setTickVector(const QVector &vec)
number of QStrings that will be displayed at the tick positions which you need to provide with
\ref setTickVector. These two vectors should have the same size. (Note that you need to disable
\ref setAutoTicks and \ref setAutoTickLabels first.)
-
+
\a vec is a vector containing the labels of the ticks. The entries correspond to the respective
indices in the tick vector, passed via \ref setTickVector.
-
+
\see setTickVector
*/
-void QCPAxis::setTickVectorLabels(const QVector &vec)
+void QCPAxis::setTickVectorLabels( const QVector& vec )
{
// don't check whether mTickVectorLabels != vec here, because it takes longer than we would save
mTickVectorLabels = vec;
@@ -4919,24 +4961,24 @@ void QCPAxis::setTickVectorLabels(const QVector &vec)
plot and \a outside is the length they will reach outside the plot. If \a outside is greater than
zero, the tick labels and axis label will increase their distance to the axis accordingly, so
they won't collide with the ticks.
-
+
\see setSubTickLength, setTickLengthIn, setTickLengthOut
*/
-void QCPAxis::setTickLength(int inside, int outside)
+void QCPAxis::setTickLength( int inside, int outside )
{
- setTickLengthIn(inside);
- setTickLengthOut(outside);
+ setTickLengthIn( inside );
+ setTickLengthOut( outside );
}
/*!
Sets the length of the inward ticks in pixels. \a inside is the length the ticks will reach
inside the plot.
-
+
\see setTickLengthOut, setTickLength, setSubTickLength
*/
-void QCPAxis::setTickLengthIn(int inside)
+void QCPAxis::setTickLengthIn( int inside )
{
- if (mAxisPainter->tickLengthIn != inside)
+ if( mAxisPainter->tickLengthIn != inside )
{
mAxisPainter->tickLengthIn = inside;
}
@@ -4946,22 +4988,22 @@ void QCPAxis::setTickLengthIn(int inside)
Sets the length of the outward ticks in pixels. \a outside is the length the ticks will reach
outside the plot. If \a outside is greater than zero, the tick labels and axis label will
increase their distance to the axis accordingly, so they won't collide with the ticks.
-
+
\see setTickLengthIn, setTickLength, setSubTickLength
*/
-void QCPAxis::setTickLengthOut(int outside)
+void QCPAxis::setTickLengthOut( int outside )
{
- if (mAxisPainter->tickLengthOut != outside)
+ if( mAxisPainter->tickLengthOut != outside )
{
mAxisPainter->tickLengthOut = outside;
- mCachedMarginValid = false; // only outside tick length can change margin
+ mCachedMarginValid = false; // only outside tick length can change margin
}
}
/*!
Sets the number of sub ticks in one (major) tick step. A sub tick count of three for example,
divides the tick intervals in four sub intervals.
-
+
By default, the number of sub ticks is chosen automatically in a reasonable manner as long as the
mantissa of the tick step is a multiple of 0.5. When \ref setAutoTickStep is enabled, this is
always the case.
@@ -4969,7 +5011,7 @@ void QCPAxis::setTickLengthOut(int outside)
If you want to disable automatic sub tick count and use this function to set the count manually,
see \ref setAutoSubTicks.
*/
-void QCPAxis::setSubTickCount(int count)
+void QCPAxis::setSubTickCount( int count )
{
mSubTickCount = count;
}
@@ -4979,24 +5021,24 @@ void QCPAxis::setSubTickCount(int count)
the plot and \a outside is the length they will reach outside the plot. If \a outside is greater
than zero, the tick labels and axis label will increase their distance to the axis accordingly,
so they won't collide with the ticks.
-
+
\see setTickLength, setSubTickLengthIn, setSubTickLengthOut
*/
-void QCPAxis::setSubTickLength(int inside, int outside)
+void QCPAxis::setSubTickLength( int inside, int outside )
{
- setSubTickLengthIn(inside);
- setSubTickLengthOut(outside);
+ setSubTickLengthIn( inside );
+ setSubTickLengthOut( outside );
}
/*!
Sets the length of the inward subticks in pixels. \a inside is the length the subticks will reach inside
the plot.
-
+
\see setSubTickLengthOut, setSubTickLength, setTickLength
*/
-void QCPAxis::setSubTickLengthIn(int inside)
+void QCPAxis::setSubTickLengthIn( int inside )
{
- if (mAxisPainter->subTickLengthIn != inside)
+ if( mAxisPainter->subTickLengthIn != inside )
{
mAxisPainter->subTickLengthIn = inside;
}
@@ -5006,56 +5048,56 @@ void QCPAxis::setSubTickLengthIn(int inside)
Sets the length of the outward subticks in pixels. \a outside is the length the subticks will reach
outside the plot. If \a outside is greater than zero, the tick labels will increase their
distance to the axis accordingly, so they won't collide with the ticks.
-
+
\see setSubTickLengthIn, setSubTickLength, setTickLength
*/
-void QCPAxis::setSubTickLengthOut(int outside)
+void QCPAxis::setSubTickLengthOut( int outside )
{
- if (mAxisPainter->subTickLengthOut != outside)
+ if( mAxisPainter->subTickLengthOut != outside )
{
mAxisPainter->subTickLengthOut = outside;
- mCachedMarginValid = false; // only outside tick length can change margin
+ mCachedMarginValid = false; // only outside tick length can change margin
}
}
/*!
Sets the pen, the axis base line is drawn with.
-
+
\see setTickPen, setSubTickPen
*/
-void QCPAxis::setBasePen(const QPen &pen)
+void QCPAxis::setBasePen( const QPen& pen )
{
mBasePen = pen;
}
/*!
Sets the pen, tick marks will be drawn with.
-
+
\see setTickLength, setBasePen
*/
-void QCPAxis::setTickPen(const QPen &pen)
+void QCPAxis::setTickPen( const QPen& pen )
{
mTickPen = pen;
}
/*!
Sets the pen, subtick marks will be drawn with.
-
+
\see setSubTickCount, setSubTickLength, setBasePen
*/
-void QCPAxis::setSubTickPen(const QPen &pen)
+void QCPAxis::setSubTickPen( const QPen& pen )
{
mSubTickPen = pen;
}
/*!
Sets the font of the axis label.
-
+
\see setLabelColor
*/
-void QCPAxis::setLabelFont(const QFont &font)
+void QCPAxis::setLabelFont( const QFont& font )
{
- if (mLabelFont != font)
+ if( mLabelFont != font )
{
mLabelFont = font;
mCachedMarginValid = false;
@@ -5064,10 +5106,10 @@ void QCPAxis::setLabelFont(const QFont &font)
/*!
Sets the color of the axis label.
-
+
\see setLabelFont
*/
-void QCPAxis::setLabelColor(const QColor &color)
+void QCPAxis::setLabelColor( const QColor& color )
{
mLabelColor = color;
}
@@ -5076,9 +5118,9 @@ void QCPAxis::setLabelColor(const QColor &color)
Sets the text of the axis label that will be shown below/above or next to the axis, depending on
its orientation. To disable axis labels, pass an empty string as \a str.
*/
-void QCPAxis::setLabel(const QString &str)
+void QCPAxis::setLabel( const QString& str )
{
- if (mLabel != str)
+ if( mLabel != str )
{
mLabel = str;
mCachedMarginValid = false;
@@ -5087,12 +5129,12 @@ void QCPAxis::setLabel(const QString &str)
/*!
Sets the distance between the tick labels and the axis label.
-
+
\see setTickLabelPadding, setPadding
*/
-void QCPAxis::setLabelPadding(int padding)
+void QCPAxis::setLabelPadding( int padding )
{
- if (mAxisPainter->labelPadding != padding)
+ if( mAxisPainter->labelPadding != padding )
{
mAxisPainter->labelPadding = padding;
mCachedMarginValid = false;
@@ -5104,14 +5146,14 @@ void QCPAxis::setLabelPadding(int padding)
When \ref QCPAxisRect::setAutoMargins is enabled, the padding is the additional outer most space,
that is left blank.
-
+
The axis padding has no meaning if \ref QCPAxisRect::setAutoMargins is disabled.
-
+
\see setLabelPadding, setTickLabelPadding
*/
-void QCPAxis::setPadding(int padding)
+void QCPAxis::setPadding( int padding )
{
- if (mPadding != padding)
+ if( mPadding != padding )
{
mPadding = padding;
mCachedMarginValid = false;
@@ -5120,25 +5162,25 @@ void QCPAxis::setPadding(int padding)
/*!
Sets the offset the axis has to its axis rect side.
-
+
If an axis rect side has multiple axes and automatic margin calculation is enabled for that side,
only the offset of the inner most axis has meaning (even if it is set to be invisible). The
offset of the other, outer axes is controlled automatically, to place them at appropriate
positions.
*/
-void QCPAxis::setOffset(int offset)
+void QCPAxis::setOffset( int offset )
{
mAxisPainter->offset = offset;
}
/*!
Sets the font that is used for tick labels when they are selected.
-
+
\see setTickLabelFont, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions
*/
-void QCPAxis::setSelectedTickLabelFont(const QFont &font)
+void QCPAxis::setSelectedTickLabelFont( const QFont& font )
{
- if (font != mSelectedTickLabelFont)
+ if( font != mSelectedTickLabelFont )
{
mSelectedTickLabelFont = font;
// don't set mCachedMarginValid to false here because margin calculation is always done with non-selected fonts
@@ -5147,10 +5189,10 @@ void QCPAxis::setSelectedTickLabelFont(const QFont &font)
/*!
Sets the font that is used for the axis label when it is selected.
-
+
\see setLabelFont, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions
*/
-void QCPAxis::setSelectedLabelFont(const QFont &font)
+void QCPAxis::setSelectedLabelFont( const QFont& font )
{
mSelectedLabelFont = font;
// don't set mCachedMarginValid to false here because margin calculation is always done with non-selected fonts
@@ -5158,12 +5200,12 @@ void QCPAxis::setSelectedLabelFont(const QFont &font)
/*!
Sets the color that is used for tick labels when they are selected.
-
+
\see setTickLabelColor, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions
*/
-void QCPAxis::setSelectedTickLabelColor(const QColor &color)
+void QCPAxis::setSelectedTickLabelColor( const QColor& color )
{
- if (color != mSelectedTickLabelColor)
+ if( color != mSelectedTickLabelColor )
{
mSelectedTickLabelColor = color;
}
@@ -5171,40 +5213,40 @@ void QCPAxis::setSelectedTickLabelColor(const QColor &color)
/*!
Sets the color that is used for the axis label when it is selected.
-
+
\see setLabelColor, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions
*/
-void QCPAxis::setSelectedLabelColor(const QColor &color)
+void QCPAxis::setSelectedLabelColor( const QColor& color )
{
mSelectedLabelColor = color;
}
/*!
Sets the pen that is used to draw the axis base line when selected.
-
+
\see setBasePen, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions
*/
-void QCPAxis::setSelectedBasePen(const QPen &pen)
+void QCPAxis::setSelectedBasePen( const QPen& pen )
{
mSelectedBasePen = pen;
}
/*!
Sets the pen that is used to draw the (major) ticks when selected.
-
+
\see setTickPen, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions
*/
-void QCPAxis::setSelectedTickPen(const QPen &pen)
+void QCPAxis::setSelectedTickPen( const QPen& pen )
{
mSelectedTickPen = pen;
}
/*!
Sets the pen that is used to draw the subticks when selected.
-
+
\see setSubTickPen, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions
*/
-void QCPAxis::setSelectedSubTickPen(const QPen &pen)
+void QCPAxis::setSelectedSubTickPen( const QPen& pen )
{
mSelectedSubTickPen = pen;
}
@@ -5212,14 +5254,14 @@ void QCPAxis::setSelectedSubTickPen(const QPen &pen)
/*!
Sets the style for the lower axis ending. See the documentation of QCPLineEnding for available
styles.
-
+
For horizontal axes, this method refers to the left ending, for vertical axes the bottom ending.
Note that this meaning does not change when the axis range is reversed with \ref
setRangeReversed.
-
+
\see setUpperEnding
*/
-void QCPAxis::setLowerEnding(const QCPLineEnding &ending)
+void QCPAxis::setLowerEnding( const QCPLineEnding& ending )
{
mAxisPainter->lowerEnding = ending;
}
@@ -5227,14 +5269,14 @@ void QCPAxis::setLowerEnding(const QCPLineEnding &ending)
/*!
Sets the style for the upper axis ending. See the documentation of QCPLineEnding for available
styles.
-
+
For horizontal axes, this method refers to the right ending, for vertical axes the top ending.
Note that this meaning does not change when the axis range is reversed with \ref
setRangeReversed.
-
+
\see setLowerEnding
*/
-void QCPAxis::setUpperEnding(const QCPLineEnding &ending)
+void QCPAxis::setUpperEnding( const QCPLineEnding& ending )
{
mAxisPainter->upperEnding = ending;
}
@@ -5242,25 +5284,26 @@ void QCPAxis::setUpperEnding(const QCPLineEnding &ending)
/*!
If the scale type (\ref setScaleType) is \ref stLinear, \a diff is added to the lower and upper
bounds of the range. The range is simply moved by \a diff.
-
+
If the scale type is \ref stLogarithmic, the range bounds are multiplied by \a diff. This
corresponds to an apparent "linear" move in logarithmic scaling by a distance of log(diff).
*/
-void QCPAxis::moveRange(double diff)
+void QCPAxis::moveRange( double diff )
{
QCPRange oldRange = mRange;
- if (mScaleType == stLinear)
+ if( mScaleType == stLinear )
{
mRange.lower += diff;
mRange.upper += diff;
- } else // mScaleType == stLogarithmic
+ }
+ else // mScaleType == stLogarithmic
{
mRange.lower *= diff;
mRange.upper *= diff;
}
mCachedMarginValid = false;
- emit rangeChanged(mRange);
- emit rangeChanged(mRange, oldRange);
+ emit rangeChanged( mRange );
+ emit rangeChanged( mRange, oldRange );
}
/*!
@@ -5269,31 +5312,35 @@ void QCPAxis::moveRange(double diff)
coordinate 1.0 won't have changed its position in the QCustomPlot widget (i.e. coordinates
around 1.0 will have moved symmetrically closer to 1.0).
*/
-void QCPAxis::scaleRange(double factor, double center)
+void QCPAxis::scaleRange( double factor, double center )
{
QCPRange oldRange = mRange;
- if (mScaleType == stLinear)
+ if( mScaleType == stLinear )
{
QCPRange newRange;
- newRange.lower = (mRange.lower-center)*factor + center;
- newRange.upper = (mRange.upper-center)*factor + center;
- if (QCPRange::validRange(newRange))
+ newRange.lower = ( mRange.lower - center ) * factor + center;
+ newRange.upper = ( mRange.upper - center ) * factor + center;
+ if( QCPRange::validRange( newRange ) )
mRange = newRange.sanitizedForLinScale();
- } else // mScaleType == stLogarithmic
+ }
+ else // mScaleType == stLogarithmic
{
- if ((mRange.upper < 0 && center < 0) || (mRange.upper > 0 && center > 0)) // make sure center has same sign as range
+ if( ( mRange.upper < 0 && center < 0 ) ||
+ ( mRange.upper > 0 && center > 0 ) ) // make sure center has same sign as range
{
QCPRange newRange;
- newRange.lower = pow(mRange.lower/center, factor)*center;
- newRange.upper = pow(mRange.upper/center, factor)*center;
- if (QCPRange::validRange(newRange))
+ newRange.lower = pow( mRange.lower / center, factor ) * center;
+ newRange.upper = pow( mRange.upper / center, factor ) * center;
+ if( QCPRange::validRange( newRange ) )
mRange = newRange.sanitizedForLogScale();
- } else
- qDebug() << Q_FUNC_INFO << "Center of scaling operation doesn't lie in same logarithmic sign domain as range:" << center;
+ }
+ else
+ qDebug() << Q_FUNC_INFO
+ << "Center of scaling operation doesn't lie in same logarithmic sign domain as range:" << center;
}
mCachedMarginValid = false;
- emit rangeChanged(mRange);
- emit rangeChanged(mRange, oldRange);
+ emit rangeChanged( mRange );
+ emit rangeChanged( mRange, oldRange );
}
/*!
@@ -5309,110 +5356,121 @@ void QCPAxis::scaleRange(double factor, double center)
won't have the desired effect, since the widget dimensions aren't defined yet, and a resizeEvent
will follow.
*/
-void QCPAxis::setScaleRatio(const QCPAxis *otherAxis, double ratio)
+void QCPAxis::setScaleRatio( const QCPAxis* otherAxis, double ratio )
{
int otherPixelSize, ownPixelSize;
-
- if (otherAxis->orientation() == Qt::Horizontal)
+
+ if( otherAxis->orientation() == Qt::Horizontal )
otherPixelSize = otherAxis->axisRect()->width();
else
otherPixelSize = otherAxis->axisRect()->height();
-
- if (orientation() == Qt::Horizontal)
+
+ if( orientation() == Qt::Horizontal )
ownPixelSize = axisRect()->width();
else
ownPixelSize = axisRect()->height();
-
- double newRangeSize = ratio*otherAxis->range().size()*ownPixelSize/(double)otherPixelSize;
- setRange(range().center(), newRangeSize, Qt::AlignCenter);
+
+ double newRangeSize = ratio * otherAxis->range().size() * ownPixelSize / (double)otherPixelSize;
+ setRange( range().center(), newRangeSize, Qt::AlignCenter );
}
/*!
Changes the axis range such that all plottables associated with this axis are fully visible in
that dimension.
-
+
\see QCPAbstractPlottable::rescaleAxes, QCustomPlot::rescaleAxes
*/
-void QCPAxis::rescale(bool onlyVisiblePlottables)
+void QCPAxis::rescale( bool onlyVisiblePlottables )
{
QList p = plottables();
QCPRange newRange;
bool haveRange = false;
- for (int i=0; irealVisibility() && onlyVisiblePlottables)
+ if( !p.at( i )->realVisibility() && onlyVisiblePlottables )
continue;
QCPRange plottableRange;
bool currentFoundRange;
QCPAbstractPlottable::SignDomain signDomain = QCPAbstractPlottable::sdBoth;
- if (mScaleType == stLogarithmic)
- signDomain = (mRange.upper < 0 ? QCPAbstractPlottable::sdNegative : QCPAbstractPlottable::sdPositive);
- if (p.at(i)->keyAxis() == this)
- plottableRange = p.at(i)->getKeyRange(currentFoundRange, signDomain);
+ if( mScaleType == stLogarithmic )
+ signDomain = ( mRange.upper < 0 ? QCPAbstractPlottable::sdNegative : QCPAbstractPlottable::sdPositive );
+ if( p.at( i )->keyAxis() == this )
+ plottableRange = p.at( i )->getKeyRange( currentFoundRange, signDomain );
else
- plottableRange = p.at(i)->getValueRange(currentFoundRange, signDomain);
- if (currentFoundRange)
+ plottableRange = p.at( i )->getValueRange( currentFoundRange, signDomain );
+ if( currentFoundRange )
{
- if (!haveRange)
+ if( !haveRange )
newRange = plottableRange;
else
- newRange.expand(plottableRange);
+ newRange.expand( plottableRange );
haveRange = true;
}
}
- if (haveRange)
+ if( haveRange )
{
- if (!QCPRange::validRange(newRange)) // likely due to range being zero (plottable has only constant data in this axis dimension), shift current range to at least center the plottable
+ if( !QCPRange::validRange( newRange ) ) // likely due to range being zero (plottable has only constant data in this
+ // axis dimension), shift current range to at least center the plottable
{
- double center = (newRange.lower+newRange.upper)*0.5; // upper and lower should be equal anyway, but just to make sure, incase validRange returned false for other reason
- if (mScaleType == stLinear)
+ double center = ( newRange.lower + newRange.upper ) * 0.5; // upper and lower should be equal anyway, but just to
+ // make sure, incase validRange returned false for
+ // other reason
+ if( mScaleType == stLinear )
{
- newRange.lower = center-mRange.size()/2.0;
- newRange.upper = center+mRange.size()/2.0;
- } else // mScaleType == stLogarithmic
+ newRange.lower = center - mRange.size() / 2.0;
+ newRange.upper = center + mRange.size() / 2.0;
+ }
+ else // mScaleType == stLogarithmic
{
- newRange.lower = center/qSqrt(mRange.upper/mRange.lower);
- newRange.upper = center*qSqrt(mRange.upper/mRange.lower);
+ newRange.lower = center / qSqrt( mRange.upper / mRange.lower );
+ newRange.upper = center * qSqrt( mRange.upper / mRange.lower );
}
}
- setRange(newRange);
+ setRange( newRange );
}
}
/*!
Transforms \a value, in pixel coordinates of the QCustomPlot widget, to axis coordinates.
*/
-double QCPAxis::pixelToCoord(double value) const
+double QCPAxis::pixelToCoord( double value ) const
{
- if (orientation() == Qt::Horizontal)
+ if( orientation() == Qt::Horizontal )
{
- if (mScaleType == stLinear)
+ if( mScaleType == stLinear )
{
- if (!mRangeReversed)
- return (value-mAxisRect->left())/(double)mAxisRect->width()*mRange.size()+mRange.lower;
+ if( !mRangeReversed )
+ return ( value - mAxisRect->left() ) / (double)mAxisRect->width() * mRange.size() + mRange.lower;
else
- return -(value-mAxisRect->left())/(double)mAxisRect->width()*mRange.size()+mRange.upper;
- } else // mScaleType == stLogarithmic
- {
- if (!mRangeReversed)
- return pow(mRange.upper/mRange.lower, (value-mAxisRect->left())/(double)mAxisRect->width())*mRange.lower;
- else
- return pow(mRange.upper/mRange.lower, (mAxisRect->left()-value)/(double)mAxisRect->width())*mRange.upper;
+ return -( value - mAxisRect->left() ) / (double)mAxisRect->width() * mRange.size() + mRange.upper;
}
- } else // orientation() == Qt::Vertical
+ else // mScaleType == stLogarithmic
+ {
+ if( !mRangeReversed )
+ return pow( mRange.upper / mRange.lower, ( value - mAxisRect->left() ) / (double)mAxisRect->width() ) *
+ mRange.lower;
+ else
+ return pow( mRange.upper / mRange.lower, ( mAxisRect->left() - value ) / (double)mAxisRect->width() ) *
+ mRange.upper;
+ }
+ }
+ else // orientation() == Qt::Vertical
{
- if (mScaleType == stLinear)
+ if( mScaleType == stLinear )
{
- if (!mRangeReversed)
- return (mAxisRect->bottom()-value)/(double)mAxisRect->height()*mRange.size()+mRange.lower;
+ if( !mRangeReversed )
+ return ( mAxisRect->bottom() - value ) / (double)mAxisRect->height() * mRange.size() + mRange.lower;
else
- return -(mAxisRect->bottom()-value)/(double)mAxisRect->height()*mRange.size()+mRange.upper;
- } else // mScaleType == stLogarithmic
+ return -( mAxisRect->bottom() - value ) / (double)mAxisRect->height() * mRange.size() + mRange.upper;
+ }
+ else // mScaleType == stLogarithmic
{
- if (!mRangeReversed)
- return pow(mRange.upper/mRange.lower, (mAxisRect->bottom()-value)/(double)mAxisRect->height())*mRange.lower;
+ if( !mRangeReversed )
+ return pow( mRange.upper / mRange.lower, ( mAxisRect->bottom() - value ) / (double)mAxisRect->height() ) *
+ mRange.lower;
else
- return pow(mRange.upper/mRange.lower, (value-mAxisRect->bottom())/(double)mAxisRect->height())*mRange.upper;
+ return pow( mRange.upper / mRange.lower, ( value - mAxisRect->bottom() ) / (double)mAxisRect->height() ) *
+ mRange.upper;
}
}
}
@@ -5420,50 +5478,59 @@ double QCPAxis::pixelToCoord(double value) const
/*!
Transforms \a value, in coordinates of the axis, to pixel coordinates of the QCustomPlot widget.
*/
-double QCPAxis::coordToPixel(double value) const
+double QCPAxis::coordToPixel( double value ) const
{
- if (orientation() == Qt::Horizontal)
+ if( orientation() == Qt::Horizontal )
{
- if (mScaleType == stLinear)
+ if( mScaleType == stLinear )
{
- if (!mRangeReversed)
- return (value-mRange.lower)/mRange.size()*mAxisRect->width()+mAxisRect->left();
+ if( !mRangeReversed )
+ return ( value - mRange.lower ) / mRange.size() * mAxisRect->width() + mAxisRect->left();
else
- return (mRange.upper-value)/mRange.size()*mAxisRect->width()+mAxisRect->left();
- } else // mScaleType == stLogarithmic
+ return ( mRange.upper - value ) / mRange.size() * mAxisRect->width() + mAxisRect->left();
+ }
+ else // mScaleType == stLogarithmic
{
- if (value >= 0 && mRange.upper < 0) // invalid value for logarithmic scale, just draw it outside visible range
- return !mRangeReversed ? mAxisRect->right()+200 : mAxisRect->left()-200;
- else if (value <= 0 && mRange.upper > 0) // invalid value for logarithmic scale, just draw it outside visible range
- return !mRangeReversed ? mAxisRect->left()-200 : mAxisRect->right()+200;
+ if( value >= 0 && mRange.upper < 0 ) // invalid value for logarithmic scale, just draw it outside visible range
+ return !mRangeReversed ? mAxisRect->right() + 200 : mAxisRect->left() - 200;
+ else if( value <= 0 &&
+ mRange.upper > 0 ) // invalid value for logarithmic scale, just draw it outside visible range
+ return !mRangeReversed ? mAxisRect->left() - 200 : mAxisRect->right() + 200;
else
{
- if (!mRangeReversed)
- return baseLog(value/mRange.lower)/baseLog(mRange.upper/mRange.lower)*mAxisRect->width()+mAxisRect->left();
+ if( !mRangeReversed )
+ return baseLog( value / mRange.lower ) / baseLog( mRange.upper / mRange.lower ) * mAxisRect->width() +
+ mAxisRect->left();
else
- return baseLog(mRange.upper/value)/baseLog(mRange.upper/mRange.lower)*mAxisRect->width()+mAxisRect->left();
+ return baseLog( mRange.upper / value ) / baseLog( mRange.upper / mRange.lower ) * mAxisRect->width() +
+ mAxisRect->left();
}
}
- } else // orientation() == Qt::Vertical
+ }
+ else // orientation() == Qt::Vertical
{
- if (mScaleType == stLinear)
+ if( mScaleType == stLinear )
{
- if (!mRangeReversed)
- return mAxisRect->bottom()-(value-mRange.lower)/mRange.size()*mAxisRect->height();
+ if( !mRangeReversed )
+ return mAxisRect->bottom() - ( value - mRange.lower ) / mRange.size() * mAxisRect->height();
else
- return mAxisRect->bottom()-(mRange.upper-value)/mRange.size()*mAxisRect->height();
- } else // mScaleType == stLogarithmic
+ return mAxisRect->bottom() - ( mRange.upper - value ) / mRange.size() * mAxisRect->height();
+ }
+ else // mScaleType == stLogarithmic
{
- if (value >= 0 && mRange.upper < 0) // invalid value for logarithmic scale, just draw it outside visible range
- return !mRangeReversed ? mAxisRect->top()-200 : mAxisRect->bottom()+200;
- else if (value <= 0 && mRange.upper > 0) // invalid value for logarithmic scale, just draw it outside visible range
- return !mRangeReversed ? mAxisRect->bottom()+200 : mAxisRect->top()-200;
+ if( value >= 0 && mRange.upper < 0 ) // invalid value for logarithmic scale, just draw it outside visible range
+ return !mRangeReversed ? mAxisRect->top() - 200 : mAxisRect->bottom() + 200;
+ else if( value <= 0 &&
+ mRange.upper > 0 ) // invalid value for logarithmic scale, just draw it outside visible range
+ return !mRangeReversed ? mAxisRect->bottom() + 200 : mAxisRect->top() - 200;
else
{
- if (!mRangeReversed)
- return mAxisRect->bottom()-baseLog(value/mRange.lower)/baseLog(mRange.upper/mRange.lower)*mAxisRect->height();
+ if( !mRangeReversed )
+ return mAxisRect->bottom() -
+ baseLog( value / mRange.lower ) / baseLog( mRange.upper / mRange.lower ) * mAxisRect->height();
else
- return mAxisRect->bottom()-baseLog(mRange.upper/value)/baseLog(mRange.upper/mRange.lower)*mAxisRect->height();
+ return mAxisRect->bottom() -
+ baseLog( mRange.upper / value ) / baseLog( mRange.upper / mRange.lower ) * mAxisRect->height();
}
}
}
@@ -5473,73 +5540,76 @@ double QCPAxis::coordToPixel(double value) const
Returns the part of the axis that is hit by \a pos (in pixels). The return value of this function
is independent of the user-selectable parts defined with \ref setSelectableParts. Further, this
function does not change the current selection state of the axis.
-
+
If the axis is not visible (\ref setVisible), this function always returns \ref spNone.
-
+
\see setSelectedParts, setSelectableParts, QCustomPlot::setInteractions
*/
-QCPAxis::SelectablePart QCPAxis::getPartAt(const QPointF &pos) const
+QCPAxis::SelectablePart QCPAxis::getPartAt( const QPointF& pos ) const
{
- if (!mVisible)
+ if( !mVisible )
return spNone;
-
- if (mAxisPainter->axisSelectionBox().contains(pos.toPoint()))
+
+ if( mAxisPainter->axisSelectionBox().contains( pos.toPoint() ) )
return spAxis;
- else if (mAxisPainter->tickLabelsSelectionBox().contains(pos.toPoint()))
+ else if( mAxisPainter->tickLabelsSelectionBox().contains( pos.toPoint() ) )
return spTickLabels;
- else if (mAxisPainter->labelSelectionBox().contains(pos.toPoint()))
+ else if( mAxisPainter->labelSelectionBox().contains( pos.toPoint() ) )
return spAxisLabel;
else
return spNone;
}
/* inherits documentation from base class */
-double QCPAxis::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const
+double QCPAxis::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const
{
- if (!mParentPlot) return -1;
- SelectablePart part = getPartAt(pos);
- if ((onlySelectable && !mSelectableParts.testFlag(part)) || part == spNone)
+ if( !mParentPlot )
return -1;
-
- if (details)
- details->setValue(part);
- return mParentPlot->selectionTolerance()*0.99;
+ SelectablePart part = getPartAt( pos );
+ if( ( onlySelectable && !mSelectableParts.testFlag( part ) ) || part == spNone )
+ return -1;
+
+ if( details )
+ details->setValue( part );
+ return mParentPlot->selectionTolerance() * 0.99;
}
/*!
Returns a list of all the plottables that have this axis as key or value axis.
-
+
If you are only interested in plottables of type QCPGraph, see \ref graphs.
-
+
\see graphs, items
*/
QList QCPAxis::plottables() const
{
QList result;
- if (!mParentPlot) return result;
-
- for (int i=0; imPlottables.size(); ++i)
+ if( !mParentPlot )
+ return result;
+
+ for( int i = 0; i < mParentPlot->mPlottables.size(); ++i )
{
- if (mParentPlot->mPlottables.at(i)->keyAxis() == this ||mParentPlot->mPlottables.at(i)->valueAxis() == this)
- result.append(mParentPlot->mPlottables.at(i));
+ if( mParentPlot->mPlottables.at( i )->keyAxis() == this || mParentPlot->mPlottables.at( i )->valueAxis() == this )
+ result.append( mParentPlot->mPlottables.at( i ) );
}
return result;
}
/*!
Returns a list of all the graphs that have this axis as key or value axis.
-
+
\see plottables, items
*/
QList QCPAxis::graphs() const
{
QList