Public Slots | Public Member Functions | Protected Member Functions
HistogramWidget Class Reference

Brief description of class still missing. More...

#include <HistogramWidget.h>

List of all members.

Public Slots

void addMeanCurve ()
void addMedianCurve ()
void addModeCurve ()
void show ()

Public Member Functions

void fillGrid ()
 HistogramWidget (QWidget *parent=0)
 HistogramWidget (MaxEntryList *maxList, QWidget *parent=0)
void initGrid (int nValueClasses, double minValueHisto, double maxValueHisto, SamplingOption ySampling)
bool loadMax (QString fileName)
MaxEntryListmaxEntryList ()
bool select (bool scaleTypeForced, SamplingOption scaleType)
void setHistogram (Histogram2D *hist)
void toStream (QTextStream &s, int curveIndex)
 ~HistogramWidget ()
 ~HistogramWidget ()

Protected Member Functions

void closeEvent (QCloseEvent *e)
virtual void closeEvent (QCloseEvent *e)

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

HistogramWidget::HistogramWidget ( QWidget *  parent = 0)

Description of constructor still missing

References SciFigs::ParallelBands::addBand(), SciFigs::LineLayer::addLine(), SciFigs::GraphContentLayer::addTrackingAction(), SciFigs::Axis::setNumberPrecision(), SciFigs::Axis::setNumberType(), SciFigs::GraphicObject::setObjectName(), SciFigs::GraphContentLayer::setOpacity(), SciFigs::GraphicObject::setPrintHeight(), SciFigs::GraphicObject::setPrintLeft(), SciFigs::GraphicObject::setPrintTop(), SciFigs::GraphicObject::setPrintWidth(), SciFigs::Axis::setRange(), SciFigs::LineLayer::setReferenceLine(), SciFigs::LineLayer::setReferencePen(), SciFigs::Axis::setTitle(), QGpCoreTools::tr(), TRACE, SciFigs::AxisWindow::updateInternalGeometry(), w, and SciFigs::AxisWindow::yAxis().

    : QWidget(parent)
{
  TRACE;
  setupUi(this);
  setAttribute(Qt::WA_DeleteOnClose, false);
  setFocusPolicy(Qt::ClickFocus);
  _hist=0;
  _lastX=0;

  AxisWindow * w;
  QAction * a;

  w=new AxisWindow(this);
  w->setObjectName( "Histogram" );
  sheet->sheet()->addObject(w);
  w->setPrintLeft(0.5);
  w->setPrintTop(0.5);
  w->setPrintWidth(16.0);
  w->setPrintHeight(8.0);
  w->updateInternalGeometry();
  _histogramLayer=new IrregularGrid2DPlot(w);
  LineLayer * curveLayer=new LineLayer(w);
  curveLayer->setReferenceLine(new RealStatisticalLine);
  curves->setProxy(new RealStatisticalProxy);
  curves->initLayer(curveLayer);
  curves->setCurrentLayer(curveLayer);
  //a=curves->addCurveAction(tr("&Adjust"), tr("Adjust current curve to the closest maximum"), true);
  //connect(a, SIGNAL(triggered()), this, SLOT(adjustCurve()) );
  sheet->sheet()->showObject(w);

  new QShortcut(Qt::Key_Up, this, SLOT(nextX()));
  new QShortcut(Qt::Key_Up+Qt::SHIFT, this, SLOT(nextXReject()));
  new QShortcut(Qt::Key_Down, this, SLOT(previousX()));
  new QShortcut(Qt::Key_Down+Qt::SHIFT, this, SLOT(previousXReject()));
  new QShortcut(Qt::Key_Left, this, SLOT(decreaseLowLimit()));
  new QShortcut(Qt::Key_Left+Qt::SHIFT, this, SLOT(decreaseHighLimit()));
  new QShortcut(Qt::Key_Right, this, SLOT(increaseLowLimit()));
  new QShortcut(Qt::Key_Right+Qt::SHIFT, this, SLOT(increaseHighLimit()));

  // Init the curve menu
  QMenu * m=new QMenu(this);
  m->setTitle(tr( "Curve"));
  m->setTearOffEnabled (true);
  curveBut->setMenu(m);

  a=new QAction(tr("&Mean"), this);
  curveBut->menu()->addAction(a);
  connect(a, SIGNAL(triggered()), this, SLOT(addMeanCurve()) );
  a=new QAction(tr("Medi&an"), this);
  curveBut->menu()->addAction(a);
  connect(a, SIGNAL(triggered()), this, SLOT(addMedianCurve()) );
  a=new QAction(tr("Mo&de"), this);
  curveBut->menu()->addAction(a);
  connect(a, SIGNAL(triggered()), this, SLOT(addModeCurve()) );

  w=new AxisWindow(this);
  sheet->sheet()->addObject(w);
  w->setPrintLeft(0.5);
  w->setPrintTop(8.5);
  w->setPrintWidth(8.0);
  w->setPrintHeight(6.0);
  w->updateInternalGeometry();
  _densityBandLayer=new ParallelBands(w);
  _densityBandLayer->setObjectName( "DensitySelection" );
  _densityBandLayer->addTrackingAction(tr("Pick bands"), 0, tr("Define the X band to reject."));
  _densityBandLayer->setOpacity(0.6);
  _densityBandLayer->addBand(0, 0, Brush(QColor( 205, 242, 255) ));
  connect(_densityBandLayer, SIGNAL(bandPicked(double, double)), this, SLOT(setBand( double, double) ));
  _densityCurveLayer=new LineLayer(w);
  _densityCurveLayer->setObjectName( "Density" );
  _densityCurveLayer->setReferenceLine(new PlotLine2D);
  _densityCurveLayer->setReferencePen(Pen( Qt::blue) );
  _densityCurveLayer->addLine(Pen( Qt::blue), Symbol());
  _densityCurveLayer->addLine(Pen( Qt::red), Symbol());
  w->yAxis()->setNumberType(Number::Scientific);
  w->yAxis()->setNumberPrecision(1);
  w->yAxis()->setTitle( "Probability density" );
  sheet->sheet()->showObject(w);

  w=new AxisWindow(this);
  sheet->sheet()->addObject(w);
  w->setPrintLeft(8.5);
  w->setPrintTop(8.5);
  w->setPrintWidth(8.0);
  w->setPrintHeight(6.0);
  w->updateInternalGeometry();
  _cumulativeBandLayer=new ParallelBands(w);
  _cumulativeBandLayer->setObjectName( "CumulativeSelection" );
  _cumulativeBandLayer->addTrackingAction(tr("Pick bands"), 0, tr("Define the X band to reject."));
  _cumulativeBandLayer->setOpacity(0.6);
  _cumulativeBandLayer->addBand(0, 0, Brush(QColor( 205, 242, 255) ));
  connect(_cumulativeBandLayer, SIGNAL(bandPicked(double, double)), this, SLOT(setBand( double, double) ));
  _cumulativeCurveLayer=new LineLayer(w);
  _cumulativeCurveLayer->setObjectName( "Cumulative" );
  _cumulativeCurveLayer->setReferenceLine(new PlotLine2D);
  _cumulativeCurveLayer->setReferencePen(Pen( Qt::blue) );
  _cumulativeCurveLayer->addLine(Pen( Qt::blue), Symbol());
  _cumulativeCurveLayer->addLine(Pen( Qt::red), Symbol());
  w->yAxis()->setRange(0.0, 1.0);
  w->yAxis()->setNumberType(Number::Fixed);
  w->yAxis()->setNumberPrecision(1);
  w->yAxis()->setTitle( "Cumulative probability" );
  sheet->sheet()->showObject(w);

  Settings::getWidget(this, "Histogram" );
}

Description of destructor still missing

References TRACE.

{
  TRACE;
}
HistogramWidget::HistogramWidget ( MaxEntryList maxList,
QWidget *  parent = 0 
)

References MaxEntryList::CURVE, MaxEntryList::FK, SciFigs::CurveBrowser::initLayer(), SciFigs::CurveBrowser::setCurrentLayer(), StatGridAnalyser::setGrid(), SciFigs::GraphicObject::setObjectName(), SciFigs::CurveBrowser::setProxy(), SciFigs::LineLayer::setReferenceLine(), MaxEntryList::SPAC, MaxEntryList::TFA, TRACE, MaxEntryList::type(), MaxEntryList::Undefined, and SciFigs::AxisWindow::yAxis().

                                                                         : QWidget(parent)
{
  TRACE;
  setupUi(this);

  QSplitter * hSplitter=new QSplitter(this);
  hSplitter->setOrientation(Qt::Horizontal);
  _curves=new CurveBrowser(hSplitter);
  AxisWindow * graph=new AxisWindow(hSplitter);
  graph->setObjectName( "HistogramWidget" );
  _gridLayer=new IrregularGrid2DPlot(graph);
  _gridLayer->setObjectName("histograms");
  LineLayer * curveLayer=new LineLayer(graph);
  curveLayer->setObjectName("curves");

  _maxList=maxList;
  switch (_maxList->type()) {
  case MaxEntryList::Undefined: ASSERT(false);
  case MaxEntryList::FK:
    _curves->setProxy(new DispersionProxy);
    curveLayer->setReferenceLine(new ModalLine);
    break;
  case MaxEntryList::SPAC:
    _curves->setProxy(new AutocorrProxy);
    curveLayer->setReferenceLine(new ModalLine);
   break;
  case MaxEntryList::TFA:
    _curves->setProxy(new EllipticityProxy);
    curveLayer->setReferenceLine(new ModalLine);
    break;
  case MaxEntryList::CURVE:
    _curves->setProxy(new RealStatisticalProxy);
    curveLayer->setReferenceLine(new RealStatisticalLine);
    break;
  }
  _curves->initLayer(curveLayer);
  _curves->setCurrentLayer(curveLayer);
  //QAction * a=_curves->addCurveAction(tr("&Adjust"), tr("Adjust current curve to the closest maximum"), true);
  //connect(a, SIGNAL(triggered()), this, SLOT(adjustCurve()) );
  qobject_cast<QVBoxLayout *>(layout())->insertWidget(0, hSplitter);

  Settings::getRect(this, "HistogramWidget" );

  _statWidget=new StatGridAnalyser(0, Qt::Window);
  _statWidget->setGrid(_gridLayer, graph->yAxis());
  Settings::getWidget(_statWidget, "StatGridAnalyser");
  connect(_statWidget, SIGNAL(reject( double, double, double) ),
           this, SLOT(unselectValue( double, double, double) ));
  connect(_statWidget, SIGNAL(undo( double) ),
           this, SLOT(selectAll( double) ));
  connect(_statWidget, SIGNAL(newMean()), this, SLOT(addMeanCurve()) );
  connect(_statWidget, SIGNAL(newMedian()), this, SLOT(addMedianCurve()) );
  connect(_statWidget, SIGNAL(newMode()), this, SLOT(addModeCurve()) );
}

Member Function Documentation

void HistogramWidget::addMeanCurve ( ) [slot]
void HistogramWidget::addMedianCurve ( ) [slot]
void HistogramWidget::addModeCurve ( ) [slot]
void HistogramWidget::closeEvent ( QCloseEvent *  e) [protected]

References TRACE.

{
  TRACE;
  Settings::setWidget(this, "Histogram");
  e->accept();
}
virtual void HistogramWidget::closeEvent ( QCloseEvent *  e) [protected, virtual]

References SciFigs::AxisWindow::deepUpdate(), MaxEntryList::fillGrid(), SciFigs::IrregularGrid2DPlot::grid(), StatGridAnalyser::gridChanged(), SciFigs::IrregularGrid2DPlot::setGrid(), and TRACE.

Referenced by main(), and select().

{
  TRACE;
  IrregularGrid2D grid=_gridLayer->grid();
  _maxList->fillGrid(grid);
  // Normalize histogram
  normalizeGrid(grid);
  _gridLayer->setGrid(grid);
  _statWidget->gridChanged();
  graph()->deepUpdate();
}
void HistogramWidget::initGrid ( int  nValueClasses,
double  minValueHisto,
double  maxValueHisto,
SamplingOption  ySampling 
)

References SciFigs::CurveBrowser::currentLayer(), QGpCoreTools::endl(), MaxEntryList::initGrid(), QGpCoreTools::LinearScale, QGpCoreTools::LogScale, SciFigs::LineLayer::setErrorBar(), SciFigs::IrregularGrid2DPlot::setGrid(), SciFigs::Axis::setScaleType(), QGpCoreTools::tr(), TRACE, and SciFigs::AxisWindow::yAxis().

Referenced by main(), and select().

{
  TRACE;
  if(minValueHisto > maxValueHisto) {
    double tmp=minValueHisto;
    minValueHisto=maxValueHisto;
    maxValueHisto=tmp;
  }
  if((ySampling & LogScale) && (minValueHisto<=0.0 || maxValueHisto<=0.0) ) {
    App::stream() << tr("Null or negative values not allowed for log scales, back to linear scale") << endl;
    ySampling=LinearScale;
  }
  if(ySampling==LogScale) {
    graph()->yAxis()->setScaleType(Scale::Log);
    _curves->currentLayer()->setErrorBar(LineLayer::VerticalLogBar);
  }
  _gridLayer->setGrid(_maxList->initGrid(nValueClasses, minValueHisto, maxValueHisto, ySampling) );
}
bool HistogramWidget::loadMax ( QString  fileName)

Referenced by filter(), and main().

{return _maxList;}
bool HistogramWidget::select ( bool  scaleTypeForced,
SamplingOption  scaleType 
)

References MaxEntryList::CURVE, fillGrid(), MaxEntryList::FK, SciFigs::IrregularGrid2DPlot::grid(), initGrid(), MaxEntryList::keepComponent(), MaxEntryList::keepRing(), QGpCoreTools::LinearScale, QGpCoreTools::LogScale, QGpCoreTools::IrregularGrid2D::maximumValue(), SciFigs::GridPlot::palette(), MaxEntryList::rejectNPeaksPerMinute(), MaxEntryList::rejectPower(), SAFE_UNINITIALIZED, QGpGuiTools::ColorPalette::setColor(), SciFigs::GridPlot::setPalette(), StatGridAnalyser::setUnits(), QGpGuiTools::ColorPalette::setVLinear(), MaxEntryList::SPAC, MaxEntryList::TFA, TRACE, and MaxEntryList::type().

Referenced by main().

{
  TRACE;
  double minValueHisto, maxValueHisto;
  int nValueClasses, ringIndex, componentIndex;
  double relFac, absFac, nppm;
  SAFE_UNINITIALIZED(nppm,0);
  SAFE_UNINITIALIZED(relFac,0);
  SAFE_UNINITIALIZED(absFac,0);
  SAFE_UNINITIALIZED(componentIndex,0);
  SAFE_UNINITIALIZED(ringIndex,0);
  SAFE_UNINITIALIZED(nValueClasses,0);
  SAFE_UNINITIALIZED(minValueHisto,0);
  SAFE_UNINITIALIZED(maxValueHisto,0);
  switch (_maxList->type()) {
  case MaxEntryList::FK: {
      FKOptions * d=new FKOptions(this);
      Settings::getWidget(d);
      if(d->exec()!=QDialog::Accepted) {
        delete d;
        return false;
      }
      minValueHisto=1.0/d->maxVelocity->text().toDouble();
      maxValueHisto=1.0/d->minVelocity->text().toDouble();
      nValueClasses=d->nVelocityClasses->value();
      relFac=d->relPowerThreshold->value() * 0.01;
      absFac=d->absPowerThreshold->value() * 0.01;
      Settings::setWidget(d);
      delete d;
    }
    setWindowTitle(windowTitle().arg("FK"));
    _statWidget->setUnits("s/m");
    if(!scaleTypeForced) scaleType=LinearScale;
    break;
  case MaxEntryList::SPAC: {
      SPACOptions * d=new SPACOptions(this);
      Settings::getWidget(d);
      if(d->exec()!=QDialog::Accepted) {
        delete d;
        return false;
      }
      minValueHisto=d->maxValue->text().toDouble();
      maxValueHisto=d->minValue->text().toDouble();
      nValueClasses=d->nValueClasses->value();
      ringIndex=d->ringIndex->value();
      componentIndex=d->componentIndex->value();
      Settings::setWidget(d);
      delete d;
      setWindowTitle(windowTitle().arg("SPAC - ring %1 - component %2").arg(ringIndex).arg(componentIndex));
    }
    _statWidget->setUnits("");
    if(!scaleTypeForced) scaleType=LinearScale;
    break;
  case MaxEntryList::TFA: {
      TFAOptions * d=new TFAOptions(this);
      Settings::getWidget(d);
      if(d->exec()!=QDialog::Accepted) {
        delete d;
        return false;
      }
      minValueHisto=d->maxValue->text().toDouble();
      maxValueHisto=d->minValue->text().toDouble();
      nValueClasses=d->nValueClasses->value();
      nppm=d->nppm->value();
      Settings::setWidget(d);
      delete d;
    }
    setWindowTitle(windowTitle().arg("TFA"));
    _statWidget->setUnits("");
    if(!scaleTypeForced) scaleType=LogScale;
    break;
  case MaxEntryList::CURVE: {
      GenericOptions * d=new GenericOptions(this);
      Settings::getWidget(d);
      if(d->exec()!=QDialog::Accepted) {
        delete d;
        return false;
      }
      //minValueHisto=d->minValue->text().toDouble();
      //maxValueHisto=d->maxValue->text().toDouble();
      //nValueClasses=d->nValueClasses->value();
      Settings::setWidget(d);
      delete d;
    }
    setWindowTitle(windowTitle().arg("CURVE"));
    _statWidget->setUnits("");
    if(!scaleTypeForced) scaleType=LinearScale;
    break;
  default:
    return false;
  }
  // Sample selection
  switch (_maxList->type()) {
  case MaxEntryList::FK:
    _maxList->rejectPower(relFac, absFac);
    break;
  case MaxEntryList::SPAC:
    _maxList->keepRing(ringIndex);
    _maxList->keepComponent(componentIndex);
    break;
  case MaxEntryList::TFA:
    _maxList->rejectNPeaksPerMinute(nppm);
    break;
  default:
    break;
  }
  initGrid(nValueClasses, minValueHisto, maxValueHisto, scaleType);
  fillGrid();
  addMedianCurve();
  setLimits();
  ColorPalette pal=_gridLayer->palette();
  pal.setVLinear(0, _gridLayer->grid().maximumValue());
  pal.setColor(0, Qt::white);
 _gridLayer->setPalette(pal);
  return true;
}
void HistogramWidget::show ( ) [slot]

References TRACE.

Referenced by main().

{
  TRACE;
  QWidget::show();
  _statWidget->show();
}
void HistogramWidget::toStream ( QTextStream &  s,
int  curveIndex 
)

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines