From kde-commits Sun Dec 31 20:55:58 2017 From: Jasem Mutlaq Date: Sun, 31 Dec 2017 20:55:58 +0000 To: kde-commits Subject: [kstars] kstars: Just a few minor changes. Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=151475377325963 Git commit 660266ca288df0fcfd6a8b8ec9599915e6812008 by Jasem Mutlaq, on beh= alf of Robert Lancaster. Committed on 31/12/2017 at 20:54. Pushed by mutlaqja into branch 'master'. Just a few minor changes. 1. I added more functions to the nonlinear spin box to make it easier for K= Stars to add new recommended value items and to get the list of recommended= values. 2. I made sure that in those new functions, it would not mess up the overal= l range of the spin box. It will expand the range if the new recommended v= alue is outside the current range but will not make the range smaller. 3. I made sure that the recommended values are always sorted correctly. 4. I changed the exposure spin box in the capture module to use the new fun= ctions. This also ensures that 0 does not get added to the list if the min= and the max do not get set from the current CCD. 5. I made the guide module request the valid exposure values and set the sp= in box to those recommended values on equipment connection, and save the me= ssage so if the user tries to set it to an invalid value, it doesn=E2=80=99= t have to ask PHD2 what the valid values are every time. M +36 -3 kstars/auxiliary/nonlineardoublespinbox.cpp M +4 -0 kstars/auxiliary/nonlineardoublespinbox.h M +7 -5 kstars/ekos/capture/capture.cpp M +6 -3 kstars/ekos/guide/externalguide/phd2.cpp M +2 -0 kstars/ekos/guide/externalguide/phd2.h M +7 -0 kstars/ekos/guide/guide.cpp M +3 -0 kstars/ekos/guide/guide.h https://commits.kde.org/kstars/660266ca288df0fcfd6a8b8ec9599915e6812008 diff --git a/kstars/auxiliary/nonlineardoublespinbox.cpp b/kstars/auxiliary= /nonlineardoublespinbox.cpp index 5eed665db..8d748e0ea 100644 --- a/kstars/auxiliary/nonlineardoublespinbox.cpp +++ b/kstars/auxiliary/nonlineardoublespinbox.cpp @@ -15,7 +15,8 @@ NonLinearDoubleSpinBox::NonLinearDoubleSpinBox(QWidget *p= arent) : QDoubleSpinBox { _values << 0.01 << 0.02 << 0.05 << 0.1 << 0.2 << 0.25 << 0.5 << 1 << 1= .5 << 2 << 2.5 << 3 << 5 << 6 << 7 << 8 << 9 << 10 << 20 << 30 << 40 << 50 = << 60 << 120 << 180 << 300 << 600 << 900; setRange(_values.first() , _values.last()); - //This will give -1 if not in the list, and the index if it is in the = list. + + //This will update the _idx variable to the index of the new value. I= t will give -1 if not in the list, and the index if it is in the list. connect(this, QOverload::of(&QDoubleSpinBox::valueChanged),[= =3D](double d){ _idx =3D _values.indexOf(d);}); } = @@ -46,8 +47,40 @@ void NonLinearDoubleSpinBox::stepBy(int steps) setValue( _values.at(_idx) ); } = -void NonLinearDoubleSpinBox::setRecommendedValues(QList values){ +void NonLinearDoubleSpinBox::setRecommendedValues(QList values) +{ _values =3D values; - _idx =3D _values.indexOf(value()); //This way it will search for curr= ent value in the new list or set it to negative 1 if it isn't in the list. + updateRecommendedValues(); +} + +void NonLinearDoubleSpinBox::addRecommendedValue(double v) +{ + _values.append(v); //This will be sorted into place in the next comma= nd. + updateRecommendedValues(); +} + +void NonLinearDoubleSpinBox::updateRecommendedValues() +{ + qSort(_values); //This will make sure they are all in order. + _idx =3D _values.indexOf(value()); //This will update the _idx variab= le to the index of the new value. It will search for current value in the = new list or set it to negative 1 if it isn't in the list. setRange(_values.first() , _values.last()); + //This makes sure all the values are in the range. The range is expan= ded if necessary. + if(_values.first() < minimum()) + setMinimum(_values.first()); + if(_values.last() > maximum()) + setMaximum(_values.last()); +} + +QList NonLinearDoubleSpinBox::getRecommendedValues() +{ + return _values; +} + +QString NonLinearDoubleSpinBox::getRecommendedValuesString() +{ + QString returnString; + for(int i=3D0; i < _values.size() - 1; i++) + returnString +=3D QString::number(_values.at(i)) + ", "; + returnString +=3D QString::number(_values.last()); + return returnString; } diff --git a/kstars/auxiliary/nonlineardoublespinbox.h b/kstars/auxiliary/n= onlineardoublespinbox.h index 7de0a7c73..85931fa43 100644 --- a/kstars/auxiliary/nonlineardoublespinbox.h +++ b/kstars/auxiliary/nonlineardoublespinbox.h @@ -22,10 +22,14 @@ class NonLinearDoubleSpinBox : public QDoubleSpinBox = void stepBy(int steps); void setRecommendedValues(QList values); + void addRecommendedValue(double v); + QList getRecommendedValues(); + QString getRecommendedValuesString(); = private: QList _values; int _idx =3D -1; + void updateRecommendedValues(); }; = #endif // NONLINEARDOUBLESPINBOX_H diff --git a/kstars/ekos/capture/capture.cpp b/kstars/ekos/capture/capture.= cpp index 77cc4f6c5..603c98c18 100644 --- a/kstars/ekos/capture/capture.cpp +++ b/kstars/ekos/capture/capture.cpp @@ -708,21 +708,23 @@ void Capture::updateFrameProperties(int reset) binXIN->setEnabled(targetChip->canBin()); binYIN->setEnabled(targetChip->canBin()); = + QList exposureValues; + exposureValues << 0.01 << 0.02 << 0.05 << 0.1 << 0.2 << 0.25 << 0.5 <<= 1 << 1.5 << 2 << 2.5 << 3 << 5 << 6 << 7 << 8 << 9 << 10 << 20 << 30 << 40= << 50 << 60 << 120 << 180 << 300 << 600 << 900; + exposureIN->setRecommendedValues(exposureValues); + if (currentCCD->getMinMaxStep(exposureProp, exposureElem, &min, &max, = &step)) { exposureIN->setMinimum(min); exposureIN->setMaximum(max); - exposureIN->setSingleStep(step); = if (min < 0.001) exposureIN->setDecimals(6); else exposureIN->setDecimals(3); - } = - QList exposureValues; - exposureValues << min << 0.01 << 0.02 << 0.05 << 0.1 << 0.2 << 0.25 <<= 0.5 << 1 << 1.5 << 2 << 2.5 << 3 << 5 << 6 << 7 << 8 << 9 << 10 << 20 << 3= 0 << 40 << 50 << 60 << 120 << 180 << 300 << 600 << 900 << max; - exposureIN->setRecommendedValues(exposureValues); + exposureIN->addRecommendedValue(min); + exposureIN->addRecommendedValue(max); + } = if (currentCCD->getMinMaxStep(frameProp, "WIDTH", &min, &max, &step)) { diff --git a/kstars/ekos/guide/externalguide/phd2.cpp b/kstars/ekos/guide/e= xternalguide/phd2.cpp index ab09556bc..c914eb063 100644 --- a/kstars/ekos/guide/externalguide/phd2.cpp +++ b/kstars/ekos/guide/externalguide/phd2.cpp @@ -562,9 +562,11 @@ void PHD2::processPHD2Result(const QJsonObject &jsonOb= j, QString rawString) case EXPOSURE_DURATIONS: //get_exposure_duratio= ns { QVariantList exposureListArray=3DjsonObj["result"].toArray().t= oVariantList(); - QString logValidExposureTimes =3D i18n("PHD2: Valid Exposure T= imes: Auto"); + logValidExposureTimes =3D i18n("PHD2: Valid Exposure Times: Au= to, "); + QList values; for(int i=3D1; i < exposureListArray.size(); i ++) //For some = reason PHD2 has a negative exposure time of 1 at the start of the array? - logValidExposureTimes +=3D ", " + QString::number(exposure= ListArray.at(i).toDouble()/1000.0); //PHD2 reports in ms. + values << exposureListArray.at(i).toDouble()/1000.0;//PHD2= reports in ms. + logValidExposureTimes +=3D KStars::Instance()->ekosManager()->= guideModule()->setRecommendedExposureValues(values); emit newLog(logValidExposureTimes); break; } @@ -647,7 +649,7 @@ void PHD2::processPHD2Error(const QJsonObject &jsonErro= r) //This means the user mistakenly entered an invalid exposure time. if(resultRequest =3D=3D SET_EXPOSURE_COMMAND_RECEIVED) { - requestExposureDurations(); //This will let the user know the= valid exposure durations + emit newLog(logValidExposureTimes); //This will let the user = know the valid exposure durations QTimer::singleShot(300, [=3D]{requestExposureTime();}); //This= will reset the Exposure time in Ekos to PHD2's current exposure time after= a third of a second. } else if(resultRequest =3D=3D CONNECTION_RESULT) @@ -734,6 +736,7 @@ void PHD2::setEquipmentConnected() connection =3D EQUIPMENT_CONNECTED; emit newStatus(Ekos::GUIDE_CONNECTED); updateGuideParameters(); + QTimer::singleShot(800, [=3D]{requestExposureDurations();}); } } = diff --git a/kstars/ekos/guide/externalguide/phd2.h b/kstars/ekos/guide/ext= ernalguide/phd2.h index 6a414f904..49071bf32 100644 --- a/kstars/ekos/guide/externalguide/phd2.h +++ b/kstars/ekos/guide/externalguide/phd2.h @@ -231,5 +231,7 @@ class PHD2 : public GuideInterface int starReAcquisitionTime=3D5000; = double pixelScale=3D0; + + QString logValidExposureTimes; }; } diff --git a/kstars/ekos/guide/guide.cpp b/kstars/ekos/guide/guide.cpp index 5ba889ce7..15fe37180 100644 --- a/kstars/ekos/guide/guide.cpp +++ b/kstars/ekos/guide/guide.cpp @@ -109,6 +109,7 @@ Guide::Guide() : QWidget() guideDataClearB->setAttribute(Qt::WA_LayoutUsesWidgetRect); = // Exposure + //Should we set the range for the spin box here? QList exposureValues; exposureValues << 0.02 << 0.05 << 0.1 << 0.2 << 0.5 << 1 << 1.5 << 2 <= < 2.5 << 3 << 3.5 << 4 << 4.5 << 5 << 6 << 7 << 8 << 9 << 10 << 15 << 30; exposureIN->setRecommendedValues(exposureValues); @@ -773,6 +774,12 @@ void Guide::exportGuideData() file.close(); } = +QString Guide::setRecommendedExposureValues(QList values) +{ + exposureIN->setRecommendedValues(values); + return exposureIN->getRecommendedValuesString(); +} + void Guide::addCCD(ISD::GDInterface *newCCD) { ISD::CCD *ccd =3D static_cast(newCCD); diff --git a/kstars/ekos/guide/guide.h b/kstars/ekos/guide/guide.h index 107da6143..e54903acb 100644 --- a/kstars/ekos/guide/guide.h +++ b/kstars/ekos/guide/guide.h @@ -320,6 +320,9 @@ class Guide : public QWidget, public Ui::Guide */ void setTelescopeInfo(double primaryFocalLength, double primaryApertur= e, double guideFocalLength, double guideAperture); = + //This Funciton will allow PHD2 to update the exposure values to the r= ecommended ones. + QString setRecommendedExposureValues(QList values); + // Append Log entry void appendLogText(const QString &); =20