1 /*  $Id: update_viewer_window.hpp 448679 2014-10-08 13:59:20Z thiessen $
2 * ===========================================================================
3 *
4 *                            PUBLIC DOMAIN NOTICE
5 *               National Center for Biotechnology Information
6 *
7 *  This software/database is a "United States Government Work" under the
8 *  terms of the United States Copyright Act.  It was written as part of
9 *  the author's official duties as a United States Government employee and
10 *  thus cannot be copyrighted.  This software/database is freely available
11 *  to the public for use. The National Library of Medicine and the U.S.
12 *  Government have not placed any restriction on its use or reproduction.
13 *
14 *  Although all reasonable efforts have been taken to ensure the accuracy
15 *  and reliability of the software and data, the NLM and the U.S.
16 *  Government do not and cannot warrant the performance or results that
17 *  may be obtained by using this software or data. The NLM and the U.S.
18 *  Government disclaim all warranties, express or implied, including
19 *  warranties of performance, merchantability or fitness for any particular
20 *  purpose.
21 *
22 *  Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Authors:  Paul Thiessen
27 *
28 * File Description:
29 *      implementation of GUI part of update viewer
30 *
31 * ===========================================================================
32 */
33 
34 #ifndef CN3D_UPDATE_VIEWER_WINDOW__HPP
35 #define CN3D_UPDATE_VIEWER_WINDOW__HPP
36 
37 #include "viewer_window_base.hpp"
38 
39 #include <wx/spinctrl.h>
40 #include <algo/structure/wx_tools/wx_tools.hpp>
41 
42 
43 BEGIN_SCOPE(Cn3D)
44 
45 class UpdateViewer;
46 class SequenceDisplay;
47 
48 class UpdateViewerWindow : public ViewerWindowBase
49 {
50     friend class SequenceDisplay;
51 
52 public:
53     UpdateViewerWindow(UpdateViewer *parentUpdateViewer);
54     ~UpdateViewerWindow(void);
55 
56     void EnableDerivedEditorMenuItems(bool enabled);
57 
58     bool SaveDialog(bool prompt, bool canCancel);
59 
60     void SetWindowTitle(void);
61 
62 private:
63     UpdateViewer *updateViewer;
64 
65     // menu identifiers - additional items beyond base class items
66     enum {
67         MID_DELETE_ALL_BLOCKS = START_VIEWER_WINDOW_DERIVED_MID,
68         MID_DELETE_BLOCKS_ALL_ROWS,
69         MID_SORT_UPDATES,
70         MID_SORT_UPDATES_IDENTIFIER,
71         MID_SORT_UPDATES_PSSM,
72         MID_IMPORT_SEQUENCES,
73         MID_IMPORT_STRUCTURE,
74         MID_THREAD_ONE,
75         MID_THREAD_ALL,
76         MID_BLAST_ONE,
77         MID_BLAST_PSSM_ONE,
78         MID_BLAST_NEIGHBOR,
79         MID_BLOCKALIGN_ONE,
80         MID_BLOCKALIGN_ALL,
81         MID_EXTEND_ONE,
82         MID_EXTEND_ALL,
83         MID_SET_REGION,
84         MID_RESET_REGIONS,
85         MID_MERGE_ONE,
86         MID_MERGE_NEIGHBOR,
87         MID_MERGE_ALL,
88         MID_DELETE_ONE,
89         MID_DELETE_ALL
90     };
91 
92     void OnCloseWindow(wxCloseEvent& event);
93     void OnSortUpdates(wxCommandEvent& event);
94     void OnRunThreader(wxCommandEvent& event);
95     void OnRunBlast(wxCommandEvent& event);
96     void OnBlockAlign(wxCommandEvent& event);
97     void OnExtend(wxCommandEvent& event);
98     void OnSetRegion(wxCommandEvent& event);
99     void OnMerge(wxCommandEvent& event);
100     void OnDelete(wxCommandEvent& event);
101     void OnImport(wxCommandEvent& event);
102 
DeleteAllBlocksOff(void)103     void DeleteAllBlocksOff(void)
104     {
105         menuBar->Check(MID_DELETE_ALL_BLOCKS, false);
106         SetCursor(wxNullCursor);
107     }
ThreadSingleOff(void)108     void ThreadSingleOff(void)
109     {
110         menuBar->Check(MID_THREAD_ONE, false);
111         SetCursor(wxNullCursor);
112     }
BlastSingleOff(void)113     void BlastSingleOff(void)
114     {
115         menuBar->Check(MID_BLAST_ONE, false);
116         SetCursor(wxNullCursor);
117     }
BlastPSSMSingleOff(void)118     void BlastPSSMSingleOff(void)
119     {
120         menuBar->Check(MID_BLAST_PSSM_ONE, false);
121         SetCursor(wxNullCursor);
122     }
BlastNeighborSingleOff(void)123     void BlastNeighborSingleOff(void)
124     {
125         menuBar->Check(MID_BLAST_NEIGHBOR, false);
126         SetCursor(wxNullCursor);
127     }
BlockAlignSingleOff(void)128     void BlockAlignSingleOff(void)
129     {
130         menuBar->Check(MID_BLOCKALIGN_ONE, false);
131         SetCursor(wxNullCursor);
132     }
ExtendSingleOff(void)133     void ExtendSingleOff(void)
134     {
135         menuBar->Check(MID_EXTEND_ONE, false);
136         SetCursor(wxNullCursor);
137     }
SetRegionOff(void)138     void SetRegionOff(void)
139     {
140         menuBar->Check(MID_SET_REGION, false);
141         SetCursor(wxNullCursor);
142     }
MergeSingleOff(void)143     void MergeSingleOff(void)
144     {
145         menuBar->Check(MID_MERGE_ONE, false);
146         SetCursor(wxNullCursor);
147     }
MergeNeighborOff(void)148     void MergeNeighborOff(void)
149     {
150         menuBar->Check(MID_MERGE_NEIGHBOR, false);
151         SetCursor(wxNullCursor);
152     }
DeleteSingleOff(void)153     void DeleteSingleOff(void)
154     {
155         menuBar->Check(MID_DELETE_ONE, false);
156         SetCursor(wxNullCursor);
157     }
158 
GetMouseModeForCreateAndMerge(void)159     SequenceViewerWidget::eMouseMode GetMouseModeForCreateAndMerge(void)
160     {
161         return SequenceViewerWidget::eSelectRectangle;
162     }
163 
164     DECLARE_EVENT_TABLE()
165 
166 public:
DoDeleteAllBlocks(void) const167     bool DoDeleteAllBlocks(void) const { return menuBar->IsChecked(MID_DELETE_ALL_BLOCKS); }
DoThreadSingle(void) const168     bool DoThreadSingle(void) const { return menuBar->IsChecked(MID_THREAD_ONE); }
DoBlastSingle(void) const169     bool DoBlastSingle(void) const { return menuBar->IsChecked(MID_BLAST_ONE); }
DoBlastPSSMSingle(void) const170     bool DoBlastPSSMSingle(void) const { return menuBar->IsChecked(MID_BLAST_PSSM_ONE); }
DoBlastNeighborSingle(void) const171     bool DoBlastNeighborSingle(void) const { return menuBar->IsChecked(MID_BLAST_NEIGHBOR); }
DoBlockAlignSingle(void) const172     bool DoBlockAlignSingle(void) const { return menuBar->IsChecked(MID_BLOCKALIGN_ONE); }
DoExtendSingle(void) const173     bool DoExtendSingle(void) const { return menuBar->IsChecked(MID_EXTEND_ONE); }
DoSetRegion(void) const174     bool DoSetRegion(void) const { return menuBar->IsChecked(MID_SET_REGION); }
DoMergeSingle(void) const175     bool DoMergeSingle(void) const { return menuBar->IsChecked(MID_MERGE_ONE); }
DoMergeNeighbor(void) const176     bool DoMergeNeighbor(void) const { return menuBar->IsChecked(MID_MERGE_NEIGHBOR); }
DoDeleteSingle(void) const177     bool DoDeleteSingle(void) const { return menuBar->IsChecked(MID_DELETE_ONE); }
178 
CancelDerivedSpecialModesExcept(int id)179     void CancelDerivedSpecialModesExcept(int id)
180     {
181         if (id != MID_DELETE_ALL_BLOCKS && DoDeleteAllBlocks()) DeleteAllBlocksOff();
182         if (id != MID_THREAD_ONE && DoThreadSingle()) ThreadSingleOff();
183         if (id != MID_BLAST_ONE && DoBlastSingle()) BlastSingleOff();
184         if (id != MID_BLAST_PSSM_ONE && DoBlastPSSMSingle()) BlastPSSMSingleOff();
185         if (id != MID_BLAST_NEIGHBOR && DoBlastNeighborSingle()) BlastNeighborSingleOff();
186         if (id != MID_BLOCKALIGN_ONE && DoBlockAlignSingle()) BlockAlignSingleOff();
187         if (id != MID_EXTEND_ONE && DoExtendSingle()) ExtendSingleOff();
188         if (id != MID_SET_REGION && DoSetRegion()) SetRegionOff();
189         if (id != MID_MERGE_ONE && DoMergeSingle()) MergeSingleOff();
190         if (id != MID_MERGE_NEIGHBOR && DoMergeNeighbor()) MergeNeighborOff();
191         if (id != MID_DELETE_ONE && DoDeleteSingle()) DeleteSingleOff();
192     }
193 };
194 
195 
196 ///// dialog used to get threader options from user /////
197 
198 class ThreaderOptions;
199 class Sequence;
200 
201 class ThreaderOptionsDialog : public wxDialog
202 {
203 public:
204     ThreaderOptionsDialog(wxWindow* parent, const ThreaderOptions& initialOptions);
205     ~ThreaderOptionsDialog(void);
206 
207     // set the ThreaderOptions from values in the panel; returns true if all values are valid
208     bool GetValues(ThreaderOptions *options);
209 
210 private:
211     wxButton *bOK, *bCancel;
212     ncbi::FloatingPointSpinCtrl *fpWeight, *fpLoops;
213     ncbi::IntegerSpinCtrl *iStarts, *iResults, *iCutoff;
214     wxCheckBox *bMerge, *bFreeze;
215 
216     void OnCloseWindow(wxCloseEvent& event);
217     void OnButton(wxCommandEvent& event);
218 
219     DECLARE_EVENT_TABLE()
220 };
221 
222 class RegionDialog : public wxDialog
223 {
224 public:
225     RegionDialog(wxWindow* parentFrame, const Sequence *sequence, int initialFrom, int initialTo);
226     ~RegionDialog(void);
227 
228     // get the values in the panel; returns true if all values are valid
229     bool GetValues(int *from, int *to);
230 
231 private:
232     ncbi::IntegerSpinCtrl *iFrom, *iTo;
233 
234     void OnCloseWindow(wxCloseEvent& event);
235     void OnButton(wxCommandEvent& event);
236 
237     DECLARE_EVENT_TABLE()
238 };
239 
240 END_SCOPE(Cn3D)
241 
242 #endif // CN3D_UPDATE_VIEWER_WINDOW__HPP
243