1 /*   $Id: viewmgr.h,v 1.19 2006/07/13 17:06:39 bollin Exp $
2 * ===========================================================================
3 *
4 *                            PUBLIC DOMAIN NOTICE
5 *            National Center for Biotechnology Information (NCBI)
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 do not place any restriction on its use or reproduction.
13 *  We would, however, appreciate having the NCBI and the author cited in
14 *  any work or product based on this material
15 *
16 *  Although all reasonable efforts have been taken to ensure the accuracy
17 *  and reliability of the software and data, the NLM and the U.S.
18 *  Government do not and cannot warrant the performance or results that
19 *  may be obtained by using this software or data. The NLM and the U.S.
20 *  Government disclaim all warranties, express or implied, including
21 *  warranties of performance, merchantability or fitness for any particular
22 *  purpose.
23 *
24 * ===========================================================================
25 *
26 * File Name:  $Id: viewmgr.h,v 1.19 2006/07/13 17:06:39 bollin Exp $
27 *
28 * Author:  Lewis Geer
29 *
30 * Version Creation Date:   2/1/00
31 *
32 * $Revision: 1.19 $
33 *
34 * File Description: The ViewMgr is the part of the alignment management
35 *                   system that creates a viewable seqalign from an original
36 *                   seqalign (called a target) by applying a set of
37 *                   transforms to the target, such as show/hide rows.  The
38 *                   ViewMgr also deals with allocation/deallocation of
39 *                   the target and view seqaligns.
40 *
41 * Modifications:
42 * --------------------------------------------------------------------------
43 * $Log: viewmgr.h,v $
44 * Revision 1.19  2006/07/13 17:06:39  bollin
45 * use Uint4 instead of Uint2 for itemID values
46 * removed unused variables
47 * resolved compiler warnings
48 *
49 * Revision 1.18  2001/01/18 22:28:06  hurwitz
50 * added fast option for ViewMgr_Update
51 *
52 * Revision 1.17  2000/08/30 13:43:11  lewisg
53 * change seqalign state when made into multiple
54 *
55 * Revision 1.16  2000/08/01 12:54:29  lewisg
56 * *** empty log message ***
57 *
58 * Revision 1.15  2000/07/08 20:43:55  vakatov
59 * Get all "#include" out of the 'extern "C" { }' scope;  other cleanup...
60 *
61 * Revision 1.14  2000/06/20 19:35:12  hurwitz
62 * use indexed seqAlign when necessary, make multiple when redrawing
63 *
64 * Revision 1.13  2000/06/13 18:23:54  hurwitz
65 * made ViewMgr_MakeMultiple routine, call this on each launch of DDE rather than launch of DDV
66 *
67 * Revision 1.12  2000/05/24 21:42:59  hurwitz
68 * getting hide/show rows to work with DDV and DDE together
69 *
70 * Revision 1.11  2000/04/17 21:47:52  lewisg
71 * do not do double index on viewmgr update, rename menus
72 *
73 * Revision 1.10  2000/03/29 23:38:06  lewisg
74 * hide/show, fixes to saving and opening
75 *
76 * Revision 1.9  2000/03/27 22:15:04  lewisg
77 * add show/hide row dialog
78 *
79 * Revision 1.8  2000/03/14 14:20:15  lewisg
80 * add extern row conversion functions
81 *
82 * Revision 1.7  2000/03/10 18:47:01  lewisg
83 * add show/hide
84 *
85 * Revision 1.6  2000/03/08 21:46:14  lewisg
86 * cn3d saves viewport, misc bugs
87 *
88 * Revision 1.5  2000/03/02 21:11:05  lewisg
89 * use bandalign for import sequence, make standalone ddv use viewmgr, make dialogs modal, send color update
90 *
91 * Revision 1.4  2000/03/01 22:53:41  lewisg
92 * import bioseq, neatlyindex, get rid of dead code
93 *
94 * Revision 1.3  2000/02/19 01:23:58  lewisg
95 * use ibm, add row tracking code, various bug fixes
96 *
97 * Revision 1.2  2000/02/15 22:40:57  lewisg
98 * add ability to launch udv so that it colors by row, fixes to colormgr, track rows from viewmgr, fix visual c projects
99 *
100 * Revision 1.1  2000/02/05 01:32:23  lewisg
101 * add viewmgr, move place freeing is done in ddv, modify visual c++ projects
102 *
103 *
104 *
105 * ==========================================================================
106 */
107 
108 #ifndef _VIEWMGR_
109 #define _VIEWMGR_
110 
111 #include <ncbi.h>
112 #include <objalign.h>
113 #include <ddvcolor.h>
114 
115 #undef NLM_EXTERN
116 #ifdef NLM_IMPORT
117 #define NLM_EXTERN NLM_IMPORT
118 #else
119 #define NLM_EXTERN extern
120 #endif
121 
122 #ifdef __cplusplus
123 extern "C" {
124 #endif
125 
126 typedef struct _ViewMgr_ChildInfo {
127     SeqAlign *pChild; /* pointer to the child */
128     Boolean Hidden;   /* is this child hidden */
129     Boolean Keep;     /* should this alignment be kept */
130 } ViewMgr_ChildInfo;
131 
132 typedef struct _ViewMgr_AlignInfo {
133     SeqAlign *pTarget, *pView, *pBegin, *pBeginIndexed;
134     /* the target, view, beginning, and indexed beginning seqaligns */
135     ValNode *pHiddenRows; /* rows to hide */
136     ValNode *pDeleteRows; /* rows to delete */
137     Boolean Intersect;    /* do we run intersect on master? */
138     Boolean Neat;         /* do we neatly index the seqalign? */
139     ValNode *pChildInfo;  /* list of ViewMgr_ChildInfo, one per child. NYI */
140     Uint2 entityID;
141     ValNode *pUserKey2Row;  /* converts a userkey to a row #*/
142     ValNode *pTransforms;    /* these point to valnode chains of ViewMgr_FromTo */
143     Boolean BeginIndexed;
144 } ViewMgr_AlignInfo;
145 
146 typedef struct _ViewMgr_Global {
147     Int4 refcount;
148     ValNode *pAlignList;  /* list of ViewMgr_AlignInfo */
149     Uint2 userkey;
150     Uint2 procid;
151 } ViewMgr_Global;
152 
153 typedef struct _ViewMgr_FromTo {
154     Int4 From;
155     Int4 To;
156 } ViewMgr_FromTo;
157 
158 #define VMGR_ROWWISE (0)
159 #define VMGR_DELETE (1)
160 #define VMGR_HIDE (2)
161 #define VMGR_IBM (3)
162 #define VMGR_REORDER (4)
163 
164 /*****************************************************************************
165 
166 Function: ViewMgr_VRow2TRow
167 
168 Purpose: Converts a viewed row to a target row
169 
170 Parameters: salp, the seqalign
171             pGlobal, the ViewMgr_Global
172             VRow, the row number in the viewed SeqAlign
173 
174 Returns: the row in the target SeqAlign, -1 on failure
175 
176 *****************************************************************************/
177 NLM_EXTERN Int4 ViewMgr_VRow2TRow(SeqAlign *salp, Int4 VRow);
178 
179 /*****************************************************************************
180 
181 Function: ViewMgr_TRow2VRow
182 
183 Purpose: Finds a seqalign by pointer inside of the ViewMgr_Global
184 
185 Parameters: salp, the seqalign
186             TRow, the row number in the target SeqAlign
187 
188 Returns: the row in the viewed SeqAlign, -1 on failure
189 
190 *****************************************************************************/
191 NLM_EXTERN Int4 ViewMgr_TRow2VRow (SeqAlign *salp, Int4 TRow);
192 
193 /*****************************************************************************
194 
195 Function: ViewMgr_MakeMultiple
196 
197 Purpose: Turns a pairwise seqalign into a multiple
198 
199 Parameters: salp, the seqalign to be turned into a multiple
200 
201 Returns: 1 on success, 0 otherwise
202 
203 *****************************************************************************/
204 
205 NLM_EXTERN Int4 ViewMgr_MakeMultiple(SeqAlign *salp);
206 
207 /*****************************************************************************
208 
209 Function: ViewMgr_GetTarget
210 
211 Purpose: return the original *indexed* SeqAlign given the view seqalign
212 
213 *****************************************************************************/
214 NLM_EXTERN SeqAlign * ViewMgr_GetTarget(SeqAlign *salp);
215 
216 /*****************************************************************************
217 
218 Function: ViewMgr_GetBegin
219 
220 Purpose: return the original SeqAlign given the view seqalign
221 
222 *****************************************************************************/
223 NLM_EXTERN SeqAlign * ViewMgr_GetBegin(SeqAlign *salp);
224 
225 /*****************************************************************************
226 
227 Function: ViewMgr_SetBegin
228 
229 Purpose: make pNewBegin the original SeqAlign
230 
231 *****************************************************************************/
232 NLM_EXTERN SeqAlign * ViewMgr_SetBegin(SeqAlign *salp, SeqAlign *pNewBegin,
233                                        Boolean Neat, Boolean Intersect);
234 
235 /*****************************************************************************
236 
237 Function: ViewMgr_GetBeginIndexed
238 
239 Purpose: return the original SeqAlign given the view seqalign.  This is
240 an indexed copy of the original SeqAlign.
241 
242 *****************************************************************************/
243 NLM_EXTERN SeqAlign * ViewMgr_GetBeginIndexed(SeqAlign *salp);
244 
245 /*****************************************************************************
246 
247 Function: ViewMgr_IsNeat
248 
249 Purpose: is the seqalign neatly indexed?
250 
251 *****************************************************************************/
252 NLM_EXTERN Boolean ViewMgr_IsNeat(SeqAlign *salp);
253 
254 /*****************************************************************************
255 
256 Function: ViewMgr_IsIBM
257 
258 Purpose: is the seqalign IBMed?
259 
260 *****************************************************************************/
261 NLM_EXTERN Boolean ViewMgr_IsIBM(SeqAlign *salp);
262 
263 /*****************************************************************************
264 
265 Function: ViewMgr_SetRow
266 
267 Purpose: Sets the row that a bioseq viewer is looking at, given the
268          viewer's unique UserKey
269 
270 Parameters: pGlobal, the DDV_ColorGlobal
271             UserKey, the userkey of the viewer
272             Row, the row the viewer is looking at
273 
274 Returns: 1 on success, 0 on failure
275 
276 *****************************************************************************/
277 NLM_EXTERN Int4 ViewMgr_SetRow(DDV_ColorGlobal *pCGlobal, Uint2 UserKey,
278                                Int4 Row);
279 
280 /*****************************************************************************
281 
282 Function: ViewMgr_GetRow
283 
284 Purpose: Returns the row that a bioseq viewer is looking at, given the
285          viewer's unique UserKey
286 
287 Parameters: pGlobal, the ViewMgr_Global
288             UserKey, the userkey of the viewer
289 
290 Returns: the row, -1 on failure
291 
292 *****************************************************************************/
293 NLM_EXTERN Int4 ViewMgr_GetRow(DDV_ColorGlobal *pCGlobal, Uint2 UserKey);
294 
295 /*****************************************************************************
296 
297 Function: ViewMgr_FreeInfo
298 
299 Purpose: Free a ViewMgr_AlignInfo
300 
301 Parameters: pInfo, to be freed
302 
303 Returns: 1 on success
304 
305 *****************************************************************************/
306 NLM_EXTERN Int4 ViewMgr_FreeInfo(ViewMgr_AlignInfo *pInfo);
307 
308 /*****************************************************************************
309 
310 Function: ViewMgr_RemoveSA
311 
312 Purpose: Takes the information about a seqalign out of the ViewMgr
313 
314 Parameters: salp, the seqalign to remove
315 
316 Returns: 1 on success
317 
318 *****************************************************************************/
319 NLM_EXTERN Int4 ViewMgr_RemoveSA(SeqAlign *salp);
320 
321 /*****************************************************************************
322 
323 Function: ViewMgr_New
324 
325 Purpose: Creates a new View Manager global for tracking SeqAligns
326 
327 Returns: the new global
328 
329 *****************************************************************************/
330 NLM_EXTERN ViewMgr_Global * ViewMgr_New(void);
331 
332 /*****************************************************************************
333 
334 Function: ViewMgr_Attach
335 
336 Purpose:  Adds the seqalign to the global and starts tracking it
337 
338 Parameters: salp, a seqalign that *isn't* indexed.
339             Intersect, true if intersect-on-master should be applied
340             Neat, true if AlnMgrNeatlyIndex should be applied
341             entityID, itemID of object passed in.  If entityID == 0,
342                 then salp is used to look up the values.
343 
344 Returns: 0 on error, 1 otherwise
345 
346 Notes: will index the seqalign
347 
348 *****************************************************************************/
349 NLM_EXTERN Int4 ViewMgr_Attach(SeqAlign *salp, Boolean Neat,
350                                Boolean Intersect, Uint2 entityID,
351                                Uint4 itemID);
352 
353 /*****************************************************************************
354 
355 Function: ViewMgr_Add
356 
357 Purpose: Add a seqalign to a seqalign already in the viewmgr
358 
359 Parameters: salp, the seqalign to be added to.  Must be attached to viewmgr
360             salpAdd, the seqalign to be added.  Shouldn't be indexed.
361 
362 Returns: 1 on success
363 
364 *****************************************************************************/
365 NLM_EXTERN Int4 ViewMgr_Add(SeqAlign *salp, SeqAlign *salpAdd);
366 
367 /*****************************************************************************
368 
369 Function: ViewMgr_SetHidden
370 
371 Purpose: Set a row to contribute / not contribute to the seqalign
372 
373 Parameters: salp, the seqalign to be shown/hid
374             Row, the row to show or hide
375             Hidden,
376 
377 Returns: 1 on success, 0 on setup failure, -1 if the requested action can't
378          be done.
379 
380 *****************************************************************************/
381 NLM_EXTERN Int4 ViewMgr_SetHidden(SeqAlign *salp, Boolean Hidden, Int4 Row);
382 
383 /*****************************************************************************
384 
385 Function: ViewMgr_Update
386 
387 Purpose: Copies the target into the viewed seqalign, performs all the
388         transformations, then sends an update message
389 
390 Parameters: salp, the seqalign to work on
391 
392 Returns: 1 on success
393 
394 *****************************************************************************/
395 NLM_EXTERN Int4 ViewMgr_Update(SeqAlign *salp);
396 NLM_EXTERN Int4 ViewMgr_Update2(SeqAlign *salp, Boolean Fast);
397 
398 /*****************************************************************************
399 
400 Function: ViewMgr_RegisterFunc
401 
402 Purpose: Adds the ViewMgr message function to the seqalign
403 
404 *****************************************************************************/
405 NLM_EXTERN Int2 LIBCALLBACK ViewMgr_RegisterFunc(Pointer data);
406 
407 #ifdef __cplusplus
408 }
409 #endif
410 
411 #undef NLM_EXTERN
412 #ifdef NLM_EXPORT
413 #define NLM_EXTERN NLM_EXPORT
414 #else
415 #define NLM_EXTERN
416 #endif
417 
418 #endif
419