ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccHistogramWindow Class Reference

Histogram widget. More...

#include <ecvHistogramWindow.h>

Inheritance diagram for ccHistogramWindow:
Collaboration diagram for ccHistogramWindow:

Public Types

enum  HISTOGRAM_COLOR_SCHEME { USE_SOLID_COLOR , USE_CUSTOM_COLOR_SCALE , USE_SF_SCALE }
 
enum class  AxisDisplayOption { None = 0x0 , XAxis = 0x01 , YAxis = 0x02 , All = XAxis | YAxis }
 
enum class  SFInteractionMode { None = 0x0 , DisplayRange = 0x01 , SaturationRange = 0x02 , All = DisplayRange | SaturationRange }
 

Signals

void sfMinDispValChanged (double)
 
void sfMaxDispValChanged (double)
 
void sfMinSatValChanged (double)
 
void sfMaxSatValChanged (double)
 

Public Member Functions

 ccHistogramWindow (QWidget *parent=0)
 Default constructor. More...
 
virtual ~ccHistogramWindow ()
 Destructor. More...
 
void setTitle (const QString &str)
 Sets title. More...
 
void setAxisLabels (const QString &xLabel, const QString &yLabel)
 Sets axis labels. More...
 
void fromSF (ccScalarField *sf, unsigned initialNumberOfClasses=0, bool numberOfClassesCanBeChanged=true, bool showNaNValuesInGrey=true)
 Computes histogram from a scalar field. More...
 
void fromBinArray (const std::vector< unsigned > &histoValues, double minVal, double maxVal)
 
void setCurveValues (const std::vector< double > &curveValues)
 Sets overlay curve values. More...
 
void setColorScheme (HISTOGRAM_COLOR_SCHEME scheme)
 Sets how the gradient bars should be colored. More...
 
void setSolidColor (QColor color)
 Sets solid color. More...
 
void setColorScale (ccColorScale::Shared scale)
 Sets gradient color scale. More...
 
void clear ()
 Clears the display. More...
 
void refresh ()
 Updates the display. More...
 
void refreshBars ()
 Updates the histogram bars only. More...
 
const std::vector< unsigned > & histoValues () const
 Returns the current histogram bins. More...
 
double minVal () const
 Returns the current histogram min value. More...
 
double maxVal () const
 Returns the current histogram max value. More...
 
void setSFInteractionMode (SFInteractionModes modes)
 Enables SF interaction mode. More...
 
void setAxisDisplayOption (AxisDisplayOptions axisOptions)
 
void setRefreshAfterResize (bool refreshAfterResize)
 
void setMinDispValue (double)
 
void setMaxDispValue (double)
 
void setMinSatValue (double)
 
void setMaxSatValue (double)
 

Protected Types

enum  SELECTABLE_ITEMS {
  NONE , LEFT_AREA , RIGHT_AREA , BOTH_AREAS ,
  LEFT_ARROW , RIGHT_ARROW , BOTH_ARROWS
}
 Selectable items in "SF interaction" mode. More...
 

Protected Member Functions

void setNumberOfClasses (size_t n)
 Changes the current number of classes. More...
 
void mousePressEvent (QMouseEvent *event)
 
void mouseMoveEvent (QMouseEvent *event)
 
void wheelEvent (QWheelEvent *event)
 
void resizeEvent (QResizeEvent *event)
 
unsigned getMaxHistoVal ()
 Returns current maximum bin size. More...
 
bool computeBinArrayFromSF (size_t binCount)
 Dynamically computes histogram bins from scalar field. More...
 
void updateOverlayCurveWidth (int w, int h)
 Updates overlay curve width depending on the widget display size. More...
 

Protected Attributes

QString m_titleStr
 
QCPTextElement * m_titlePlot
 
HISTOGRAM_COLOR_SCHEME m_colorScheme
 Color scheme. More...
 
QColor m_solidColor
 Solid color. More...
 
ccColorScale::Shared m_colorScale
 Gradient color scale. More...
 
ccScalarFieldm_associatedSF
 Associated scalar field. More...
 
bool m_numberOfClassesCanBeChanged
 
bool m_refreshAfterResize
 
QCPColoredBarsm_histogram
 
std::vector< unsigned > m_histoValues
 
double m_minVal
 
double m_maxVal
 
unsigned m_maxHistoVal
 
QCPGraph * m_overlayCurve
 Overlay curve. More...
 
std::vector< double > m_curveValues
 
QCPBarsWithTextm_vertBar
 
bool m_drawVerticalIndicator
 
double m_verticalIndicatorPositionPercent
 
QFont m_renderingFont
 Rendering font. More...
 
AxisDisplayOptions m_axisDisplayOptions
 
SFInteractionModes m_sfInteractionModes
 Which SF interaction modes are enabled. More...
 
SELECTABLE_ITEMS m_selectedItem
 Currently selected item. More...
 
QCPHiddenAream_areaLeft
 Left greyed area. More...
 
double m_areaLeftlastValue
 
QCPHiddenAream_areaRight
 Right greyed area. More...
 
double m_areaRightlastValue
 
QCPArrowm_arrowLeft
 Left arrow. More...
 
double m_arrowLeftlastValue
 
QCPArrowm_arrowRight
 Right arrow. More...
 
double m_arrowRightlastValue
 
QPoint m_lastMouseClick
 Last mouse click. More...
 

Detailed Description

Histogram widget.

Definition at line 28 of file ecvHistogramWindow.h.

Member Enumeration Documentation

◆ AxisDisplayOption

Enumerator
None 
XAxis 
YAxis 
All 

Definition at line 111 of file ecvHistogramWindow.h.

◆ HISTOGRAM_COLOR_SCHEME

Enumerator
USE_SOLID_COLOR 
USE_CUSTOM_COLOR_SCALE 
USE_SF_SCALE 

Definition at line 75 of file ecvHistogramWindow.h.

◆ SELECTABLE_ITEMS

Selectable items in "SF interaction" mode.

Enumerator
NONE 
LEFT_AREA 
RIGHT_AREA 
BOTH_AREAS 
LEFT_ARROW 
RIGHT_ARROW 
BOTH_ARROWS 

Definition at line 218 of file ecvHistogramWindow.h.

◆ SFInteractionMode

Enumerator
None 
DisplayRange 
SaturationRange 
All 

Definition at line 120 of file ecvHistogramWindow.h.

Constructor & Destructor Documentation

◆ ccHistogramWindow()

ccHistogramWindow::ccHistogramWindow ( QWidget *  parent = 0)
explicit

Default constructor.

Definition at line 35 of file ecvHistogramWindow.cpp.

References m_renderingFont.

◆ ~ccHistogramWindow()

ccHistogramWindow::~ccHistogramWindow ( )
virtual

Destructor.

Definition at line 85 of file ecvHistogramWindow.cpp.

Member Function Documentation

◆ clear()

void ccHistogramWindow::clear ( void  )

◆ computeBinArrayFromSF()

bool ccHistogramWindow::computeBinArrayFromSF ( size_t  binCount)
protected

◆ fromBinArray()

void ccHistogramWindow::fromBinArray ( const std::vector< unsigned > &  histoValues,
double  minVal,
double  maxVal 
)

Creates histogram from a bin array (each bin = number of elements per class) Number of classes can't be modified.

Parameters
histoValuesarray of bins
minValminimum value
maxValmaximum value
Returns
success

Definition at line 153 of file ecvHistogramWindow.cpp.

References getMaxHistoVal(), histoValues(), m_histoValues, m_maxHistoVal, m_maxVal, m_minVal, m_numberOfClassesCanBeChanged, maxVal(), minVal(), and CVLog::Warning().

Referenced by ccColorFromScalarDlg::ccColorFromScalarDlg(), ccEntityAction::computeStatParams(), MainWindow::spawnHistogramDialog(), and ccColorLevelsDlg::updateHistogram().

◆ fromSF()

void ccHistogramWindow::fromSF ( ccScalarField sf,
unsigned  initialNumberOfClasses = 0,
bool  numberOfClassesCanBeChanged = true,
bool  showNaNValuesInGrey = true 
)

Computes histogram from a scalar field.

Number of classes can be freely modified afterwards (if enabled).

Parameters
sfassociated scalar field
initialNumberOfClassesinitial number of classes
numberOfClassesCanBeChangedwhether to allow the user to modify the number of classes
showNaNValuesInGreyshow NaN values (in gray)
Returns
success

Definition at line 127 of file ecvHistogramWindow.cpp.

References ccScalarField::displayRange(), cloudViewer::ScalarField::getMax(), cloudViewer::ScalarField::getMin(), CCShareable::link(), m_associatedSF, m_maxVal, m_minVal, m_numberOfClassesCanBeChanged, CCShareable::release(), setColorScheme(), setNumberOfClasses(), ccScalarField::Range::start(), ccScalarField::Range::stop(), and USE_SF_SCALE.

Referenced by sfEditDlg::fillDialogWith(), ccComparisonDlg::showHisto(), and ccColorFromScalarDlg::updateChannel().

◆ getMaxHistoVal()

unsigned ccHistogramWindow::getMaxHistoVal ( )
protected

Returns current maximum bin size.

Definition at line 245 of file ecvHistogramWindow.cpp.

References m_histoValues, m_maxHistoVal, and max().

Referenced by fromBinArray(), and setNumberOfClasses().

◆ histoValues()

const std::vector<unsigned>& ccHistogramWindow::histoValues ( ) const
inline

Returns the current histogram bins.

Definition at line 102 of file ecvHistogramWindow.h.

References m_histoValues.

Referenced by ccHistogramWindowDlg::exportToCSV(), and fromBinArray().

◆ maxVal()

double ccHistogramWindow::maxVal ( ) const
inline

Returns the current histogram max value.

Definition at line 108 of file ecvHistogramWindow.h.

References m_maxVal.

Referenced by ccHistogramWindowDlg::exportToCSV(), fromBinArray(), and refresh().

◆ minVal()

double ccHistogramWindow::minVal ( ) const
inline

Returns the current histogram min value.

Definition at line 106 of file ecvHistogramWindow.h.

References m_minVal.

Referenced by ccHistogramWindowDlg::exportToCSV(), fromBinArray(), and refresh().

◆ mouseMoveEvent()

◆ mousePressEvent()

◆ refresh()

void ccHistogramWindow::refresh ( )

Updates the display.

Definition at line 323 of file ecvHistogramWindow.cpp.

References QCPBarsWithText::appendText(), ecvColor::RgbTpl< Type >::b, colors, ecvColor::darkGrey(), ecvGui::ParamStruct::displayedNumPrecision, DisplayRange, ccScalarField::displayRange(), ecvColor::RgbTpl< Type >::g, ccScalarField::getColor(), ccScalarField::getColorRampSteps(), ccScalarField::getColorScale(), ccColorScalesManager::GetDefaultScale(), height, ecvColor::lightGrey(), m_areaLeft, m_areaLeftlastValue, m_areaRight, m_areaRightlastValue, m_arrowLeft, m_arrowLeftlastValue, m_arrowRight, m_arrowRightlastValue, m_associatedSF, m_axisDisplayOptions, m_colorScale, m_colorScheme, m_curveValues, m_drawVerticalIndicator, m_histogram, m_histoValues, m_maxHistoVal, m_maxVal, m_minVal, m_overlayCurve, m_renderingFont, m_sfInteractionModes, m_solidColor, m_titlePlot, m_titleStr, m_vertBar, m_verticalIndicatorPositionPercent, ccScalarField::Range::max(), max(), maxVal(), ccScalarField::Range::min(), min(), minVal(), ecvGui::Parameters(), ecvColor::RgbTpl< Type >::r, ecvColor::red(), SaturationRange, ccScalarField::saturationRange(), QCPArrow::setColor(), QCPSelectableCursor::setCurrentVal(), QCPColoredBars::setData(), QCPSelectableCursor::setRange(), QCPBarsWithText::setText(), QCPBarsWithText::setTextAlignment(), ccScalarField::Range::start(), ccScalarField::Range::stop(), ccScalarField::symmetricalScale(), updateOverlayCurveWidth(), USE_CUSTOM_COLOR_SCALE, USE_SF_SCALE, USE_SOLID_COLOR, width, XAxis, and YAxis.

Referenced by clear(), ccEntityAction::computeStatParams(), sfEditDlg::logScaleChanged(), mouseMoveEvent(), resizeEvent(), MainWindow::spawnHistogramDialog(), sfEditDlg::symmetricalScaleChanged(), ccColorLevelsDlg::updateHistogram(), ccColorFromScalarDlg::updateHistogram(), and wheelEvent().

◆ refreshBars()

◆ resizeEvent()

void ccHistogramWindow::resizeEvent ( QResizeEvent *  event)
protected

◆ setAxisDisplayOption()

void ccHistogramWindow::setAxisDisplayOption ( AxisDisplayOptions  axisOptions)

Definition at line 315 of file ecvHistogramWindow.cpp.

References m_axisDisplayOptions.

Referenced by ccColorFromScalarDlg::updateHistogram().

◆ setAxisLabels()

void ccHistogramWindow::setAxisLabels ( const QString &  xLabel,
const QString &  yLabel 
)

◆ setColorScale()

void ccHistogramWindow::setColorScale ( ccColorScale::Shared  scale)
inline

Sets gradient color scale.

Only used if color scheme is set to USE_CUSTOM_COLOR_SCALE.

Definition at line 90 of file ecvHistogramWindow.h.

References m_colorScale.

Referenced by ccEntityAction::computeStatParams().

◆ setColorScheme()

void ccHistogramWindow::setColorScheme ( HISTOGRAM_COLOR_SCHEME  scheme)
inline

Sets how the gradient bars should be colored.

Definition at line 81 of file ecvHistogramWindow.h.

References m_colorScheme.

Referenced by ccColorLevelsDlg::ccColorLevelsDlg(), ccEntityAction::computeStatParams(), and fromSF().

◆ setCurveValues()

void ccHistogramWindow::setCurveValues ( const std::vector< double > &  curveValues)

Sets overlay curve values.

The curve will only appear over an histogram

Parameters
curveValuescurve points 'Y' coordinates only (regularly sampled between the min and max histogram values)

Definition at line 170 of file ecvHistogramWindow.cpp.

References m_curveValues, and CVLog::Warning().

Referenced by ccEntityAction::computeStatParams().

◆ setMaxDispValue()

◆ setMaxSatValue()

◆ setMinDispValue()

◆ setMinSatValue()

◆ setNumberOfClasses()

void ccHistogramWindow::setNumberOfClasses ( size_t  n)
protected

Changes the current number of classes.

Warning: n should be a multiple of 4.

Definition at line 255 of file ecvHistogramWindow.cpp.

References computeBinArrayFromSF(), getMaxHistoVal(), m_associatedSF, m_histoValues, and m_maxHistoVal.

Referenced by fromSF(), and wheelEvent().

◆ setRefreshAfterResize()

void ccHistogramWindow::setRefreshAfterResize ( bool  refreshAfterResize)

Definition at line 319 of file ecvHistogramWindow.cpp.

References m_refreshAfterResize.

Referenced by ccColorFromScalarDlg::ccColorFromScalarDlg().

◆ setSFInteractionMode()

void ccHistogramWindow::setSFInteractionMode ( SFInteractionModes  modes)

Enables SF interaction mode.

Definition at line 311 of file ecvHistogramWindow.cpp.

References m_sfInteractionModes.

Referenced by sfEditDlg::sfEditDlg(), and ccColorFromScalarDlg::updateHistogram().

◆ setSolidColor()

void ccHistogramWindow::setSolidColor ( QColor  color)
inline

Sets solid color.

Only used if color scheme is set to USE_SOLID_COLOR.

Definition at line 87 of file ecvHistogramWindow.h.

References color, and m_solidColor.

Referenced by ccColorLevelsDlg::ccColorLevelsDlg(), and ccColorLevelsDlg::updateHistogram().

◆ setTitle()

void ccHistogramWindow::setTitle ( const QString &  str)

◆ sfMaxDispValChanged

void ccHistogramWindow::sfMaxDispValChanged ( double  )
signal

◆ sfMaxSatValChanged

void ccHistogramWindow::sfMaxSatValChanged ( double  )
signal

◆ sfMinDispValChanged

void ccHistogramWindow::sfMinDispValChanged ( double  )
signal

◆ sfMinSatValChanged

void ccHistogramWindow::sfMinSatValChanged ( double  )
signal

◆ updateOverlayCurveWidth()

void ccHistogramWindow::updateOverlayCurveWidth ( int  w,
int  h 
)
protected

Updates overlay curve width depending on the widget display size.

Definition at line 656 of file ecvHistogramWindow.cpp.

References m_overlayCurve, and max().

Referenced by refresh(), and resizeEvent().

◆ wheelEvent()

void ccHistogramWindow::wheelEvent ( QWheelEvent *  event)
protected

Member Data Documentation

◆ m_areaLeft

QCPHiddenArea* ccHistogramWindow::m_areaLeft
protected

Left greyed area.

Definition at line 231 of file ecvHistogramWindow.h.

Referenced by mouseMoveEvent(), mousePressEvent(), refresh(), and setMinDispValue().

◆ m_areaLeftlastValue

double ccHistogramWindow::m_areaLeftlastValue
protected

Definition at line 232 of file ecvHistogramWindow.h.

Referenced by refresh(), and setMinDispValue().

◆ m_areaRight

QCPHiddenArea* ccHistogramWindow::m_areaRight
protected

Right greyed area.

Definition at line 234 of file ecvHistogramWindow.h.

Referenced by mouseMoveEvent(), mousePressEvent(), refresh(), and setMaxDispValue().

◆ m_areaRightlastValue

double ccHistogramWindow::m_areaRightlastValue
protected

Definition at line 235 of file ecvHistogramWindow.h.

Referenced by refresh(), and setMaxDispValue().

◆ m_arrowLeft

QCPArrow* ccHistogramWindow::m_arrowLeft
protected

Left arrow.

Definition at line 238 of file ecvHistogramWindow.h.

Referenced by mouseMoveEvent(), mousePressEvent(), refresh(), and setMinSatValue().

◆ m_arrowLeftlastValue

double ccHistogramWindow::m_arrowLeftlastValue
protected

Definition at line 239 of file ecvHistogramWindow.h.

Referenced by refresh(), and setMinSatValue().

◆ m_arrowRight

QCPArrow* ccHistogramWindow::m_arrowRight
protected

Right arrow.

Definition at line 241 of file ecvHistogramWindow.h.

Referenced by mouseMoveEvent(), mousePressEvent(), refresh(), and setMaxSatValue().

◆ m_arrowRightlastValue

double ccHistogramWindow::m_arrowRightlastValue
protected

Definition at line 242 of file ecvHistogramWindow.h.

Referenced by refresh(), and setMaxSatValue().

◆ m_associatedSF

ccScalarField* ccHistogramWindow::m_associatedSF
protected

◆ m_axisDisplayOptions

AxisDisplayOptions ccHistogramWindow::m_axisDisplayOptions
protected

Definition at line 211 of file ecvHistogramWindow.h.

Referenced by refresh(), and setAxisDisplayOption().

◆ m_colorScale

ccColorScale::Shared ccHistogramWindow::m_colorScale
protected

Gradient color scale.

Definition at line 181 of file ecvHistogramWindow.h.

Referenced by refresh(), and setColorScale().

◆ m_colorScheme

HISTOGRAM_COLOR_SCHEME ccHistogramWindow::m_colorScheme
protected

Color scheme.

Definition at line 177 of file ecvHistogramWindow.h.

Referenced by refresh(), refreshBars(), and setColorScheme().

◆ m_curveValues

std::vector<double> ccHistogramWindow::m_curveValues
protected

Definition at line 201 of file ecvHistogramWindow.h.

Referenced by refresh(), and setCurveValues().

◆ m_drawVerticalIndicator

bool ccHistogramWindow::m_drawVerticalIndicator
protected

Definition at line 205 of file ecvHistogramWindow.h.

Referenced by mouseMoveEvent(), and refresh().

◆ m_histogram

QCPColoredBars* ccHistogramWindow::m_histogram
protected

Definition at line 193 of file ecvHistogramWindow.h.

Referenced by mouseMoveEvent(), refresh(), and refreshBars().

◆ m_histoValues

std::vector<unsigned> ccHistogramWindow::m_histoValues
protected

◆ m_lastMouseClick

QPoint ccHistogramWindow::m_lastMouseClick
protected

Last mouse click.

Definition at line 245 of file ecvHistogramWindow.h.

Referenced by mouseMoveEvent(), and mousePressEvent().

◆ m_maxHistoVal

unsigned ccHistogramWindow::m_maxHistoVal
protected

Definition at line 197 of file ecvHistogramWindow.h.

Referenced by fromBinArray(), getMaxHistoVal(), refresh(), and setNumberOfClasses().

◆ m_maxVal

double ccHistogramWindow::m_maxVal
protected

◆ m_minVal

double ccHistogramWindow::m_minVal
protected

◆ m_numberOfClassesCanBeChanged

bool ccHistogramWindow::m_numberOfClassesCanBeChanged
protected

Only possible with an associated scalar field.

Definition at line 188 of file ecvHistogramWindow.h.

Referenced by fromBinArray(), fromSF(), and wheelEvent().

◆ m_overlayCurve

QCPGraph* ccHistogramWindow::m_overlayCurve
protected

Overlay curve.

Definition at line 200 of file ecvHistogramWindow.h.

Referenced by refresh(), and updateOverlayCurveWidth().

◆ m_refreshAfterResize

bool ccHistogramWindow::m_refreshAfterResize
protected

Definition at line 190 of file ecvHistogramWindow.h.

Referenced by resizeEvent(), and setRefreshAfterResize().

◆ m_renderingFont

QFont ccHistogramWindow::m_renderingFont
protected

Rendering font.

Definition at line 209 of file ecvHistogramWindow.h.

Referenced by ccHistogramWindow(), and refresh().

◆ m_selectedItem

SELECTABLE_ITEMS ccHistogramWindow::m_selectedItem
protected

Currently selected item.

Definition at line 228 of file ecvHistogramWindow.h.

Referenced by mouseMoveEvent(), and mousePressEvent().

◆ m_sfInteractionModes

SFInteractionModes ccHistogramWindow::m_sfInteractionModes
protected

Which SF interaction modes are enabled.

Definition at line 215 of file ecvHistogramWindow.h.

Referenced by mouseMoveEvent(), mousePressEvent(), refresh(), and setSFInteractionMode().

◆ m_solidColor

QColor ccHistogramWindow::m_solidColor
protected

Solid color.

Definition at line 179 of file ecvHistogramWindow.h.

Referenced by refresh(), and setSolidColor().

◆ m_titlePlot

QCPTextElement* ccHistogramWindow::m_titlePlot
protected

Definition at line 174 of file ecvHistogramWindow.h.

Referenced by refresh().

◆ m_titleStr

QString ccHistogramWindow::m_titleStr
protected

Definition at line 173 of file ecvHistogramWindow.h.

Referenced by refresh(), and setTitle().

◆ m_vertBar

QCPBarsWithText* ccHistogramWindow::m_vertBar
protected

Definition at line 204 of file ecvHistogramWindow.h.

Referenced by refresh().

◆ m_verticalIndicatorPositionPercent

double ccHistogramWindow::m_verticalIndicatorPositionPercent
protected

Definition at line 206 of file ecvHistogramWindow.h.

Referenced by mouseMoveEvent(), and refresh().


The documentation for this class was generated from the following files: