diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 315823258..8a2bb30c7 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -320,8 +320,8 @@ void qDrawPlot::SetupWidgetWindow(){ plotLayout = new QGridLayout(boxPlot); plotLayout->setContentsMargins(0,0,0,0); - plotLayout->addWidget(plot1D,0,0,3,3); - plotLayout->addWidget(plot2D,0,0,3,3); + plotLayout->addWidget(plot1D,0,0,4,4); + plotLayout->addWidget(plot2D,0,0,4,4); //gainplot @@ -333,11 +333,11 @@ void qDrawPlot::SetupWidgetWindow(){ gainplot2D->setFont(QFont("Sans Serif",9,QFont::Normal)); gainplot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,startPixel,endPixel,gainImageArray); gainplot2D->setTitle(GetImageTitle()); - gainplot2D->SetXTitle(imageXAxisTitle); - gainplot2D->SetYTitle(imageYAxisTitle); - gainplot2D->SetZTitle(QString("Gain ") + imageZAxisTitle); gainplot2D->setAlignment(Qt::AlignLeft); - plotLayout->addWidget(gainplot2D,1,3,1,1); + gainplot2D->GetPlot()->enableAxis(0,false); + gainplot2D->GetPlot()->enableAxis(1,false); + gainplot2D->GetPlot()->enableAxis(2,false); + plotLayout->addWidget(gainplot2D,0,4,1,1); gainplot2D->hide(); gainPlotEnable = false; @@ -1500,10 +1500,6 @@ void qDrawPlot::UpdatePlot(){ if (gainPlotEnable) { gainplot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,startPixel,endPixel,gainImageArray); gainplot2D->setTitle(GetImageTitle()); - gainplot2D->SetXTitle(imageXAxisTitle); - gainplot2D->SetYTitle(imageYAxisTitle); - gainplot2D->SetZTitle(QString("Gain ") + imageZAxisTitle); - gainplot2D->show(); }else { gainplot2D->hide(); @@ -1517,16 +1513,18 @@ void qDrawPlot::UpdatePlot(){ if(!IsXYRange[qDefs::YMAXIMUM]) XYRangeValues[qDefs::YMAXIMUM]= plot2D->GetPlot()->GetYMaximum(); plot2D->GetPlot()->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]); plot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]); - if (gainPlotEnable) { - gainplot2D->GetPlot()->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]); - gainplot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]); - } + gainplot2D->GetPlot()->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]); + gainplot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]); XYRangeChanged = false; } plot2D->GetPlot()->Update(); if (gainPlotEnable) { gainplot2D->GetPlot()->Update(); - } + gainplot2D->setFixedWidth(plot2D->width()/4); + gainplot2D->setFixedHeight(plot2D->height()/4); + gainplot2D->show(); + }else + gainplot2D->hide(); //Display Statistics if(displayStatistics){ double min=0,max=0,sum=0; diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp index 1cab16655..b4e10c518 100644 --- a/slsDetectorGui/src/qTabPlot.cpp +++ b/slsDetectorGui/src/qTabPlot.cpp @@ -539,20 +539,40 @@ void qTabPlot::maintainAspectRatio(int axis) { } // if x changed: y adjusted, y changed: x adjusted, aspect ratio clicked: larger one adjusted + double newval=0; switch(axis) { case 0: //change x - dispXMax->setText(QString::number(idealAspectratio * (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM]) + ranges[qDefs::XMINIMUM])); + newval = idealAspectratio * (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM]) + ranges[qDefs::XMINIMUM]; + if (newval <= myPlot->GetXMaximum()) { + dispXMax->setText(QString::number(newval)); #ifdef VERYVERBOSE - cprintf(BLUE,"new xmax: %f\n",dispXMax->text().toDouble()); + cprintf(BLUE,"new xmax: %f\n",newval); #endif + } else { + newval = ranges[qDefs::XMAXIMUM] - (idealAspectratio * (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM])); + dispXMin->setText(QString::number(newval)); +#ifdef VERYVERBOSE + cprintf(BLUE,"new xmin: %f\n",newval); +#endif + } + break; case 1: // change y - dispYMax->setText(QString::number(((ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) / idealAspectratio) + ranges[qDefs::YMINIMUM])); + newval = ((ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) / idealAspectratio) + ranges[qDefs::YMINIMUM]; + if (newval <= myPlot->GetYMaximum()) { + dispYMax->setText(QString::number(newval)); + //#ifdef VERYVERBOSE + cprintf(BLUE,"new ymax: %f\n",newval); + //#endif + } else { + newval = ranges[qDefs::YMAXIMUM] - ((ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) / idealAspectratio); + dispYMin->setText(QString::number(newval)); #ifdef VERYVERBOSE - cprintf(BLUE,"new ymax: %f\n",dispYMax->text().toDouble()); + cprintf(BLUE,"new ymin: %f\n",newval); #endif + } break; default: break; @@ -694,6 +714,22 @@ void qTabPlot::SetXAxisRange(){ cout << "Setting X Axis Range" << endl; #endif + disconnect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); + disconnect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); + + if (dispXMin->text().toDouble() < myPlot->GetXMinimum()) { + qDefs::Message(qDefs::WARNING,"Outside Plot Range","qTabPlot::CheckZRange"); + dispXMin->setText(QString::number(myPlot->GetXMinimum())); + } + + if (dispXMax->text().toDouble() > myPlot->GetXMaximum()) { + qDefs::Message(qDefs::WARNING,"Outside Plot Range","qTabPlot::CheckZRange"); + dispXMax->setText(QString::number(myPlot->GetXMaximum())); + } + + connect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); + connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); + // keeping aspect ratio if (chkAspectRatio->isChecked()) { maintainAspectRatio(1); @@ -709,9 +745,26 @@ void qTabPlot::SetXAxisRange(){ void qTabPlot::SetYAxisRange(){ #ifdef VERBOSE - cout << "Setting X Axis Range" << endl; + cout << "Setting Y Axis Range" << endl; #endif + disconnect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + disconnect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + + if (dispYMin->text().toDouble() < myPlot->GetYMinimum()) { + qDefs::Message(qDefs::WARNING,"Outside Plot Range","qTabPlot::CheckZRange"); + dispYMin->setText(QString::number(myPlot->GetYMinimum())); + } + + if (dispYMax->text().toDouble() > myPlot->GetYMaximum()) { + qDefs::Message(qDefs::WARNING,"Outside Plot Range","qTabPlot::CheckZRange"); + dispYMax->setText(QString::number(myPlot->GetYMaximum())); + } + + connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + + // keeping aspect ratio if (chkAspectRatio->isChecked()) { maintainAspectRatio(0);