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_GT_UTILS_SEQUENCE_VIEW_H
23 #define _U2_GT_UTILS_SEQUENCE_VIEW_H
24 
25 #include <GTGlobals.h>
26 
27 #include <QString>
28 
29 namespace U2 {
30 
31 class ADVSingleSequenceWidget;
32 class DetView;
33 class PanView;
34 class U2Region;
35 class Overview;
36 class GSequenceGraphView;
37 class GraphLabelTextBox;
38 
39 class GTUtilsSequenceView {
40 public:
41     /** Returns active sequence view window or fails if not found. */
42     static QWidget *getActiveSequenceViewWindow(HI::GUITestOpStatus &os);
43 
44     /** Checks that there is an active sequence view window or fails if not found. */
45     static void checkSequenceViewWindowIsActive(HI::GUITestOpStatus &os);
46 
47     /** Checks that there is no sequence view window opened: either active or non-active. */
48     static void checkNoSequenceViewWindowIsOpened(HI::GUITestOpStatus &os);
49 
50     static void getSequenceAsString(HI::GUITestOpStatus &os, QString &sequence);
51     static QString getSequenceAsString(HI::GUITestOpStatus &os, int number = 0);
52     static QString getBeginOfSequenceAsString(HI::GUITestOpStatus &os, int length);
53     static QString getEndOfSequenceAsString(HI::GUITestOpStatus &os, int length);
54     static int getLengthOfSequence(HI::GUITestOpStatus &os);
55     static int getVisibleStart(HI::GUITestOpStatus &os, int widgetNumber = 0);
56     static U2Region getVisibleRange(HI::GUITestOpStatus &os, int widgetNumber = 0);
57     static void checkSequence(HI::GUITestOpStatus &os, const QString &expectedSequence);
58     static void selectSequenceRegion(HI::GUITestOpStatus &os, int from, int to);
59     static void selectSeveralRegionsByDialog(HI::GUITestOpStatus &os, const QString &multipleRangeString);
60 
61     static void openSequenceView(HI::GUITestOpStatus &os, const QString &sequenceName);
62     static void addSequenceView(HI::GUITestOpStatus &os, const QString &sequenceName);
63 
64     static void goToPosition(HI::GUITestOpStatus &os, qint64 position);
65 
66     /** Moves mouse to the safe sequence view area (Pan or Det view, not a scrollbar) and clicks (brings focus) into it. */
67     static void clickMouseOnTheSafeSequenceViewArea(HI::GUITestOpStatus &os);
68 
69     /** Opens popup menu safely on the sequence view. The sequence view must have either Det or Pan view widget. */
70     static void openPopupMenuOnSequenceViewArea(HI::GUITestOpStatus &os, int number = 0);
71 
72     /**
73      * Returns currently opened PanView or DetView widget.
74      * This method is useful to trigger mouse events over a sequence safely with no chance of hitting scrollbars, etc...
75      */
76     static QWidget *getPanOrDetView(HI::GUITestOpStatus &os, int number = 0);
77 
78     static ADVSingleSequenceWidget *getSeqWidgetByNumber(HI::GUITestOpStatus &os, int number = 0, const GTGlobals::FindOptions & = GTGlobals::FindOptions());
79     static DetView *getDetViewByNumber(HI::GUITestOpStatus &os, int number = 0, const GTGlobals::FindOptions & = GTGlobals::FindOptions());
80     static PanView *getPanViewByNumber(HI::GUITestOpStatus &os, int number = 0, const GTGlobals::FindOptions & = GTGlobals::FindOptions());
81     static Overview *getOverviewByNumber(HI::GUITestOpStatus &os, int number = 0, const GTGlobals::FindOptions & = GTGlobals::FindOptions());
82     static int getSeqWidgetsNumber(HI::GUITestOpStatus &os);
83     static QVector<U2Region> getSelection(HI::GUITestOpStatus &os, int number = 0);
84     static QString getSeqName(HI::GUITestOpStatus &os, int number = 0);
85     static QString getSeqName(HI::GUITestOpStatus &os, ADVSingleSequenceWidget *seqWidget);
86 
87     /**
88      * Clicks on the center of the annotation region in DetView.
89      * Locates the region to click by the annotationName and annotationRegionStartPos(visual, starts with 1) that must be one of the location.region.startPos.
90      * */
91     static void clickAnnotationDet(HI::GUITestOpStatus &os, const QString &annotationName, int annotationRegionStartPos, int sequenceWidgetIndex = 0, const bool isDoubleClick = false, Qt::MouseButton button = Qt::LeftButton);
92 
93     static void clickAnnotationPan(HI::GUITestOpStatus &os, QString name, int startPos, int number = 0, const bool isDoubleClick = false, Qt::MouseButton button = Qt::LeftButton);
94 
95     static GSequenceGraphView *getGraphView(HI::GUITestOpStatus &os);
96     static QList<QVariant> getLabelPositions(HI::GUITestOpStatus &os, GSequenceGraphView *graph);
97     static QList<GraphLabelTextBox *> getGraphLabels(HI::GUITestOpStatus &os, GSequenceGraphView *graph);
98     static QColor getGraphColor(HI::GUITestOpStatus &os, GSequenceGraphView *graph);
99 
100     /** Toggle graph visibility by graph name. */
101     static void toggleGraphByName(HI::GUITestOpStatus &os, const QString &graphName, int sequenceViewIndex = 0);
102 
103     /** Clicks zoom in button. */
104     static void zoomIn(HI::GUITestOpStatus &os, int sequenceViewIndex = 0);
105 
106     static void enableEditingMode(HI::GUITestOpStatus &os, bool enable = true, int sequenceNumber = 0);
107 
108     /** Enables editing mode, sets cursor to the offset, enters the sequence and disables editing mode. */
109     static void insertSubsequence(HI::GUITestOpStatus &os, qint64 offset, const QString &subsequence, bool isDirectStrand = true);
110 
111     /** It is supposed, that the editing mode is enabled and DetView is visible.
112       * The method sets the cursor before the @position (0-based) in the first sequence in the view
113       The case with translations and turned off complementary supported bad, let's try to avoid this situation now
114       **/
115     static void setCursor(HI::GUITestOpStatus &os, qint64 position, bool clickOnDirectLine = false, bool doubleClick = false);
116 
117     static qint64 getCursor(HI::GUITestOpStatus &os);
118 
119     static QString getRegionAsString(HI::GUITestOpStatus &os, const U2Region &region);
120 
121     static void clickOnDetView(HI::GUITestOpStatus &os);
122 
123     /** Enables det-view widget if it is not visible. */
124     static void makeDetViewVisible(HI::GUITestOpStatus &os);
125 };
126 
127 }  // namespace U2
128 
129 #endif  // _U2_GT_UTILS_SEQUENCE_VIEW_H
130