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 GTUTILSMSAEDITORSEQUENCEAREA_H
23 #define GTUTILSMSAEDITORSEQUENCEAREA_H
24 
25 #include <GTGlobals.h>
26 
27 #include <U2View/MSAEditorSequenceArea.h>
28 
29 #include "runnables/ugene/corelibs/U2Gui/AppSettingsDialogFiller.h"
30 
31 namespace U2 {
32 
33 class GTUtilsMSAEditorSequenceArea {
34 public:
35     static MSAEditorSequenceArea *getSequenceArea(GUITestOpStatus &os);
36     static void callContextMenu(GUITestOpStatus &os, const QPoint &innerCoords = QPoint());  // zero-based position
37 
38     static void checkSelectedRect(GUITestOpStatus &os, const QRect &expectedRect);
39 
40     static void checkConsensus(GUITestOpStatus &os, QString cons);
41     // may be used for selecting visible columns only
42     static void selectColumnInConsensus(GUITestOpStatus &os, int columnNumber);
43 
44     // MSAEditorNameList
45 
46     /** Returns all names in MSA object as stored in the object. */
47     static QStringList getNameList(GUITestOpStatus &os);
48 
49     /**
50      * Returns ordered list of row names rendered on the screen: both from the visible on the screen are and from the overflow (available with the scroll).
51      * Excludes invisible rows inside of collapsed groups.
52      * */
53     static QStringList getCurrentRowNames(GUITestOpStatus &os);
54 
55     static bool hasSequencesWithNames(GUITestOpStatus &os, const QStringList &names);
56 
57     /**
58      * Returns list of visible row names.
59      * Uses original MSA row names if 'asShownInNameList' is false (default) or the final rendered
60      * row text if 'asShownInNameList' is true.
61      */
62     static QStringList getVisibleNames(GUITestOpStatus &os, bool asShownInNameList = false);
63 
64     static QString getSimilarityValue(GUITestOpStatus &os, int row);
65     static void clickCollapseTriangle(GUITestOpStatus &os, QString seqName);
66     static bool isCollapsed(GUITestOpStatus &os, QString seqName);
67     static bool collapsingMode(GUITestOpStatus &os);
68 
69     static int getFirstVisibleBase(GUITestOpStatus &os);
70     static int getLastVisibleBase(GUITestOpStatus &os);
71 
72     static int getLength(GUITestOpStatus &os);
73     static int getNumVisibleBases(GUITestOpStatus &os);
74 
75     static QRect getSelectedRect(GUITestOpStatus &os);
76     static void dragAndDropSelection(GUITestOpStatus &os, const QPoint &fromMaPosition, const QPoint &toMaPosition);
77 
78     static void moveTo(GUITestOpStatus &os, const QPoint &p);
79 
80     // selects area in MSA coordinates, if some p coordinate less than 0, it becomes max valid coordinate
81     // zero-based position
82     static void selectArea(GUITestOpStatus &os, QPoint p1 = QPoint(0, 0), QPoint p2 = QPoint(-1, -1), GTGlobals::UseMethod method = GTGlobals::UseKey);
83     static void cancelSelection(GUITestOpStatus &os);
84     /** Returns on-screen (global) bounding rectangle for the base position. */
85     static QRect getPositionRect(GUITestOpStatus &os, const QPoint &position);
86     static QPoint convertCoordinates(GUITestOpStatus &os, const QPoint p);
87     static void click(GUITestOpStatus &os, const QPoint &screenMaPoint = QPoint(0, 0));
88 
89     /** Calls context menu Copy/Paste->Copy. */
90     static void copySelectionByContextMenu(GUITestOpStatus &os);
91 
92     // scrolls to the position (in the MSA zero-based coordinates)
93     static void scrollToPosition(GUITestOpStatus &os, const QPoint &position);
94     static void scrollToBottom(GUITestOpStatus &os);
95     static void moveMouseToPosition(GUITestOpStatus &os, const QPoint &globalMaPosition);
96     static void clickToPosition(GUITestOpStatus &os, const QPoint &globalMaPosition);
97 
98     static void selectSequence(GUITestOpStatus &os, const QString &seqName);
99     static void selectSequence(GUITestOpStatus &os, const int row);
100     static bool isSequenceSelected(GUITestOpStatus &os, const QString &seqName);
101     static void removeSequence(GUITestOpStatus &os, const QString &sequenceName);
102     static int getSelectedSequencesNum(GUITestOpStatus &os);
103     static bool isSequenceVisible(GUITestOpStatus &os, const QString &seqName);
104     static QString getSequenceData(GUITestOpStatus &os, const QString &sequenceName);
105     static QString getSequenceData(GUITestOpStatus &os, int rowNumber);
106 
107     static bool offsetsVisible(GUITestOpStatus &os);
108 
109     static bool hasAminoAlphabet(GUITestOpStatus &os);
110     static bool isSequenceHighlighted(GUITestOpStatus &os, const QString &seqName);
111     static QString getColor(GUITestOpStatus &os, QPoint p);
112     static bool hasPixelWithColor(GUITestOpStatus &os, const QPoint &p, const QColor &color);
113     static void checkMsaCellColors(GUITestOpStatus &os, const QPoint &pos, const QString &fgColor, const QString &bgColor);
114     static void checkMsaCellColor(GUITestOpStatus &os, const QPoint &pos, const QString &color);
115     static bool checkColor(GUITestOpStatus &os, const QPoint &p, const QString &expectedColor);
116     static int getRowHeight(GUITestOpStatus &os, int rowNumber);
117 
118     static void renameSequence(GUITestOpStatus &os, const QString &seqToRename, const QString &newName, bool useCopyPaste = false);
119     static void replaceSymbol(GUITestOpStatus &os, const QPoint &maPoint, char newSymbol);
120 
121     static void createColorScheme(GUITestOpStatus &os, const QString &schemeName, const NewColorSchemeCreator::alphabet al);
122     static void deleteColorScheme(GUITestOpStatus &os, const QString &schemeName);
123 
124     static void checkSelection(GUITestOpStatus &os, const QPoint &start, const QPoint &end, const QString &expected);
125 
126     static bool isAlignmentLocked(GUITestOpStatus &os);
127 
128     /*
129      *expandedBorder: 0 - top, 1 - right, 2 - bottom, 3 - left, 4 - right top, 5 - right bottom, 6 - left bottom, 7 - left top
130      */
131     static void expandSelectedRegion(GUITestOpStatus &os, const int expandedBorder, const int symbolsToExpand);
132 
133     static void zoomIn(GUITestOpStatus &os);
134     static void zoomOut(GUITestOpStatus &os);
135     static void zoomToMax(GUITestOpStatus &os);
136     static void zoomToMin(GUITestOpStatus &os);
137 
138     static const QString highlightingColor;
139 };
140 
141 }  // namespace U2
142 #endif  // GTUTILSMSAEDITORSEQUENCEAREA_H
143