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 #ifndef _U2_ANNOT_HIGHLIGHT_WIDGET_H_ 23 #define _U2_ANNOT_HIGHLIGHT_WIDGET_H_ 24 25 #include "AnnotHighlightSettings.h" 26 #include "AnnotHighlightTree.h" 27 28 class QPushButton; 29 30 namespace U2 { 31 32 class ADVSequenceObjectContext; 33 class ADVSequenceWidget; 34 class AnnotatedDNAView; 35 class Annotation; 36 class AnnotationModification; 37 class AnnotationTableObject; 38 class AnnotatedRegion; 39 class U2Region; 40 41 /** Label that can be pressed with two states: show all types or types for sequence only */ 42 class ShowAllAnnotTypesLabel : public QLabel { 43 Q_OBJECT 44 public: 45 ShowAllAnnotTypesLabel(); isShowAllSelected()46 inline bool isShowAllSelected() { 47 return showAllIsSelected; 48 } 49 50 signals: 51 void si_showAllStateChanged(); 52 53 private: 54 virtual void mousePressEvent(QMouseEvent *); 55 56 bool showAllIsSelected; 57 }; 58 59 class AnnotHighlightWidget : public QWidget { 60 Q_OBJECT 61 public: 62 AnnotHighlightWidget(AnnotatedDNAView *); 63 64 private slots: 65 void sl_onShowAllStateChanged(); 66 void sl_onSelectedItemChanged(const QString &annotName); 67 void sl_storeNewColor(const QString &annotName, const QColor &newColor); 68 void sl_storeNewSettings(AnnotationSettings *annotSettings); 69 void sl_onSequenceModified(ADVSequenceObjectContext *); 70 void sl_onAnnotationsAdded(const QList<Annotation *> &); 71 void sl_onAnnotationsRemoved(const QList<Annotation *> &); 72 void sl_onAnnotationsModified(); 73 void sl_onAnnotationObjectAdded(AnnotationTableObject *); 74 void sl_onAnnotationObjectRemoved(AnnotationTableObject *); 75 void sl_onNextAnnotationClick(); 76 void sl_onPrevAnnotationClick(); 77 void sl_onAnnotationSelectionChanged(); 78 79 private: 80 void initLayout(); 81 /** 82 * Annotation types tree and settings are not shown. 83 * A label describes that there are no annotations. 84 */ 85 void setNoAnnotsLayout(); 86 87 /** 88 * The tree and the settings are shown, the "no annotation" 89 * label is not visible. 90 */ 91 void setLayoutWithAnnotsSelection(); 92 93 /** The label value depends on the number of sequences (one or more) */ 94 void setNoAnnotTypesLabelValue(); 95 96 void connectSlots(); 97 void connectSlotsForAnnotTableObj(const AnnotationTableObject *annotTableObj); 98 void disconnectSlotsForAnnotTableObj(const AnnotationTableObject *annotTableObj); 99 100 /** 101 * Depending on the showAllLabel loads either annotations 102 * for the sequence or all annotations. 103 * The tree is cleared before adding the items. 104 */ 105 void loadAnnotTypes(); 106 107 /** 108 * Searches for all annotation types IN the current Sequence View and 109 * saves the results into the annotNamesWithAminoInfo map. 110 * "annotIsOnAminoSeq" = true, when annotations of this type were found 111 * on amino acid sequences only, otherwise it is "true" 112 */ 113 void findAllAnnotationsNamesForSequence(); 114 115 /** 116 * Searches for ALL registered annotation types and 117 * saves the results into the annotNamesWithAminoInfo map. 118 * "annotIsOnAminoSeq" = false in this case (i.e. enable the "Show on translation" option). 119 */ 120 void findAllAnnotationsNamesInSettings(); 121 122 void selectNextAnnotation(bool isForward) const; 123 124 /** 125 * Returns true if provided @region of @annotation is: 126 * - the first one in case @fromTheBeginning is true, 127 * - the last one in case @fromTheBeginning is false. 128 */ 129 bool isFirstAnnotatedRegion(Annotation *annotation, const U2Region ®ion, bool fromTheBeginning = true) const; 130 131 bool noAnnotatedRegions() const; 132 133 bool findFirstAnnotatedRegion(AnnotatedRegion &annRegion, bool fromTheBeginning = true) const; 134 135 bool findFirstAnnotatedRegionAfterPos(AnnotatedRegion &annRegion, qint64 startPos, bool isForward) const; 136 137 bool findNextUnselectedAnnotatedRegion(AnnotatedRegion &annRegion, bool isForward) const; 138 139 QList<AnnotatedRegion> getAllAnnotatedRegionsByStartPos(qint64 startPos) const; 140 141 void updateAnnotationNames(); 142 143 AnnotatedDNAView *annotatedDnaView; 144 145 /** 146 * For each annotation type specifies whether the "Show on translation" option 147 * should be enabled or disabled. 148 */ 149 QMap<QString, bool> annotNamesWithAminoInfo; 150 151 QLabel *noAnnotTypesLabel; 152 QLabel *annotTreeTitle; 153 AnnotHighlightTree *annotTree; 154 ShowAllAnnotTypesLabel *showAllLabel; 155 QLabel *settingsTitle; 156 AnnotHighlightSettingsWidget *annotSettingsWidget; 157 QPushButton *nextAnnotationButton; 158 QPushButton *prevAnnotationButton; 159 }; 160 161 } // namespace U2 162 163 #endif 164