1 /**
2 * UGENE - Integrated Bioinformatics Tools.
3 * Copyright (C) 2008-2021 UniPro <ugene@unipro.ru>
4 * http://ugene.net
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (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, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 * MA 02110-1301, USA.
20 */
21
22 #include "SequenceExportSettingsWidget.h"
23
24 #include <U2Core/DNASequenceObject.h>
25 #include <U2Core/U2SafePoints.h>
26
27 #include <U2Gui/RegionSelector.h>
28
29 namespace U2 {
30
SequenceExportSettingsWidget(U2SequenceObject * seqObject,QSharedPointer<CustomExportSettings> s,DNASequenceSelection * selection)31 SequenceExportSettingsWidget::SequenceExportSettingsWidget(U2SequenceObject *seqObject,
32 QSharedPointer<CustomExportSettings> s,
33 DNASequenceSelection *selection)
34 : seqObject(seqObject) {
35 setupUi(this);
36 settings = qSharedPointerCast<SequenceExportSettings>(s);
37 SAFE_POINT(settings != nullptr, tr("Cannot cast CustomExportSettings to SequenceExportSettings"), );
38 SAFE_POINT(seqObject != nullptr, tr("Sequence Object is NULL"), );
39
40 regionSelector = new RegionSelector(this, seqObject->getSequenceLength(), true, selection);
41 regionLayout->addWidget(regionSelector);
42 regionSelector->setVisible(!currentViewButton->isChecked());
43
44 connect(buttonGroup, SIGNAL(buttonClicked(int)), SLOT(sl_areaChanged()));
45 connect(regionSelector, SIGNAL(si_regionChanged(U2Region)), SLOT(sl_regionChanged(U2Region)));
46 }
47
getExportType() const48 SequenceExportType SequenceExportSettingsWidget::getExportType() const {
49 if (zoomButton->isChecked()) {
50 return ExportZoomedView;
51 }
52 if (detailsButton->isChecked()) {
53 return ExportDetailsView;
54 }
55 return ExportCurrentView;
56 }
57
sl_areaChanged()58 void SequenceExportSettingsWidget::sl_areaChanged() {
59 regionSelector->setVisible(!currentViewButton->isChecked());
60 settings->setType(getExportType());
61 settings->setRegion(regionSelector->getRegion());
62 }
63
sl_regionChanged(const U2Region & r)64 void SequenceExportSettingsWidget::sl_regionChanged(const U2Region &r) {
65 settings->setRegion(r);
66 }
67
68 } // namespace U2
69