[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kstars] kstars: Just a few minor changes.
From: Jasem Mutlaq <null () kde ! org>
Date: 2017-12-31 20:55:58
Message-ID: E1eVkeE-0000c2-En () code ! kde ! org
[Download RAW message or body]
Git commit 660266ca288df0fcfd6a8b8ec9599915e6812008 by Jasem Mutlaq, on behalf 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 KStars 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 overall range of the spin box. It will expand the range if the new recommended \
value 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 functions. 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 spin box to those recommended values on equipment connection, and save the message so if the user \
tries to set it to an invalid value, it doesn'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 *parent) : 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. It will give -1 if not in the \
list, and the index if it is in the list.
connect(this, QOverload<double>::of(&QDoubleSpinBox::valueChanged),[=](double d){ _idx = \
_values.indexOf(d);}); }
@@ -46,8 +47,40 @@ void NonLinearDoubleSpinBox::stepBy(int steps)
setValue( _values.at(_idx) );
}
-void NonLinearDoubleSpinBox::setRecommendedValues(QList<double> values){
+void NonLinearDoubleSpinBox::setRecommendedValues(QList<double> values)
+{
_values = values;
- _idx = _values.indexOf(value()); //This way it will search for current 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 command.
+ updateRecommendedValues();
+}
+
+void NonLinearDoubleSpinBox::updateRecommendedValues()
+{
+ qSort(_values); //This will make sure they are all in order.
+ _idx = _values.indexOf(value()); //This will update the _idx variable 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 expanded if necessary. + if(_values.first() < minimum())
+ setMinimum(_values.first());
+ if(_values.last() > maximum())
+ setMaximum(_values.last());
+}
+
+QList<double> NonLinearDoubleSpinBox::getRecommendedValues()
+{
+ return _values;
+}
+
+QString NonLinearDoubleSpinBox::getRecommendedValuesString()
+{
+ QString returnString;
+ for(int i=0; i < _values.size() - 1; i++)
+ returnString += QString::number(_values.at(i)) + ", ";
+ returnString += QString::number(_values.last());
+ return returnString;
}
diff --git a/kstars/auxiliary/nonlineardoublespinbox.h b/kstars/auxiliary/nonlineardoublespinbox.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<double> values);
+ void addRecommendedValue(double v);
+ QList<double> getRecommendedValues();
+ QString getRecommendedValuesString();
private:
QList<double> _values;
int _idx = -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<double> 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<double> 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 << 30 << 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/externalguide/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 &jsonObj, QString rawString)
case EXPOSURE_DURATIONS: //get_exposure_durations
{
QVariantList exposureListArray=jsonObj["result"].toArray().toVariantList();
- QString logValidExposureTimes = i18n("PHD2: Valid Exposure Times: Auto");
+ logValidExposureTimes = i18n("PHD2: Valid Exposure Times: Auto, ");
+ QList<double> values;
for(int i=1; i < exposureListArray.size(); i ++) //For some reason PHD2 has a negative \
exposure time of 1 at the start of the array?
- logValidExposureTimes += ", " + \
QString::number(exposureListArray.at(i).toDouble()/1000.0); //PHD2 reports in ms. + \
values << exposureListArray.at(i).toDouble()/1000.0;//PHD2 reports in ms. + \
logValidExposureTimes += \
KStars::Instance()->ekosManager()->guideModule()->setRecommendedExposureValues(values); emit \
newLog(logValidExposureTimes); break;
}
@@ -647,7 +649,7 @@ void PHD2::processPHD2Error(const QJsonObject &jsonError)
//This means the user mistakenly entered an invalid exposure time.
if(resultRequest == 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, [=]{requestExposureTime();}); //This will reset the Exposure time in \
Ekos to PHD2's current exposure time after a third of a second. }
else if(resultRequest == CONNECTION_RESULT)
@@ -734,6 +736,7 @@ void PHD2::setEquipmentConnected()
connection = EQUIPMENT_CONNECTED;
emit newStatus(Ekos::GUIDE_CONNECTED);
updateGuideParameters();
+ QTimer::singleShot(800, [=]{requestExposureDurations();});
}
}
diff --git a/kstars/ekos/guide/externalguide/phd2.h b/kstars/ekos/guide/externalguide/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=5000;
double pixelScale=0;
+
+ 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<double> 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<double> values)
+{
+ exposureIN->setRecommendedValues(values);
+ return exposureIN->getRecommendedValuesString();
+}
+
void Guide::addCCD(ISD::GDInterface *newCCD)
{
ISD::CCD *ccd = static_cast<ISD::CCD *>(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 primaryAperture, double guideFocalLength, \
double guideAperture);
+ //This Funciton will allow PHD2 to update the exposure values to the recommended ones.
+ QString setRecommendedExposureValues(QList<double> values);
+
// Append Log entry
void appendLogText(const QString &);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic