AstRawDark
Manage your astrophoto dark frames
 All Classes Functions Variables Enumerations Enumerator Pages
lightsCheckCommand.cpp
1 /*
2  * AstRawDark
3  *
4  * Copyright (C) 2015 - Frédéric CORNU
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include "lightsCheckCommand.h"
21 #include "data/dto/imageInfo.h"
22 #include "data/dataStore.h"
23 #include "signalDispatcher.h"
24 #include <QList>
25 
26 
28 {
29  _description = QString(tr("Lights consistency check"));
30 
31  connect(this,
35 }
36 
38 {
39  QList<ImageInfo> lights = DataStore::getInstance()->getScannedLights();
40 
41  bool consistent = true;
42 
43  _message = tr("Checking lights...");
44  emit statusChanged(this);
45 
46  ImageInfo reference, test;
47 
48  for ( int referenceIndex = 0; referenceIndex < lights.count() && consistent; ++referenceIndex) {
49 
50  reference = lights[referenceIndex];
51 
52  for ( int testIndex = referenceIndex +1; testIndex < lights.count() && consistent; ++testIndex ) {
53 
54  test = lights[testIndex];
55 
56  if ( ! ( reference.getCameraSerial() == test.getCameraSerial() &&
57  reference.getIso() == test.getIso() &&
58  reference.getExposure() == test.getExposure() ) ) {
59 
60  consistent = false;
61  }
62  }
63  }
64 
65  if ( consistent ) {
66 
67  _reportMessages << tr("OK");
68  _commandReport.addSection(tr("Completed successfully"),QStringList());
69 
70  } else {
71 
72  _warning = true;
73 
74  QString msg = tr("WARNING - you have mismatched lights in this folder");
75 
76  _reportMessages << msg;
77 
78  _commandReport.addSection(msg, QStringList() << tr("%1\nand\n%2\n")
79  .arg(reference.getPath())
80  .arg(test.getPath()).append(tr("don't have the same serial# + ISO + exposure time")));
81  }
82 
83  _message = tr("All lights checked");
84  emit statusChanged(this);
85  emit consistencyResult(consistent);
86 }
87