Debian Codegraph @

HercUtilities/HetMap.cpp

raw symbols SCIP
1 /*
2 * File: HetMap.cpp
3 *
4 * Author: Jacob Dekel
5 * Created on: Sep 6, 2010
6 *
7 * Copyright (c) 2009-2013 Jacob Dekel
8 * $Id$
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24
25 #include "HetMap.h"
26 #include "HerculesStudio.h"
27 #include "UtilityRunner.h"
28 #include "Preferences.h"
29
30 #include <QFileDialog>
31 #include <QMessageBox>
32
33 #include <csignal>
34
35 HetMap::HetMap(QWidget *parent)
36 : GenericUtility("hetmap",parent)
37 {
38 ui.setupUi(this);
39 mInternalChange = false;
40
41 connect(ui.runButton, SIGNAL(clicked()), this, SLOT(runClicked()));
42 connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(exitClicked()));
43 connect(ui.allCheckBox, SIGNAL(stateChanged(int)), this, SLOT(allClicked()));
44 connect(ui.fileInfoCheckBox, SIGNAL(stateChanged(int)), this, SLOT(fileInfoClicked()));
45 connect(ui.labelInfoCheckBox, SIGNAL(stateChanged(int)), this, SLOT(labelInfoClicked()));
46 connect(ui.dataInfoCheckBox, SIGNAL(stateChanged(int)), this, SLOT(dataInfoClicked()));
47 connect(ui.tapemapCheckBox, SIGNAL(stateChanged(int)), this, SLOT(tapemapClicked()));
48 connect(ui.selFile, SIGNAL(clicked()), this, SLOT(browseFileClicked()));
49 }
50
51 HetMap::~HetMap()
52 {
53
54 }
55
56 void HetMap::runClicked()
57 {
58 if (!runOrStopClicked())
59 {
60 ui.runButton->setText("Run");
61 return;
62 }
63
64 if (ui.filename->text().isEmpty())
65 {
66 QMessageBox::warning(this, "hetmap", "Please specify tape file to map",
67 QMessageBox::Ok, QMessageBox::NoButton);
68 return;
69 }
70 std::vector<std::string> parameters;
71
72 if (ui.dataInfoCheckBox->isChecked())
73 parameters.push_back("-d");
74 if (ui.allCheckBox->isChecked())
75 parameters.push_back("-a");
76 if (ui.fileInfoCheckBox->isChecked())
77 parameters.push_back("-f");
78 if (ui.labelInfoCheckBox->isChecked())
79 parameters.push_back("-l");
80 if (ui.tapemapCheckBox->isChecked())
81 parameters.push_back("-t");
82 parameters.push_back(ui.filename->text().toStdString());
83
84 std::string command = "hetmap";
85
86 execute(command, Preferences::getInstance().hercDir(), parameters);
87 ui.runButton->setText("Stop");
88 }
89
90
91 void HetMap::exitClicked()
92 {
93 deleteLater();
94 }
95
96 void HetMap::browseFileClicked()
97 {
98 QString s = QFileDialog::getOpenFileName(this,"Browse for Input File",ui.filename->text());
99 if (s.size() > 0)
100 ui.filename->setText(s);
101 }
102
103 void HetMap::allClicked()
104 {
105 if (mInternalChange) return;
106 mInternalChange = true; // do not trigger signal when changing the bellow checkboxes
107
108 ui.fileInfoCheckBox->setChecked(false);
109 ui.labelInfoCheckBox->setChecked(false);
110 ui.allCheckBox->setChecked(true);
111
112 mInternalChange = false; // resume propagating signals
113 }
114
115 void HetMap::fileInfoClicked()
116 {
117 if (mInternalChange) return;
118 mInternalChange = true; // do not trigger signal when changing the bellow checkboxes
119
120 ui.allCheckBox->setChecked(false);
121 ui.fileInfoCheckBox->setChecked(true);
122
123 mInternalChange = false; // resume propagating signals
124 }
125
126 void HetMap::labelInfoClicked()
127 {
128 if (mInternalChange) return;
129 mInternalChange = true; // do not trigger signal when changing the bellow checkboxes
130
131 ui.allCheckBox->setChecked(false);
132 ui.labelInfoCheckBox->setChecked(true);
133
134 mInternalChange = false; // resume propagating signals
135 }
136
137 void HetMap::dataInfoClicked()
138 {
139 if (mInternalChange) return;
140 mInternalChange = true; // do not trigger signal when changing the bellow checkboxes
141
142 if (ui.dataInfoCheckBox->isChecked())
143 {
144 ui.allCheckBox->setChecked(false);
145 ui.fileInfoCheckBox->setChecked(false);
146 ui.labelInfoCheckBox->setChecked(false);
147 ui.tapemapCheckBox->setChecked(false);
148 ui.allCheckBox->setEnabled(false);
149 ui.fileInfoCheckBox->setEnabled(false);
150 ui.labelInfoCheckBox->setEnabled(false);
151 ui.tapemapCheckBox->setEnabled(false);
152 }
153 else
154 {
155 ui.allCheckBox->setEnabled(true);
156 ui.fileInfoCheckBox->setEnabled(true);
157 ui.labelInfoCheckBox->setEnabled(true);
158 ui.tapemapCheckBox->setEnabled(true);
159 ui.allCheckBox->setChecked(true);
160 }
161 mInternalChange = false; // resume propagating signals
162 }
163
164 void HetMap::tapemapClicked()
165 {
166 if (mInternalChange) return;
167 mInternalChange = true; // do not trigger signal when changing the bellow checkboxes
168
169 if (ui.tapemapCheckBox->isChecked())
170 {
171 ui.allCheckBox->setChecked(false);
172 ui.fileInfoCheckBox->setChecked(false);
173 ui.labelInfoCheckBox->setChecked(false);
174 ui.dataInfoCheckBox->setChecked(false);
175 ui.allCheckBox->setEnabled(false);
176 ui.fileInfoCheckBox->setEnabled(false);
177 ui.labelInfoCheckBox->setEnabled(false);
178 ui.dataInfoCheckBox->setEnabled(false);
179 }
180 else
181 {
182 ui.allCheckBox->setEnabled(true);
183 ui.fileInfoCheckBox->setEnabled(true);
184 ui.labelInfoCheckBox->setEnabled(true);
185 ui.dataInfoCheckBox->setEnabled(true);
186 ui.allCheckBox->setChecked(true);
187 }
188
189 mInternalChange = false; // resume propagating signals
190 }
191
192 void HetMap::runnerError(const QByteArray &line)
193 {
194 QByteArray lineCopy = line;
195 if (lineCopy.endsWith("\n"))
196 lineCopy.chop(1);
197 emit output(lineCopy);
198 }
199
200 void HetMap::finishedSlot()
201 {
202 deleteLater();
203 }