Exemplo n.º 1
0
void MainWindow::saveSettings(){
    if(fullScreen())
        this->showNormal();

    QSettings settingsNative;

    settingsNative.setValue("pos",  pos());
    settingsNative.setValue("size", size());

    settingsNative.setValue("backgroundRed", backgroundColor().red());
    settingsNative.setValue("backgroundGreen", backgroundColor().green());
    settingsNative.setValue("backgroundBlue", backgroundColor().blue());

    settingsNative.setValue("canvasRed", canvasColor().red());
    settingsNative.setValue("canvasGreen", canvasColor().green());
    settingsNative.setValue("canvasBlue", canvasColor().blue());

    settingsNative.setValue("infoRed", infoColor().red());
    settingsNative.setValue("infoGreen", infoColor().green());
    settingsNative.setValue("infoBlue", infoColor().blue());

    QSettings settings(Constants::SETTINGS_FOLDER + "/" + Constants::PLAYER_SETTINGS_FILE, QSettings::IniFormat);

    settings.setValue("orientation", orientation());
    settings.setValue("alwaysOnTop", alwaysOnTop());
    settings.setValue("autoScale",   autoScale());
    settings.setValue("width",       width());
    settings.setValue("height",      height());
    settings.setValue("fps",         fps());
    settings.setValue("scale",       scale());
    settings.setValue("drawInfos",   drawInfos());

    if(fullScreen())
        this->showFullScreen();
}
Exemplo n.º 2
0
void QcepPlot::contextMenuEvent(QContextMenuEvent *event)
{
  QMenu plotMenu(NULL, NULL);

  QAction *xLog = plotMenu.addAction("Log X Axis");
  QAction *yLog = plotMenu.addAction("Log Y Axis");
  QAction *auSc = plotMenu.addAction("Autoscale");
  QAction *prGr = plotMenu.addAction("Print Graph...");

  QcepPlotSettingsPtr set(m_PlotSettings);

  if (set) {
    xLog->setCheckable(true);
    yLog->setCheckable(true);
    xLog->setChecked(set->get_XAxisLog());
    yLog->setChecked(set->get_YAxisLog());

    QAction *action = plotMenu.exec(event->globalPos());

    if (action == xLog) {
      set->toggle_XAxisLog();
    } else if (action == yLog) {
      set->toggle_YAxisLog();
    } else if (action == auSc) {
      autoScale();
    } else if (action == prGr) {
      printGraph();
    }
  }

  event->accept();
}
Exemplo n.º 3
0
/*!
  \brief Set the range

  \param minValue value corresponding lower or left end 
                  of the thermometer
  \param maxValue value corresponding to the upper or 
                  right end of the thermometer
  \param logarithmic logarithmic mapping, true or false
*/
void QwtThermo::setRange( 
    double minValue, double maxValue, bool logarithmic )
{
    if ( minValue == d_data->minValue && maxValue == d_data->maxValue
        && logarithmic == qwtIsLogarithmic( this ) )
    {
        return;
    }

    if ( logarithmic != qwtIsLogarithmic( this ) )
    {
        if ( logarithmic )
            setScaleEngine( new QwtLog10ScaleEngine );
        else
            setScaleEngine( new QwtLinearScaleEngine );
    }

    d_data->minValue = minValue;
    d_data->maxValue = maxValue;

    /*
      There are two different maps, one for the scale, the other
      for the values. This is confusing and will be changed
      in the future. TODO ...
     */

    d_data->map.setTransformation( scaleEngine()->transformation() );
    d_data->map.setScaleInterval( minValue, maxValue );

    if ( autoScale() )
        rescale( minValue, maxValue );

    layoutThermo( true );
}
Exemplo n.º 4
0
void Image::layout()
{
    qreal f = _sizeIsSpatium ? spatium() : MScore::DPMM;
    // if autoscale && inside a box, scale to box relevant size
    if (autoScale() && parent() && ((parent()->type() == HBOX || parent()->type() == VBOX))) {
        if (_lockAspectRatio) {
            QSizeF size(imageSize());
            qreal ratio = size.width() / size.height();
            qreal w = parent()->width();
            qreal h = parent()->height();
            if ((w / h) < ratio) {
                _size.setWidth(w / f);
                _size.setHeight((w / ratio) / f);
            }
            else {
                _size.setHeight(h / f);
                _size.setWidth(h * ratio / f);
            }
        }
        else
            _size = parent()->bbox().size() / f;
    }

    // in any case, adjust position relative to parent
    adjustReadPos();
    setbbox(QRectF(0.0, 0.0, _size.width() * f, _size.height() * f));
}
Exemplo n.º 5
0
/*!
  \brief Notify a change of the range

  Called by QwtAbstractSlider
*/
void QwtKnob::rangeChange()
{
    if ( autoScale() )
        rescale( minValue(), maxValue() );

    layoutKnob( true );
    recalcAngle();
}
Exemplo n.º 6
0
void Image::layout()
      {
      setPos(0.0, 0.0);
      if (imageType == ImageType::SVG && !svgDoc) {
            if (_storeItem) {
                  svgDoc = new QSvgRenderer(_storeItem->buffer());
                  if (svgDoc->isValid()) {
                        if (_size.isNull()) {
                              _size = svgDoc->defaultSize();
                              if (_sizeIsSpatium)
                                    _size /= 10.0;    // by convention
                              }
                        }
                  }
            }
      else if (imageType == ImageType::RASTER && !rasterDoc) {
            if (_storeItem) {
                  rasterDoc = new QImage;
                  rasterDoc->loadFromData(_storeItem->buffer());
                  if (!rasterDoc->isNull()) {
                        if (_size.isNull()) {
                              _size = rasterDoc->size() * 0.4;
                              if (_sizeIsSpatium)
                                    _size /= spatium();
                              else
                                    _size /= MScore::DPMM;
                              }
                        _dirty = true;
                        }
                  }
            }

      qreal f = _sizeIsSpatium ? spatium() : MScore::DPMM;
      // if autoscale && inside a box, scale to box relevant size
      if (autoScale() && parent() && ((parent()->type() == Element::Type::HBOX || parent()->type() == Element::Type::VBOX))) {
            if (_lockAspectRatio) {
                  QSizeF size(imageSize());
                  qreal ratio = size.width() / size.height();
                  qreal w = parent()->width();
                  qreal h = parent()->height();
                  if ((w / h) < ratio) {
                        _size.setWidth(w / f);
                        _size.setHeight((w / ratio) / f);
                        }
                  else {
                        _size.setHeight(h / f);
                        _size.setWidth(h * ratio / f);
                        }
                  }
            else
                  _size = parent()->bbox().size() / f;
            }

      // in any case, adjust position relative to parent
      adjustReadPos();
      bbox().setRect(0.0, 0.0, _size.width() * f, _size.height() * f);
      }
Exemplo n.º 7
0
void MainWindow::updateAutoScale(){
    if(autoScale()){
        ui.centralWidget->setMinimumSize(1, 1);

    }else{
        ui.centralWidget->setMinimumSize(0, 0);

        QAction *action = resolutionGroup_->checkedAction();
        if(action){
            setWidth(action->property("width").toInt());
            setHeight(action->property("height").toInt());
        }
    }

    resolutionGroup_->setEnabled(!autoScale());

    updateResolution();
}
Exemplo n.º 8
0
//! Notify change of range
void QwtSlider::rangeChange()
{
    d_data->map.setScaleInterval(minValue(), maxValue());

    if (autoScale())
        rescale(minValue(), maxValue());

    QwtAbstractSlider::rangeChange();
    layoutSlider();
}
Exemplo n.º 9
0
void Chart::fullUpdate() {
	autoScale();

    if(_style == STYLE_BAR) {
        drawFullGraphBar(false);
    } else if(_style == STYLE_LINE) {
        drawFullGraphLine();
    } else if(_style == STYLE_BAR_REL) {
        drawFullGraphBar(true);
    }
}
Exemplo n.º 10
0
void CurveWidget::addCurve(const QString &title, const QPen &pen, const QVector<QPointF> &samples)
{
    Curve* curve = new Curve(title);
    curve->setLinePen(pen);
    curve->attach(this);
    curve->setSamples(samples);
    curve->setSheftCount(100);
    autoScale();

    q_curves.push_back(curve);
}
Exemplo n.º 11
0
void TimelineWidget::setRange(double vmin, double vmax, bool lg)
{
   mpD->minValue = vmin;
   mpD->maxValue = vmax;
   setScaleEngine(new QwtLinearScaleEngine);
   mpD->map.setTransformation(scaleEngine()->transformation());
   mpD->map.setScaleInterval(mpD->minValue, mpD->maxValue);
   if(autoScale())
   {
      rescale(mpD->minValue, mpD->maxValue);
   }
}
Exemplo n.º 12
0
void QxrdImagePlot::replotImage()
{
  m_DataImage -> setData(m_DataRaster);

  m_DataImage -> invalidateCache();
  m_DataImage -> itemChanged();

  if (m_FirstTime) {
    autoScale();
    m_FirstTime = false;
  } else {
    replot();
  }
}
Exemplo n.º 13
0
QVariant Image::getProperty(Pid propertyId) const
      {
      switch(propertyId) {
            case Pid::AUTOSCALE:
                  return autoScale();
            case Pid::SIZE:
                  return size();
            case Pid::LOCK_ASPECT_RATIO:
                  return lockAspectRatio();
            case Pid::SIZE_IS_SPATIUM:
                  return sizeIsSpatium();
            default:
                  return Element::getProperty(propertyId);
            }
      }
Exemplo n.º 14
0
void MainWindow::checkLoadedSettings(){
    QAction *action;

    action = resolutionGroup_->checkedAction();

    if(action)
        action->setChecked(false);

    QList<QAction*> resolutionListActions = resolutionGroup_->actions();
    foreach(QAction *action, resolutionListActions){
        if(action->property("width").toInt() == width() && action->property("height").toInt() == height()){
            action->setChecked(true);
            break;
        }
    }

    action = fpsGroup_->checkedAction();
    if(action)
        action->setChecked(false);

    QList<QAction*> fpsListActions = fpsGroup_->actions();
    foreach(QAction *action, fpsListActions){
        if(action->property("fps").toInt() == fps()){
            action->setChecked(true);
            break;
        }
    }

    action = orientationGroup_->checkedAction();
    if(action)
        action->setChecked(false);

    QList<QAction*> orientationListActions = orientationGroup_->actions();
    foreach(QAction *action, orientationListActions){
        if(static_cast<Orientation>(action->property("orientation").toInt()) == orientation()){
            action->setChecked(true);
            break;
        }
    }

    ui.actionDraw_Infos->setChecked(drawInfos());
    ui.actionAlways_on_Top->setChecked(alwaysOnTop());
    ui.actionAuto_Scale->setChecked(autoScale());
}
Exemplo n.º 15
0
void Image::layout()
      {
      setPos(0.0, 0.0);
      if (imageType == ImageType::SVG && !svgDoc) {
            if (_storeItem)
                  svgDoc = new QSvgRenderer(_storeItem->buffer());
            }
      else if (imageType == ImageType::RASTER && !rasterDoc) {
            if (_storeItem) {
                  rasterDoc = new QImage;
                  rasterDoc->loadFromData(_storeItem->buffer());
                  if (!rasterDoc->isNull())
                        _dirty = true;
                  }
            }
      if (_size.isNull())
            _size = pixel2size(imageSize());

      // if autoscale && inside a box, scale to box relevant size
      if (autoScale() && parent() && ((parent()->isHBox() || parent()->isVBox()))) {
            if (_lockAspectRatio) {
                  qreal f = _sizeIsSpatium ? spatium() : DPMM;
                  QSizeF size(imageSize());
                  qreal ratio = size.width() / size.height();
                  qreal w = parent()->width();
                  qreal h = parent()->height();
                  if ((w / h) < ratio) {
                        _size.setWidth(w / f);
                        _size.setHeight((w / ratio) / f);
                        }
                  else {
                        _size.setHeight(h / f);
                        _size.setWidth(h * ratio / f);
                        }
                  }
            else
                  _size = pixel2size(parent()->bbox().size());
            }

      // in any case, adjust position relative to parent
      setbbox(QRectF(QPointF(), size2pixel(_size)));
      }
Exemplo n.º 16
0
void MainWindow::updateResolution(){
    if(autoScale()){
        setWidth(ui.centralWidget->width());
        setHeight(ui.centralWidget->height());

        if(orientation() == eLandscapeLeft || orientation() == eLandscapeRight){
            setWidth(ui.centralWidget->height());
            setHeight(ui.centralWidget->width());

            if(hideMenu())
                setWidth(width() + ui.menuBar->height());

        }else if(hideMenu())
            setHeight(height() + ui.menuBar->height());
    }

    float canvasScaleFactor = 1;
    float widgetScaleFactor = 1;

    if (deviceScale() != 0) {
        const float hundredPercentScale = 100;
        canvasScaleFactor = hundredPercentScale / deviceScale();
        widgetScaleFactor = hundredPercentScale / scale();
    }

    ui.glCanvas->setScale(canvasScaleFactor);

    switch (orientation()){
        case ePortrait:
        case ePortraitUpsideDown:
            ui.glCanvas->setFixedSize(width() / widgetScaleFactor, height() / widgetScaleFactor);
            break;

        case eLandscapeLeft:
        case eLandscapeRight:
            ui.glCanvas->setFixedSize(height() / widgetScaleFactor, width() / widgetScaleFactor);
            break;
    }

    ui.glCanvas->setResolution(width(), height());
}
Exemplo n.º 17
0
void Image::layout()
{
#if 0
    if (!autoScale() || !parent() || (parent()->type() != HBOX && parent()->type() != VBOX))
        return;

    if (_lockAspectRatio) {
        QSizeF size(imageSize());
        qreal ratio = size.width() / size.height();
        qreal w = parent()->width();
        qreal h = parent()->height();
        if ((w / h) < ratio) {
            sz.setWidth(w);
            sz.setHeight(w / ratio);
        }
        else {
            sz.setHeight(h);
            sz.setWidth(h * ratio);
        }
    }
    else
        sz = parent()->bbox().size();
#endif
}
Exemplo n.º 18
0
/*!
  \brief Set the range
  \param vmin value corresponding lower or left end of the thermometer
  \param vmax value corresponding to the upper or right end of the thermometer
  \param logarithmic logarithmic mapping, true or false
*/
void QwtThermo::setRange(double vmin, double vmax, bool logarithmic)
{
    d_data->minValue = vmin;
    d_data->maxValue = vmax;

    if ( logarithmic )
        setScaleEngine(new QwtLog10ScaleEngine);
    else
        setScaleEngine(new QwtLinearScaleEngine);

    /*
      There are two different maps, one for the scale, the other
      for the values. This is confusing and will be changed
      in the future. TODO ...
     */

    d_data->map.setTransformation(scaleEngine()->transformation());
    d_data->map.setScaleInterval(d_data->minValue, d_data->maxValue);

    if (autoScale())
        rescale(d_data->minValue, d_data->maxValue);

    layoutThermo();
}
Exemplo n.º 19
0
void MainWindow::resizeEvent(QResizeEvent*){    
    if(autoScale())
        updateResolution();
}
Exemplo n.º 20
0
struct histoResult *histoGram(float *values, size_t N, float binSize,
                              unsigned binCount, float minValue, float min, float max,
                              struct histoResult *accumHisto)
/*	construct histogram of data in values[N] array.  The extra
 *	options of binSize, binCount, minValue, min, max are optional.
 *	Run autoScaling when min == max == 0.0
 *	Defaults for binSize, binCount and minValue can be given even
 *	when auto-scaling, or NAN's for the floats, or 0 for the
 *	binCount to determine them too.
 *	When they are specified they will be used in place of auto
 *	scaled determined values.  If the min and max of the data is
 *	known, pass those in on min,max to aid the calculation of auto
 *	scaled values.  NAN's can be in the values[N] array and will be
 *	ignored.
 *	NOTE: when giving a binCount, it is actually one
 *	higher to get the minimum and maximum values in the first and
 *	last (binCount-1) bins correctly.  The resulting histogram will
 *	appear to be (binCount-1) number of bins.
 *	When given a pointer to accumHisto, use that existing histo gram
 *	and continue accumulations in it.
 */
{
    float autoBinSize = NAN;	/*	pass NAN's to cause auto scaling */
    float autoMinValue = NAN;
    float range = 0.0;
    unsigned autoBinCount = 0;
    unsigned autoValueCount = 0;
    boolean autoScaling = FALSE;
    unsigned valueCount = 0;
    unsigned i;			/*	array index	*/
    struct histoResult *hr;
    unsigned missed = 0;

    if (N == 0)
        return NULL;	/*	we don't work on zero number of values	*/

    if (accumHisto)		/*	if accumulating in existing histogram	*/
    {   /*	use its parameters as the scaling values */
        autoBinCount = accumHisto->binCount;
        autoBinSize = accumHisto->binSize;
        autoMinValue = accumHisto->binZero;
        autoScaling = FALSE;
        range = autoBinSize * (autoBinCount - 1);
        valueCount = accumHisto->count;
    }
    else
    {
        /*	Caller may give us a range to work within	*/
        if ( (0.0 == min) && (0.0 == max) )
            autoScaling = TRUE;
        else
        {
            range = max - min;
            if (range == 0.0)
                return NULL;	/*	caller gave us equal min, max !	*/
        }

        /*	Caller may give us any of the binCount, binSize, minValue */
        if (binCount > 1)
            autoBinCount = binCount;
        else if (!autoScaling)
            autoBinCount = DEFAULT_BIN_COUNT;

        if (!isnan(binSize))
            autoBinSize = binSize;
        else if (!autoScaling)
            autoBinSize = range / (autoBinCount - 1);

        if (!isnan(minValue))
            autoMinValue = minValue;
        else if (!autoScaling)
            autoMinValue = min;

        if (autoScaling)
        {
            autoValueCount = autoScale(values, N, &autoBinSize,
                                       &autoBinCount, &autoMinValue, &min, &max);
            if (autoValueCount == 0)
                return NULL;	/*	no result !	*/
        }
        else
            autoValueCount = N;
    }

    if (accumHisto)		/*	if accumulating in existing histogram	*/
        hr = accumHisto;
    else
    {
        AllocVar(hr);
        AllocArray(hr->binCounts,autoBinCount);
        AllocArray(hr->pValues,autoBinCount);
    }

    for (i = 0; i < N; ++i)
    {
        if (!isnan(values[i]) && (values[i] >= autoMinValue))
        {
            if ( (values[i] <= max) && (values[i] >= min) )
            {
                float f = values[i] - autoMinValue;
                int inx = (int) floor(f / autoBinSize);

                if ( (inx >= 0) && (inx < autoBinCount))
                {
                    ++valueCount;
                    ++hr->binCounts[inx];
                }
                else
                    ++missed;
            }
            else
                ++missed;
        }
        else
            ++missed;
    }	/*	for (i = 0; i < N; ++i)	*/

    if (accumHisto)		/*	if accumulating in existing histogram	*/
        hr->count = valueCount;	/*	only this is new	*/
    else
    {
        hr->binSize = autoBinSize;
        hr->binCount = autoBinCount;
        hr->count = valueCount;
        hr->binZero = autoMinValue;
    }

    for (i = 0; i < autoBinCount; ++i)
    {
        if (hr->binCounts[i] > 0)
            hr->pValues[i] = (float) hr->binCounts[i] / (float) valueCount;
        else
            hr->pValues[i] = 0.0;
    }

    return hr;
}
Exemplo n.º 21
0
FilterWindow::FilterWindow()
{
    id = 0;
    QToolBar *toolBar = new QToolBar(this);
    QToolBar *lowerToolBar = new QToolBar(this);
    //lowerToolBar->setFixedHeight(80);
    toolBar->setFixedHeight(80);

#if QT_VERSION < 0x040000
    setDockEnabled(TornOff, true);
    setRightJustification(true);
#else
    toolBar->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
    lowerToolBar->setAllowedAreas(Qt::BottomToolBarArea);
#endif
    QWidget *hBox = new QWidget(toolBar);
    QWidget *lowerBox = new QWidget(lowerToolBar);
    QLabel *label = new QLabel("Frequency", hBox);
    QLabel *clabel = new QLabel("Range Max", hBox);
    QLabel *mlabel = new QLabel("Range Min", hBox);


    QwtCounter *counter = new QwtCounter(hBox);
    QwtCounter *rangeCounter = new QwtCounter(hBox);
    QwtCounter *minCounter = new QwtCounter(hBox);
    QPushButton *scaleButton = new QPushButton("&Autoscale", hBox);
    QPushButton *mgxButton = new QPushButton("MG&x", lowerBox);
    QPushButton *avgButton = new QPushButton("Local Avg", lowerBox);
    QPushButton *eButton = new QPushButton("e", lowerBox);
    QPushButton *fButton = new QPushButton("f[n]", lowerBox);
    QPushButton *mavgButton = new QPushButton("Moving Avg", lowerBox);

    QwtKnob *rcKnob = new QwtKnob(lowerBox);
    rcKnob->setRange(0,5,.1,0);
    rcKnob->setScaleMaxMajor(10);
    rcKnob->setValue(5.0);
    QLabel *rcLabel = new QLabel("RC", rcKnob);
    rcLabel->setAlignment(Qt::AlignTop | Qt::AlignHCenter);

    QwtKnob *dtKnob = new QwtKnob(lowerBox);
    dtKnob->setRange(0,5,.1,0);
    dtKnob->setScaleMaxMajor(10);
    dtKnob->setValid(1.0);
    QLabel *dtLabel = new QLabel("Dt", dtKnob);
    dtLabel->setAlignment(Qt::AlignTop | Qt::AlignHCenter);

    QwtKnob *duKnob = new QwtKnob(lowerBox);
    duKnob->setRange(0,5000,10,1);

    duKnob->setScaleMaxMajor(10);
    duKnob->setValid(1.0);

    QLabel *duLabel = new QLabel("Du", duKnob);

    duLabel->setAlignment(Qt::AlignTop | Qt::AlignHCenter);


    // Sets the range and increment of the widgets
    counter->setRange(-1.0, 2000.0, 10.0);
    rangeCounter->setRange(-1048576.0,INT_MAX,100.0);
    minCounter->setRange(-1048576.0, INT_MAX, 100.0);

    QHBoxLayout *layout = new QHBoxLayout(hBox);
    layout->addWidget(label);
    layout->addWidget(counter);
    layout->addWidget(clabel);
    layout->addWidget(rangeCounter);
    layout->addWidget(mlabel);
    layout->addWidget(minCounter);
    layout->addWidget(scaleButton);

    QHBoxLayout *lowerLayout = new QHBoxLayout(lowerBox);
    
    lowerLayout->addWidget(mgxButton);
    lowerLayout->addWidget(avgButton);
    lowerLayout->addWidget(eButton);
    lowerLayout->addWidget(fButton);
    lowerLayout->addWidget(mavgButton);
    lowerLayout->addWidget(rcKnob);
    lowerLayout->addWidget(dtKnob);
    lowerLayout->addWidget(duKnob);

  //  layout->addWidget(new QWidget(hBox), 10); // spacer);

#if QT_VERSION >= 0x040000
    toolBar->addWidget(hBox);
    lowerToolBar->addWidget(lowerBox);
  #endif
    addToolBar(toolBar);
    

    // Instantiates the plot, this being the parent widget
    plot = new FilteredDataPlot(this);
    setCentralWidget(plot);
    addToolBarBreak(Qt::TopToolBarArea);
    addToolBar(lowerToolBar);
    


   // Connect signals
    connect(counter, SIGNAL(valueChanged(double)),
        plot, SLOT(setTimerInterval(double)) );
    connect(rangeCounter, SIGNAL(valueChanged(double)),
            plot, SLOT(setRange(double)));
    connect(minCounter, SIGNAL(valueChanged(double)),
            plot, SLOT(setMinRange(double)));
    connect(mgxButton, SIGNAL(clicked()), plot, SLOT(detachMgx()));
    connect(avgButton, SIGNAL(clicked()), plot, SLOT(detachAvg()));
    connect(eButton,SIGNAL(clicked()), plot, SLOT(detachE()));
    connect(fButton, SIGNAL(clicked()), plot, SLOT(detachF()));
    connect(mavgButton, SIGNAL(clicked()), plot, SLOT(detachMavg()));
    connect(scaleButton, SIGNAL(clicked()), plot, SLOT(autoScale()));
    connect(scaleButton, SIGNAL(clicked()), plot->getDataFilter(), SLOT(resetLocalMax()));
    connect(rcKnob, SIGNAL(valueChanged(double)), plot->getDataFilter(), SLOT(setRc(double)) );
    connect(dtKnob, SIGNAL(valueChanged(double)), plot->getDataFilter(), SLOT(setDt(double)) );
    connect(duKnob, SIGNAL(valueChanged(double)), plot->getDataFilter(), SLOT(setU(double)));
    counter->setValue(50.0);
    rangeCounter->setValue(10000.0);
    minCounter->setValue(2000);

}
Exemplo n.º 22
0
void SignalDataVisualizer::add2dPlotToChart(int _nodeLabel, STACCATO_VectorField_components _type) {
	// Preparing Plot Data
	xValues.clear();
	yValues.clear();

	for (int it = 0; it < myHMesh->myOutputDatabase->getTimeDescription(myVisualizerSetting->PROPERTY_CURRENT_ANALYSIS_INDEX).size(); it++) {
		if (myHMesh->myOutputDatabase->myAnalyses[myVisualizerSetting->PROPERTY_CURRENT_ANALYSIS_INDEX].type == STACCATO_Analysis_Static)
			xValues.push_back(0);
		else
			xValues.push_back(std::stoi(myHMesh->myOutputDatabase->getTimeDescription(myVisualizerSetting->PROPERTY_CURRENT_ANALYSIS_INDEX)[it]));
	}
	for (int i = 0; i < xValues.size(); i++) {
		yValues.push_back(myHMesh->myOutputDatabase->getVectorFieldFromDatabase()[myVisualizerSetting->PROPERTY_CURRENT_ANALYSIS_INDEX].getResultScalarFieldAtNodes(_type, i)[_nodeLabel]);
	}
	// Data Series
	mySeries2D = new QLineSeries();
	for (int i = 0; i < xValues.size(); i++) {
		mySeries2D->append(xValues[i], yValues[i]);;
	}
	if (_type == STACCATO_x_Re) {
		mySeries2D->setName(tr("Ux_Re Node ") + QString::fromStdString(std::to_string(_nodeLabel)));
	}
	else if (_type == STACCATO_y_Re) {
		mySeries2D->setName(tr("Uy_Re Node ") + QString::fromStdString(std::to_string(_nodeLabel)));
	}
	else if (_type == STACCATO_z_Re) {
		mySeries2D->setName(tr("Uz_Re Node ") + QString::fromStdString(std::to_string(_nodeLabel)));
	}
	else if (_type == STACCATO_x_Im) {
		mySeries2D->setName(tr("Ux_Im Node ") + QString::fromStdString(std::to_string(_nodeLabel)));
	}
	else if (_type == STACCATO_y_Im) {
		mySeries2D->setName(tr("Uy_Im Node ") + QString::fromStdString(std::to_string(_nodeLabel)));
	}
	else if (_type == STACCATO_z_Im) {
		mySeries2D->setName(tr("Uz_Im Node ") + QString::fromStdString(std::to_string(_nodeLabel)));
	}
	mySeries2D->setPointsVisible(myPointVisibilityBox->isChecked());

	mySeriesList.append(mySeries2D);

	myChart2D->addSeries(mySeriesList.last());
	myChart2D->setTitle("Solution Distribution over Node");
	myChart2D->legend()->setAlignment(Qt::AlignBottom);				// Legend Alignment

	QPen pen(mySeriesList.last()->color());							// Line Width
	pen.setWidth(myLineWidthText->text().toDouble());
	mySeriesList.last()->setPen(pen);

	myAxisX->setTitleText("Frequency (in Hz)");
	myAxisX->setLabelFormat("%d");
	//myAxisX->setMinorTickCount(0);
	myAxisX->setTickCount(10);

	myAxisLogX->setTitleText("Frequency (in Hz), Log Scale");
	myAxisLogX->setLabelFormat("%g");
	myAxisLogX->setBase(10.0);
	myAxisLogX->setMinorTickCount(-1);

	// Chart Axes
	if (myHMesh->myOutputDatabase->myAnalyses[myVisualizerSetting->PROPERTY_CURRENT_ANALYSIS_INDEX].type == STACCATO_Analysis_Static)
	{
		myAxisX->setTitleText("Static");
		myAxisLogX->setTitleText("Static, Log Scale");
	}

	if (_type == STACCATO_x_Re || _type == STACCATO_y_Re || _type == STACCATO_z_Re || _type == STACCATO_x_Im || _type == STACCATO_y_Im || _type == STACCATO_z_Im) {
		myAxisY->setTitleText("Displacement");
	}
	else {
		myAxisY->setTitleText("Unrecognized Axis");
	}
	myAxisY->setLabelFormat("%d");

	// Set Connections
	connect(mySeriesList.last(), &QLineSeries::clicked, this, &SignalDataVisualizer::handleClickedPoint);
	connect(mySeriesList.last(), &QLineSeries::hovered, this, &SignalDataVisualizer::tooltip);

	enableInteractiveClick(mySeriesList.last());		// Enable Scattering

	// Axes-Chart Association
	myChart2D->addAxis(myAxisX, Qt::AlignBottom);
	myChart2D->setAcceptHoverEvents(true);
	myChart2D->addAxis(myAxisY, Qt::AlignLeft);

	chartView2D->setChart(myChart2D);
	chartView2D->setRenderHint(QPainter::Antialiasing);
	chartView2D->setMinimumSize(600, 300);

	myAxisX->setTickCount(mySeriesList.last()->count());
	mySeriesList.last()->attachAxis(myAxisX);
	//myAxisY->setTickCount(mySeries2D->count());
	mySeriesList.last()->attachAxis(myAxisY);
	mySeries2scatter->attachAxis(myAxisX);
	mySeries2scatter->attachAxis(myAxisY);
	mySnapSeries2scatter->attachAxis(myAxisX);
	mySnapSeries2scatter->attachAxis(myAxisY);

	updateLegends();

	// Coordinate Hover
	myCoordX = new QGraphicsSimpleTextItem(myChart2D);
	myCoordX->setPos(myChart2D->size().width() / 2 - 50, myChart2D->size().height());
	myCoordY = new QGraphicsSimpleTextItem(myChart2D);
	myCoordY->setPos(myChart2D->size().width() / 2 + 50, myChart2D->size().height());

	double yValueMinNew = *std::min_element(yValues.begin(), yValues.end());
	double yValueMaxNew = *std::max_element(yValues.begin(), yValues.end());
	
	autoScale(yValueMinNew, yValueMaxNew);
	if(myLogXAxisBox->isChecked()){
		myLogScaleTriggered();
	}
}
Exemplo n.º 23
0
int main(int argc, char *argv[])
/* Process command line. */
{
char * binSizeStr = (char *) NULL;

optionInit(&argc, argv, optionSpecs);
if (argc < 2)
    usage();

binSizeStr = optionVal("binSize", "1");
maxBinCount = optionInt("maxBinCount", 25);
minValStr = optionVal("minVal", "0");
doLog = optionExists("log");
noStar = optionExists("noStar");
probValues = optionExists("probValues");
col = optionInt("col", 1) - 1;
aveCol = optionInt("aveCol", 0) - 1;
real = optionExists("real");
autoscale = optionInt("autoscale", 0);
if (autoscale == 0)
    autoscale = optionInt("autoScale", 0);
freq = optionExists("freq") && !probValues;  /* freq and probValues don't currently work right together */
skip = optionInt("skip", 0);

/*	probValues turns on noStar too	*/
if (probValues) noStar = TRUE;

if (real)
    {
    char *valEnd;
    char *val = binSizeStr;
    binSizeR = strtod(val, &valEnd);
    if ((*val == '\0') || (*valEnd != '\0'))
	errAbort("Not a valid float for -binSize=%s\n", binSizeStr);
    if (binSizeR <= 0.0)
	errAbort("invalid binSize, must be greater than zero: %g\n", binSizeR);
    val = minValStr;
    minValR = strtod(val, &valEnd);
    if ((*val == '\0') || (*valEnd != '\0'))
	errAbort("Not a valid float for -minVal=%s\n", binSizeStr);
    }
else
    {
    binSize = atoi(binSizeStr);
    if (binSize < 1)
	errAbort("invalid binSize, must be >= one: %d\n", binSize);
    minVal = atoi(minValStr);
    }

verbose(2,"#\tbinSize: ");
if (real) verbose(2, "%f\n", binSizeR);
    else verbose(2, "%d\n", binSize);
verbose(2,"#\tmaxBinCount: %d\n", maxBinCount);
verbose(2,"#\tminVal: ");
if (real) verbose(2, "%f\n", minValR);
    else verbose(2, "%d\n", minVal);
verbose(2,"#\tlog function: %s\n", doLog ? "ON" : "OFF" );
verbose(2,"#\tdraw asterisks: %s\n", noStar ? "NO" : "YES" );
verbose(2,"#\thistogram on data input column: %d\n", col+1);
if (aveCol >= 0)
    verbose(2, "#\taveCol: %d\n", aveCol);
else
    verbose(2, "#\taveCol: not selected\n");
verbose(2,"#\treal valued data: %s\n", real ? "YES" : "NO" );
if (autoscale > 0)
    verbose(2, "#\tautoscaling to %d bins\n", autoscale);
else
    verbose(2, "#\tautoscale: not selected\n");
verbose(2, "#\tshow prob-Values: %s\n", probValues ? "YES" : "NO" );

/*	to autoscale stdin we would need to keep all the data read in
 *	during the min,max scan and reuse that data for the histogram
 *	calculation.  Not implemented yet.
 */
if (autoscale > 0)
    {
    if (startsWith("stdin", argv[1]))
	{
	errAbort("Sorry, can not autoscale stdin at this time.  Outstanding feature request.");
	}
    autoScale(argv[1]);
    }

textHistogram(argv[1]);
return 0;
}
Exemplo n.º 24
0
void QxrdImagePlot::contextMenuEvent(QContextMenuEvent * event)
{
  if (m_ContextMenuEnabled) {
    QxrdImagePlotSettingsPtr set(m_ImagePlotSettings);

    if (set) {
      QMenu plotMenu(NULL, NULL);

      QAction *auSc = plotMenu.addAction("Autoscale");
      QAction *prGr = plotMenu.addAction("Print Graph...");

      plotMenu.addSeparator();

      QxrdDataProcessorPtr dp(m_DataProcessor);

      if (dp) {
        QxrdCenterFinderPtr cf(dp->centerFinder());

        if (cf) {
          QwtScaleMap xMap = canvasMap(QwtPlot::xBottom);
          QwtScaleMap yMap = canvasMap(QwtPlot::yLeft);

          QWidget *canv = canvas();

          QPoint evlocal = canv->mapFromParent(event->pos());

          double x = xMap.invTransform(evlocal.x());
          double y = yMap.invTransform(evlocal.y());

          QxrdPowderPoint nearest = cf->nearestPowderPoint(x, y);

          QAction *fitCircle        = plotMenu.addAction(tr("Fit Circle Center from Points on Ring %1").arg(nearest.n1()));
          QAction *fitEllipse       = plotMenu.addAction(tr("Fit Ellipse from Points on Ring %1").arg(nearest.n1()));
          QAction *fitEllipses      = plotMenu.addAction(tr("Fit Ellipses to all powder rings"));
          QAction *delPoint         = plotMenu.addAction(tr("Delete point at (%1,%2)").arg(nearest.x()).arg(nearest.y()));
          QAction *delRing          = plotMenu.addAction(tr("Delete Ring %1").arg(nearest.n1()));
          QAction *deleteAllPoints  = plotMenu.addAction(tr("Delete all Rings"));
          QAction *disableRing      = plotMenu.addAction(tr("Disable Ring %1").arg(nearest.n1()));
          QAction *enableRing       = plotMenu.addAction(tr("Enable Ring %1").arg(nearest.n1()));
          QAction *normalizeRings   = plotMenu.addAction(tr("Normalize Powder Rings"));
          QAction *fitPeakNear      = plotMenu.addAction(tr("Fit Diffracted Peak near (%1,%2) [%3,%4]").arg(x).arg(y).arg(event->x()).arg(event->y()));
          QAction *fitRingNear      = plotMenu.addAction(tr("Fit Point on Diffracted Ring near (%1,%2) [%3,%4]").arg(x).arg(y).arg(event->x()).arg(event->y()));
          QAction *traceRingClockwise = plotMenu.addAction(tr("Trace Diffracted Ring starting at (%1,%2) [%3,%4]").arg(x).arg(y).arg(event->x()).arg(event->y()));
          QAction *missingRing      = plotMenu.addAction(tr("Missing Diffracted Ring near (%1,%2)").arg(x).arg(y));
          //          QAction *traceRingParallel = plotMenu.addAction(tr("Trace Diffracted Ring starting at (%1,%2) [%3,%4] in parallel").arg(x).arg(y).arg(event->x()).arg(event->y()));
          QAction *zapPixel         = plotMenu.addAction(tr("Zap (replace with avg of neighboring values) pixel [%1,%2]").arg((int)x).arg(int(y)));

          QAction *action = plotMenu.exec(event->globalPos());

          if (action == auSc) {
            autoScale();
          } else if (action == prGr) {
            printGraph();
          } else if (action == fitCircle) {
            cf->fitPowderCircle(nearest.n1());
          } else if (action == fitEllipse) {
            cf->fitPowderEllipse(nearest.n1());
          } else if (action == fitEllipses) {
            cf->fitPowderEllipses();
          } else if (action == delPoint) {
            cf->deletePowderPointNear(x,y);
          } else if (action == delRing) {
            cf->deletePowderRing(nearest.n1());
          } else if (action == deleteAllPoints) {
            cf->deletePowderPoints();
          } else if (action == enableRing) {
            cf->enablePowderRing(nearest.n1());
          } else if (action == disableRing) {
            cf->disablePowderRing(nearest.n1());
          } else if (action == normalizeRings) {
            cf->normalizePowderRings();
          } else if (action == fitPeakNear) {
            QMetaObject::invokeMethod(cf.data(), "fitPeakNear",
                                      Q_ARG(double,x),
                                      Q_ARG(double,y));
          } else if (action == fitRingNear) {
            QMetaObject::invokeMethod(cf.data(), "fitRingNear",
                                      Q_ARG(double,x),
                                      Q_ARG(double,y));
          } else if (action == traceRingClockwise) {
            QMetaObject::invokeMethod(cf.data(), "traceRingNear",
                                      Q_ARG(double,x),
                                      Q_ARG(double,y),
                                      Q_ARG(double,25.0));
          } else if (action == missingRing) {
Exemplo n.º 25
0
void QcepPlot::init(QcepPlotSettingsWPtr settings)
{
  m_PlotSettings = settings;

  setCanvasBackground(QColor(Qt::white));

  m_Zoomer = new QcepPlotZoomer(canvas(), this);
  m_Zoomer -> setStateMachine(new QwtPickerDragRectMachine());
  m_Zoomer -> setTrackerMode(QwtPicker::AlwaysOn);
  m_Zoomer -> setRubberBand(QwtPicker::RectRubberBand);

  m_Zoomer -> setMousePattern(QwtEventPattern::MouseSelect2,
                              Qt::LeftButton, Qt::ControlModifier | Qt::ShiftModifier);
  m_Zoomer -> setMousePattern(QwtEventPattern::MouseSelect3,
                              Qt::LeftButton, Qt::ControlModifier);

  m_Zoomer -> setEnabled(true);

  m_Legend = new QwtLegend(this);
  m_Legend -> setDefaultItemMode(QwtLegendData::Checkable);

  m_Panner = new QwtPlotPanner(canvas());
  m_Panner -> setEnabled(true);
  m_Panner -> setMouseButton(Qt::MidButton);
  m_Panner -> setAxisEnabled(QwtPlot::yRight, false);

  m_Magnifier = new QwtPlotMagnifier(canvas());
  m_Magnifier -> setEnabled(true);
  m_Magnifier -> setMouseButton(Qt::NoButton);
  m_Magnifier -> setAxisEnabled(QwtPlot::yRight, false);

  m_Measurer = new QcepPlotMeasurer(canvas(), this);
  m_Measurer -> setEnabled(false);

  setAxisLabelRotation(QwtPlot::yLeft, -90);
  setAxisLabelAlignment(QwtPlot::yLeft, Qt::AlignVCenter);

  autoScale();

  QcepPlotSettingsPtr set(m_PlotSettings);

  if (set) {
    connect(set->prop_XAxisLog(), SIGNAL(valueChanged(bool,int)), this, SLOT(setXAxisLog(bool)));
    connect(set->prop_YAxisLog(), SIGNAL(valueChanged(bool,int)), this, SLOT(setYAxisLog(bool)));
    connect(set->prop_X2AxisLog(), SIGNAL(valueChanged(bool,int)), this, SLOT(setX2AxisLog(bool)));
    connect(set->prop_Y2AxisLog(), SIGNAL(valueChanged(bool,int)), this, SLOT(setY2AxisLog(bool)));

    setXAxisLog(set->get_XAxisLog());
    setYAxisLog(set->get_YAxisLog());
    setX2AxisLog(set->get_X2AxisLog());
    setY2AxisLog(set->get_Y2AxisLog());

    if (m_Legend) {
      int legendPos = set->get_LegendPosition();

      if (legendPos >= 0) {
        insertLegend(m_Legend, (QwtPlot::LegendPosition) legendPos);
      }
    }
  }

  if (m_Legend) {
    connect(m_Legend, SIGNAL(clicked(const QVariant &,int)),      this, SLOT(onLegendClicked(const QVariant&, int)));
    connect(m_Legend, SIGNAL(checked(const QVariant &,bool,int)), this, SLOT(onLegendChecked(const QVariant&, bool, int)));
  }
}
Exemplo n.º 26
0
RImageDock::RImageDock(OGLWidget* newOGLWidget, QWidget *parent)
    :QWidget(parent)
{
    widgetTitle = QString("");
    frameIndex = 0;
    this->oglWidget = newOGLWidget;

    matImage = newOGLWidget->matImageListRGB.at(frameIndex);
    naxis1 = matImage.cols;
    naxis2 = matImage.rows;
    bscale = newOGLWidget->rMatImageList.at(0).getBscale();


    qDebug() << "RImageDock::matImage.channels()" << matImage.channels();
    // Convert to gray before getting the Max and Min

    cvtColor(matImage, matImageGray, CV_RGB2GRAY);
    dataMin = 0;
    dataMax = 0;
    cv::minMaxLoc(matImageGray, &dataMin, &dataMax);
    dataRange = dataMax - dataMin;

    qDebug() << "rImageDock::dataMin =" << dataMin;
    qDebug() << "rImageDock::dataMax =" << dataMax;


    gamma = 1;

    // String number format parameters
    if (dataRange < 0.1)
    {
        format = 'g';
        precision = 2;
    }
    else if (dataRange < 10)
    {
        format = 'f';
        precision = 3;
    }
    else
    {
        format = 'f';
        precision = 0;
    }

    newMin = dataMin;
    newMax = dataMax;


    // Set the slider steps
    // We need to differiente between scientific calibrated data values and
    // uncalibrated, unphysical values scaled only within [0-65535]
    // We know this from the bscale values.
    // We deal typically with uncalibrated 8 bits [0-256], 16 bits [0=65535]
    // or calibrated 32 bits data, whose unit will depend on bscale.

    // if bscale = 1, we stick to a 16 bits range. This includes the 8-bits case (maybe this will change)
    colorRange = 65536.0f;
    sliderMin = 1;
    sliderMax = sliderMin + colorRange -1;

    if (bscale == 1)
    {

        sliderScaleStep = 1.0f;
        qDebug() << "rImageDock:: sliderScaleStep =" << sliderScaleStep;

        // Set initial constrast stretching factors
        alpha = 1.0f / colorRange;
        beta = 0.0f;
    }
    else // Stretch the data into their physical range at 16-bits precision.
    {

        sliderScaleStep = dataRange/colorRange;

        // Set initial constrast stretching factors
        alpha = (float) (1.0f / dataRange);
        beta = (float) (-newMin / dataRange);
    }

    oglWidget->setAlpha(alpha);
    oglWidget->setBeta(beta);

    // Create the Sliders and Layout of the dock widget.

    //QLabels setup
    QLabel  *labelHigh = new QLabel("High");
    QLabel  *labelLow = new QLabel("Low");
    QLabel  *labelGamma = new QLabel("Gamma");

    //QSliders setup
    sliderHigh = new QSlider(Qt::Horizontal);
    sliderLow = new QSlider(Qt::Horizontal);
    sliderGamma = new QSlider(Qt::Horizontal);


    float gammaRange = 40;
    maxGamma = 2.1;
    minGamma = 0.1;
    sliderGammaStep = (maxGamma - minGamma)/gammaRange;

    // set sliders range
    sliderHigh->setRange((int)sliderMin, (int)sliderMax);
    sliderHigh->setSingleStep(1);
    sliderLow->setRange((int)sliderMin, (int)sliderMax);
    sliderLow->setSingleStep(1);
    sliderGamma->setRange(1, (int) gammaRange);
    sliderLow->setSingleStep(1);

    // set sliders value
    sliderHigh->setValue(sliderMax);
    sliderLow->setValue(sliderMin);
    sliderGamma->setValue(convertGammaToSlider(QString::number(gamma)));

    //QLineEdit setup
    valueHighLineEdit = new QLineEdit(QString::number(dataMax, format, precision));
    valueLowLineEdit = new QLineEdit(QString::number(dataMin, format, precision));
    valueGammaLineEdit = new QLineEdit(QString::number(gamma));

    int editMinimumWidth = 20;
    int editMaximumWidth = 60;

    valueHighLineEdit->setMinimumWidth(editMinimumWidth);
    valueHighLineEdit->setMaximumWidth(editMaximumWidth);

    valueLowLineEdit->setMinimumWidth(editMinimumWidth);
    valueLowLineEdit->setMaximumWidth(editMaximumWidth);

    valueGammaLineEdit->setMinimumWidth(editMinimumWidth);
    valueGammaLineEdit->setMaximumWidth(editMaximumWidth);

    // QGridLayout setup
    QGridLayout *sliderLayout = new QGridLayout();

    // Add the labels
    sliderLayout->addWidget(labelHigh, 0, 0);
    sliderLayout->addWidget(labelLow, 1, 0);
    sliderLayout->addWidget(labelGamma, 2, 0);
    // Add the sliders
    sliderLayout->addWidget(sliderHigh, 0, 1);
    sliderLayout->addWidget(sliderLow, 1, 1);
    sliderLayout->addWidget(sliderGamma, 2, 1);
    // Add the line edits.
    sliderLayout->addWidget(valueHighLineEdit, 0, 2);
    sliderLayout->addWidget(valueLowLineEdit, 1, 2);
    sliderLayout->addWidget(valueGammaLineEdit, 2, 2);

    // Define the minimum spacing between sliders. This may need some adjusting.
    int vSpacing  = 0;
    int hSpacing = 10;


    //QMargins margins(10, 10, 5, 5);
    //sliderLayout->setContentsMargins(margins);
    sliderLayout->setVerticalSpacing(vSpacing);
    sliderLayout->setHorizontalSpacing(hSpacing);


    // Set the minimum column widths of the layout,
    int sliderWidth = 350;
    int lineEditWidth = 20;

    sliderLayout->setColumnMinimumWidth(1, sliderWidth);
    sliderLayout->setColumnMinimumWidth(2, lineEditWidth);
    sliderLayout->setMargin(0);

    QWidget *sliderWidget = new QWidget();
    sliderWidget->setLayout(sliderLayout);
    sliderWidget->setMinimumHeight(60);


    // Calibration type
    QWidget *calibrationTypeWidget = new QWidget();
    light = new QCheckBox(QString("Light"));
    bias = new QCheckBox(QString("Bias"));
    dark = new QCheckBox(QString("Dark"));
    flat = new QCheckBox(QString("Flat"));

    // Histrogram button
    QPushButton *histButton = new QPushButton("Histogram");

    QGridLayout *grid = new QGridLayout();
    grid->addWidget(light,0,0);
    grid->addWidget(bias,0,1);
    grid->addWidget(dark,1,0);
    grid->addWidget(flat,1,1);
    grid->addWidget(histButton, 2, 0, 1, 2);
    grid->setMargin(0);
    calibrationTypeWidget->setLayout(grid);
    calibrationTypeWidget->setMinimumHeight(60);

    QHBoxLayout *hBox = new QHBoxLayout();
    hBox->addWidget(sliderWidget);
    hBox->addWidget(calibrationTypeWidget);

    // Set the above layout in this QWidget
    setLayout(hBox);

    setMinimumWidth(600);
    //setMaximumWidth(800);
    setMaximumHeight(80);
    // Connect the change of the slider position with the QLineEdit
    QObject::connect(sliderHigh, SIGNAL(valueChanged(int)), this, SLOT(updateQLineEditSlot(int)));
    QObject::connect(sliderLow, SIGNAL(valueChanged(int)), this, SLOT(updateQLineEditSlot(int)));
    QObject::connect(sliderGamma, SIGNAL(valueChanged(int)), this, SLOT(updateQLineEditSlot(int)));

    QObject::connect(valueHighLineEdit, SIGNAL( returnPressed()), this, SLOT(setSliderValueSlot()));
    QObject::connect(valueLowLineEdit, SIGNAL( returnPressed()), this, SLOT(setSliderValueSlot()));
    QObject::connect(valueGammaLineEdit, SIGNAL( returnPressed()), this, SLOT(setSliderValueSlot()));

    //Connect the slider value changed with the Image display.
    QObject::connect(sliderHigh, SIGNAL(valueChanged(int)), this, SLOT(scaleImageSlot(int)));
    QObject::connect(sliderLow, SIGNAL(valueChanged(int)), this, SLOT(scaleImageSlot(int)));
    QObject::connect(sliderGamma, SIGNAL(valueChanged(int)), this, SLOT(gammaScaleImageSlot(int)));

    QObject::connect(histButton, SIGNAL(released()), this, SLOT(drawHist()));

    // Connect mouse events with OGLWidget
    QObject::connect(newOGLWidget, SIGNAL(destroyed(QObject*)), this, SLOT(deleteLater()));

    qRegisterMetaType<QVector<int> >("QVector<int>");
    qRegisterMetaType<QVector<QString> >("QVector<QString>");

    // Get initial tatistics
    calcStats();
    autoScale();
}