summaryrefslogtreecommitdiff
path: root/ddv
diff options
context:
space:
mode:
authorAaron M. Ucko <ucko@debian.org>2005-03-23 17:39:07 +0000
committerAaron M. Ucko <ucko@debian.org>2005-03-23 17:39:07 +0000
commita7c5bff619aa4850d09825888b5f46c7cd086f11 (patch)
tree2ab2dd2ff2977a5e0bcfdd90a17ca4f1a73181fc /ddv
parentbfbecafe8b6142e8356e8447f0822b43e94b64b7 (diff)
Load ncbi (6.1.20010709) into ncbi-tools6/branches/upstream/current.
Diffstat (limited to 'ddv')
-rw-r--r--ddv/README4
-rw-r--r--ddv/ddv.dsp121
-rw-r--r--ddv/ddvclick.c2975
-rw-r--r--ddv/ddvclick.h152
-rw-r--r--ddv/ddvcreate.c3439
-rw-r--r--ddv/ddvcreate.h303
-rw-r--r--ddv/ddvgraph.c1349
-rw-r--r--ddv/ddvgraph.h171
-rw-r--r--ddv/ddvlib.dsp126
-rw-r--r--ddv/ddvmain.c447
-rw-r--r--ddv/ddvmain.h398
-rw-r--r--ddv/ddvopen.c3441
-rw-r--r--ddv/ddvopen.h336
-rw-r--r--ddv/ddvpanel.c3674
-rw-r--r--ddv/ddvpanel.h278
-rw-r--r--ddv/udv.dsp117
16 files changed, 17331 insertions, 0 deletions
diff --git a/ddv/README b/ddv/README
new file mode 100644
index 00000000..8466e504
--- /dev/null
+++ b/ddv/README
@@ -0,0 +1,4 @@
+The code in this directory except ddvgraph is restricted checkin as it has
+been forked and placed in the C++ toolkit. Please check in only bugfixes and
+make sure that these bugfixes are also checked into the C++ code. New features
+should only go into the C++ code. For more info, contact lewisg.
diff --git a/ddv/ddv.dsp b/ddv/ddv.dsp
new file mode 100644
index 00000000..15eda6ca
--- /dev/null
+++ b/ddv/ddv.dsp
@@ -0,0 +1,121 @@
+# Microsoft Developer Studio Project File - Name="ddv" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=ddv - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "ddv.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "ddv.mak" CFG="ddv - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "ddv - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE "ddv - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "ddv - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\biostruc\cdd" /I ".." /I "..\ddv" /I "..\cn3d" /I "..\access" /I "..\asnstat" /I "..\connect\lbapi" /I "..\connect" /I "..\asnlib" /I "..\vibrant" /I "..\biostruc" /I "..\object" /I "..\api" /I "..\cdromlib" /I "..\desktop" /I "..\tools" /I "..\corelib" /I "..\network\taxon1\common" /I "..\network\vibnet" /I "..\network\entrez\client" /I "..\network\nsclilib" /I "..\network\medarch\client" /I "..\network\id1arch" /I "..\network\taxon1\taxon2" /I "..\network\blast3\client" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# SUBTRACT CPP /Fr
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib opengl32.lib glu32.lib glaux.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib ncbimmdb.lib ncbidesk.lib ncbitool.lib vibnet.lib ncbinacc.lib netcli.lib vibrant.lib ncbicdr.lib ncbiobj.lib ncbi.lib ddvlib.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"..\cdromlib\debug" /libpath:"..\biostruc" /libpath:"..\cdromlib\ncbicdr___Win32_Debug" /libpath:"..\corelib\debug" /libpath:"..\vibrant\debug" /libpath:"..\object\debug" /libpath:"..\biostruc\debug" /libpath:"..\desktop\debug" /libpath:"..\tools\debug" /libpath:"..\network\entrez\client\debug" /libpath:"..\network\vibnet\debug" /libpath:"..\network\nsclilib\debug" /libpath:"..\network\taxon1\taxon2\debug" /libpath:"..\network\id1arch\debug" /libpath:"..\network\medarch\client\debug" /libpath:"..\network\blast3\client\debug" /libpath:"ddvlib___Win32_Debug"
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "ddv - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "ddv___Win32_Release"
+# PROP BASE Intermediate_Dir "ddv___Win32_Release"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "ddv___Win32_Release"
+# PROP Intermediate_Dir "ddv___Win32_Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\biostruc\cdd" /I ".." /I "..\ddv" /I "..\cn3d" /I "..\access" /I "..\asnstat" /I "..\connect\lbapi" /I "..\connect" /I "..\asnlib" /I "..\vibrant" /I "..\biostruc" /I "..\object" /I "..\api" /I "..\cdromlib" /I "..\desktop" /I "..\tools" /I "..\corelib" /I "..\network\taxon1\common" /I "..\network\vibnet" /I "..\network\entrez\client" /I "..\network\nsclilib" /I "..\network\medarch\client" /I "..\network\id1arch" /I "..\network\taxon1\taxon2" /I "..\network\blast3\client" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# SUBTRACT BASE CPP /Fr
+# ADD CPP /nologo /W3 /Gm /GX /Zi /I "..\biostruc\cdd" /I ".." /I "..\ddv" /I "..\cn3d" /I "..\access" /I "..\asnstat" /I "..\connect\lbapi" /I "..\connect" /I "..\asnlib" /I "..\vibrant" /I "..\biostruc" /I "..\object" /I "..\api" /I "..\cdromlib" /I "..\desktop" /I "..\tools" /I "..\corelib" /I "..\network\taxon1\common" /I "..\network\vibnet" /I "..\network\entrez\client" /I "..\network\nsclilib" /I "..\network\medarch\client" /I "..\network\id1arch" /I "..\network\taxon1\taxon2" /I "..\network\blast3\client" /D "_WINDOWS" /D "WIN32" /D "_MBCS" /YX /FD /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib opengl32.lib glu32.lib glaux.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib ncbimmdb.lib ncbidesk.lib ncbitool.lib vibnet.lib ncbinacc.lib netcli.lib vibrant.lib ncbicdr.lib ncbiobj.lib ncbi.lib ddvlib.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"..\cdromlib\debug" /libpath:"..\biostruc" /libpath:"..\cdromlib\ncbicdr___Win32_Debug" /libpath:"..\corelib\debug" /libpath:"..\vibrant\debug" /libpath:"..\object\debug" /libpath:"..\biostruc\debug" /libpath:"..\desktop\debug" /libpath:"..\tools\debug" /libpath:"..\network\entrez\client\debug" /libpath:"..\network\vibnet\debug" /libpath:"..\network\nsclilib\debug" /libpath:"..\network\taxon1\taxon2\debug" /libpath:"..\network\taxon1\common\debug" /libpath:"..\network\id1arch\debug" /libpath:"..\network\medarch\client\debug" /libpath:"..\network\blast3\client\debug" /libpath:"ddvlib___Win32_Debug"
+# SUBTRACT BASE LINK32 /pdb:none
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib opengl32.lib glu32.lib glaux.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib ncbimmdb.lib ncbidesk.lib ncbitool.lib vibnet.lib ncbinacc.lib netcli.lib vibrant.lib ncbicdr.lib ncbiobj.lib ncbi.lib ddvlib.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"..\cdromlib\ncbicdr___Win32_Release" /libpath:"..\cdromlib\ncbinacc___Win32_Release" /libpath:"..\corelib\ncbi___Win32_Release" /libpath:"..\vibrant\vibrant___Win32_Release" /libpath:"..\object\object___Win32_Release" /libpath:"..\biostruc\mmdb___Win32_Release" /libpath:"..\desktop\desktop___Win32_Release" /libpath:"..\tools\tools___Win32_Release" /libpath:"..\network\entrez\client\netentr___Win32_Release" /libpath:"..\network\vibnet\vibnet___Win32_Release" /libpath:"..\network\nsclilib\netcli___Win32_Release" /libpath:"..\network\taxon1\taxon2\ncbitxc2___Win32_Release" /libpath:"..\network\id1arch\ncbiid1___Win32_Release" /libpath:"..\network\medarch\client\medarch___Win32_Release" /libpath:"..\network\blast3\client\netblast___Win32_Release" /libpath:"..\cn3d\ncbicn3d___Win32_Release" /libpath:"..\ddv\ddvlib___Win32_Release"
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "ddv - Win32 Debug"
+# Name "ddv - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\link\mswin\ddv.rc
+# End Source File
+# Begin Source File
+
+SOURCE=..\ddv\ddvmain.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\ddv\ddvmain.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/ddv/ddvclick.c b/ddv/ddvclick.c
new file mode 100644
index 00000000..ffeff805
--- /dev/null
+++ b/ddv/ddvclick.c
@@ -0,0 +1,2975 @@
+/* $Id: ddvclick.c,v 1.65 2000/07/25 20:30:23 hurwitz Exp $
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information (NCBI)
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government do not place any restriction on its use or reproduction.
+* We would, however, appreciate having the NCBI and the author cited in
+* any work or product based on this material
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* ===========================================================================
+*
+* File Name: ddvclick.c
+*
+* Author: Patrick Durand
+*
+* Version Creation Date: 09/20/99
+*
+* $Revision: 1.65 $
+*
+* File Description: mouse management code for DeuxD-Viewer (DDV)
+*
+* Modifications:
+* --------------------------------------------------------------------------
+* $Log: ddvclick.c,v $
+* Revision 1.65 2000/07/25 20:30:23 hurwitz
+* bug fixes: panel update when file is closed, double-click launches UDV from DDE, seqName agrees in status line and left col
+*
+* Revision 1.64 2000/07/24 22:00:08 hurwitz
+* fixed bug that 1/2 characters were displayed sometimes
+*
+* Revision 1.63 2000/07/20 22:25:57 hurwitz
+* bug fix. mouse-mode query working again
+*
+* Revision 1.62 2000/07/14 22:24:55 lewisg
+* fix scroll, click, visual c++ build bugs. add command line arg parse to ddv
+*
+* Revision 1.61 2000/07/12 22:22:41 hurwitz
+* added delete block to DDV
+*
+* Revision 1.60 2000/07/12 21:18:13 hurwitz
+* fixed display problems with select rectangle
+*
+* Revision 1.59 2000/07/12 15:38:08 hurwitz
+* made rectangle select much faster. it's almost working.
+*
+* Revision 1.58 2000/07/05 19:23:13 lewisg
+* add two panes to ddv, update msvc project files
+*
+* Revision 1.57 2000/07/05 18:42:16 hurwitz
+* added split block function to DDV
+*
+* Revision 1.56 2000/06/30 22:31:51 hurwitz
+* added merge block function for DDV
+*
+* Revision 1.55 2000/06/28 19:41:31 hurwitz
+* auto vertical scroll working for rectangle selection
+*
+* Revision 1.54 2000/06/27 20:46:38 hurwitz
+* fixed bugs with select rectangle, added select row option
+*
+* Revision 1.53 2000/06/26 19:32:17 hurwitz
+* can select a rectangle instead of a single row, auto horizontal scroll works but not vertical scroll yet
+*
+* Revision 1.52 2000/06/22 20:56:52 hurwitz
+* assorted bug fixes
+*
+* Revision 1.51 2000/06/21 21:20:56 hurwitz
+* a couple bug fixes
+*
+* Revision 1.50 2000/06/20 19:35:11 hurwitz
+* use indexed seqAlign when necessary, make multiple when redrawing
+*
+* Revision 1.49 2000/06/16 18:40:02 lewisg
+* send mouseup message when drag ends off of sequence
+*
+* Revision 1.48 2000/06/15 20:26:05 hurwitz
+* added left/right/center justify for DDE
+*
+* Revision 1.47 2000/06/13 18:23:54 hurwitz
+* made ViewMgr_MakeMultiple routine, call this on each launch of DDE rather than launch of DDV
+*
+* Revision 1.46 2000/06/12 23:02:40 hurwitz
+* enable launch of DDE from Cn3D, swith from DDV_ComputeRuler to DDE_ReMakeRuler, get rid of styles option for DDE
+*
+* Revision 1.45 2000/06/06 20:09:22 lewisg
+* fix double redraw bug
+*
+* Revision 1.44 2000/05/31 23:07:26 hurwitz
+* made NoGaps a runtime parameter, fixed bug with vertical scroll of show/hide list, save edits query is not performed if nothing to save
+*
+* Revision 1.43 2000/05/25 21:40:42 hurwitz
+* rows hidden in DDV are hidden in DDE, can save edits when rows are hidden in DDE
+*
+* Revision 1.42 2000/05/24 21:42:59 hurwitz
+* getting hide/show rows to work with DDV and DDE together
+*
+* Revision 1.41 2000/05/19 13:48:31 hurwitz
+* made a version of DDE that doesn't allow aligned gaps, changed wording for adding new rows
+*
+* Revision 1.40 2000/05/16 19:43:01 hurwitz
+* grey out create block, delete block, undo, and redo as needed
+*
+* Revision 1.39 2000/05/08 22:48:33 hurwitz
+* on launch of DDE, merge nodes that are same MsaTxtDisp alignment and gap
+*
+* Revision 1.38 2000/05/05 20:24:13 hurwitz
+* some bug fixes, also redraw proper block in DDE after a save operation that causes a merge of 2 blocks
+*
+* Revision 1.37 2000/05/04 22:43:38 hurwitz
+* don't launch DDE on top of DDV, change some wording, redraw DDE after save to AlnMgr
+*
+* Revision 1.36 2000/05/02 19:50:38 hurwitz
+* fixed some bugs with launching DDE from DDV, added new alnMgr fn for positioning DDE on proper column
+*
+* Revision 1.35 2000/04/27 17:01:44 hurwitz
+* small fixes to shift row and shift boundary
+*
+* Revision 1.34 2000/04/26 21:54:27 hurwitz
+* added save function to tell AlnMgr about edits made in DDE
+*
+* Revision 1.33 2000/04/21 23:00:51 hurwitz
+* can launch DDE from DDV
+*
+* Revision 1.32 2000/04/13 18:57:03 hurwitz
+* for DDE: many bug fixes, also get rid of columns that are all unaligned gaps
+*
+* Revision 1.31 2000/04/10 20:58:42 hurwitz
+* added GUI controls for DeleteBlock in DDE
+*
+* Revision 1.30 2000/04/07 16:21:08 hurwitz
+* made delete block faster, added delete block to edit menu
+*
+* Revision 1.29 2000/04/05 20:52:35 hurwitz
+* added GUI control for shifting left and right alignment boundaries
+*
+* Revision 1.28 2000/04/04 22:18:43 lewisg
+* add defline to ddv, fix seq import bugs, set boundbox
+*
+* Revision 1.27 2000/04/03 22:26:31 hurwitz
+* can now shift a row with click and drag
+*
+* Revision 1.26 2000/03/30 23:35:22 hurwitz
+* fixed a bug involving scrolling while moving a row
+*
+* Revision 1.25 2000/03/29 20:02:48 hurwitz
+* keep track of master during move row operations
+*
+* Revision 1.24 2000/03/28 21:03:14 hurwitz
+* added gui control to re-order rows
+*
+* Revision 1.23 2000/03/27 18:07:48 hurwitz
+* page up and page down working, give panel focus on launch
+*
+* Revision 1.22 2000/03/25 00:22:09 hurwitz
+* put DDE_StackPtr in DDV_Main, add to stack inside DDE api's, added insert char, delete char, home and end keyboard control
+*
+* Revision 1.21 2000/03/01 22:49:41 lewisg
+* import bioseq, neatlyindex, get rid of dead code
+*
+* Revision 1.20 2000/03/01 20:23:39 durand
+* update select/deselect code to allow DDV sending correct message to Cn3D
+*
+* Revision 1.19 2000/02/15 22:40:57 lewisg
+* add ability to launch udv so that it colors by row, fixes to colormgr, track rows from viewmgr, fix visual c projects
+*
+* Revision 1.18 2000/02/07 18:57:58 durand
+* fixed a selection problem
+*
+* Revision 1.17 2000/02/04 16:05:40 durand
+* add click action to select a row
+*
+* Revision 1.16 2000/02/02 14:44:29 durand
+* added function to create data structure for block editor, fixed some bugs
+*
+* Revision 1.15 2000/01/12 15:49:42 durand
+* add About dlg box and fix a bug in selection
+*
+* Revision 1.14 2000/01/10 15:09:45 durand
+* Use Entrez instead of ID1
+*
+* Revision 1.13 2000/01/05 21:11:13 durand
+* update mouse click actions and DrawSequence function for a better use from ddv and cn3d
+*
+* Revision 1.12 1999/12/07 21:40:13 durand
+* add mouse modes menu and caret facility for the editor
+*
+* Revision 1.11 1999/12/06 16:19:19 durand
+* add GoTo facility to DDV
+*
+* Revision 1.10 1999/12/03 23:17:22 lewisg
+* Patrick's new global update msg, argument passing when launching ddv, experimental editing
+*
+* Revision 1.9 1999/11/29 15:26:25 durand
+* designed a new GUI to fix problems under MacOS, Linux and SGI
+*
+* Revision 1.8 1999/11/18 00:21:42 lewisg
+* draw speedups and selection on mouseup
+*
+* Revision 1.7 1999/11/17 22:44:01 durand
+* speed up the selection manager for large SeqAlign
+*
+* Revision 1.6 1999/11/03 21:29:48 durand
+* add CTRL and SHFT keys for mouse selection. redesign the loader functions of DDV to properly register the message callbacks
+*
+* Revision 1.5 1999/10/29 14:15:39 durand
+* add simple mouse selection functions
+*
+* Revision 1.4 1999/10/22 14:19:05 durand
+* add new code for mouse selection
+*
+* Revision 1.3 1999/10/21 13:12:43 durand
+* update selection system
+*
+* Revision 1.2 1999/10/12 15:01:28 lewisg
+* resolve confict with internal/ddv
+*
+* Revision 1.1 1999/09/30 14:10:24 durand
+* add ddv to toolkit
+*
+* Revision 1.2 1999/09/22 20:41:17 durand
+* add mouse-click and drag functions
+*
+* Revision 1.1 1999/09/21 14:19:59 durand
+* add basic mouse management functions
+*
+*
+*
+* ==========================================================================
+*/
+
+#include <ncbi.h>
+#include <vibrant.h>
+
+#include <udviewer.h>
+#include <ddvpanel.h>
+#include <ddvclick.h>
+#include <ddvgraph.h>
+#include <alignmgr.h>
+#include <sqnutils.h>
+#include <seqmgr.h>
+#include <pgppop.h>
+#include <samutil.h>
+#include <tofasta.h>
+#include <viewmgr.h>
+
+/*static MonitorPtr mon=NULL;*/
+static Boolean OnAlignmentBoundary(PoinT pt, PaneL p, DdvMainPtr dmp,
+ Int4* pBlockIndex, Boolean* pLeftBoundary,
+ Int4* pCol, Int4* pHPos);
+static Boolean GetBlockAndAlignment(PoinT pt, PaneL p, DdvMainPtr dmp,
+ Int4* pBlockIndex, Boolean* pIsUnAligned,
+ Int4* pCol, Int4* pOffset, Int4* pWidth, RecT* rcP);
+static Boolean GetBlockAndAlignmentForCol(DdvMainPtr dmp, Int4 Col, Int4* pBlockIndex,
+ Boolean* pIsUnAligned, Int4* pOffset, Int4* pWidth);
+static RecT DrawOutline(PaneL p, Int4 Line_num_start, Int4 Disp_coord_start,
+ Int4 Line_num_stop, Int4 Disp_coord_stop, Boolean Draw);
+static RecT DrawOutlineGivenScroll(PaneL p, Int4 Line_num_start, Int4 Disp_coord_start,
+ Int4 Line_num_stop, Int4 Disp_coord_stop,
+ Int4 VScroll, Int4 HScroll, Boolean Draw);
+static void EraseOutline(PaneL p);
+static Boolean RectanglesAreSame(RecT rc1, RecT rc2);
+static void DDV_SelectRegion(DdvMainPtr dmp, PoinT pt, RecT rc,
+ Int4 row_start, Int4 row_stop,
+ Int4 col_start, Int4 col_stop);
+
+
+NLM_EXTERN Int4 DDV_GetHPixelPosGivenColNumberAndScroll(DdvMainPtr dmp, RecT rc,
+ Int4 Col, Int4 ScrollPos) {
+/*****************************************************************************
+* return number of pixels right to (0-based) Col.
+*****************************************************************************/
+ Int4 NumPixels;
+
+ InsetRect(&rc,4,4);
+ DDV_AdjustDrawingRect(&rc,&(dmp->GrData.udv_font),dmp);
+ NumPixels = (Col+1-ScrollPos) * dmp->GrData.udv_font.ColWidth;
+ NumPixels += dmp->GrData.udv_panel.cxName + dmp->GrData.udv_scale.cxLeftScale;
+ NumPixels += rc.left;
+ return(NumPixels);
+}
+
+
+NLM_EXTERN Int4 DDV_GetHPixelPosGivenColNumber(DdvMainPtr dmp, RecT rc, Int4 Col) {
+/*****************************************************************************
+* return number of pixels right to (0-based) Col for current ScrollPos.
+*****************************************************************************/
+ return(DDV_GetHPixelPosGivenColNumberAndScroll(dmp, rc, Col, dmp->GrData.udv_hscrl.ScrollPos));
+}
+
+
+NLM_EXTERN Int4 DDV_GetVPixelPosGivenRowNumberAndScroll(DdvMainPtr dmp, RecT rc,
+ Int4 Row, Int4 ScrollPos) {
+/*****************************************************************************
+* return number of pixels down to (0-based) Row.
+*****************************************************************************/
+ Int4 NumPixels;
+
+ InsetRect(&rc,4,4);
+ DDV_AdjustDrawingRect(&rc,&(dmp->GrData.udv_font), dmp);
+ NumPixels = (Row+1-ScrollPos) * dmp->GrData.udv_font.LineHeight;
+ /* next line is copied from DDV_GetRowGivenMousePos */
+ NumPixels += 3*dmp->GrData.udv_panel.cyScale/2;
+ NumPixels += rc.top;
+ return(NumPixels);
+}
+
+
+NLM_EXTERN Int4 DDV_GetVPixelPosGivenRowNumber(DdvMainPtr dmp, RecT rc, Int4 Row) {
+/*****************************************************************************
+* return number of pixels down to (0-based) Row for current scrollPos.
+*****************************************************************************/
+ return(DDV_GetVPixelPosGivenRowNumberAndScroll(dmp, rc, Row, dmp->GrData.udv_vscrl.ScrollPos));
+}
+
+
+NLM_EXTERN void DDV_GetVPixelPosOfEmptySpace(DdvMainPtr dmp, RecT rc, Int4* pTop, Int4* pBot) {
+/*****************************************************************************
+* return Top: number of pixels down to top of empty space.
+* return Bot: number of pixels down to bot of empty space.
+*****************************************************************************/
+ InsetRect(&rc,4,4);
+ *pTop = rc.top;
+ *pBot = rc.top + dmp->GrData.udv_panel.cyScale/2;
+ return;
+}
+
+
+NLM_EXTERN Int4 DDV_GetColNumberGivenMousePos(DdvMainPtr dmp, RecT rc, PoinT pt) {
+/*****************************************************************************
+* return the display coordinate at this mouse position.
+*****************************************************************************/
+ Int4 mouse_col;
+
+ InsetRect(&rc,4,4);
+ DDV_AdjustDrawingRect(&rc,&(dmp->GrData.udv_font),dmp);
+ rc.left+=dmp->GrData.udv_panel.cxName + dmp->GrData.udv_scale.cxLeftScale;
+ mouse_col=(pt.x-rc.left)/dmp->GrData.udv_font.ColWidth+
+ dmp->GrData.udv_hscrl.ScrollPos;
+ return(mouse_col);
+}
+
+
+/*****************************************************************************
+
+Function: DDV_GetRowGivenMousePos()
+
+Purpose: given some graphical info, this function returns line_num, the row
+ number (absolute value) and the ParaGLine_Num (i.e. sequence/row
+
+ number; this value must be use to get data from TableHead).
+
+Return value: line_num (-1 if not found ; otherwise a one-based value)
+
+*****************************************************************************/
+static Int4 DDV_GetRowGivenMousePos(DdvMainPtr dmp, RecT * rcP, PoinT * pt,
+
+ Int4Ptr ParaGLine_Num)
+{
+Int4 Line_num=(Int4)-1,mouse_row,i,n;
+ParaGPtr pgp;
+
+ /*size of the Panel; see also DDV_DrawPanelContent_H()*/
+ InsetRect(rcP,4,4);
+ DDV_AdjustDrawingRect(rcP,&(dmp->GrData.udv_font),dmp);
+ rcP->left+=dmp->GrData.udv_panel.cxName+dmp->GrData.udv_scale.cxLeftScale;
+ rcP->top+=3*dmp->GrData.udv_panel.cyScale/2;
+
+ /*mouse position*/
+ mouse_row=(pt->y-rcP->top)/dmp->GrData.udv_font.LineHeight+
+ dmp->GrData.udv_vscrl.ScrollPos;
+
+ /*use the first ParaG of each sequence and mouse_row to find
+ row (==sequence) number*/
+ for(i=0;i<dmp->MSA_d.pgp_l.nBsp;i++){
+ pgp=(ParaGPtr)(dmp->MSA_d.pgp_l.TableHead[i]->data.ptrvalue);
+ if (pgp->ScaleStyle==SCALE_POS_NONE) n=0;
+ else n=1;
+ /*within each ParaG, the seq. in on line 0 or 1 (if ruler)*/
+ if (mouse_row>=pgp->StartLine && mouse_row<=(pgp->StartLine+n)){
+ Line_num=mouse_row+1;
+
+ *ParaGLine_Num=i+1;
+ break;
+ }
+ }
+
+ return(Line_num);
+}
+
+/*****************************************************************************
+
+Function: DDV_GetClosetSeqLocGivenBspPos()
+
+Purpose: given a position in the Bioseq, this function return the closest
+ selected region on that bioseq.
+
+Parameters: sip, eID, iID; bsioseq identifiers
+ bsp_pos; current position on that bioseq
+ old_pos; returns old_pos of a selection (used only if bModify is TRUE)
+ bModify; if TRUE, create a modified slp
+
+Note : sip can be null ONLY if bModify if FALSE.
+
+Return value: see Purpose.
+
+*****************************************************************************/
+static SeqLocPtr DDV_GetClosetSeqLocGivenBspPos(SeqIdPtr sip, Uint2 eID,
+ Uint2 iID, Int4 bsp_pos, Int4Ptr old_pos, Boolean bModify)
+{
+SelStructPtr ssp;
+SeqLocPtr slp=NULL;
+ValNodePtr vnp_bsp,vnp;
+Int4 diff,old_diff,diff_l,diff_r,bsp_start,bsp_stop;
+Uint1 strand;
+
+ ssp=ObjMgrGetSelected();
+ if (ssp==NULL) return(NULL);
+
+ vnp_bsp=DDV_GetSelectedRegions(ssp,eID,iID);
+ if (vnp_bsp==NULL) return(NULL);
+ vnp=vnp_bsp;
+ *old_pos=(Int4)-1;
+ old_diff=(Int4)INT4_MAX;
+
+ while(vnp){
+ bsp_start=SeqLocStart((SeqLocPtr)vnp->data.ptrvalue);
+ bsp_stop=SeqLocStop((SeqLocPtr)vnp->data.ptrvalue);
+ strand=SeqLocStrand((SeqLocPtr)vnp->data.ptrvalue);
+ if (bsp_pos<bsp_start){/*left of a selected region ?*/
+ diff=bsp_start-bsp_pos;
+ if (diff<old_diff){
+ if (slp) slp=SeqLocFree(slp);
+ if (bModify){
+ slp = SeqLocIntNew (bsp_pos, bsp_stop, strand/*Seq_strand_minus*/, sip);
+ *old_pos=bsp_stop;
+ }
+ else{
+ slp = SeqLocIntNew (bsp_start, bsp_stop, strand, sip);
+ *old_pos=(Int4)-1;
+ }
+ old_diff=diff;
+ }
+ }
+ else if (bsp_pos>bsp_stop){/*right of a selected region ?*/
+ diff=bsp_pos-bsp_stop;
+ if (diff<old_diff){
+ if (slp) slp=SeqLocFree(slp);
+ if (bModify){
+ slp = SeqLocIntNew (bsp_start, bsp_pos, strand/*Seq_strand_plus*/, sip);
+ *old_pos=bsp_start;
+ }
+ else{
+ slp = SeqLocIntNew (bsp_start, bsp_stop, strand, sip);
+ *old_pos=(Int4)-1;
+ }
+ old_diff=diff;
+ }
+ }
+ else{/*inside a selected region ?*/
+ if(bModify){
+ diff_l=bsp_pos-bsp_start;
+ diff_r=bsp_stop-bsp_pos;
+ if (diff_l<diff_r){
+ bsp_start=bsp_pos;
+ *old_pos=bsp_stop;
+ /*strand=Seq_strand_plus;*/
+ }
+ else{
+ bsp_stop=bsp_pos;
+ *old_pos=bsp_start;
+ /*strand=Seq_strand_minus;*/
+ }
+ slp = SeqLocIntNew (bsp_start, bsp_stop, strand, sip);
+ break;
+ }
+ }
+ vnp=vnp->next;
+ }
+ ValNodeFree(vnp_bsp);
+ return(slp);
+}
+
+/*****************************************************************************
+
+Function: DDV_IsFullBspAlreadySel()
+
+Purpose: check if a row is already selected.
+
+Parameters: bsp_eID,bsp_iID; bsp identifiers
+ bsp_start,bsp_stop; full sequence
+
+Return value: TRUE if the sequence is already fully selected
+
+*****************************************************************************/
+static Boolean DDV_IsFullBspAlreadySel(Uint2 bsp_eID,Uint2 bsp_iID,Int4 bsp_start,
+ Int4 bsp_stop)
+{
+SelStructPtr ssp;
+ValNodePtr vnp_bsp,vnp;
+Int4 sel_bsp_start,sel_bsp_stop;
+
+ ssp=ObjMgrGetSelected();
+ if (ssp==NULL) return(FALSE);
+
+ vnp_bsp=DDV_GetSelectedRegions(ssp,bsp_eID,bsp_iID);
+ if (vnp_bsp==NULL) return(FALSE);
+ vnp=vnp_bsp;
+
+ while(vnp){
+ sel_bsp_start=SeqLocStart((SeqLocPtr)vnp->data.ptrvalue);
+ sel_bsp_stop=SeqLocStop((SeqLocPtr)vnp->data.ptrvalue);
+ if (bsp_start==sel_bsp_start && bsp_stop==sel_bsp_stop)
+ return(TRUE);
+ vnp=vnp->next;
+ }
+ return(FALSE);
+}
+
+
+static Uint1 DDV_GetRegionInParaG(ParaGPtr pgp, Int4 Line_num) {
+/*****************************************************************************
+* get region within ParaG
+*****************************************************************************/
+ Int4 mouse_row, diff;
+
+ mouse_row = Line_num-1;
+
+ if (pgp->ScaleStyle==SCALE_POS_NONE)
+ diff=0;
+ else
+ diff=1;
+
+ if (mouse_row==(pgp->StartLine+diff)){
+ return(PGP_REGION_SEQ);
+ }
+ else if (mouse_row > (pgp->StartLine+ diff) &&
+ mouse_row <= (pgp->StartLine+ pgp->nLines-1)){
+ return(PGP_REGION_FEAT);
+ }
+ return(PGP_REGION_NOWHERE);
+}
+
+
+static void DDV_GetRowAndColGivenPtAndScroll(DdvMainPtr dmp, RecT rc, PoinT pt,
+ Int4 HScroll, Int4 VScroll,
+ Int4Ptr Disp_coord, Int4Ptr Line_num) {
+/*****************************************************************************
+* get row and column where the mouse is clicked. Provide scroll positions.
+*****************************************************************************/
+ Int4 mouse_row, mouse_col;
+
+ InsetRect(&rc,4,4);
+ DDV_AdjustDrawingRect(&rc, &(dmp->GrData.udv_font), dmp);
+ rc.left += dmp->GrData.udv_panel.cxName + dmp->GrData.udv_scale.cxLeftScale;
+ rc.top += 3*dmp->GrData.udv_panel.cyScale/2;
+
+ mouse_row = (pt.y - rc.top)/dmp->GrData.udv_font.LineHeight + VScroll;
+ mouse_col = (pt.x - rc.left)/dmp->GrData.udv_font.ColWidth + HScroll;
+
+ *Line_num=mouse_row+1;
+ *Disp_coord=mouse_col;
+}
+
+
+static void DDV_GetRowAndColGivenPt(DdvMainPtr dmp, RecT rc, PoinT pt,
+ Int4Ptr Disp_coord, Int4Ptr Line_num) {
+/***********************************************************************************
+* get row and column where the mouse is clicked. Assume current scroll positions.
+***********************************************************************************/
+ DDV_GetRowAndColGivenPtAndScroll(dmp, rc, pt,
+ dmp->GrData.udv_hscrl.ScrollPos, dmp->GrData.udv_vscrl.ScrollPos,
+ Disp_coord, Line_num);
+}
+
+
+static Int4 DDV_GetParaGLineNumGivenLineNum(DdvMainPtr dmp, Int4 Line_num) {
+/*****************************************************************************
+* get the ParaGLine_Num for Line_num.
+*****************************************************************************/
+ Int4 i, row;
+ ParaGPtr pgp;
+
+ row = Line_num-1;
+ for (i=0; i<dmp->MSA_d.pgp_l.nBsp; i++) {
+ pgp = (ParaGPtr)(dmp->MSA_d.pgp_l.TableHead[i]->data.ptrvalue);
+ if (row>=pgp->StartLine && row<=(pgp->StartLine + pgp->nLines-1)) {
+ return(i+1);
+ }
+ }
+ return(-1);
+}
+
+
+static Int4 DDV_GetSeqAlignCoordGivenCol(DdvMainPtr dmp, Int4 Disp_coord) {
+/*****************************************************************************
+* get the SeqAlignCoord for Disp_coord.
+*****************************************************************************/
+ ValNodePtr vnp;
+ DDVRulerDescrPtr drdp;
+ Int4 diff;
+
+ vnp=dmp->MSA_d.pgp_l.RulerDescr;
+ while(vnp){
+ drdp=(DDVRulerDescrPtr)vnp->data.ptrvalue;
+ if (!drdp->bUnAligned){
+ diff = Disp_coord - drdp->disp_start;
+ if (Disp_coord>=drdp->disp_start && Disp_coord<=drdp->disp_stop){
+ return(drdp->align_start + diff);
+ }
+ }
+ vnp=vnp->next;
+ }
+ return(-1);
+}
+
+
+static ParaGPtr DDV_GetPGPGivenRowAndCol(DdvMainPtr dmp, Int4 Line_num, Int4 Disp_coord) {
+/*****************************************************************************
+* get the ParaG ptr that contains (Line_num, Disp_coord)
+*****************************************************************************/
+ ParaGPtr pgp=NULL;
+ ValNodePtr vnp;
+
+ vnp=dmp->MSA_d.pgp_l.TableHead[Line_num-1];
+ while(vnp){
+ pgp=(ParaGPtr)vnp->data.ptrvalue;
+ if (Disp_coord>=pgp->StartLetter && Disp_coord<=pgp->StopLetter){
+ return(pgp);
+ }
+ vnp=vnp->next;
+ }
+ return(pgp);
+}
+
+
+static Boolean DDV_GetCoordsGivenAClickAndScrollPos(DdvMainPtr dmp, RecT * rcP, PoinT * pt,
+ Int4 HScroll, Int4 VScroll,
+ Int4Ptr bsp_coord, Int4Ptr SeqAlign_coord, Int4Ptr Disp_coord,
+ Int4Ptr Line_num, Int4Ptr ParaGLine_Num, Uint1Ptr uWhere,
+ ParaGPtr PNTR cur_pgp)
+/*****************************************************************************
+* variation on DDV_GetCoordsGivenAClick.
+* pass: VScroll and HScroll -- the positions of the vertical and
+* horizontal scroll bars.
+*****************************************************************************/
+{
+ValNodePtr vnp;
+ParaGPtr pgp,TheParaG;
+/*MsaTxtDispPtr mtdp;*/
+DDVRulerDescrPtr drdp;
+Int4 mouse_row,mouse_col,i,diff;
+Boolean bFound;
+
+ *ParaGLine_Num = -1;
+ /*size of the Panel; see also DDV_DrawPanelContent_H()*/
+ InsetRect(rcP,4,4);
+ DDV_AdjustDrawingRect(rcP,&(dmp->GrData.udv_font),dmp);
+ rcP->left+=dmp->GrData.udv_panel.cxName+dmp->GrData.udv_scale.cxLeftScale;
+ rcP->top+=3*dmp->GrData.udv_panel.cyScale/2;
+
+ /*mouse position*/
+ mouse_row=(pt->y-rcP->top)/dmp->GrData.udv_font.LineHeight+VScroll;
+ mouse_col=(pt->x-rcP->left)/dmp->GrData.udv_font.ColWidth+HScroll;
+
+ bFound=FALSE;
+
+ for(i=0;i<dmp->MSA_d.pgp_l.nBsp;i++){
+ /*use the first ParaG of each sequence and mouse_row to find
+ row (==sequence) number; then go though the ParaG list of that
+ sequence to find The ParaG, using mouse_col*/
+ pgp=(ParaGPtr)(dmp->MSA_d.pgp_l.TableHead[i]->data.ptrvalue);
+ if (mouse_row>=pgp->StartLine && mouse_row<=(pgp->StartLine+pgp->nLines-1)){
+ vnp=dmp->MSA_d.pgp_l.TableHead[i];
+ *ParaGLine_Num = i + 1;
+ while(vnp){
+ pgp=(ParaGPtr)vnp->data.ptrvalue;
+ if (mouse_col>=pgp->StartLetter && mouse_col<=pgp->StopLetter){
+ bFound=TRUE;
+ TheParaG=pgp;
+ break;
+ }
+ vnp=vnp->next;
+ }
+ if (bFound) break;
+ }
+ }
+ /*ok : the mouse is inside a ParaG*/
+ if (bFound){
+ *cur_pgp=TheParaG;
+ /*where is the mouse in the ParaG ?*/
+ *uWhere=PGP_REGION_NOWHERE;
+ if (TheParaG->ScaleStyle==SCALE_POS_NONE)
+ diff=0;
+ else
+ diff=1;
+ if (mouse_row==(TheParaG->StartLine+diff)){
+ *uWhere=PGP_REGION_SEQ;
+ }
+ else if (mouse_row>(TheParaG->StartLine+diff) &&
+ mouse_row<=(pgp->StartLine+pgp->nLines-1)){
+ *uWhere=PGP_REGION_FEAT;
+ }
+
+ /*a. get Disp Coord*/
+ *Line_num=mouse_row+1;/*base 1 value*/
+ *Disp_coord=mouse_col;
+
+ /*on the Sequence ? Then, get the coords. (BSP, DISP, SEQALIGN)*/
+ /*PGP_REGION_FEAT is not yet implemented... ;-) */
+ if (*uWhere==PGP_REGION_SEQ){
+ /*b. get BSP coord*/
+ *bsp_coord=DDV_GetBspCoordGivenDispCoord(TheParaG,mouse_col);
+
+ /*c. get SeqAlign Coord*/
+ vnp=dmp->MSA_d.pgp_l.RulerDescr;
+ while(vnp){
+ drdp=(DDVRulerDescrPtr)vnp->data.ptrvalue;
+ if (!drdp->bUnAligned){
+ diff=mouse_col-drdp->disp_start;
+ if (mouse_col>=drdp->disp_start && mouse_col<=drdp->disp_stop){
+ *SeqAlign_coord=drdp->align_start+diff;
+ break;
+ }
+ }
+ else{
+ *SeqAlign_coord=(Int4)-1;
+ }
+ vnp=vnp->next;
+ }
+ }
+ }
+
+ return(bFound);
+}
+
+
+/*****************************************************************************
+
+Function: DDV_GetCoordsGivenAClick()
+
+Purpose: given some graphical info, this function returns bsp_coord, SeqAlign_coord,
+ Disp_coord. Future implementation : will also return eID, iID, idx of
+ a feature (if the nice user clicks on a feature).
+
+Parameters: dmp; panel main data block
+ rcP; panel size
+ pt; mouse position
+ bsp_coord, SeqAlign_coord, Disp_coord,Line_num; return values
+ uWhere; where the mouse is in a ParaG
+
+Note : all but Line_num are zero-based values. Line_num is a one-based value.
+
+Return value: TRUE if the user clicks within a ParaG (see also
+ bsp_coord, SeqAlign_coord, Disp_coord, uWhere). NOTE : if the function
+ returns FALSE then bsp_coord, SeqAlign_coord, Line_num, Disp_coord and
+ uWhere are undefined !
+
+*****************************************************************************/
+static Boolean DDV_GetCoordsGivenAClick(DdvMainPtr dmp, RecT * rcP, PoinT * pt,
+ Int4Ptr bsp_coord, Int4Ptr SeqAlign_coord, Int4Ptr Disp_coord,
+ Int4Ptr Line_num, Int4Ptr ParaGLine_Num, Uint1Ptr uWhere,
+ ParaGPtr PNTR cur_pgp)
+{
+ /* return coordinates for the current scroll position */
+ return(DDV_GetCoordsGivenAClickAndScrollPos(dmp, rcP, pt,
+ dmp->GrData.udv_hscrl.ScrollPos, dmp->GrData.udv_vscrl.ScrollPos,
+ bsp_coord, SeqAlign_coord, Disp_coord, Line_num, ParaGLine_Num, uWhere, cur_pgp));
+}
+
+/*****************************************************************************
+
+Function: DDV_AutoHScroll()
+
+Purpose: used from drag/hold mouse to auto-scroll the panel horizontally when
+ the mouse reaches the left/right borders of the panel
+
+
+Return value: none
+
+*****************************************************************************/
+static void DDV_AutoHScroll(DdvMainPtr dmp,Int4 Disp_coord)
+{
+Int4 from_col,to_col,from_row,to_row,old_pos;
+BaR hsb;
+
+ DDV_GetCurrentDispRange(dmp->hWndDDV,&(dmp->GrData),dmp->MSA_d.pgp_l.LengthAli,
+ &from_col,&to_col,&from_row,&to_row);
+
+ hsb = GetSlateHScrollBar ((SlatE) dmp->hWndDDV);
+ old_pos=GetBarValue(hsb);
+ if (Disp_coord>=to_col){/*scroll to the right*/
+ SetValue(hsb,old_pos+1);
+ }
+ else if (Disp_coord<=from_col){
+ SetValue(hsb,old_pos-1);
+ }
+
+}
+
+/*****************************************************************************
+
+Function: DDV_AutoVScroll()
+
+Purpose: used from drag/hold mouse to auto-scroll the panel vertically when
+ the mouse reaches the top/bottom borders of the panel
+
+
+Return value: none
+
+*****************************************************************************/
+static void DDV_AutoVScroll(DdvMainPtr dmp,Int4 Line_num)
+{
+Int4 from_col,to_col,from_row,to_row,old_pos;
+BaR vsb;
+
+ DDV_GetCurrentDispRange(dmp->hWndDDV,&(dmp->GrData),dmp->MSA_d.pgp_l.LengthAli,
+ &from_col,&to_col,&from_row,&to_row);
+
+ vsb = GetSlateVScrollBar ((SlatE) dmp->hWndDDV);
+ old_pos=GetBarValue(vsb);
+ if (Line_num>=(to_row-1)){/*scroll down*/
+ SetValue(vsb,old_pos+1);
+ }
+ else if (Line_num<=(from_row+1)){/*scroll up*/
+ SetValue(vsb,old_pos-1);
+ }
+}
+
+
+/*****************************************************************************
+
+Function: DDV_DispSelRangeInStatus()
+
+Purpose: display position while selection is in progress. (mouse mode : selection)
+
+Return value: none
+
+*****************************************************************************/
+static void DDV_DispSelRangeInStatus(PrompT InfoPanel,Int4 bsp_start, Int4 bsp_stop,
+ Int4 line_num,CharPtr szSeqName)
+{
+Char szText[250];
+
+ sprintf(szText,"Selection : %s, [%i]:[%i..%i]",szSeqName,line_num,
+ bsp_start,bsp_stop);
+ SetTitle(InfoPanel,szText);
+}
+
+
+/*****************************************************************************
+
+Function: DDV_DispPositionInStatus()
+
+Purpose: display position (mouse mode : query).
+
+Return value: none
+
+*****************************************************************************/
+NLM_EXTERN void DDV_DispPositionInStatus(PrompT InfoPanel,Int4 bsp_pos,
+ Int4 line_num,CharPtr szSeqName)
+{
+Char szText[250];
+
+ sprintf(szText,"Position : %s, [%i]:[%i]",szSeqName,line_num,bsp_pos);
+ SetTitle(InfoPanel,szText);
+}
+
+
+static void DDV_DispStatus(DdvMainPtr dmp, Int4 Line_num_stop,
+ Int4 Disp_coord_start, Int4 Disp_coord_stop) {
+/*****************************************************************************
+
+Function: DDV_DispStatus()
+
+Purpose: display position while selection is in progress. (mouse mode : selection)
+
+Return value: none
+
+*****************************************************************************/
+ DdvMainWinPtr mWin_d;
+ Int4 ParaGLine_num, bsp_start, bsp_stop;
+ ParaGPtr pgp;
+ char szAccess[21];
+
+ mWin_d = (DdvMainWinPtr) GetObjectExtra(dmp->hParent);
+ if (mWin_d != NULL) {
+ ParaGLine_num = DDV_GetParaGLineNumGivenLineNum(dmp, Line_num_stop);
+ if (ParaGLine_num != -1) {
+ DDV_GetSeqNameGivenRow(dmp->MSA_d.pgp_l.TableHead, ParaGLine_num, szAccess);
+ pgp = DDV_GetPGPGivenRowAndCol(dmp, Line_num_stop, Disp_coord_stop);
+ bsp_stop = DDV_GetBspCoordGivenDispCoord(pgp, Disp_coord_stop);
+ if (dmp->MouseMode == DDV_MOUSEMODE_SELECT ||
+ dmp->MouseMode == DDV_MOUSEMODE_SELECT_ONE_ROW) {
+ pgp = DDV_GetPGPGivenRowAndCol(dmp, Line_num_stop, Disp_coord_start);
+ bsp_start = DDV_GetBspCoordGivenDispCoord(pgp, Disp_coord_start);
+ DDV_DispSelRangeInStatus(mWin_d->InfoPanel, bsp_start+1, bsp_stop+1,
+ ParaGLine_num, szAccess);
+ }
+ else {
+ DDV_DispPositionInStatus(mWin_d->InfoPanel, bsp_stop+1,
+ ParaGLine_num, szAccess);
+ }
+ }
+ }
+}
+
+
+/*****************************************************************************
+
+Function: DDV_GetSeqNameGivenRow()
+
+Purpose: get a sequence number, given a list of ParaG and a row number
+
+Note: row_num is a one-based value; this value must be in the range 0 to nBsp.
+
+(I don't check that here, so be carefull when calling this function)
+
+
+Return value: -
+
+*****************************************************************************/
+NLM_EXTERN void DDV_GetSeqNameGivenRow(ValNodePtr * ParaG_List, Int4 row_num,
+ CharPtr szSeqName)
+{
+ SeqIdPtr sip;
+ ParaGPtr pgp;
+ BioseqPtr bsp;
+
+ pgp=(ParaGPtr)(ParaG_List[row_num-1]->data.ptrvalue);
+
+ /*get a name*/
+ bsp = BioseqLockById(pgp->sip);
+ if(bsp) {
+ /* get name but not gi */
+ sip = SeqIdFindBestAccession(bsp->id);
+ BioseqUnlock(bsp);
+ }
+
+ if (!sip)
+ sip = SeqIdFindBest(pgp->sip, 0);
+ SeqIdWrite(sip, szSeqName,PRINTID_TEXTID_ACCESSION, 20);
+}
+
+/*****************************************************************************
+
+Function: DDV_SendBSPSelectMsg_OLD()
+
+Purpose: send a message to select a range of letters on a bioseq.
+
+Return value: none
+
+*****************************************************************************/
+static void DDV_SendBSPSelectMsg_OLD(DdvMainPtr dmp,Int4 bsp_coord,Int4 SeqAlign_coord,
+ Int4 first_Disp_coord, Int4 Disp_coord,Int4 Line_num,Int4 ParaGLine_Num,
+ ParaGPtr cur_pgp,PoinT * pt, Boolean Display)
+{
+Int4 first_bsp_coord, bsp_pos;
+Uint1 direction;/*use to tell ObjMgr the direction of the mouse (left,right)*/
+SeqLocPtr slp;/*to send an AlsoSelectMsg*/
+Uint2 bsp_eID,bsp_iID;
+Boolean bDeselectAll=TRUE;
+DdvMainWinPtr dmwp;
+
+ /*analyse the bsp coords*/
+ if (bsp_coord==(Int4)-1){/*this is a gap*/
+ dmp->ms.oldPos=dmp->ms.newPos=*pt;
+ dmp->ms.old_row=Line_num;
+ dmp->ms.old_col=Disp_coord;
+ dmp->ms.old_pgp=cur_pgp;
+ return;
+ }
+
+ /*get the very first click (from DDV_ClickProc)*/
+ first_bsp_coord=
+ DDV_GetBspCoordGivenDispCoord(dmp->ms.first_pgps[Line_num-1],
+ dmp->ms.first_cols[Line_num-1]);
+ if (first_bsp_coord==(Int4)-1){/*the first time the user
+ clicked, it was on a gap*/
+ /*if we are in this scope, that means we have a bsp coord*/
+ first_bsp_coord=bsp_coord;
+ dmp->ms.first_cols[Line_num-1]=Disp_coord;
+ dmp->ms.first_pgps[Line_num-1]=cur_pgp;
+ }
+
+ bsp_pos=bsp_coord;
+
+ if (ctrlKey || shftKey)
+ bDeselectAll=FALSE;
+
+ /*the mouse is moving to the left or to the right ?*/
+ /*don't forget to check the strand... ;-) */
+ if (AlnMgrGetNthStrand(dmp->MSA_d.pgp_l.sap, ParaGLine_Num)==Seq_strand_plus){
+ if (dmp->ms.oldPos.x<pt->x)
+ direction=Seq_strand_plus;
+ else
+ direction=Seq_strand_minus;
+ }
+ else{
+ if (dmp->ms.oldPos.x>pt->x)
+ direction=Seq_strand_minus;
+ else
+ direction=Seq_strand_plus;
+ }
+ /*'from' (first_bsp_coord) always less than 'to' (bsp_coord)*/
+ if (first_bsp_coord>bsp_coord)
+ swap(&first_bsp_coord,&bsp_coord);
+ /*save the new position*/
+ dmp->ms.oldPos=dmp->ms.newPos=*pt;
+ dmp->ms.old_row=Line_num;
+ dmp->ms.old_col=Disp_coord;
+ dmp->ms.old_pgp=cur_pgp;
+
+ /*now, we can send the Select message*/
+ /* first_pgp, old_pgp & cur_pgp have the same sip...
+ they are on a same row; I can use one of them*/
+ slp = SeqLocIntNew (first_bsp_coord, bsp_coord, direction, cur_pgp->sip);
+ UDV_DecodeIdxFeat (dmp->MSA_d.pgp_l.entitiesTbl[ParaGLine_Num-1],&bsp_eID,&bsp_iID);
+ if (bsp_eID!=0 && bsp_iID!=0 && slp){
+ /*update InfoPanel*/
+ dmwp=(DdvMainWinPtr)GetObjectExtra(dmp->hParent);
+ if (dmwp){
+ Char szAccess[21];
+
+ DDV_GetSeqNameGivenRow(dmp->MSA_d.pgp_l.TableHead, ParaGLine_Num, szAccess);
+
+ switch(dmp->MouseMode){
+ case DDV_MOUSEMODE_SELECT:
+ case DDV_MOUSEMODE_SELECT_ONE_ROW:
+ if (Display) {
+ DDV_DispSelRangeInStatus(dmwp->InfoPanel,first_bsp_coord+1,
+ bsp_coord+1,ParaGLine_Num,szAccess);/*+1 : switch to one-based value*/
+ }
+ break;
+ case DDV_MOUSEMODE_QUERY:
+ case DDV_MOUSEMODE_EDIT:
+ DDV_DispPositionInStatus(dmwp->InfoPanel,
+ bsp_pos+1,ParaGLine_Num,szAccess);/*+1 : switch to one-based value*/
+ break;
+ }
+ }
+ /*send the message*/
+ if (dmp->MouseMode==DDV_MOUSEMODE_SELECT ||
+ dmp->MouseMode==DDV_MOUSEMODE_SELECT_ONE_ROW){
+ ObjMgrAlsoSelect (bsp_eID, bsp_iID, OBJ_BIOSEQ,OM_REGION_SEQLOC, slp);
+ }
+ }
+ else {
+ if (slp)
+ SeqLocFree(slp);
+ }
+}
+
+
+/*****************************************************************************
+
+Function: DDV_SendBSPSelectMsg()
+
+Purpose: send a message to select a range of letters on a bioseq.
+ I've rewritten this. Hope I did it right. Dave H.
+
+Return value: none
+
+*****************************************************************************/
+static void DDV_SendBSPSelectMsg(DdvMainPtr dmp,
+ Int4 col_start, Int4 col_stop, Int4 row, Boolean Display)
+{
+ Int4 bsp_coord_start, bsp_coord_stop, ParaGLine_Num, col;
+ Uint1 direction;/*used to tell ObjMgr the direction of the mouse (left,right)*/
+ SeqLocPtr slp;/*to send an AlsoSelectMsg*/
+ Uint2 bsp_eID, bsp_iID;
+ Boolean bDeselectAll=TRUE;
+ ParaGPtr pgp;
+ DdvMainWinPtr dmwp;
+
+ if (col_start > col_stop) swap(&col_start, &col_stop);
+
+ /* calculate bsp_coord_start */
+ for (col=col_start; col<=col_stop; col++) {
+ pgp = DDV_GetPGPGivenRowAndCol(dmp, row, col);
+ bsp_coord_start = DDV_GetBspCoordGivenDispCoord(pgp, col);
+ if (bsp_coord_start != -1) break;
+ }
+
+ /* calculate bsp_coord_stop */
+ for (col=col_stop; col>=col_start; col--) {
+ pgp = DDV_GetPGPGivenRowAndCol(dmp, row, col);
+ bsp_coord_stop = DDV_GetBspCoordGivenDispCoord(pgp, col);
+ if (bsp_coord_stop != -1) break;
+ }
+
+ ParaGLine_Num = DDV_GetParaGLineNumGivenLineNum(dmp, row);
+
+ if (ctrlKey || shftKey)
+ bDeselectAll=FALSE;
+
+ /*the mouse is moving to the left or to the right ?*/
+ /*don't forget to check the strand... ;-) */
+ if (AlnMgrGetNthStrand(dmp->MSA_d.pgp_l.sap, ParaGLine_Num)==Seq_strand_plus) {
+ direction=Seq_strand_plus;
+ }
+ else {
+ direction=Seq_strand_minus;
+ }
+
+ /*now, we can send the Select message*/
+ /* first_pgp, old_pgp & cur_pgp have the same sip...
+ they are on a same row; I can use one of them*/
+ slp = SeqLocIntNew (bsp_coord_start, bsp_coord_stop, direction, pgp->sip);
+ UDV_DecodeIdxFeat (dmp->MSA_d.pgp_l.entitiesTbl[ParaGLine_Num-1],&bsp_eID,&bsp_iID);
+ if (bsp_eID!=0 && bsp_iID!=0 && slp){
+ /*update InfoPanel*/
+ dmwp=(DdvMainWinPtr)GetObjectExtra(dmp->hParent);
+ if (dmwp){
+ Char szAccess[21];
+
+ DDV_GetSeqNameGivenRow(dmp->MSA_d.pgp_l.TableHead, ParaGLine_Num, szAccess);
+
+ switch(dmp->MouseMode){
+ case DDV_MOUSEMODE_SELECT:
+ case DDV_MOUSEMODE_SELECT_ONE_ROW:
+ if (Display) {
+ DDV_DispSelRangeInStatus(dmwp->InfoPanel, bsp_coord_start+1,
+ bsp_coord_stop+1, ParaGLine_Num, szAccess); /*+1 : switch to one-based value*/
+ }
+ break;
+ case DDV_MOUSEMODE_QUERY:
+ case DDV_MOUSEMODE_EDIT:
+ DDV_DispPositionInStatus(dmwp->InfoPanel,
+ bsp_coord_stop+1, ParaGLine_Num, szAccess);/*+1 : switch to one-based value*/
+ break;
+ }
+ }
+ /*send the message*/
+ if (dmp->MouseMode==DDV_MOUSEMODE_SELECT ||
+ dmp->MouseMode==DDV_MOUSEMODE_SELECT_ONE_ROW){
+ ObjMgrAlsoSelect (bsp_eID, bsp_iID, OBJ_BIOSEQ, OM_REGION_SEQLOC, slp);
+ }
+ }
+ else {
+ if (slp)
+ SeqLocFree(slp);
+ }
+}
+
+
+/*****************************************************************************
+
+Functions: DDV_ClickProcUpper() and DDV_ClickProcLower()
+
+Purpose: mouse click funcions attached to the upper
+ and lower panels in 2-panel mode. They switch focus between the upper
+ and lower panels, then call the main DDV_ClickProc.
+
+Parameters: p; panel handle (currently unused)
+ pt; new mouse position
+
+Return value: none
+
+*****************************************************************************/
+
+NLM_EXTERN void DDV_ClickProcUpper(PaneL p, PoinT pt)
+{
+DdvMainWinPtr mWin_d;
+WindoW hWinMain;
+Boolean tempClick;
+
+ hWinMain=(WindoW)ParentWindow(p);
+ if (hWinMain==NULL) return;
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (hWinMain);
+ if (mWin_d==NULL) return;
+ mWin_d->hWndDDV = mWin_d->hUpperPanel;
+ DDV_SetMenuFocus(hWinMain);
+ mWin_d->InfoPanel = mWin_d->UpperInfoPanel;
+ tempClick = Nlm_dblClick; /* keep vibrant from resetting double click */
+ SetTitle(mWin_d->InfoPanel,"Ready !");
+ SetTitle(mWin_d->LowerInfoPanel,"");
+ Nlm_dblClick = tempClick;
+
+ DDV_ClickProc(p, pt);
+}
+
+NLM_EXTERN void DDV_ClickProcLower(PaneL p, PoinT pt)
+{
+DdvMainWinPtr mWin_d;
+WindoW hWinMain;
+Boolean tempClick;
+
+ hWinMain=(WindoW)ParentWindow(p);
+ if (hWinMain==NULL) return;
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (hWinMain);
+ if (mWin_d==NULL) return;
+ mWin_d->hWndDDV = mWin_d->hLowerPanel;
+ DDV_SetMenuFocus(hWinMain);
+ mWin_d->InfoPanel = mWin_d->LowerInfoPanel;
+ tempClick = Nlm_dblClick; /* keep vibrant from resetting double click */
+ SetTitle(mWin_d->InfoPanel,"Ready !");
+ SetTitle(mWin_d->UpperInfoPanel,"");
+ Nlm_dblClick = tempClick;
+
+ DDV_ClickProc(p, pt);
+}
+
+/*****************************************************************************
+
+Function: DDV_ClickProc()
+
+Purpose: manage Mouse-Click; this function is designed for the autonomous viewer
+ to manage the InfoPanel and the Features List Dialog Box
+ DON'T USE FOR EXTERNAL SOFTWARE...
+
+Parameters: p; panel handle (currently unused)
+ pt; new mouse position
+
+Return value: none
+
+*****************************************************************************/
+NLM_EXTERN void DDV_ClickProc(PaneL p, PoinT pt)
+{
+DdvMainPtr dmp;
+DdvMainWinPtr mWin_d;
+RecT rcP, rcP2;
+Int4 bsp_coord, SeqAlign_coord, Disp_coord, Line_num,bsp_start,bsp_stop,
+ old_pos, ParaGLine_Num, VPos, HPos;
+Int4 from_row, to_row, from_col, to_col;
+Uint1 uWhere;
+ParaGPtr cur_pgp=NULL;
+SeqLocPtr slp;
+Uint2 bsp_eID,bsp_iID;
+Boolean bDeselectAll=TRUE,bIsAlreadyFullSel;
+Int4 BlockIndex, Col, NumBlocks;
+Boolean LeftBoundary, IsUnAligned;
+DdvMainWinPtr dmwp;
+BioseqPtr bsp;
+Char buf[81], szAccess[21];
+ParaGPtr pgp;
+Int4 i, NumRows, ColCnt, Offset, Width;
+
+MsaParaGPopListPtr mpplp;
+SeqAlignPtr sap;
+DDE_StackPtr dsp;
+Boolean IsEditable, *pNoGaps, NoGaps, FoundIt;
+
+ /*get the panel data*/
+ dmp = (DdvMainPtr) GetObjectExtra(p);
+ if (dmp==NULL) return;
+ mWin_d = (DdvMainWinPtr) GetObjectExtra(dmp->hParent);
+ if (mWin_d == NULL) return;
+
+ ObjectRect(p,&rcP);
+
+ if (ctrlKey || shftKey)
+ bDeselectAll=FALSE;
+
+ /* handle the case when a block is being deleted in DDV */
+ if (dmp->MouseMode == DDV_MOUSEMODE_DELETEBLOCK) {
+ /* get block index, etc */
+ if (GetBlockAndAlignment(pt, p, dmp, &BlockIndex, &IsUnAligned, &Col, &Offset, &Width, &rcP)) {
+ /* if block is aligned */
+ if (!IsUnAligned) {
+ /* create display for single block */
+ sap = ViewMgr_GetBeginIndexed(dmp->MSA_d.pgp_l.sap);
+ dmp->MSA_d.pgp_l.viewed_sap = dmp->MSA_d.pgp_l.sap;
+ mpplp = DDE_CreateDisplay(sap, BlockIndex, IsUnAligned, &NumBlocks);
+ dsp = DDE_NewStack(mpplp);
+ /* record which block is being edited, etc */
+ dsp->LaunchBlock = BlockIndex;
+ dsp->NumBlocks = NumBlocks;
+ dsp->IsUnAligned = IsUnAligned;
+ DDE_MergeNodesLists(dsp->pEdit);
+ /* delete block, tell AlnMgr to save edits, redraw DDV */
+ DDE_DeleteBlock(dsp, 0, FALSE);
+ dmp->dsp = dsp;
+ DDV_SaveEdits(dmp, TRUE);
+ /* free stack */
+ dsp = DDE_FreeStack(dsp);
+ dmp->dsp = dsp;
+ }
+ }
+ ArrowCursor();
+ dmp->MouseMode = dmp->SavedMouseMode;
+ }
+
+ /* handle the click when splitting 2 blocks */
+ if (dmp->MouseMode == DDV_MOUSEMODE_SPLITBLOCK) {
+ FoundIt = FALSE;
+ /* adjust x position so vertical bar jumps when mouse is on center of char */
+ pt.x -= dmp->GrData.udv_font.ColWidth/2;
+ /* if user clicked on an aligned block */
+ if (GetBlockAndAlignment(pt, p, dmp, &BlockIndex, &IsUnAligned, &Col, &Offset, &Width, &rcP)) {
+ /* save col where vertical bar was last drawn */
+ dmp->SaveCol = Col;
+ /* draw vertical bar after this column */
+ HPos = DDV_GetHPixelPosGivenColNumber(dmp, rcP, Col);
+ UDV_draw_vertical_bar(rcP, HPos, FALSE);
+ dmp->ms.Action_type = MS_ACTION_SPLIT_BLOCK;
+ FoundIt = TRUE;
+ }
+ if (!FoundIt) {
+ ArrowCursor();
+ }
+ dmp->MouseMode = dmp->SavedMouseMode;
+ }
+
+ /* handle the 1st click when merging 2 blocks */
+ /* for the 1st click just need to record the block */
+ else if (dmp->MouseMode == DDV_MOUSEMODE_MERGEBLOCKS1) {
+ FoundIt = FALSE;
+ /* if mouse is in a valid place, get BlockIndex and alignment status */
+ if (GetBlockAndAlignment(pt, p, dmp, &BlockIndex, &IsUnAligned, &Col, &Offset, &Width, &rcP)) {
+ if (!IsUnAligned) {
+ dmp->BlockIndex = BlockIndex;
+ dmp->MouseMode = DDV_MOUSEMODE_MERGEBLOCKS2;
+ FoundIt = TRUE;
+ }
+ }
+ if (!FoundIt) {
+ dmp->MouseMode = dmp->SavedMouseMode;
+ ArrowCursor();
+ }
+ }
+
+ /* handle the 2nd click when merging 2 blocks */
+ else if (dmp->MouseMode == DDV_MOUSEMODE_MERGEBLOCKS2) {
+ /* if mouse is in a valid place, get BlockIndex and alignment status */
+ if (GetBlockAndAlignment(pt, p, dmp, &BlockIndex, &IsUnAligned, &Col, &Offset, &Width, &rcP)) {
+ /* if 2 blocks are next to each other and both aligned */
+ if ((!IsUnAligned) && (ABS(BlockIndex - dmp->BlockIndex) == 1)) {
+ /* create a stack for the block on the right */
+ BlockIndex = MAX(BlockIndex, dmp->BlockIndex);
+ sap = ViewMgr_GetBeginIndexed(dmp->MSA_d.pgp_l.sap);
+ dmp->MSA_d.pgp_l.viewed_sap = dmp->MSA_d.pgp_l.sap;
+ mpplp = DDE_CreateDisplay(sap, BlockIndex, IsUnAligned, &NumBlocks);
+ dsp = DDE_NewStack(mpplp);
+ /* record which block is being edited, etc */
+ dsp->LaunchBlock = BlockIndex;
+ dsp->NumBlocks = NumBlocks;
+ dsp->IsUnAligned = IsUnAligned;
+ DDE_MergeNodesLists(dsp->pEdit);
+ /* if block on right is flush left */
+ if (DDE_FirstColumnIsAligned(dsp->pEdit)) {
+ /* delete block on right. count number of cols that were in block. */
+ ColCnt = DDE_DeleteBlock(dsp, 0, FALSE);
+ /* tell AlnMgr to save edits, don't redraw yet */
+ dmp->dsp = dsp;
+ DDV_SaveEdits(dmp, FALSE);
+ /* free stack for block on right. create stack for block on left */
+ DDE_FreeStack(dsp);
+ sap = ViewMgr_GetBeginIndexed(dmp->MSA_d.pgp_l.sap);
+ dmp->MSA_d.pgp_l.viewed_sap = dmp->MSA_d.pgp_l.sap;
+ mpplp = DDE_CreateDisplay(sap, BlockIndex-1, IsUnAligned, &NumBlocks);
+ dsp = DDE_NewStack(mpplp);
+ /* record which block is being edited, etc */
+ dsp->LaunchBlock = BlockIndex-1;
+ dsp->NumBlocks = NumBlocks;
+ dsp->IsUnAligned = IsUnAligned;
+ DDE_MergeNodesLists(dsp->pEdit);
+ DDE_Verify(dsp->pEdit);
+ /* shift right boundary of left block by number cols in right block */
+ DDE_ShiftRightBoundary(dsp, 0, ColCnt, FALSE);
+ /* tell AlnMgr to save edits, now redraw */
+ dmp->dsp = dsp;
+ DDV_SaveEdits(dmp, TRUE);
+ }
+ /* free remaining stack */
+ dsp = DDE_FreeStack(dsp);
+ dmp->dsp = dsp;
+ }
+ }
+ dmp->MouseMode = dmp->SavedMouseMode;
+ ArrowCursor();
+ }
+
+
+ /* handle the case when we're launching the editor on a block */
+ else if (dmp->MouseMode == DDV_MOUSEMODE_LAUNCHEDITOR) {
+ /* if mouse is in a valid place, get BlockIndex and alignment status */
+ if (GetBlockAndAlignment(pt, p, dmp, &BlockIndex, &IsUnAligned, &Col, &Offset, &Width, &rcP)) {
+ /* don't allow editing when there are gaps and no gaps are allowed */
+ pNoGaps = (Boolean*) GetAppProperty("dde_nogaps");
+ if (pNoGaps == NULL) NoGaps = TRUE;
+ else NoGaps = *pNoGaps;
+ IsEditable = AlnMgrIsEditable(dmp->MSA_d.pgp_l.sap);
+ if (!(IsEditable == AM_EDITGAPS && NoGaps) && IsEditable) {
+ ViewMgr_MakeMultiple(dmp->MSA_d.pgp_l.sap);
+ }
+ else {
+ Message(MSG_OK, "%s", "Unable to convert this alignment\n into an editable form.");
+ dmp->MouseMode = dmp->SavedMouseMode;
+ ArrowCursor();
+ return;
+ }
+ /* get pointer to original seqAlign */
+ sap = ViewMgr_GetBeginIndexed(dmp->MSA_d.pgp_l.sap);
+ /* create display for editor */
+ mpplp = DDE_CreateDisplay(sap, BlockIndex, IsUnAligned, &NumBlocks);
+ mpplp->viewed_sap = dmp->MSA_d.pgp_l.sap;
+ /* create the stack used by editor */
+ dsp = DDE_NewStack(mpplp);
+ DDE_MergeNodesLists(dsp->pEdit);
+ /* record which block is being edited, etc */
+ dsp->LaunchBlock = BlockIndex;
+ dsp->NumBlocks = NumBlocks;
+ dsp->IsUnAligned = IsUnAligned;
+ /* hide the rows in DDE that are hidden in DDV */
+ NumRows = dsp->pEdit->TotalNumRows;
+ for (i=0; i<NumRows; i++) {
+ if (ViewMgr_TRow2VRow(dmp->MSA_d.pgp_l.sap, i+1) == -1) {
+ DDE_HideRow(dsp, i, FALSE);
+ }
+ }
+ DDE_Add(dsp);
+ dsp->SomethingToSave = FALSE;
+ /* launch the editor as a slave */
+ SetAppProperty("ddeinterndata",(void*)dsp);
+ GatherProcLaunch(OMPROC_EDIT, FALSE, dmp->MSA_d.entityID,
+ dmp->MSA_d.itemID, OBJ_SEQALIGN, 0, 0, OBJ_SEQALIGN, 0);
+ RemoveAppProperty("ddeinterndata");
+ }
+ dmp->MouseMode = dmp->SavedMouseMode;
+ ArrowCursor();
+ }
+
+ /* handle the case when we're creating an aligned block */
+ else if (dmp->MouseMode == DDV_MOUSEMODE_CREATEBLOCK) {
+ ObjectRect(p, &rcP);
+ InsetRect(&rcP,4,4);
+ DDV_AdjustDrawingRect(&rcP,&(dmp->GrData.udv_font),dmp);
+ rcP.left += dmp->GrData.udv_panel.cxName + dmp->GrData.udv_scale.cxLeftScale;
+ /* if the point is in a valid spot */
+ if (PtInRect(pt, &rcP)) {
+ ObjectRect(p, &rcP);
+ Col = DDV_GetColNumberGivenMousePos(dmp, rcP, pt);
+ /* and the column's legal */
+ if ((Col >= 0) && (Col < dmp->MSA_d.pgp_l.LengthAli)) {
+ /* and there is no aligned block already */
+ if (DDE_GetNumBlocks(dmp->dsp->pEdit) == 0) {
+ /* save start col */
+ dmp->dsp->FromCol = Col;
+ /* save col where vertical bar was last drawn */
+ dmp->dsp->SaveCol = Col;
+ /* draw vertical bar before and after this column */
+ HPos = DDV_GetHPixelPosGivenColNumber(dmp, rcP, dmp->dsp->SaveCol);
+ UDV_draw_vertical_bar(rcP, HPos, TRUE);
+ HPos -= dmp->GrData.udv_font.ColWidth;
+ UDV_draw_vertical_bar(rcP, HPos, TRUE);
+ dmp->ms.Action_type = MS_ACTION_CREATE_BLOCK;
+ }
+ else {
+ dmp->MouseMode = dmp->SavedMouseMode;
+ ArrowCursor();
+ }
+ }
+ else {
+ dmp->MouseMode = dmp->SavedMouseMode;
+ ArrowCursor();
+ }
+ }
+ else {
+ dmp->MouseMode = dmp->SavedMouseMode;
+ ArrowCursor();
+ }
+ }
+
+ /*the mouse is located in a ParaG ?*/
+ /*if YES : the user is selecting either sequence letter(s) or a feature*/
+ else if ((pt.x>(rcP.left+dmp->GrData.udv_panel.cxName+
+ dmp->GrData.udv_scale.cxLeftScale)) &&
+ (pt.y>(rcP.top+dmp->GrData.udv_panel.cyScale))) {
+ /*get the ParaG list and look for the ParaG where the mouse is located*/
+ /*note : only implemented for DDV_DISP_HORZ type of display...*/
+ if (dmp->MSA_d.pgp_l.DisplayType==DDV_DISP_HORZ){
+ if (DDV_GetCoordsGivenAClick(dmp,&rcP,&pt,
+ &bsp_coord,&SeqAlign_coord,&Disp_coord,&Line_num,
+ &ParaGLine_Num,&uWhere,&cur_pgp)){
+ if (uWhere==PGP_REGION_SEQ){
+ if (bDeselectAll && (dmp->MouseMode==DDV_MOUSEMODE_SELECT ||
+ dmp->MouseMode==DDV_MOUSEMODE_SELECT_ONE_ROW))
+ ObjMgrDeSelectAll ();
+ if (shftKey && bsp_coord!=(Int4)-1){
+ UDV_DecodeIdxFeat (dmp->MSA_d.pgp_l.entitiesTbl[ParaGLine_Num-1],
+ &bsp_eID,&bsp_iID);
+ if (bsp_eID!=0 && bsp_iID!=0){
+ slp=DDV_GetClosetSeqLocGivenBspPos(cur_pgp->sip,bsp_eID,
+ bsp_iID, bsp_coord, &old_pos, TRUE);
+ if (slp){
+ if (dmp->MouseMode==DDV_MOUSEMODE_SELECT ||
+ dmp->MouseMode==DDV_MOUSEMODE_SELECT_ONE_ROW)
+ ObjMgrAlsoSelect (bsp_eID, bsp_iID,
+ OBJ_BIOSEQ,OM_REGION_SEQLOC, slp);
+ if (old_pos!=(Int4)-1)
+ Disp_coord=old_pos;
+ }
+ }
+ dmp->ms.oldPos=pt;
+ dmp->ms.Action_type=MS_ACTION_SELECT_SEQ;
+ return;
+ }
+
+ /* display info about residues that's clicked */
+ if (ParaGLine_Num != -1) {
+ DDV_GetSeqNameGivenRow(dmp->MSA_d.pgp_l.TableHead, ParaGLine_Num, szAccess);
+ DDV_DispPositionInStatus(mWin_d->InfoPanel, bsp_coord+1, ParaGLine_Num, szAccess);
+ }
+
+ /*save the positions */
+ dmp->ms.oldPos=pt;
+ dmp->ms.newPos=pt;
+ dmp->ms.Action_type=MS_ACTION_SELECT_SEQ;
+ dmp->ms.old_row=Line_num;
+ dmp->ms.old_col=Disp_coord;
+ dmp->ms.old_pgp=cur_pgp;
+ dmp->ms.first_row=Line_num;
+ dmp->ms.first_col=Disp_coord;
+ dmp->ms.last_row=Line_num;
+ dmp->ms.last_col=Disp_coord;
+
+ /* show outline of highlighted area */
+ CopyMode();
+ DrawOutline(p, Line_num, Disp_coord, Line_num, Disp_coord, TRUE);
+
+ if (dmp->ms.first_cols == NULL) {
+ NumRows = dmp->MSA_d.pgp_l.nBsp;
+ dmp->ms.first_cols = MemNew(NumRows * sizeof(Int4));
+ dmp->ms.first_pgps = MemNew(NumRows * sizeof(ParaGPtr));
+ }
+ dmp->ms.first_cols[Line_num-1]=Disp_coord;
+ dmp->ms.first_pgps[Line_num-1]=cur_pgp;
+ dmp->ms.first_point=pt;
+ dmp->ms.first_HScroll=dmp->GrData.udv_hscrl.ScrollPos;
+ dmp->ms.first_VScroll=dmp->GrData.udv_vscrl.ScrollPos;
+ dmp->ms.old_HScroll = dmp->GrData.udv_hscrl.ScrollPos;
+ dmp->ms.old_VScroll = dmp->GrData.udv_vscrl.ScrollPos;
+ /*update caret pos, if needed only*/
+ if (dmp->MouseMode==DDV_MOUSEMODE_EDIT){
+ dmp->dci.old_row=dmp->dci.new_row;
+ dmp->dci.old_col=dmp->dci.new_col;
+ }
+ /* if we're in the editor and mousemode is query */
+ /* click and drag on sequence will cause the whole row to shift */
+ if (dmp->bEditor) {
+ if (dmp->MouseMode == DDV_MOUSEMODE_QUERY) {
+ /* make sure column is legit */
+ DDV_GetCurrentDispRange(dmp->hWndDDV,&(dmp->GrData),
+ dmp->MSA_d.pgp_l.LengthAli,&from_col,&to_col,&from_row,&to_row);
+ /* Don't shift row if clicking on first or last column of */
+ /* display because then the screen scrolls */
+ if (((Disp_coord>from_col) && (Disp_coord<=to_col)) || (Disp_coord==0)) {
+ /* draw a double rectangle around the selected char */
+ /* to mark the from spot */
+ ObjectRect(p, &rcP);
+ VPos = DDV_GetVPixelPosGivenRowNumber(dmp, rcP, Line_num-1); /* 1-based */
+ HPos = DDV_GetHPixelPosGivenColNumber(dmp, rcP, Disp_coord); /* 0-based */
+ rcP2.left = HPos - dmp->GrData.udv_font.ColWidth;
+ rcP2.right = HPos;
+ rcP2.top = VPos - dmp->GrData.udv_font.LineHeight;
+ rcP2.bottom = VPos;
+ UDV_draw_rectangle(rcP2, FALSE);
+ InsetRect(&rcP2, 1, 1);
+ UDV_draw_rectangle(rcP2, FALSE);
+ CrossCursor();
+ dmp->dsp->FromCol = Disp_coord;
+ dmp->dsp->FromRow = Line_num-1;
+ dmp->dsp->SaveCol = Disp_coord;
+ dmp->dsp->SaveRow = Line_num-1;
+ dmp->ms.Action_type = MS_ACTION_SHIFT_ROW;
+ }
+ }
+ }
+ /*select a single letter*/
+ if (dmp->MouseMode == DDV_MOUSEMODE_SELECT ||
+ dmp->MouseMode == DDV_MOUSEMODE_SELECT_ONE_ROW) {
+/*
+ DDV_SendBSPSelectMsg(dmp, bsp_coord, SeqAlign_coord,
+ Disp_coord, Line_num, ParaGLine_Num, cur_pgp, &pt, TRUE);
+*/
+ }
+ }
+ }
+ }
+ }
+ /*the mouse is located within the Name list region (left of ParaG) ?*/
+ else if (pt.x>=dmp->GrData.udv_panel.cxName-1 &&
+ pt.x<=dmp->GrData.udv_panel.cxName+3){
+ rcP.left=5*dmp->GrData.udv_font.cxChar; /*min value*/
+ rcP.right=2*PANEL_NAME_WIDTH*dmp->GrData.udv_font.cxChar;/*max val*/
+ pt.x=dmp->GrData.udv_panel.cxName;
+ dmp->ms.oldPos=pt;
+ dmp->ms.newPos=pt;
+ dmp->ms.rcClip=rcP;
+ dmp->ms.Action_type=MS_ACTION_RESIZE_WIN;
+ InvertMode();
+ UDV_draw_double_cursor(dmp->ms.rcClip,
+ dmp->ms.oldPos);
+ CrossCursor();
+ }
+ /*the mouse is located on a sequence name ?*/
+ else if (pt.x<dmp->GrData.udv_panel.cxName &&
+ pt.y>(rcP.top+dmp->GrData.udv_panel.cyScale)){
+ Line_num=DDV_GetRowGivenMousePos(dmp, &rcP, &pt,&ParaGLine_Num);
+ if (Line_num!=(Int4)-1){
+ UDV_DecodeIdxFeat (dmp->MSA_d.pgp_l.entitiesTbl[ParaGLine_Num-1],
+ &bsp_eID,&bsp_iID);
+ if (dblClick /*&& !dmp->bEditor*/){/*load the sequence viewer on that sequence*/
+ {
+ SAM_ViewGlobal vg;
+
+ MemSet(&vg, 0, sizeof(SAM_ViewGlobal));
+ vg.pCGlobal = dmp->Globals.colorp;
+ vg.Row = Line_num;
+ if(!dmp->bEditor) vg.MasterViewer = SAMVIEWDDV;
+ else vg.MasterViewer = SAMVIEWDDE;
+ SetAppProperty(SAM_ViewString, &vg);
+ GatherSpecificProcLaunch(0, "OneD-Viewer", OMPROC_VIEW,
+ FALSE, bsp_eID, bsp_iID, OBJ_BIOSEQ);
+ RemoveAppProperty(SAM_ViewString);
+ }
+ }
+ else{
+ if (dmp->bEditor){
+ WindoW temport;
+ dmp->deri.curEditRow=ParaGLine_Num-1;
+ rcP.left=0;
+ rcP.right=rcP.left+dmp->GrData.udv_panel.cxName;
+ temport=SavePort(ParentWindow(p));
+ Select(p);
+ InvalRect(&rcP);
+ Update();
+ RestorePort(temport);
+ /* record the row that's moving */
+ dmp->dsp->FromRow = Line_num - 1;
+ /* keep track of where the underline is */
+ dmp->dsp->SaveRow = Line_num - 1;
+ dmp->ms.Action_type = MS_ACTION_MOVE_ROW;
+ /* make a rectangle of the sequence names region */
+ ObjectRect(p,&rcP);
+ rcP2.left = rcP.left;
+ rcP2.right = rcP.left + dmp->GrData.udv_panel.cxName - 10;
+ rcP2.top = rcP.top;
+ rcP2.bottom = rcP.bottom;
+ /* draw the underline */
+ VPos = DDV_GetVPixelPosGivenRowNumber(dmp, rcP2, Line_num-1);
+ UDV_draw_horizontal_line(rcP2, VPos);
+ CrossCursor();
+ }
+ else /* not editor */ {
+ dmwp=(DdvMainWinPtr)GetObjectExtra(dmp->hParent);
+ if(dmwp) {
+ pgp=(ParaGPtr)(dmp->MSA_d.pgp_l.TableHead[Line_num-1]->data.ptrvalue);
+ bsp=BioseqLockById(pgp->sip);
+ CreateDefLine(NULL,bsp,buf,80,0,NULL,NULL);
+ BioseqUnlock(bsp);
+ SetTitle(dmwp->InfoPanel,buf);
+ }
+ }
+ }
+ }
+ }
+ /*the mouse is located just on the left of a sequence ?
+ If true, select the full sequence*/
+ else if ((pt.x>=dmp->GrData.udv_panel.cxName+3) /*after the name of the sequence ?*/
+ &&
+ (pt.x<=dmp->GrData.udv_panel.cxName+3+dmp->GrData.udv_scale.cxLeftScale+
+ dmp->GrData.udv_font.cxChar) /*before the sequence ?*/
+ &&
+ (dmp->MouseMode==DDV_MOUSEMODE_SELECT ||
+ dmp->MouseMode==DDV_MOUSEMODE_SELECT_ONE_ROW)/*valid only if selection mode*/
+ ){
+ if (pt.y>(rcP.top+dmp->GrData.udv_panel.cyScale)){
+ /*get the ParaG list and look for the ParaG where the mouse is located*/
+ /*note : only implemented for DDV_DISP_HORZ type of display...*/
+ if (dmp->MSA_d.pgp_l.DisplayType==DDV_DISP_HORZ){
+ Line_num=DDV_GetRowGivenMousePos(dmp, &rcP, &pt,&ParaGLine_Num);
+ if (Line_num!=(Int4)-1){
+ /*get min,max coord. of BSP*/
+ UDV_GetBspRangeinPGPList(dmp->MSA_d.pgp_l.TableHead[ParaGLine_Num-1],
+ &bsp_start,&bsp_stop);
+ if (bsp_start!=INT4_MAX && bsp_stop!=INT4_MIN){
+ /*now, we can send the Select message*/
+ /* first_pgp, old_pgp & cur_pgp have the same sip...
+ they are on a same row; I can use one of them*/
+ cur_pgp=(ParaGPtr)(dmp->MSA_d.pgp_l.TableHead[ParaGLine_Num-1]->data.ptrvalue);
+ slp = SeqLocIntNew (bsp_start, bsp_stop, Seq_strand_plus, cur_pgp->sip);
+ UDV_DecodeIdxFeat (dmp->MSA_d.pgp_l.entitiesTbl[ParaGLine_Num-1],
+ &bsp_eID,&bsp_iID);
+ if (bsp_eID!=0 && bsp_iID!=0 && slp){
+ bIsAlreadyFullSel=DDV_IsFullBspAlreadySel(bsp_eID,bsp_iID,
+ bsp_start,bsp_stop);
+ if (!bIsAlreadyFullSel){
+ if (!bDeselectAll){
+ ObjMgrAlsoSelect (bsp_eID, bsp_iID,
+ OBJ_BIOSEQ,OM_REGION_SEQLOC, slp);
+ }
+ else{
+ ObjMgrDeSelectAll ();
+ ObjMgrSelect (bsp_eID, bsp_iID,
+ OBJ_BIOSEQ,OM_REGION_SEQLOC, slp);
+ }
+ }
+ else{
+ if (bDeselectAll)
+ ObjMgrDeSelectAll ();
+ ObjMgrDeSelect (bsp_eID, bsp_iID,
+ OBJ_BIOSEQ,OM_REGION_SEQLOC, slp);
+ }
+ }
+ }
+ dmp->ms.Action_type=MS_ACTION_SELECT_FULL_SEQ;
+ }
+ }
+ }
+ }
+
+ /* if the mouse is located on one of the vertical bars, on top, that */
+ /* mark an alignment boundary */
+ else if (OnAlignmentBoundary(pt, p, dmp, &BlockIndex, &LeftBoundary, &Col, &HPos)) {
+ /* record the boundary and block that are being moved */
+ dmp->dsp->FromCol = Col;
+ dmp->dsp->BlockIndex = BlockIndex;
+ dmp->dsp->LeftBoundary = LeftBoundary;
+ /* record the column of the last drawn vertical bar */
+ dmp->dsp->SaveCol = Col;
+ dmp->ms.Action_type = MS_ACTION_SHIFT_BOUNDARY;
+ /* draw a dotted outline of the vertical bar */
+ ObjectRect(p, &rcP);
+ UDV_draw_vertical_bar(rcP, HPos, TRUE);
+ CrossCursor();
+ }
+
+ else{/*click outside "special" regions : deselect everything*/
+ if (dmp->MouseMode==DDV_MOUSEMODE_SELECT ||
+ dmp->MouseMode==DDV_MOUSEMODE_SELECT_ONE_ROW)
+ ObjMgrDeSelectAll ();
+ /*this line if for cn3d only*/
+ ObjMgrSendMsg(OM_MSG_MOUSEUP, dmp->MSA_d.entityID,
+ dmp->MSA_d.itemID, OBJ_SEQALIGN);
+ }
+
+ if (dmp->bEditor) {
+ DDV_GreyOut(mWin_d, DDE_AtStartOfStack(dmp->dsp), DDE_AtEndOfStack(dmp->dsp));
+ }
+}
+
+
+static Boolean GetBlockAndAlignmentForCol(DdvMainPtr dmp, Int4 Col, Int4* pBlockIndex,
+ Boolean* pIsUnAligned, Int4* pOffset, Int4* pWidth) {
+/*****************************************************************************
+* get the BlockIndex and Alignment status for Col.
+*****************************************************************************/
+ /* if Col is legal */
+ if ((Col >= 0) && (Col < dmp->MSA_d.pgp_l.LengthAli)) {
+ /* get the block or unaligned-region index */
+ if (DDE_IsColValid(&(dmp->MSA_d.pgp_l), Col, pBlockIndex, pIsUnAligned, pOffset, pWidth)) {
+ return(TRUE);
+ }
+ }
+ *pBlockIndex = -1;
+ *pIsUnAligned = TRUE;
+ return(FALSE);
+}
+
+
+static Boolean GetBlockAndAlignment(PoinT pt, PaneL p, DdvMainPtr dmp,
+ Int4* pBlockIndex, Boolean* pIsUnAligned,
+ Int4* pCol, Int4* pOffset, Int4* pWidth, RecT* rcP) {
+/*****************************************************************************
+* get the BlockIndex and Alignment status for point pt.
+*****************************************************************************/
+ ObjectRect(p, rcP);
+ InsetRect(rcP,4,4);
+ DDV_AdjustDrawingRect(rcP, &(dmp->GrData.udv_font), dmp);
+ rcP->left += dmp->GrData.udv_panel.cxName + dmp->GrData.udv_scale.cxLeftScale;
+ /* if the point is in a valid spot */
+ if (PtInRect(pt, rcP)) {
+ ObjectRect(p, rcP);
+ *pCol = DDV_GetColNumberGivenMousePos(dmp, *rcP, pt);
+ /* and the column's legal */
+ if ((*pCol >= 0) && (*pCol < dmp->MSA_d.pgp_l.LengthAli)) {
+ /* get the block or unaligned-region index */
+ if (DDE_IsColValid(&(dmp->MSA_d.pgp_l), *pCol, pBlockIndex, pIsUnAligned, pOffset, pWidth)) {
+ return(TRUE);
+ }
+ }
+ }
+ *pCol=-1;
+ *pBlockIndex = -1;
+ *pIsUnAligned = TRUE;
+ return(FALSE);
+}
+
+
+static Boolean RectanglesAreSame(RecT rc1, RecT rc2) {
+/*****************************************************************************
+* return TRUE if 2 rectangles are identical.
+*****************************************************************************/
+ if (rc1.left != rc2.left) return(FALSE);
+ if (rc1.right != rc2.right) return(FALSE);
+ if (rc1.top != rc2.top) return(FALSE);
+ if (rc1.bottom != rc2.bottom) return(FALSE);
+ return(TRUE);
+}
+
+
+static void EraseOutline(PaneL p) {
+/*****************************************************************************
+* erase the old outline of the region selected for highlighting.
+*****************************************************************************/
+ DdvMainPtr dmp;
+ BaR hsb, vsb;
+ Int4 HScroll, VScroll;
+
+ dmp = (DdvMainPtr) GetObjectExtra(p);
+ if (dmp==NULL) return;
+
+ hsb = GetSlateHScrollBar((SlatE) dmp->hWndDDV);
+ vsb = GetSlateVScrollBar((SlatE) dmp->hWndDDV);
+
+ /* save current scroll positions, set scroll positions to saved scroll positions */
+ HScroll = dmp->GrData.udv_hscrl.ScrollPos;
+ VScroll = dmp->GrData.udv_vscrl.ScrollPos;
+ SetValue(hsb, dmp->ms.old_HScroll);
+ SetValue(vsb, dmp->ms.old_VScroll);
+
+ /* erase the old rectangle */
+ InvertMode();
+ UDV_draw_rectangle(dmp->ms.outline, FALSE);
+
+ /* restore scroll positions */
+ SetValue(hsb, HScroll);
+ SetValue(vsb, VScroll);
+}
+
+
+static RecT DrawOutline(PaneL p, Int4 Line_num_start, Int4 Disp_coord_start,
+ Int4 Line_num_stop, Int4 Disp_coord_stop, Boolean Draw) {
+/*****************************************************************************
+* use current scroll postions.
+*****************************************************************************/
+ RecT rcP2;
+ DdvMainPtr dmp;
+
+ rcP2.left = rcP2.right = rcP2.top = rcP2.bottom = 0;
+
+ dmp = (DdvMainPtr) GetObjectExtra(p);
+ if (dmp==NULL) return(rcP2);
+
+ return(DrawOutlineGivenScroll(p,
+ Line_num_start, Disp_coord_start, Line_num_stop, Disp_coord_stop,
+ dmp->GrData.udv_vscrl.ScrollPos, dmp->GrData.udv_hscrl.ScrollPos, Draw));
+}
+
+
+static RecT DrawOutlineGivenScroll(PaneL p, Int4 Line_num_start, Int4 Disp_coord_start,
+ Int4 Line_num_stop, Int4 Disp_coord_stop,
+ Int4 VScroll, Int4 HScroll, Boolean Draw) {
+/*****************************************************************************
+* draw the outline of the region being selected for highlighting.
+* Line_num_stop and Disp_coord_stop are for the current mouse position.
+* Line_num_start and Disp_coord_start are for the first click position.
+* if Draw is FALSE, just return the rectangle and don't draw it.
+* Line_num's are 1-based. Disp_coord's are 0-based.
+* treat VScroll and HScroll as the current scroll positions.
+* return rectangle that's drawn.
+*****************************************************************************/
+ RecT rcP, rcP2;
+ DdvMainPtr dmp;
+ Int4 Line_num_stop_save, Disp_coord_stop_save;
+
+ rcP2.left = rcP2.right = rcP2.top = rcP2.bottom = 0;
+ Line_num_stop_save = Line_num_stop;
+ Disp_coord_stop_save = Disp_coord_stop;
+
+ dmp = (DdvMainPtr) GetObjectExtra(p);
+ if (dmp==NULL) return(rcP2);
+
+ if (Line_num_start > Line_num_stop) {
+ swap(&Line_num_start, &Line_num_stop);
+ }
+ if (Disp_coord_start > Disp_coord_stop) {
+ swap(&Disp_coord_start, &Disp_coord_stop);
+ }
+ if (Line_num_start < 1)
+ Line_num_start=1;
+ if (Line_num_stop > dmp->MSA_d.pgp_l.nBsp)
+ Line_num_stop=dmp->MSA_d.pgp_l.nBsp;
+ if (Disp_coord_start < 0)
+ Disp_coord_start=0;
+ if (Disp_coord_stop >= dmp->MSA_d.pgp_l.LengthAli)
+ Disp_coord_stop=dmp->MSA_d.pgp_l.LengthAli;
+
+ if (dmp->MouseMode==DDV_MOUSEMODE_SELECT || dmp->MouseMode==DDV_MOUSEMODE_SELECT_ONE_ROW) {
+ /* calculate new rectangle */
+ ObjectRect(p, &rcP);
+ rcP2.top = DDV_GetVPixelPosGivenRowNumber(dmp, rcP, Line_num_start-1);
+ rcP2.bottom = DDV_GetVPixelPosGivenRowNumber(dmp, rcP, Line_num_stop-1);
+ rcP2.left = DDV_GetHPixelPosGivenColNumber(dmp, rcP, Disp_coord_start);
+ rcP2.right = DDV_GetHPixelPosGivenColNumber(dmp, rcP, Disp_coord_stop);
+ rcP2.top -= dmp->GrData.udv_font.LineHeight;
+ rcP2.left -= dmp->GrData.udv_font.ColWidth;
+ if (Draw) {
+ /* make clip region */
+ InsetRect(&rcP,4,4);
+ DDV_AdjustDrawingRect(&rcP,&(dmp->GrData.udv_font),dmp);
+ rcP.left+=dmp->GrData.udv_panel.cxName+dmp->GrData.udv_scale.cxLeftScale;
+ rcP.top+=3*dmp->GrData.udv_panel.cyScale/2;
+ rcP.bottom+=2; /* so bottom of rectangle not cut */
+ ClipRect(&rcP);
+ /* draw new rectangle */
+ UDV_draw_rectangle(rcP2, FALSE);
+ ResetClip();
+ /* save row and col for current mouse pos */
+ dmp->ms.last_row = Line_num_stop_save;
+ dmp->ms.last_col = Disp_coord_stop_save;
+ }
+ }
+ return(rcP2);
+}
+
+
+static Boolean OnAlignmentBoundary(PoinT pt, PaneL p, DdvMainPtr dmp,
+ Int4* pBlockIndex, Boolean* pLeftBoundary,
+ Int4* pCol, Int4* pHPos) {
+/*****************************************************************************
+* check if point pt is on one of the vertical bars that mark
+* alignment boundaries. return TRUE if it is.
+* whether it's TRUE or not, ...
+* return BlockIndex indicating which aligned block,
+* return LeftBoundary = TRUE if p is on a left boundary,
+* return LeftBoundary = FALSE if p is on a right boundary.
+* return Col; the display coordinate for the alignment boundary.
+* return HPos; the horizontal pixel position of the boundary.
+*****************************************************************************/
+ RecT rcP, rcBanner;
+ Int4 TopVPos, BotVPos, LeftHPos, RightHPos;
+ Int4 i, NumBlocks;
+
+ /* this only works in the editor */
+ if (!dmp->bEditor) return(FALSE);
+
+ /* make rectangle for banner across top. make it extra wide */
+ ObjectRect(p, &rcP);
+ DDV_GetVPixelPosOfEmptySpace(dmp, rcP, &TopVPos, &BotVPos);
+ rcBanner = rcP;
+ rcBanner.left += dmp->GrData.udv_panel.cxName + dmp->GrData.udv_scale.cxLeftScale;
+ rcBanner.top = TopVPos-4;
+ rcBanner.bottom = BotVPos+8;
+ rcBanner.left -= 4;
+
+ /* for each aligned block */
+ NumBlocks = DDE_GetNumBlocks(dmp->dsp->pEdit);
+ for (i=0; i<NumBlocks; i++) {
+ /* check if the pt is reasonably close to the left vertical bar */
+ *pCol = DDE_GetAlignStart(dmp->dsp->pEdit, i);
+ LeftHPos = DDV_GetHPixelPosGivenColNumber(dmp, rcP, *pCol);
+ LeftHPos -= dmp->GrData.udv_font.ColWidth;
+ if ((pt.x >= LeftHPos-5) && (pt.x <= LeftHPos+5)) {
+ *pBlockIndex = i;
+ *pLeftBoundary = TRUE;
+ *pHPos = LeftHPos;
+ if (PtInRect(pt, &rcBanner)) return(TRUE);
+ return(FALSE);
+ }
+ /* check if the pt is reasonably close to the right vertical bar */
+ *pCol = DDE_GetAlignStop(dmp->dsp->pEdit, i);
+ RightHPos = DDV_GetHPixelPosGivenColNumber(dmp, rcP, *pCol);
+ if ((pt.x >= RightHPos-5) && (pt.x <= RightHPos+5)) {
+ *pBlockIndex = i;
+ *pLeftBoundary = FALSE;
+ *pHPos = RightHPos;
+ if (PtInRect(pt, &rcBanner)) return(TRUE);
+ return(FALSE);
+ }
+ }
+ return(FALSE);
+}
+
+
+/*****************************************************************************
+
+Function: DDV_DragProc()
+
+Purpose: manage Mouse-Drag
+
+Parameters: p; panel handle (currently unused)
+ pt; new position
+
+Return value: none
+
+*****************************************************************************/
+NLM_EXTERN void DDV_DragProc(PaneL p, PoinT pt)
+{
+DdvMainPtr dmp;
+RecT rcP, rcP2;
+ParaGPtr cur_pgp=NULL;
+Int4 Jump;
+Int4 Line_num, ParaGLine_num;/*to get the coordinates*/
+Int4 VPos, SavedVPos, from_col, to_col, from_row, to_row, old_VPos;
+Int4 HPos, SavedHPos, Col;
+Int4 Disp_coord_stop;
+Int4 Line_num_stop, BlockIndex, Offset, Width;
+BaR vsb;
+Boolean IsUnAligned;
+static Boolean LineToErase=TRUE;
+
+ /*get the panel data*/
+ dmp = (DdvMainPtr) GetObjectExtra(p);
+ if (dmp==NULL) return;
+
+ /*what is happening ?*/
+ switch(dmp->ms.Action_type){
+ case MS_ACTION_SELECT_SEQ:/*selection on a sequence*/
+ if (shftKey) break;
+ ObjectRect(p,&rcP);
+ /*get the ParaG list and look for the ParaG where the mouse is located*/
+ /*note : only implemented for DDV_DISP_HORZ type of display...*/
+ if (dmp->MSA_d.pgp_l.DisplayType==DDV_DISP_HORZ) {
+ /* get line num and col for current mouse position */
+ DDV_GetRowAndColGivenPt(dmp, rcP, pt, &Disp_coord_stop, &Line_num_stop);
+ /* force single row selection when needed */
+ if (dmp->MouseMode == DDV_MOUSEMODE_SELECT_ONE_ROW) Line_num_stop = dmp->ms.first_row;
+ /* erase the old rectangle */
+ InvertMode();
+ DrawOutline(p, dmp->ms.first_row, dmp->ms.first_col,
+ dmp->ms.last_row, dmp->ms.last_col, TRUE);
+ /* get display info */
+ DDV_GetCurrentDispRange(dmp->hWndDDV,&(dmp->GrData),
+ dmp->MSA_d.pgp_l.LengthAli,&from_col,&to_col,&from_row,&to_row);
+ /* draw the new rectangle */
+ CopyMode();
+ DrawOutline(p, dmp->ms.first_row, dmp->ms.first_col,
+ Line_num_stop, Disp_coord_stop, TRUE);
+ /* display info about residues that mouse is over */
+ DDV_DispStatus(dmp, Line_num_stop, dmp->ms.first_col, Disp_coord_stop);
+ }
+
+ break;
+ case MS_ACTION_RESIZE_WIN:/*the user moves the 3D line located between
+ name area and SeqAlign area*/
+ InvertMode();
+ UDV_draw_double_cursor(dmp->ms.rcClip, dmp->ms.oldPos);
+ dmp->ms.newPos=pt;
+ UDV_draw_double_cursor(dmp->ms.rcClip, dmp->ms.newPos);
+ dmp->ms.oldPos=dmp->ms.newPos;
+ Update();
+ break;
+ case MS_ACTION_SELECT_FULL_SEQ:
+ break;
+ case MS_ACTION_MOVE_ROW:
+ ObjectRect(p,&rcP);
+ rcP2.left = rcP.left;
+ rcP2.right = rcP.left + dmp->GrData.udv_panel.cxName - 10;
+ rcP2.top = rcP.top;
+ rcP2.bottom = rcP.bottom;
+ Line_num=DDV_GetRowGivenMousePos(dmp, &rcP, &pt,&ParaGLine_num);
+
+ DDV_GetCurrentDispRange(dmp->hWndDDV,&(dmp->GrData),
+ dmp->MSA_d.pgp_l.LengthAli,&from_col,&to_col,&from_row,&to_row);
+ vsb = GetSlateVScrollBar ((SlatE)dmp->hWndDDV);
+ old_VPos = GetBarValue(vsb);
+
+ if ((Line_num != -1) && (Line_num-1 >= from_row) && (Line_num-1 <= to_row)) {
+ /* scroll vertically */
+ Jump = ABS((Line_num-1) - dmp->dsp->SaveRow);
+ if (Line_num >= to_row) {
+ SetValue(vsb, old_VPos + Jump);
+ }
+ if (Line_num <= from_row+1) {
+ SetValue(vsb, old_VPos - Jump);
+ }
+ /* get new line number, erase last underline, draw new one */
+ SavedVPos = DDV_GetVPixelPosGivenRowNumber(dmp, rcP2, dmp->dsp->SaveRow);
+ if ((Line_num-1) <= dmp->dsp->FromRow) {
+ /* move before new row */
+ VPos = DDV_GetVPixelPosGivenRowNumber(dmp, rcP2, Line_num-2);
+ dmp->dsp->SaveRow = Line_num-2;
+ }
+ else {
+ /* move after new row */
+ VPos = DDV_GetVPixelPosGivenRowNumber(dmp, rcP2, Line_num-1);
+ dmp->dsp->SaveRow = Line_num-1;
+ }
+ if (LineToErase) {
+ InvertMode();
+ UDV_draw_horizontal_line(rcP2, SavedVPos);
+ }
+ LineToErase = TRUE;
+ UDV_draw_horizontal_line(rcP2, VPos);
+ }
+ else {
+ /* just one time, xor the horizontal line to turn it off */
+ if (LineToErase) {
+ InvertMode();
+ SavedVPos = DDV_GetVPixelPosGivenRowNumber(dmp, rcP2, dmp->dsp->SaveRow);
+ UDV_draw_horizontal_line(rcP2, SavedVPos);
+ LineToErase = FALSE;
+ }
+ }
+ break;
+ case MS_ACTION_SHIFT_ROW:
+ ObjectRect(p,&rcP);
+ Col = DDV_GetColNumberGivenMousePos(dmp, rcP, pt);
+ DDV_GetCurrentDispRange(dmp->hWndDDV,&(dmp->GrData),
+ dmp->MSA_d.pgp_l.LengthAli,&from_col,&to_col,&from_row,&to_row);
+ /* if we're still in a legal area */
+ if ((Col>=from_col) && (Col<=to_col) && PtInRect(pt, &rcP)) {
+ /* if a new box needs to be drawn */
+ if (dmp->dsp->SaveCol != Col) {
+ ObjectRect(p,&rcP);
+ SavedVPos = DDV_GetVPixelPosGivenRowNumber(dmp, rcP, dmp->dsp->SaveRow);
+ SavedHPos = DDV_GetHPixelPosGivenColNumber(dmp, rcP, dmp->dsp->SaveCol);
+ /* erase old box */
+ rcP2.left = SavedHPos - dmp->GrData.udv_font.ColWidth;
+ rcP2.right = SavedHPos;
+ rcP2.top = SavedVPos - dmp->GrData.udv_font.LineHeight;
+ rcP2.bottom = SavedVPos;
+ InvertMode();
+ UDV_draw_rectangle(rcP2, FALSE);
+ /* draw new box */
+ dmp->dsp->SaveCol = Col;
+ HPos = DDV_GetHPixelPosGivenColNumber(dmp, rcP, Col);
+ rcP2.left = HPos - dmp->GrData.udv_font.ColWidth;
+ rcP2.right = HPos;
+ rcP2.top = SavedVPos - dmp->GrData.udv_font.LineHeight;
+ rcP2.bottom = SavedVPos;
+ UDV_draw_rectangle(rcP2, FALSE);
+ }
+ }
+ break;
+ case MS_ACTION_SHIFT_BOUNDARY:
+ /* if we're still in a legit area */
+ ObjectRect(p, &rcP);
+ InsetRect(&rcP,4,4);
+ DDV_AdjustDrawingRect(&rcP,&(dmp->GrData.udv_font),dmp);
+ rcP.left += dmp->GrData.udv_panel.cxName + dmp->GrData.udv_scale.cxLeftScale;
+ if (PtInRect(pt, &rcP)) {
+ ObjectRect(p, &rcP);
+ /* get column of new vertical bar */
+ Col = DDV_GetColNumberGivenMousePos(dmp, rcP, pt);
+ /* if column has changed since vertical bar was last drawn */
+ if (Col != dmp->dsp->SaveCol) {
+ /* and the column's legal */
+ if ((Col >= 0) && (Col < dmp->MSA_d.pgp_l.LengthAli)) {
+ /* get horizontal pixel position of old column */
+ HPos = DDV_GetHPixelPosGivenColNumber(dmp, rcP, dmp->dsp->SaveCol);
+ /* adjust for drawing bar preceeding left boundary */
+ if (dmp->dsp->LeftBoundary) HPos -= dmp->GrData.udv_font.ColWidth;
+ /* erase old vertical bar */
+ InvertMode();
+ UDV_draw_vertical_bar(rcP, HPos, TRUE);
+ /* get horizontal pixel position of new column */
+ HPos = DDV_GetHPixelPosGivenColNumber(dmp, rcP, Col);
+ /* adjust for drawing bar preceeding left boundary */
+ if (dmp->dsp->LeftBoundary) HPos -= dmp->GrData.udv_font.ColWidth;
+ /* draw the new vertical bar */
+ UDV_draw_vertical_bar(rcP, HPos, TRUE);
+ /* save the column */
+ dmp->dsp->SaveCol = Col;
+ }
+ }
+ }
+ break;
+ case MS_ACTION_CREATE_BLOCK:
+ ObjectRect(p, &rcP);
+ InsetRect(&rcP,4,4);
+ DDV_AdjustDrawingRect(&rcP,&(dmp->GrData.udv_font),dmp);
+ rcP.left += dmp->GrData.udv_panel.cxName + dmp->GrData.udv_scale.cxLeftScale;
+ /* if we're still in a legit area */
+ if (PtInRect(pt, &rcP)) {
+ ObjectRect(p, &rcP);
+ Col = DDV_GetColNumberGivenMousePos(dmp, rcP, pt);
+ /* and the column has changed since vertical bar was last drawn */
+ if (Col != dmp->dsp->SaveCol) {
+ /* and the column's legal */
+ if ((Col >= 0) && (Col < dmp->MSA_d.pgp_l.LengthAli)) {
+ if (Col >= dmp->dsp->FromCol) {
+ /* get horizontal pixel position of old column */
+ HPos = DDV_GetHPixelPosGivenColNumber(dmp, rcP, dmp->dsp->SaveCol);
+ /* erase old vertical bar */
+ InvertMode();
+ UDV_draw_vertical_bar(rcP, HPos, TRUE);
+ /* get horizontal pixel position of new column */
+ HPos = DDV_GetHPixelPosGivenColNumber(dmp, rcP, Col);
+ /* draw the new vertical bar */
+ UDV_draw_vertical_bar(rcP, HPos, TRUE);
+ /* save the column */
+ dmp->dsp->SaveCol = Col;
+ }
+ }
+ }
+ }
+ break;
+ case MS_ACTION_SPLIT_BLOCK:
+ /* adjust x position so vertical bar jumps when mouse is on center of char */
+ pt.x -= dmp->GrData.udv_font.ColWidth/2;
+ /* get block, col, etc for new mouse position */
+ if (GetBlockAndAlignment(pt, p, dmp, &BlockIndex, &IsUnAligned, &Col, &Offset, &Width, &rcP)) {
+ /* if mouse col changed */
+ if (Col != dmp->SaveCol) {
+ /* get horizontal pixel position of old column */
+ HPos = DDV_GetHPixelPosGivenColNumber(dmp, rcP, dmp->SaveCol);
+ /* erase old vertical bar */
+ InvertMode();
+ UDV_draw_vertical_bar(rcP, HPos, FALSE);
+ /* get horizontal pixel position of new column */
+ HPos = DDV_GetHPixelPosGivenColNumber(dmp, rcP, Col);
+ /* draw the new vertical bar */
+ UDV_draw_vertical_bar(rcP, HPos, FALSE);
+ /* save the column */
+ dmp->SaveCol = Col;
+ }
+ }
+ }
+}
+
+/*****************************************************************************
+
+Function: DDV_ReleaseProc()
+
+Purpose: manage Mouse-Release
+
+Parameters: p; panel handle (currently unused)
+ pt; new position
+
+Return value: none
+
+*****************************************************************************/
+NLM_EXTERN void DDV_ReleaseProc(PaneL p, PoinT pt)
+{
+WindoW temport;
+DdvMainPtr dmp;
+DdvMainWinPtr dmwp;
+DDVUpdateMSGPtr dump;
+RecT rcP, rcP2;
+ParaGPtr cur_pgp=NULL;
+Int4 bsp_coord, SeqAlign_coord;
+Int4 Disp_coord, Line_num,ParaGLine_Num;/*to get the coordinates*/
+Uint1 uWhere; /*where the use clicked (seq, feat, name,...)*/
+Uint2 bsp_eID, bsp_iID;
+Int4 VPos, Shift, SavedVPos, SavedHPos, BlockIndex, NumBlocks;
+Boolean IsUnAligned;
+MsaParaGPopListPtr mpplp;
+SeqAlignPtr sap;
+DDE_StackPtr dsp;
+Int4 Offset, Width;
+BaR hsb;
+RecT rc;
+
+
+ /*get the panel data*/
+ dmp = (DdvMainPtr) GetObjectExtra(p);
+ if (dmp==NULL) return;
+
+ switch(dmp->ms.Action_type){
+ case MS_ACTION_SELECT_FULL_SEQ:
+ ObjectRect(p,&rcP);
+ Line_num=DDV_GetRowGivenMousePos(dmp,&rcP,&pt,&ParaGLine_Num);
+ if (Line_num!=(Int4)-1){
+ UDV_DecodeIdxFeat (dmp->MSA_d.pgp_l.entitiesTbl[ParaGLine_Num-1],
+ &bsp_eID,&bsp_iID);
+ ObjMgrSendMsg(OM_MSG_MOUSEUP, bsp_eID, bsp_iID, OBJ_BIOSEQ);
+ }
+ break;
+ case MS_ACTION_SELECT_SEQ:
+ /* erase outline */
+ InvertMode();
+ rc = DrawOutline(p, dmp->ms.first_row, dmp->ms.first_col,
+ dmp->ms.last_row, dmp->ms.last_col, TRUE);
+ CopyMode();
+ DDV_SelectRegion(dmp, pt, rc, dmp->ms.first_row, dmp->ms.last_row,
+ dmp->ms.first_col, dmp->ms.last_col);
+
+ ObjectRect(p,&rcP);
+ pt.y=dmp->ms.oldPos.y;
+ if (dmp->MSA_d.pgp_l.DisplayType==DDV_DISP_HORZ){
+ if (DDV_GetCoordsGivenAClick(dmp,&rcP,&pt,
+ &bsp_coord,&SeqAlign_coord,&Disp_coord,&Line_num,
+
+ &ParaGLine_Num,&uWhere,&cur_pgp)){
+ if (uWhere==PGP_REGION_SEQ){
+ UDV_DecodeIdxFeat (dmp->MSA_d.pgp_l.entitiesTbl[ParaGLine_Num-1],
+ &bsp_eID,&bsp_iID);
+ ObjMgrSendMsg(OM_MSG_MOUSEUP, bsp_eID, bsp_iID, OBJ_BIOSEQ);
+ /*send a OM_MSG_UPDATE message to move the caret (if needed)*/
+ if (dmp->MouseMode==DDV_MOUSEMODE_EDIT){
+ dump=(DDVUpdateMSGPtr)MemNew(sizeof(DDVUpdateMSG));
+ if (dump){
+ dmp->dci.new_row=Line_num;
+ dmp->dci.new_col=Disp_coord;
+ dump->type=UPDATE_TYPE_CARETPOS;
+ dump->data=NULL;
+ ObjMgrSendProcMsg(OM_MSG_UPDATE, bsp_eID, bsp_iID, OBJ_BIOSEQ,
+ 0,0,(Pointer)dump);
+ MemFree(dump);
+ }
+ }
+ }
+ } else { /* send mouse up anyway */
+ if(ParaGLine_Num > 0) {
+ UDV_DecodeIdxFeat (dmp->MSA_d.pgp_l.entitiesTbl[ParaGLine_Num-1],
+ &bsp_eID,&bsp_iID);
+ ObjMgrSendMsg(OM_MSG_MOUSEUP, bsp_eID, bsp_iID, OBJ_BIOSEQ);
+ }
+ }
+ }
+ break;
+ case MS_ACTION_RESIZE_WIN:
+ temport=SavePort((WindoW)p);
+ Select(p);
+ InvertMode();
+ UDV_draw_double_cursor(dmp->ms.rcClip,
+ dmp->ms.oldPos);
+ /*redraw panel with new 'cxName' value*/
+ if (PtInRect(dmp->ms.newPos,&dmp->ms.rcClip)){
+ RecT rc;
+
+ ObjectRect(p,&rc);
+ rc.left=0;/*for obscure reasons, not == 0*/
+ rc.top=0;
+ dmp->GrData.udv_panel.cxName=dmp->ms.newPos.x;
+ DDV_Resize_DDV(p,FALSE); /*DDV_SetupWin (p,FALSE,NULL); */
+ InvalRect(&rc);
+ }
+ RestorePort(temport);
+ break;
+ case MS_ACTION_MOVE_ROW:
+ ObjectRect(p, &rcP);
+ /* if the mouse is released in sequence name section */
+ if (pt.x<dmp->GrData.udv_panel.cxName &&
+ pt.y>(rcP.top+dmp->GrData.udv_panel.cyScale)){
+ /* get the line number where the mouse is released */
+ Line_num=DDV_GetRowGivenMousePos(dmp, &rcP, &pt,&ParaGLine_Num);
+ if (Line_num != -1) {
+ /* if the line number is valid */
+ if (dmp->dsp->FromRow != Line_num-1) {
+ /* move the saved row to this line number */
+ DDE_MoveRow(dmp->dsp, dmp->dsp->FromRow, Line_num-1, TRUE);
+ dmp->deri.curEditRow = Line_num-1;
+ DDV_ReDraw(dmp);
+ }
+ /* otherwise */
+ else {
+ /* since screen's not redrawn, turn off the last drawn horizontal line */
+ ObjectRect(p, &rcP);
+ rcP2.left = rcP.left;
+ rcP2.right = rcP.left + dmp->GrData.udv_panel.cxName - 10;
+ rcP2.top = rcP.top;
+ rcP2.bottom = rcP.bottom;
+ VPos = DDV_GetVPixelPosGivenRowNumber(dmp, rcP2, dmp->dsp->SaveRow);
+ InvertMode();
+ UDV_draw_horizontal_line(rcP2, VPos);
+ }
+ }
+ }
+ ArrowCursor();
+ break;
+ case MS_ACTION_SHIFT_ROW:
+ /* shift row by diff between original col position and last position */
+ Shift = dmp->dsp->SaveCol - dmp->dsp->FromCol;
+ if (DDE_ShiftRow(dmp->dsp, dmp->dsp->SaveRow, Shift, TRUE, TRUE)) {
+ DDV_ReDraw(dmp);
+ }
+ else {
+ /* if no shift was done, erase the boxes */
+ ObjectRect(p,&rcP);
+ SavedVPos = DDV_GetVPixelPosGivenRowNumber(dmp, rcP, dmp->dsp->SaveRow);
+ SavedHPos = DDV_GetHPixelPosGivenColNumber(dmp, rcP, dmp->dsp->SaveCol);
+ rcP2.left = SavedHPos - dmp->GrData.udv_font.ColWidth;
+ rcP2.right = SavedHPos;
+ rcP2.top = SavedVPos - dmp->GrData.udv_font.LineHeight;
+ rcP2.bottom = SavedVPos;
+ InsetRect(&rcP2, -2, -2);
+ InvalRect(&rcP2);
+ }
+ ArrowCursor();
+ break;
+ case MS_ACTION_SHIFT_BOUNDARY:
+ /* shift boundary by diff between original col position and last position */
+ Shift = dmp->dsp->SaveCol - dmp->dsp->FromCol;
+ if (dmp->dsp->LeftBoundary) {
+ DDE_ShiftLeftBoundary(dmp->dsp, dmp->dsp->BlockIndex, Shift, TRUE);
+ DDV_ReDraw(dmp);
+ }
+ else {
+ DDE_ShiftRightBoundary(dmp->dsp, dmp->dsp->BlockIndex, Shift, TRUE);
+ DDV_ReDraw(dmp);
+ }
+ ArrowCursor();
+ break;
+ case MS_ACTION_CREATE_BLOCK:
+ DDE_CreateBlock(dmp->dsp, dmp->dsp->FromCol, dmp->dsp->SaveCol, TRUE);
+ dmp->MouseMode = dmp->SavedMouseMode;
+ DDV_ReDraw(dmp);
+ ArrowCursor();
+ break;
+ case MS_ACTION_SPLIT_BLOCK:
+ /* get block and alignment for last saved col */
+ /* also get offset into block and width of block */
+ GetBlockAndAlignmentForCol(dmp, dmp->SaveCol, &BlockIndex, &IsUnAligned, &Offset, &Width);
+ /* if col is in aligned region */
+ if (!IsUnAligned && (Offset < (Width-1))) {
+ /* create a stack for the block */
+ sap = ViewMgr_GetBeginIndexed(dmp->MSA_d.pgp_l.sap);
+ dmp->MSA_d.pgp_l.viewed_sap = dmp->MSA_d.pgp_l.sap;
+ mpplp = DDE_CreateDisplay(sap, BlockIndex, FALSE, &NumBlocks);
+ dsp = DDE_NewStack(mpplp);
+ DDE_MergeNodesLists(dsp->pEdit);
+ /* record which block is being edited, etc */
+ dsp->LaunchBlock = BlockIndex;
+ dsp->NumBlocks = NumBlocks;
+ dsp->IsUnAligned = IsUnAligned;
+ /* shift right boundary of block left, to the split line */
+ DDE_ShiftRightBoundary(dsp, 0, -(Width-(Offset+1)), FALSE);
+ /* tell AlnMgr to save edits, don't redraw yet */
+ dmp->dsp = dsp;
+ DDV_SaveEdits(dmp, FALSE);
+ /* free stack for block. create stack for unaligned region to right of block */
+ DDE_FreeStack(dsp);
+ sap = ViewMgr_GetBeginIndexed(dmp->MSA_d.pgp_l.sap);
+ dmp->MSA_d.pgp_l.viewed_sap = dmp->MSA_d.pgp_l.sap;
+ mpplp = DDE_CreateDisplay(sap, BlockIndex+1, TRUE, &NumBlocks);
+ dsp = DDE_NewStack(mpplp);
+ DDE_MergeNodesLists(dsp->pEdit);
+ /* create new block of part that was just unaligned */
+ DDE_CreateBlock(dsp, 0, (Width-(Offset+1)-1), FALSE);
+ /* tell AlnMgr to save edits, now redraw */
+ dmp->dsp = dsp;
+ DDV_SaveEdits(dmp, TRUE);
+ /* free remaining stack */
+ dsp = DDE_FreeStack(dsp);
+ dmp->dsp = dsp;
+ dmp->MouseMode = dmp->SavedMouseMode;
+ }
+ /* get rid of vertical bar */
+ else {
+ hsb = GetSlateHScrollBar((SlatE) dmp->hWndDDV);
+ DDV_ReDrawAtCol(dmp, GetBarValue(hsb), FALSE);
+ }
+ }
+
+ ClearUDV_mouse_select(&(dmp->ms));
+ dmp->ms.Action_type=MS_ACTION_FEAT_NOTHING;
+ /*update InfoPanel*/
+ dmwp=(DdvMainWinPtr)GetObjectExtra(dmp->hParent);
+ if (dmp->bEditor) {
+ DDV_GreyOut(dmwp, DDE_AtStartOfStack(dmp->dsp), DDE_AtEndOfStack(dmp->dsp));
+ }
+ if (dmwp && dmp->MouseMode!=DDV_MOUSEMODE_EDIT)
+ SetTitle(dmwp->InfoPanel,"Ready !");
+
+ if (dmp->MouseMode != DDV_MOUSEMODE_MERGEBLOCKS2)
+ ArrowCursor();
+}
+
+/*****************************************************************************
+
+Function: DDV_HoldProc()
+
+Purpose: manage Mouse-Hold
+
+Parameters: p; panel handle (currently unused)
+ pt; new position
+
+Return value: none
+
+*****************************************************************************/
+NLM_EXTERN void DDV_HoldProc(PaneL p, PoinT pt)
+{
+DdvMainPtr dmp;
+RecT rcP;
+ParaGPtr cur_pgp=NULL;
+Int4 Disp_coord_stop;
+Int4 Line_num_stop;
+Int4 from_col, to_col, from_row, to_row;
+Boolean Scroll=FALSE;
+
+ /*get the panel data*/
+ dmp = (DdvMainPtr) GetObjectExtra(p);
+ if (dmp==NULL) return;
+
+ /*what is happening ?*/
+ switch(dmp->ms.Action_type){
+ case MS_ACTION_SELECT_SEQ:
+ if (shftKey) break;
+ ObjectRect(p,&rcP);
+ /*get the ParaG list and look for the ParaG where the mouse is located*/
+ /*note : only implemented for DDV_DISP_HORZ type of display...*/
+ if (dmp->MSA_d.pgp_l.DisplayType==DDV_DISP_HORZ) {
+ /* get line num and col for current mouse position */
+ DDV_GetRowAndColGivenPt(dmp, rcP, pt, &Disp_coord_stop, &Line_num_stop);
+ /* force single row selection when needed */
+ if (dmp->MouseMode == DDV_MOUSEMODE_SELECT_ONE_ROW) Line_num_stop = dmp->ms.first_row;
+ /* erase the old rectangle */
+ InvertMode();
+ DrawOutline(p, dmp->ms.first_row, dmp->ms.first_col,
+ dmp->ms.last_row, dmp->ms.last_col, TRUE);
+ /* get display info */
+ DDV_GetCurrentDispRange(dmp->hWndDDV,&(dmp->GrData),
+ dmp->MSA_d.pgp_l.LengthAli,&from_col,&to_col,&from_row,&to_row);
+ /* draw the new rectangle after scrolling */
+ DDV_AutoHScroll(dmp, Disp_coord_stop);
+ DDV_AutoVScroll(dmp, Line_num_stop);
+ CopyMode();
+ DrawOutline(p, dmp->ms.first_row, dmp->ms.first_col,
+ Line_num_stop, Disp_coord_stop, TRUE);
+ /* display info about residues that mouse is over */
+ DDV_DispStatus(dmp, Line_num_stop, dmp->ms.first_col, Disp_coord_stop);
+ }
+ break;
+ case MS_ACTION_RESIZE_WIN:
+ case MS_ACTION_SELECT_FULL_SEQ:
+ break;
+ }/*end switch()*/
+}
+
+/*****************************************************************************
+
+Function: DDV_MoveCaretLR()
+
+Purpose: move the caret to the right or to the left
+
+Parameters:
+
+Return value: none
+
+*****************************************************************************/
+static void DDV_MoveCaretLR(DdvMainPtr dmp,Int4 decal_Hscroll,
+ Boolean bMoveRight,BaR hsb,Int4 old_Hpos,Int4 from_col,Int4 to_col)
+{
+DDVUpdateMSGPtr dump;
+Uint2 bsp_eID, bsp_iID;
+Int4 shift, new_from_col, new_to_col;
+
+ dump=(DDVUpdateMSGPtr)MemNew(sizeof(DDVUpdateMSG));
+ if (dump){
+ /*get bsp IDs*/
+ UDV_DecodeIdxFeat(dmp->MSA_d.pgp_l.entitiesTbl[dmp->dci.new_row-1],
+ &bsp_eID,&bsp_iID);
+ /*save old position*/
+ dmp->dci.old_col=dmp->dci.new_col;
+ dmp->dci.old_row=dmp->dci.new_row;
+ /*update the position*/
+ if (bMoveRight)
+ dmp->dci.new_col+=decal_Hscroll;
+ else
+ dmp->dci.new_col-=decal_Hscroll;
+ if (dmp->dci.new_col<0){
+ dmp->dci.new_col=0;
+ Beep();
+ return;
+ }
+ if (dmp->dci.new_col>dmp->MSA_d.pgp_l.LengthAli-1){
+ dmp->dci.new_col=dmp->MSA_d.pgp_l.LengthAli-1;
+ Beep();
+ return;
+ }
+ /*auto-scroll the panel if needed*/
+ if (dmp->dci.new_col<=from_col){
+ shift = (to_col-from_col)/2;
+ new_from_col = from_col - shift;
+ new_to_col = to_col - shift;
+ if ((dmp->dci.new_col >= new_from_col) && (dmp->dci.new_col <= new_to_col)) {
+ /* shift left by 1/2 the window width */
+ SetValue(hsb,old_Hpos-shift);
+ }
+ else {
+ /* shifting by more than 1/2 the window width */
+ SetValue(hsb, dmp->dci.new_col);
+ }
+ }
+ if (dmp->dci.new_col>=to_col){
+ shift = (to_col-from_col)/2;
+ new_from_col = from_col + shift;
+ new_to_col = to_col + shift;
+ if ((dmp->dci.new_col >= new_from_col) && (dmp->dci.new_col <= new_to_col)) {
+ /* shift right by 1/2 the window width */
+ SetValue(hsb,old_Hpos+shift);
+ }
+ else {
+ /* shifting by more than 1/2 the window width */
+ SetValue(hsb, dmp->dci.new_col);
+ }
+ }
+ /*if ok, move the caret*/
+ dump->type=UPDATE_TYPE_CARETPOS;
+ dump->data=NULL;
+ ObjMgrSendProcMsg(OM_MSG_UPDATE, bsp_eID, bsp_iID, OBJ_BIOSEQ,
+ 0,0,(Pointer)dump);
+ MemFree(dump);
+ }
+}
+
+/*****************************************************************************
+
+Function: DDV_MoveCaretUD()
+
+Purpose: move the caret up or down
+
+Parameters:
+
+Return value: none
+
+*****************************************************************************/
+static void DDV_MoveCaretUD(DdvMainPtr dmp,Int4 decal_Vscroll,
+ Boolean bMoveDown,BaR vsb,Int4 old_Vpos,Int4 from_row,Int4 to_row)
+{
+DDVUpdateMSGPtr dump;
+Uint2 bsp_eID, bsp_iID;
+Int4 shift;
+
+ dump=(DDVUpdateMSGPtr)MemNew(sizeof(DDVUpdateMSG));
+ if (dump){
+ /*get bsp IDs*/
+ UDV_DecodeIdxFeat(dmp->MSA_d.pgp_l.entitiesTbl[dmp->dci.new_row-1],
+ &bsp_eID,&bsp_iID);
+ /*save old position*/
+ dmp->dci.old_row=dmp->dci.new_row;
+ dmp->dci.old_col=dmp->dci.new_col;
+ /*update the position*/
+ if (bMoveDown)
+ dmp->dci.new_row+=decal_Vscroll;
+ else
+ dmp->dci.new_row-=decal_Vscroll;
+
+ if (dmp->dci.new_row<1){
+ dmp->dci.new_row=1;
+ SetValue(vsb, 0);
+ Beep();
+ goto send_msg;
+ }
+ if (dmp->dci.new_row>dmp->MSA_d.pgp_l.nBsp){
+ dmp->dci.new_row=dmp->MSA_d.pgp_l.nBsp;
+ SetValue(vsb, dmp->MSA_d.pgp_l.nBsp);
+ Beep();
+ goto send_msg;
+ }
+
+ /*auto-scroll the panel if needed*/
+ if (ABS(decal_Vscroll) == 1) {
+ if (dmp->dci.new_row<=from_row){
+ shift = (to_row-from_row)/2;
+ SetValue(vsb, old_Vpos-shift);
+ }
+ if (dmp->dci.new_row>=to_row-1){
+ shift = (to_row-from_row)/2;
+ SetValue(vsb, old_Vpos+shift);
+ }
+ }
+ else {
+ if (bMoveDown) {
+ SetValue(vsb, old_Vpos+decal_Vscroll);
+ }
+ else {
+ SetValue(vsb, old_Vpos-decal_Vscroll);
+ }
+ }
+
+ /*if ok, move the caret*/
+send_msg:
+ dump->type=UPDATE_TYPE_CARETPOS;
+ dump->data=NULL;
+ ObjMgrSendProcMsg(OM_MSG_UPDATE, bsp_eID, bsp_iID, OBJ_BIOSEQ,
+ 0,0,(Pointer)dump);
+ MemFree(dump);
+ }
+}
+
+/*****************************************************************************
+
+Function: DDV_KeyboardProc()
+
+Purpose: manage keyboard actions
+
+Parameters: s; panel handle (DDV panel)
+ ch; key
+
+Return value: none
+
+*****************************************************************************/
+NLM_EXTERN void DDV_KeyboardProc (SlatE s, Char ch)
+{
+DdvMainWinPtr dmwp; /*main window*/
+DdvMainPtr dmp; /*DDV panel associated data*/
+BaR hsb,vsb; /*DDV' scroll bars*/
+Int4 old_Hpos,old_Vpos,/*scrolls positions*/
+ decal_Hscroll,decal_Vscroll,/*used to scroll DDV's panel*/
+ from_col,to_col,from_row,to_row,/*display size*/
+ bsp_pos, height;
+
+ if ( (int) ch == 0 ) return;
+
+ /*get the panel data*/
+ dmp = (DdvMainPtr) GetObjectExtra(s);
+ if (dmp==NULL) return;
+ dmwp = (DdvMainWinPtr) GetObjectExtra(dmp->hParent);
+ if (dmwp == NULL) return;
+
+ /*get scroll handles and data*/
+ hsb = GetSlateHScrollBar ((SlatE) dmp->hWndDDV);
+ old_Hpos=GetBarValue(hsb);
+ vsb = GetSlateVScrollBar ((SlatE) dmp->hWndDDV);
+ old_Vpos=GetBarValue(vsb);
+
+ /*get the display size*/
+ DDV_GetCurrentDispRange(dmp->hWndDDV,&(dmp->GrData),
+ dmp->MSA_d.pgp_l.LengthAli,&from_col,&to_col,&from_row,&to_row);
+
+ /*if pressed, scroll panel by one 'panel' size*/
+ if (ctrlKey) {
+ decal_Hscroll=to_col-from_col;
+ decal_Vscroll=to_row-from_row;
+ }
+ else{
+ decal_Hscroll=1;
+ decal_Vscroll=1;
+ }
+
+ /*switch to one-bsed value because dmp->dci values
+ are one-based values*/
+ from_row++;to_row++;
+
+ switch ((int) TO_UPPER(ch)){
+ case NLM_PREV:
+ /* page-up -- scoll page up one page height */
+ height = (to_row-from_row) - 1;
+ if (dmp->MouseMode==DDV_MOUSEMODE_EDIT) {
+ DDV_MoveCaretUD(dmp, height, FALSE, vsb, old_Vpos, from_row, to_row);
+ }
+ else {
+ SetValue(vsb, old_Vpos - height);
+ }
+ break;
+ case NLM_NEXT:
+ /* page-down -- scoll page down one page height */
+ height = (to_row-from_row) - 1;
+ if (dmp->MouseMode==DDV_MOUSEMODE_EDIT) {
+ DDV_MoveCaretUD(dmp, height, TRUE, vsb, old_Vpos, from_row, to_row);
+ }
+ else {
+ SetValue(vsb, old_Vpos + height);
+ }
+ break;
+ case NLM_HOME:
+ /* for home key, move cursor to start of row */
+ if (dmp->MouseMode==DDV_MOUSEMODE_EDIT){
+ /* move caret left by current col pos */
+ DDV_MoveCaretLR(dmp, dmp->dci.new_col, FALSE, hsb, old_Hpos, from_col, to_col);
+ }
+ else {
+ SetValue(hsb, 0);
+ }
+ break;
+ case NLM_END:
+ /* for end key, move cursor to end of row */
+ if (dmp->MouseMode==DDV_MOUSEMODE_EDIT){
+ /* move caret right by diff between last col and current col */
+ DDV_MoveCaretLR(dmp, ((dmp->MSA_d.pgp_l.LengthAli-1) - dmp->dci.new_col), TRUE,
+ hsb, old_Hpos, from_col, to_col);
+ }
+ else {
+ SetValue(hsb, dmp->MSA_d.pgp_l.LengthAli-1);
+ }
+ break;
+ case 0x1a:
+ /* for ctrl-z, undo the last edit */
+ if (DDE_Prev(dmp->dsp)) {
+ DDV_ReDraw(dmp);
+ }
+ break;
+ case 0x19:
+ /* for ctrl-y, redo the last undone edit */
+ if (DDE_Next(dmp->dsp)) {
+ DDV_ReDraw(dmp);
+ }
+ break;
+ case NLM_DEL:
+ /* delete key pressed -- remove a gap and leave carat in place */
+ if (dmp->MouseMode==DDV_MOUSEMODE_EDIT){
+ if (DDE_RemoveGap(dmp->dsp, dmp->dci.new_row-1, dmp->dci.new_col+1, TRUE)) {
+ DDV_ReDraw(dmp);
+ }
+ }
+ break;
+ case 0x08:
+ /* backspace key pressed -- remove gap to the left and move carat left */
+ if (dmp->MouseMode==DDV_MOUSEMODE_EDIT){
+ if (DDE_RemoveGap(dmp->dsp, dmp->dci.new_row-1, dmp->dci.new_col, TRUE)) {
+ DDV_ReDraw(dmp);
+ }
+ }
+ case NLM_LEFT:
+ /*move the caret ?*/
+ if (dmp->MouseMode==DDV_MOUSEMODE_EDIT){
+ decal_Hscroll=1;/*doesn't accept ctrlKey motions*/
+ DDV_MoveCaretLR(dmp,decal_Hscroll,FALSE,hsb,old_Hpos,
+ from_col,to_col);
+ }
+ /*scroll the panel*/
+ else{
+ SetValue(hsb,old_Hpos-decal_Hscroll);
+ }
+ break;
+ case 0x20:
+ /* space bar pressed -- insert a gap and move carat to the right */
+ if (dmp->MouseMode==DDV_MOUSEMODE_EDIT){
+ if (DDE_InsertGap(dmp->dsp, dmp->dci.new_row-1, dmp->dci.new_col+1, TRUE)) {
+ DDV_ReDraw(dmp);
+ }
+ }
+ case NLM_RIGHT:
+ /*move the caret ?*/
+ if (dmp->MouseMode==DDV_MOUSEMODE_EDIT){
+ decal_Hscroll=1;/*doesn't accept ctrlKey motions*/
+ DDV_MoveCaretLR(dmp,decal_Hscroll,TRUE,hsb,old_Hpos,
+ from_col,to_col);
+ }
+ /*scroll the panel*/
+ else {
+ SetValue(hsb,old_Hpos+decal_Hscroll);
+ }
+ break;
+ case NLM_UP:
+ /*move the caret ?*/
+ if (dmp->MouseMode==DDV_MOUSEMODE_EDIT){
+ decal_Vscroll=1;/*doesn't accept ctrlKey motions*/
+ DDV_MoveCaretUD(dmp,decal_Vscroll,FALSE,vsb,old_Vpos,
+ from_row,to_row);
+ }
+ /*scroll the panel*/
+ else{
+ SetValue(vsb,old_Vpos-decal_Vscroll);
+ }
+ break;
+ case NLM_DOWN:
+ /*move the caret ?*/
+ if (dmp->MouseMode==DDV_MOUSEMODE_EDIT){
+ decal_Vscroll=1;/*doesn't accept ctrlKey motions*/
+ DDV_MoveCaretUD(dmp,decal_Vscroll,TRUE,vsb,old_Vpos,
+ from_row,to_row);
+ }
+ /*scroll the panel*/
+ else{
+ SetValue(vsb,old_Vpos+decal_Vscroll);
+ }
+ break;
+ default:
+ Beep ();
+ break;
+ }
+ if (dmp->bEditor) {
+ DDV_GreyOut(dmwp, DDE_AtStartOfStack(dmp->dsp), DDE_AtEndOfStack(dmp->dsp));
+ }
+
+ /*update InfoPanel with position*/
+ if (dmwp && dmp->MouseMode==DDV_MOUSEMODE_EDIT){
+ Char szAccess[21];
+ DDV_GetSeqNameGivenRow(dmp->MSA_d.pgp_l.TableHead, dmp->dci.new_row,
+ szAccess);
+ bsp_pos=DDV_GetBspCoordGivenPgpList(
+ dmp->MSA_d.pgp_l.TableHead[dmp->dci.new_row-1],
+ dmp->dci.new_col);
+ if (bsp_pos!=(Int4)-1){
+ DDV_DispPositionInStatus(dmwp->InfoPanel,
+ bsp_pos+1,dmp->dci.new_row,szAccess);
+ /*+1 : switch to one-based value*/
+ }
+ }
+}
+
+
+NLM_EXTERN void DDV_ReDrawAtCol(DdvMainPtr dmp, Int4 Col, Boolean DDE) {
+/*------------------------------------------
+* resize, redraw.
+*------------------------------------------*/
+ DdvMainWinPtr dmwp;
+ WindoW temport;
+ RecT rcP;
+ BaR hsb;
+ Int4 NumBlocks;
+
+ if (DDE) {
+ MemCopy(&(dmp->MSA_d.pgp_l), dmp->dsp->pEdit->pPopList, sizeof(MsaParaGPopList));
+ }
+
+ DDV_InitColour_When_Start(dmp->MSA_d.pgp_l.sap,
+ &(dmp->MSA_d.pgp_l),&(dmp->Globals.colorp), FALSE);
+ /* recalculate window size */
+ DDV_WhatSize(dmp);
+ /* adjust horizontal scroll bar */
+ hsb = GetSlateHScrollBar((SlatE) dmp->hWndDDV);
+ DDV_UpdateHScrollVal(dmp->hWndDDV, FALSE, GetBarValue(hsb));
+
+ dmwp=(DdvMainWinPtr)GetObjectExtra(dmp->hParent);
+ temport=SavePort(dmwp->hWndDDV);
+ Select(dmwp->hWndDDV);
+ ObjectRect(dmwp->hWndDDV, &rcP);
+ InvalRect(&rcP);
+ if (Col >= 0) {
+ SetValue(hsb, Col);
+ }
+ Update();
+ RestorePort(temport);
+
+ if (DDE) {
+ /* decide about greying out undo and redo functions */
+ DDV_GreyOut(dmwp, DDE_AtStartOfStack(dmp->dsp), DDE_AtEndOfStack(dmp->dsp));
+
+ /* decide about greying out left/right/center functions */
+ NumBlocks = DDE_GetNumBlocks(dmp->dsp->pEdit);
+ if (NumBlocks == 0) {
+ Enable(dmwp->MainMenu.Justify);
+ }
+ else {
+ Disable(dmwp->MainMenu.Justify);
+ }
+ }
+
+ return;
+}
+
+
+NLM_EXTERN void DDV_ReDraw(DdvMainPtr dmp) {
+/*------------------------------------------
+* resize, redraw.
+*------------------------------------------*/
+ /* give an illegal column so the column's not set */
+ /* specify that this redraw is for DDE */
+ DDV_ReDrawAtCol(dmp, -1, TRUE);
+}
+
+
+static void DDV_SelectRegion(DdvMainPtr dmp, PoinT pt, RecT rc,
+ Int4 row_start, Int4 row_stop,
+ Int4 col_start, Int4 col_stop) {
+/*----------------------------------------------------------------------------
+* select from row_start to row_stop between columns col_start and col_stop.
+* rows are 1-based, cols are 0-based. why? go figure.
+*
+*----------------------------------------------------------------------------*/
+ Int4 row;
+ Uint1 uWhere;
+ ParaGPtr pgp;
+
+ if (row_start > row_stop) swap(&row_start, &row_stop);
+ if (row_start < 1) row_start=1;
+ if (row_stop > dmp->MSA_d.pgp_l.nBsp) row_stop=dmp->MSA_d.pgp_l.nBsp;
+
+ for (row=row_start; row<=row_stop; row++) {
+ /* send message to select all intervening columns on this row */
+ pgp = DDV_GetPGPGivenRowAndCol(dmp, row, col_stop);
+ uWhere = DDV_GetRegionInParaG(pgp, row);
+ if (uWhere == PGP_REGION_SEQ) {
+ DDV_SendBSPSelectMsg(dmp, col_start, col_stop, row, TRUE);
+ }
+ }
+
+ /* redraw section that's been highlighted */
+/*
+ InsetRect(&rc, -4, -4);
+ InvalRect(&rc);
+ Update();
+*/
+}
diff --git a/ddv/ddvclick.h b/ddv/ddvclick.h
new file mode 100644
index 00000000..ec82166f
--- /dev/null
+++ b/ddv/ddvclick.h
@@ -0,0 +1,152 @@
+/* $Id: ddvclick.h,v 1.10 2000/07/12 15:38:08 hurwitz Exp $
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information (NCBI)
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government do not place any restriction on its use or reproduction.
+* We would, however, appreciate having the NCBI and the author cited in
+* any work or product based on this material
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* ===========================================================================
+*
+* File Name: ddvclick.h
+*
+* Author: Patrick Durand
+*
+* Version Creation Date: 09/20/99
+*
+* $Revision: 1.10 $
+*
+* File Description:
+*
+* Modifications:
+* --------------------------------------------------------------------------
+* $Log: ddvclick.h,v $
+* Revision 1.10 2000/07/12 15:38:08 hurwitz
+* made rectangle select much faster. it's almost working.
+*
+* Revision 1.9 2000/07/08 20:43:58 vakatov
+* Get all "#include" out of the 'extern "C" { }' scope; other cleanup...
+*
+* Revision 1.8 2000/07/05 19:23:13 lewisg
+* add two panes to ddv, update msvc project files
+*
+* Revision 1.7 2000/07/05 18:42:16 hurwitz
+* added split block function to DDV
+*
+* Revision 1.6 2000/05/05 20:24:13 hurwitz
+* some bug fixes, also redraw proper block in DDE after a save operation that causes a merge of 2 blocks
+*
+* Revision 1.5 2000/05/04 22:43:38 hurwitz
+* don't launch DDE on top of DDV, change some wording, redraw DDE after save to AlnMgr
+*
+* Revision 1.4 2000/04/05 20:52:35 hurwitz
+* added GUI control for shifting left and right alignment boundaries
+*
+* Revision 1.3 1999/12/07 21:40:14 durand
+* add mouse modes menu and caret facility for the editor
+*
+* Revision 1.2 1999/10/29 14:15:39 durand
+* add simple mouse selection functions
+*
+* Revision 1.1 1999/09/30 14:10:25 durand
+* add ddv to toolkit
+*
+* Revision 1.2 1999/09/22 20:41:18 durand
+* add mouse-click and drag functions
+*
+* Revision 1.1 1999/09/21 14:20:00 durand
+* add basic mouse management functions
+*
+*
+*
+*
+* ==========================================================================
+*/
+
+#ifndef _DDVCLICK_
+#define _DDVCLICK_
+
+#include <ddvmain.h>
+
+#undef NLM_EXTERN
+#ifdef NLM_IMPORT
+#define NLM_EXTERN NLM_IMPORT
+#else
+#define NLM_EXTERN extern
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/******************************************************************************
+
+ structures
+
+******************************************************************************/
+
+/******************************************************************************
+
+ defines
+
+******************************************************************************/
+/*identifiers of the regions within a ParaG*/
+#define PGP_REGION_NOWHERE ((Uint1)1)
+#define PGP_REGION_SEQ ((Uint1)2)
+#define PGP_REGION_FEAT ((Uint1)3)
+
+/******************************************************************************
+
+ Exported functions
+
+******************************************************************************/
+NLM_EXTERN void DDV_DispPositionInStatus(PrompT InfoPanel,Int4 bsp_pos,
+ Int4 line_num,CharPtr szSeqName);
+NLM_EXTERN void DDV_GetSeqNameGivenRow(ValNodePtr * ParaG_List, Int4 row_num,
+ CharPtr szSeqName);
+NLM_EXTERN void DDV_ClickProcUpper(PaneL p, PoinT pt);
+NLM_EXTERN void DDV_ClickProcLower(PaneL p, PoinT pt);
+NLM_EXTERN void DDV_ClickProc(PaneL p, PoinT pt);
+NLM_EXTERN void DDV_DragProc(PaneL p, PoinT pt);
+NLM_EXTERN void DDV_HoldProc(PaneL p, PoinT pt);
+NLM_EXTERN void DDV_ReleaseProc(PaneL p, PoinT pt);
+NLM_EXTERN void DDV_KeyboardProc (SlatE s, Char ch);
+NLM_EXTERN Int4 DDV_GetHPixelPosGivenColNumber(DdvMainPtr dmp, RecT rc, Int4 Col);
+NLM_EXTERN Int4 DDV_GetHPixelPosGivenColNumberAndScroll(DdvMainPtr dmp, RecT rc,
+ Int4 Col, Int4 ScrollPos);
+NLM_EXTERN Int4 DDV_GetVPixelPosGivenRowNumber(DdvMainPtr dmp, RecT rc, Int4 Row);
+NLM_EXTERN Int4 DDV_GetVPixelPosGivenRowNumberAndScroll(DdvMainPtr dmp, RecT rc,
+ Int4 Row, Int4 ScrollPos);
+NLM_EXTERN void DDV_GetVPixelPosOfEmptySpace(DdvMainPtr dmp, RecT rc, Int4* pTop, Int4* pBot);
+NLM_EXTERN Int4 DDV_GetColNumberGivenMousePos(DdvMainPtr dmp, RecT rc, PoinT pt);
+NLM_EXTERN void DDV_ReDraw(DdvMainPtr dmp);
+NLM_EXTERN void DDV_ReDrawAtCol(DdvMainPtr dmp, Int4 Col, Boolean DDE);
+
+#ifdef __cplusplus
+}
+#endif
+
+#undef NLM_EXTERN
+#ifdef NLM_EXPORT
+#define NLM_EXTERN NLM_EXPORT
+#else
+#define NLM_EXTERN
+#endif
+
+#endif /* ndef _DDVCLICK_ */
+
diff --git a/ddv/ddvcreate.c b/ddv/ddvcreate.c
new file mode 100644
index 00000000..6964e70f
--- /dev/null
+++ b/ddv/ddvcreate.c
@@ -0,0 +1,3439 @@
+/* $Id: ddvcreate.c,v 1.66 2001/02/01 00:39:53 lewisg Exp $
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information (NCBI)
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government do not place any restriction on its use or reproduction.
+* We would, however, appreciate having the NCBI and the author cited in
+* any work or product based on this material
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* ===========================================================================
+*
+* File Name: ddvcreate.c
+*
+* Author: Sarah Wheelan
+*
+* Version Creation Date: 08/99
+*
+* $Revision: 1.66 $
+*
+* File Description:
+*
+* Modifications:
+* --------------------------------------------------------------------------
+* $Log: ddvcreate.c,v $
+* Revision 1.66 2001/02/01 00:39:53 lewisg
+* fix leak
+*
+* Revision 1.65 2001/01/29 20:35:49 hurwitz
+* make gap between aligned blocks optional
+*
+* Revision 1.64 2001/01/25 21:49:14 hurwitz
+* added option for extra gap char (tilde) between aligned blocks
+*
+* Revision 1.63 2001/01/19 22:05:40 wheelan
+* took out small spaces created by UABuildDescriptor
+*
+* Revision 1.62 2001/01/10 23:38:39 lewisg
+* fix seqid and various memory leaks
+*
+* Revision 1.61 2000/09/08 21:50:38 hurwitz
+* made DDV_ReadSeqBin public
+*
+* Revision 1.60 2000/09/06 17:41:26 shavirin
+* Fixed bug with printing gaps with discontinuous alignment.
+*
+* Revision 1.59 2000/08/25 18:55:27 shavirin
+* Changed layout - unaligned regions will be always in lower characters.
+*
+* Revision 1.58 2000/08/22 19:59:28 shavirin
+* Changed layout no.1 - it will be used for standalone blast with
+* decline-to-align parameter not = 0
+*
+* Revision 1.57 2000/07/19 18:46:19 bauer
+* Fixed bug in DDV_CreateDisplayFromIndex_EX
+*
+* Revision 1.56 2000/06/29 23:15:13 hurwitz
+* leave single space between aligned blocks with no unaligned sequence between them, no auto-merge of adjacent aligned blocks
+*
+* Revision 1.55 2000/06/22 20:56:52 hurwitz
+* assorted bug fixes
+*
+* Revision 1.54 2000/06/13 18:23:55 hurwitz
+* made ViewMgr_MakeMultiple routine, call this on each launch of DDE rather than launch of DDV
+*
+* Revision 1.53 2000/06/12 23:02:40 hurwitz
+* enable launch of DDE from Cn3D, swith from DDV_ComputeRuler to DDE_ReMakeRuler, get rid of styles option for DDE
+*
+* Revision 1.52 2000/06/08 20:04:38 hurwitz
+* made warning about converting to true multiple alignment into a Message window, and other small fixes
+*
+* Revision 1.51 2000/06/07 19:09:36 hurwitz
+* made DDE_ReMakeRuler work with linked list of ParaGs
+*
+* Revision 1.50 2000/05/10 16:17:00 hurwitz
+* can show tails for just 1 aligned block
+*
+* Revision 1.49 2000/05/08 13:16:00 wheelan
+* replaced segment-based counting with block-based counting
+*
+* Revision 1.48 2000/05/04 22:43:38 hurwitz
+* don't launch DDE on top of DDV, change some wording, redraw DDE after save to AlnMgr
+*
+* Revision 1.47 2000/05/03 19:34:38 wheelan
+* added fix for NULL alignments
+*
+* Revision 1.46 2000/05/03 14:51:02 thiessen
+* revert to ~ gap char for Cn3D
+*
+* Revision 1.45 2000/04/21 23:00:50 hurwitz
+* can launch DDE from DDV
+*
+* Revision 1.44 2000/04/19 19:08:23 hurwitz
+* problem with justification of flanking unaligned regions fixed
+*
+* Revision 1.43 2000/04/19 15:45:50 hurwitz
+* can create display for a block
+*
+* Revision 1.42 2000/04/06 17:59:50 durand
+* fixed a conflict between BLAST and DDV in the use of the function DDV_SetSTyle
+*
+* Revision 1.41 2000/04/04 19:08:00 durand
+* add new BLAST color schemas; fixed a bug in DDV_PopulateDisplayForDisc
+*
+* Revision 1.40 2000/03/31 21:33:07 durand
+* added new default color schemas for BLAST
+*
+* Revision 1.39 2000/03/28 21:20:07 shavirin
+* Adjusted for correct structure of BLAST location mask.
+*
+* Revision 1.38 2000/03/28 17:08:17 durand
+* removed debugging code lines
+*
+* Revision 1.37 2000/03/27 14:19:28 durand
+* fixed bugs in BLAST outputs
+*
+* Revision 1.36 2000/03/21 19:26:45 durand
+* adapt ddvcreate to be used by pgppop
+*
+* Revision 1.35 2000/03/20 13:46:23 durand
+* fixed a bug in BLAST functions; added DDV_BLAST_COLOR0 to produce a BLAST output without any layout
+*
+* Revision 1.34 2000/02/28 16:52:47 durand
+* wrote a new manager for unaligned regions
+*
+* Revision 1.33 2000/02/23 21:34:29 durand
+* allow custom display of gap characters
+*
+* Revision 1.32 2000/02/23 19:49:33 durand
+* use row number instead of SeqId for coloring
+*
+* Revision 1.31 2000/02/17 15:54:56 durand
+* use ~ for an unaligned gap and - for an aligned gap
+*
+* Revision 1.30 2000/02/15 22:40:57 lewisg
+* add ability to launch udv so that it colors by row, fixes to colormgr, track rows from viewmgr, fix visual c projects
+*
+* Revision 1.29 2000/02/14 16:49:33 durand
+* add new options for BLAST output
+*
+* Revision 1.28 2000/02/11 13:58:21 wheelan
+* bug fix for unaligned region of length 0 (Durand)
+*
+* Revision 1.27 2000/02/07 14:03:35 durand
+* replace BioseqUnlockById by BioseqUnlock
+*
+* Revision 1.26 2000/02/05 01:32:22 lewisg
+* add viewmgr, move place freeing is done in ddv, modify visual c++ projects
+*
+* Revision 1.25 2000/02/02 14:44:30 durand
+* added function to create data structure for block editor, fixed some bugs
+*
+* Revision 1.24 2000/01/26 13:38:54 durand
+* update the GUI for the editor. Add functions to create the data to be used by the editor
+*
+* Revision 1.23 1999/12/29 22:55:03 lewisg
+* get rid of seqalign id
+*
+* Revision 1.22 1999/12/20 20:20:41 lewisg
+* allow cn3d to do color and ddv to do case when both are running
+*
+* Revision 1.21 1999/12/20 14:45:37 durand
+* add new functions for the new BLAST outputs
+*
+* Revision 1.20 1999/12/08 22:42:17 durand
+* add the code to produce colored BLAST outputs
+*
+* Revision 1.19 1999/12/03 23:17:22 lewisg
+* Patrick's new global update msg, argument passing when launching ddv, experimental editing
+*
+* Revision 1.18 1999/12/03 18:24:08 durand
+* gapped regions are displayed using lower cases; BLAST outputs
+*
+* Revision 1.17 1999/12/03 13:23:08 durand
+* replace AlnMgrGetNumSeqs by AlnMgrGetNumRows
+*
+* Revision 1.16 1999/12/02 14:46:42 durand
+* fix a bug in UABuildDescriptor; problem with unaligned region of size 0
+*
+* Revision 1.15 1999/11/24 21:26:29 vakatov
+* Fixed for the C++ and/or MSVC DLL compilation
+*
+* Revision 1.14 1999/11/17 22:44:02 durand
+* speed up the selection manager for large SeqAlign
+*
+* Revision 1.13 1999/11/09 22:14:01 shavirin
+* Added parameter follower to the Blast score printing function
+*
+* Revision 1.12 1999/11/09 17:08:59 durand
+* transfer some functions from ddvgraph to ddvcreate, so that ddvcreate remains Vibrant free and can be compiled with BLAST
+*
+* Revision 1.11 1999/11/03 21:29:48 durand
+* add CTRL and SHFT keys for mouse selection. redesign the loader functions of DDV to properly register the message callbacks
+*
+* Revision 1.10 1999/10/29 14:15:40 durand
+* add simple mouse selection functions
+*
+* Revision 1.9 1999/10/22 20:12:47 durand
+* add Export command (text, HTML and Phylip formats)
+*
+* Revision 1.8 1999/10/22 14:57:25 durand
+* use AlnMgrIndexSingleChildSeqAlign to build BLAST output
+*
+* Revision 1.7 1999/10/22 13:17:19 durand
+* remove unreferenced variables to avoid warnings with Visual C
+*
+* Revision 1.6 1999/10/20 13:17:19 durand
+* add display for disc. SeqAlign tails
+*
+* Revision 1.5 1999/10/15 21:57:35 durand
+* add a UI for display options
+*
+* Revision 1.4 1999/10/12 15:01:29 lewisg
+* resolve confict with internal/ddv
+*
+* Revision 1.3 1999/10/07 13:36:08 wheelan
+* bug fixes -- AlnLengths were 1 too long
+*
+* Revision 1.2 1999/10/05 14:04:21 wheelan
+* made DDV_CreateDisplayFromIndex_2, which creates the display for discontinuous alignments; minor bug fixes
+*
+* Revision 1.1 1999/09/30 14:10:25 durand
+* add ddv to toolkit
+*
+* Revision 1.11 1999/09/30 13:38:09 durand
+* DDV_CreateDisplayFromIndex takes ParaG_Size as an argument
+*
+*
+*
+* ==========================================================================
+*/
+#include <ddvcreate.h>
+#include <pgppop.h>
+#include <udvseq.h>
+#include <tofasta.h>
+#include <sqnutils.h>
+
+typedef struct ddvdataforcolorfunc{
+ SeqIdPtr sip;
+ Int4 from;
+ Int4 to;
+ Int4 row;
+ Uint1 strand;
+ Boolean IsUnAligned;
+ Uint1 style;
+ Uint1 rgb[3];
+ Uint1 UAstyle;
+ Uint1 UArgb[3];
+} DDVDataForColorFunc, PNTR DDVDataForColorFuncPtr;
+
+#define MAX_NCBIstdaa 26
+#define MAX_NCBI4na 17
+#define DDVCOL_DEFAULT 0
+#define DDVCOL_HOTPINK 1
+#define DDVCOL_MAGENTA 2
+#define DDVCOL_PURPLE 3
+#define DDVCOL_BLUE 4
+#define DDVCOL_SKY 5
+#define DDVCOL_CYAN 6
+#define DDVCOL_SEA 7
+#define DDVCOL_GREEN 8
+#define DDVCOL_YELLOW 9
+#define DDVCOL_GOLD 10
+#define DDVCOL_ORANGE 11
+#define DDVCOL_RED 12
+#define DDVCOL_PINK 13
+#define DDVCOL_PINKTINT 14
+#define DDVCOL_WHITE 15
+#define DDVCOL_BLACK 16
+#define DDVCOL_BLUETINT 17
+#define DDVCOL_GREENTINT 18
+#define DDVCOL_YELLOWTINT 19
+#define DDVCOL_GRAY 20
+#define DDVCOL_BROWN 21
+#define DDV_COLOR_MAX 33
+ static Uint1 DDV_PaletteRGB[DDV_COLOR_MAX][3] =
+ {
+ /* Red Grn Blue Color ColorID Old Hex New Hex */
+ 255, 255, 255, /* default 0 0xffffff - */
+ 255, 0, 153, /* hotpink 1 0xff1493 0xff0099 */
+ 255, 0, 255, /* magenta 2 0xff00ff - */
+ 153, 51, 255, /* purple 3 0x9b30ff 0x9933ff */
+ 0, 0, 255, /* blue 4 0x0000ff - */
+ 00, 153, 255, /* sky 5 0x1e90ff 0x0099ff */
+ 0, 255, 255, /* cyan 6 0x00ffff - */
+ 0, 255, 153, /* sea 7 0x00ff8f 0x00ff99 */
+ 0, 192, 0, /* green 8 0x00ff00 - */
+ 255, 255, 0, /* yellow 9 0xffff00 - */
+ 255, 204, 0, /* gold 10 0xffa500 0xffcc00 */
+ 255, 102, 0, /* orange 11 0xff4500 0xff6600 */
+ 255, 0, 0, /* red 12 0xff0000 - */
+ 255, 153, 153, /* pink 13 0xff7256 0xff9999 */
+ 255, 204, 204, /* pinktint 14 0xffaeb9 0xffcccc */
+ 255, 255, 255, /* white 15 0xffffff -*/
+ 0, 0, 0, /* black 16 0x000000 - */
+ 204, 204, 255, /* bluetint 17 0xb0e2ff - 0xccccff*/
+ 153, 255, 153, /* greentint 18 0x9aff9a - 0x99ff99 */
+ 255, 255, 153, /* yellowtint 19 0xffec8b - 0xffff99 */
+ 102, 102, 102, /* gray 20 0x7d7d7d 0x666666 */
+ 153, 102, 51, /* brown 21 0x8b5742 01x996633 */
+ 255, 0, 0, /* perm colors 22: red 0xff0000 - */
+ 0, 255, 0, /* perm colors 23: green 0x00ff00 - */
+ 255, 0, 255, /* perm colors 24: magenta 0xff00ff - */
+ 00, 153, 255, /* perm colors 25: sky 0x1e90ff 0x0099ff */
+ 153, 51, 255, /* perm colors 26: purple 0x9b30ff 0x9933ff */
+ 0, 255, 0, /* SS colors 27: helix, green 0x00ff00 - */
+ 255, 204, 0, /* SS colors 28: strand, gold 0xffa500 0xffcc00 */
+ 255, 102, 0, /* SS colors 29: turn, orange 0xff4500 0xff6600 */
+ 0, 255, 255, /* SS colors 30: coil, cyan ox00ffff - */
+ 255, 255, 0, /* highlight colors 31: yellow 0xffff00 - */
+ 0, 0, 0 /* background colors 32: black 0x000000 - */
+ };
+Uint1 DDV_STD_AAColor[MAX_NCBIstdaa] =
+{DDVCOL_BROWN, /*-*/
+DDVCOL_GRAY, /*A*/
+DDVCOL_ORANGE, /*B*/
+DDVCOL_PINK, /*C*/
+DDVCOL_RED, /*D*/
+DDVCOL_RED, /*E*/
+DDVCOL_PURPLE, /*F*/
+DDVCOL_GRAY, /*G*/
+DDVCOL_BLUE, /*H*/
+DDVCOL_GRAY, /*I*/
+DDVCOL_BLUE, /*K*/
+DDVCOL_GRAY, /*L*/
+DDVCOL_PINK, /*M*/
+DDVCOL_CYAN, /*N*/
+DDVCOL_MAGENTA,/*P*/
+DDVCOL_CYAN, /*Q*/
+DDVCOL_BLUE, /*R*/
+DDVCOL_GREEN, /*S*/
+DDVCOL_GREEN, /*T*/
+DDVCOL_GRAY, /*V*/
+DDVCOL_PURPLE, /*W*/
+DDVCOL_GRAY, /*X*/
+DDVCOL_PURPLE, /*Y*/
+DDVCOL_ORANGE, /*Z*/
+DDVCOL_GOLD, /*U*/
+DDVCOL_HOTPINK /***/};
+
+Uint1 DDV_STD_NAColor[MAX_NCBI4na] = {
+DDVCOL_PINK, /* gap */
+DDVCOL_GREEN, /* A */
+DDVCOL_BLUE, /* C */
+DDVCOL_CYAN, /* A or C */
+DDVCOL_BLACK, /* G */
+DDVCOL_CYAN, /* G or A */
+DDVCOL_CYAN, /* G or C */
+DDVCOL_PURPLE, /* G C or A */
+DDVCOL_RED, /* T */
+DDVCOL_CYAN, /* A or T */
+DDVCOL_CYAN, /* T or C */
+DDVCOL_PURPLE, /* A C ot T */
+DDVCOL_CYAN, /* G ot T */
+DDVCOL_PURPLE, /* G or A or T */
+DDVCOL_PURPLE, /* G T or C */
+DDVCOL_HOTPINK,/* G T A or C */
+DDVCOL_GRAY /*?, but MAX_NCBI4na==17, see mmdbapi2.h*/
+};
+
+extern void display_ParaG_content(MsaParaGPopListPtr mpplp,Int2 LineSize)
+{
+BioseqPtr bsp_debug=NULL;
+Char szBuf[15];
+ParaGPtr pgp;
+MsaTxtDispPtr mtdp;
+ValNodePtr vnp,vnp2;
+Uint4 j,k,size,sum;
+FILE *fp;
+Boolean bClose=TRUE;
+Int4 i;
+ if (LineSize<=50)/*just for the integrity of the function...*/
+ LineSize=ParaG_Size;
+
+ fp=fopen("zpgplist.txt","w");
+ if (fp==NULL) {fp=stdout;bClose=FALSE;}
+ for(i=0;i<mpplp->nBsp;i++){
+ /*for each line (i.e. bioseq) */
+ vnp=mpplp->TableHead[i];
+ if (vnp) pgp=(ParaGPtr)(vnp->data.ptrvalue);
+ else pgp=NULL;
+ if(pgp){
+ if (pgp->sip) bsp_debug=BioseqLockById(pgp->sip);
+ else bsp_debug=NULL;
+ if (bsp_debug){
+ /*get the access code*/
+ SeqIdWrite(bsp_debug->id, szBuf, PRINTID_TEXTID_ACCESSION, 14);
+ fprintf(fp,"[%5u] %s , size: %d, IsAA :%d \n",
+ i,szBuf,BioseqGetLen(bsp_debug),
+ ISA_aa(bsp_debug->mol));
+ BioseqUnlock(bsp_debug);
+ }
+ else StringCpy(szBuf,"unknown");
+ }
+ k=1;size=1;
+ while(vnp){
+ pgp=(ParaGPtr)(vnp->data.ptrvalue);
+ if (pgp){/*create the name table*/
+ /*loop on the pgp*/
+ fprintf(fp," ->ParaG[%d] , range (%7d..%7d):\n",k++,size,size+LineSize-1);
+ size+=LineSize;
+ vnp2=pgp->ptxtList;
+ j=1;sum=0;
+ while(vnp2){
+ mtdp=(MsaTxtDispPtr)vnp2->data.ptrvalue;
+ if (mtdp){
+ fprintf(fp," (%4u): range(%7d..%7d) (%2d), Gap: %2d, Strand(%d)\n",
+ j++,mtdp->from,mtdp->to,mtdp->to-mtdp->from+1,mtdp->IsGap,
+ mtdp->strand);
+ }
+ sum+=(mtdp->to-mtdp->from+1);
+ vnp2=vnp2->next;
+ }
+ fprintf (fp," Total = %d.\n",sum);
+ }
+ vnp=vnp->next;
+ }
+ fprintf(fp,"\n");
+ }
+ if (bClose) fclose(fp);
+
+}
+
+static Boolean DDV_CreateDisplayFromIndex_1(SeqAlignPtr sap, MsaParaGPopListPtr mpplp, Int2 LineSize,
+ Int4 start,Int4 stop)
+{
+ AlnMsgPtr amp;
+ Int4 i,from,to;
+ Boolean more;
+ MsaTxtDispPtr mtdp;
+ Int4 n;
+ ParaGPtr pgp;
+ SeqIdPtr sip;
+ ValNodePtr vnp;
+ ValNodePtr vnp_head;
+ ValNodePtr PNTR vnp_list;
+ ValNodePtr vnp_para;
+ ValNodePtr vnp_para_head;
+
+ if (LineSize<=50)/*just for the integrity of the function...*/
+ LineSize=ParaG_Size;
+
+ amp = AlnMsgNew();
+ vnp_list = (ValNodePtr PNTR)MemNew((mpplp->nBsp)*sizeof(ValNodePtr));
+ if (start!=(Int4)-1){
+ from=start;
+ }
+ else{
+ from=0;
+ }
+ if (stop!=(Int4)-1){
+ to=stop+1;
+ }
+ else{
+ to=mpplp->LengthAli;
+ }
+
+ for (n = 1; n<=(mpplp->nBsp); n++)
+ {
+ vnp_para = vnp_para_head = NULL;
+ sip = AlnMgrGetNthSeqIdPtr(mpplp->sap, n);
+ for (i = from; i<to; i+=LineSize)
+ {
+ amp = AlnMsgReNew(amp);
+ pgp = (ParaGPtr)MemNew(sizeof(ParaG));
+ pgp->StartLine = n - 1;
+ pgp->nLines = 1;
+ pgp->StartLetter = amp->from_m = i;
+ if (i + LineSize >= to)
+ pgp->StopLetter = amp->to_m = to - 1;
+ else
+ pgp->StopLetter = amp->to_m = i + LineSize -1;
+ if(i == from) pgp->sip = sip;
+ else pgp->sip = SeqIdDup(sip);
+ pgp->ScaleStyle = SCALE_POS_NONE;
+ amp->which_bsq = NULL;
+ amp->row_num = n;
+ vnp = vnp_head = NULL;
+ amp->place = 0;
+ while (more = AlnMgrGetNextAlnBit(mpplp->sap, amp))
+ {
+ vnp = ValNodeAdd(&vnp);
+ if (!vnp_head)
+ vnp_head = vnp;
+ mtdp = (MsaTxtDispPtr)MemNew(sizeof(MsaTxtDisp));
+ mtdp->from = amp->from_b;
+ mtdp->to = amp->to_b;
+ mtdp->IsGap = (Boolean)(amp->gap);
+ if (mtdp->IsGap)
+ mtdp->TextStyle = MSA_TXT_STYLE_GAP;
+ else
+ mtdp->TextStyle = MSA_TXT_STYLE_SEQ;
+ mtdp->strand = amp->strand;
+ mtdp->IsUnAligned=FALSE;
+ vnp->data.ptrvalue = mtdp;
+ }
+ pgp->ptxtList = vnp_head;
+ vnp_para = ValNodeAdd(&vnp_para);
+ vnp_para->data.ptrvalue = pgp;
+ if (!vnp_para_head)
+ vnp_para_head = vnp_para;
+ }
+ vnp_list[n-1]=vnp_para_head;
+ }
+ mpplp->TableHead = vnp_list;
+ /*display_ParaG_content(mpplp,LineSize);*/
+ DDV_LocateParaG(mpplp->TableHead,mpplp->nBsp);
+ return TRUE;
+}
+
+
+static Boolean DDV_CreateDisplayFromIndex_2(SeqAlignPtr sap, MsaParaGPopListPtr mpplp, Int2 LineSize)
+{
+ AlnMsgPtr amp;
+ Int4 i;
+ Boolean more;
+ MsaTxtDispPtr mtdp;
+ Int4 n;
+ ParaGPtr pgp;
+
+
+ ValNodePtr vnp;
+ ValNodePtr vnp_head;
+ ValNodePtr PNTR vnp_list;
+ ValNodePtr vnp_para;
+ ValNodePtr vnp_para_head;
+ Int4 PopulateTo;
+ Int4 ReportSpacer;
+ Int4 PlaceSpacer;
+ Int4 RealAlnLength;
+ SeqIdPtr sip;
+ Boolean last;
+
+
+ amp = AlnMsgNew();
+ vnp_list = (ValNodePtr PNTR)MemNew((mpplp->nBsp)*sizeof(ValNodePtr));
+ RealAlnLength = AlnMgrGetAlnLength(mpplp->sap, FALSE);
+ for (n = 1; n<=(mpplp->nBsp); n++)
+ {
+ vnp_para = vnp_para_head = NULL;
+ sip = AlnMgrGetNthSeqIdPtr(mpplp->sap, n);
+ ReportSpacer=0;
+ amp->to_m=-1;
+ amp = AlnMsgReNew(amp);
+ last = FALSE;
+ for (i = 0; i<mpplp->LengthAli; i+=LineSize)
+ {
+ amp->place = 0;
+ pgp = (ParaGPtr)MemNew(sizeof(ParaG));
+ pgp->StartLine = n - 1;
+ pgp->nLines = 1;
+ pgp->StartLetter = i;
+ if (i + LineSize >= mpplp->LengthAli)
+ {
+ last = TRUE;
+ pgp->StopLetter = mpplp->LengthAli;
+ }
+ else
+ pgp->StopLetter = i + LineSize -1;
+ if(i == 0) pgp->sip = sip;
+ else pgp->sip = SeqIdDup(sip);
+ pgp->ScaleStyle = SCALE_POS_NONE;
+ amp->which_master = 0;
+ if (amp->to_m != 0)
+ amp->from_m = amp->to_m + 1 ;
+ else
+ amp->from_m = 0;
+ amp->to_m = amp->from_m + LineSize -1;
+ amp->row_num = n;
+ if (amp->to_m > RealAlnLength)
+ amp->to_m = RealAlnLength - 1;
+ more = TRUE;
+ vnp = vnp_head = NULL;
+ PopulateTo=0;
+ PlaceSpacer=0;
+ while (amp->place == 0)
+ {
+ vnp = ValNodeAdd(&vnp);
+ if (!vnp_head)
+ vnp_head = vnp;
+ if (amp->send_space)
+ {
+ if (!last)
+ amp->to_m=amp->to_m - PlaceSpacer;
+ }
+ if (ReportSpacer){
+ amp->to_m -=ReportSpacer;
+ mtdp = (MsaTxtDispPtr)MemNew(sizeof(MsaTxtDisp));
+ mtdp->from = pgp->StartLetter;
+ mtdp->to = mtdp->from+ReportSpacer-1;
+ PopulateTo+=(ReportSpacer+1);
+ ReportSpacer=0;
+ mtdp->IsGap = TRUE;
+ mtdp->TextStyle = MSA_TXT_STYLE_1;
+ vnp->data.ptrvalue = mtdp;
+ vnp = ValNodeAdd(&vnp);
+ }
+ amp->send_space = FALSE;
+ more = AlnMgrGetNextAlnBit(mpplp->sap, amp);
+ mtdp = (MsaTxtDispPtr)MemNew(sizeof(MsaTxtDisp));
+ mtdp->from = amp->from_b;
+ mtdp->to = amp->to_b;
+ PopulateTo+=(amp->to_b-amp->from_b+1);
+ mtdp->IsGap = (Boolean)(amp->gap);
+ if (mtdp->IsGap)
+ mtdp->TextStyle = MSA_TXT_STYLE_GAP;
+ else
+ mtdp->TextStyle = MSA_TXT_STYLE_SEQ;
+ mtdp->strand = amp->strand;
+ vnp->data.ptrvalue = mtdp;
+ if (amp->send_space)
+ {
+ vnp = ValNodeAdd(&vnp);
+ mtdp = (MsaTxtDispPtr)MemNew(sizeof(MsaTxtDisp));
+ mtdp->from = pgp->StartLetter+PopulateTo;
+ mtdp->to = mtdp->from+SPACER_TXT_BLANK-1;
+ if (mtdp->to>pgp->StopLetter){
+ ReportSpacer=mtdp->to-pgp->StopLetter;
+ mtdp->to=pgp->StopLetter;
+ }
+ else{
+ ReportSpacer=0;
+ }
+ PlaceSpacer=SPACER_TXT_BLANK-ReportSpacer;
+ PopulateTo+=(mtdp->to-mtdp->from+1);
+ mtdp->IsGap = TRUE;
+ mtdp->TextStyle = MSA_TXT_STYLE_1;
+ mtdp->IsUnAligned=FALSE;
+ vnp->data.ptrvalue = mtdp;
+ }
+ }
+ pgp->ptxtList = vnp_head;
+ vnp_para = ValNodeAdd(&vnp_para);
+ vnp_para->data.ptrvalue = pgp;
+ if (!vnp_para_head)
+ vnp_para_head = vnp_para;
+ }
+ vnp_list[n-1]=vnp_para_head;
+ }
+ mpplp->TableHead = vnp_list;
+ /*display_ParaG_content(mpplp,LineSize);*/
+ DDV_LocateParaG(mpplp->TableHead,mpplp->nBsp);
+ return TRUE;
+}
+
+
+NLM_EXTERN Boolean DDV_CreateDisplayFromIndex_EX(SeqAlignPtr sap, MsaParaGPopListPtr mpplp,
+ Int2 LineSize, DDV_Disp_OptPtr ddop,Int4 start, Int4 stop) {
+/*******************************************************************************
+* same as DDV_CreateDisplayFromIndex_EX2, but by default no extra gap char.
+*******************************************************************************/
+ return(DDV_CreateDisplayFromIndex_EX2(sap, mpplp, LineSize, ddop, start, stop, FALSE));
+}
+
+
+NLM_EXTERN Boolean DDV_CreateDisplayFromIndex_EX2(SeqAlignPtr sap, MsaParaGPopListPtr mpplp,
+ Int2 LineSize, DDV_Disp_OptPtr ddop,Int4 start, Int4 stop, Boolean WantExtraGapChar)
+{
+ AMAlignIndexPtr amaip;
+ AlnMsgPtr amp;
+ Int4 i,from,to;
+ Boolean more;
+ MsaTxtDispPtr mtdp;
+ Int4 n;
+ ParaGPtr pgp;
+
+
+ ValNodePtr vnp;
+ ValNodePtr vnp_head;
+ ValNodePtr PNTR vnp_list;
+ ValNodePtr vnp_para;
+ ValNodePtr vnp_para_head;
+ Int4 PopulateTo;
+
+
+ SeqIdPtr sip;
+ Boolean last;
+
+ if (LineSize<=50)/*just for the integrity of the function...*/
+ LineSize=ParaG_Size;
+
+ if (!sap)
+ return FALSE;
+ if (!AlnMgrIndexSeqAlign(sap))
+ return FALSE;
+ if (sap->saip->indextype == INDEX_PARENT)
+ {
+ amaip = (AMAlignIndexPtr)sap->saip;
+ if (sap->type == SAT_PARTIAL ||
+ (sap->type == SAT_MASTERSLAVE && (amaip->mstype == AM_SEGMENTED_MASTERSLAVE ||
+ amaip->mstype == AM_NULL ||
+ amaip->mstype == AM_MASTERSLAVE)))
+ {
+ return(DDV_CreateDisplay_DiscAlign2(sap,mpplp,LineSize,ddop,WantExtraGapChar));
+ }
+ else if (sap->type == SAT_MASTERSLAVE && amaip->mstype == AM_MASTERSLAVE)
+ {
+ mpplp->sap = sap;
+ if (start==(Int4)-1 && stop==(Int4)-1)
+ mpplp->LengthAli = AlnMgrGetAlnLength(mpplp->sap, FALSE);
+ else
+ mpplp->LengthAli=stop-start+1;
+ mpplp->nBsp = AlnMgrGetNumRows(mpplp->sap);
+ mpplp->DisplayType = DDV_DISP_HORZ;
+ if (!DDV_CreateDisplayFromIndex_1(sap, mpplp,LineSize,start,stop))
+ return FALSE;
+ else
+ return TRUE;
+ } else
+ mpplp->sap = (SeqAlignPtr)sap->segs;
+ } else
+ mpplp->sap = sap;
+ mpplp->LengthAli = AlnMgrGetAlnLength(mpplp->sap, FALSE);
+ mpplp->nBsp = AlnMgrGetNumRows(mpplp->sap);
+ mpplp->DisplayType = DDV_DISP_HORZ;
+ amp = AlnMsgNew();
+ vnp_list = (ValNodePtr PNTR)MemNew((mpplp->nBsp)*sizeof(ValNodePtr));
+ if (start!=(Int4)-1){
+ from=start;
+ }
+ else{
+ from=0;
+ }
+ if (stop!=(Int4)-1){
+ to=stop+1;
+ }
+ else{
+ to=mpplp->LengthAli;
+ }
+ for (n = 1; n<=(mpplp->nBsp); n++)
+ {
+ vnp_para = vnp_para_head = NULL;
+ sip = AlnMgrGetNthSeqIdPtr(mpplp->sap, n);
+ amp->to_m=-1;
+ amp = AlnMsgReNew(amp);
+ last = FALSE;
+ for (i = from; i<to; i+=LineSize)
+ {
+ amp->place = 0;
+ pgp = (ParaGPtr)MemNew(sizeof(ParaG));
+ pgp->StartLine = n - 1;
+ pgp->nLines = 1;
+ pgp->StartLetter = i;
+ if (i + LineSize >= to)
+ {
+ last = TRUE;
+ pgp->StopLetter = to;
+ }
+ else
+ pgp->StopLetter = i + LineSize -1;
+ if(i == from) pgp->sip = sip;
+ else pgp->sip = SeqIdDup(sip);
+ pgp->ScaleStyle = SCALE_POS_NONE;
+ amp->which_master = 0;
+ if (amp->to_m != 0)
+ amp->from_m = amp->to_m + 1 ;
+ else
+ amp->from_m = 0;
+ amp->to_m = amp->from_m + LineSize -1;
+ amp->row_num = n;
+ if (amp->to_m >= to)
+ amp->to_m = to - 1;
+ more = TRUE;
+ vnp = vnp_head = NULL;
+ PopulateTo=0;
+ while (more = AlnMgrGetNextAlnBit(mpplp->sap, amp))
+ {
+ vnp = ValNodeAdd(&vnp);
+ if (!vnp_head)
+ vnp_head = vnp;
+ mtdp = (MsaTxtDispPtr)MemNew(sizeof(MsaTxtDisp));
+ mtdp->from = amp->from_b;
+ mtdp->to = amp->to_b;
+ mtdp->IsGap = (Boolean)(amp->gap);
+ if (mtdp->IsGap)
+ mtdp->TextStyle = MSA_TXT_STYLE_GAP;
+ else
+ mtdp->TextStyle = MSA_TXT_STYLE_SEQ;
+ mtdp->strand = amp->strand;
+ mtdp->IsUnAligned=FALSE;
+ vnp->data.ptrvalue = mtdp;
+ }
+ pgp->ptxtList = vnp_head;
+ vnp_para = ValNodeAdd(&vnp_para);
+ vnp_para->data.ptrvalue = pgp;
+ if (!vnp_para_head)
+ vnp_para_head = vnp_para;
+ }
+ vnp_list[n-1]=vnp_para_head;
+ }
+ mpplp->TableHead = vnp_list;
+ /*display_ParaG_content(mpplp,LineSize);*/
+ DDV_LocateParaG(mpplp->TableHead,mpplp->nBsp);
+ return TRUE;
+}
+
+
+NLM_EXTERN Boolean DDV_CreateDisplayFromIndex(SeqAlignPtr sap, MsaParaGPopListPtr mpplp,
+ Int2 LineSize, DDV_Disp_OptPtr ddop) {
+/*******************************************************************************
+* same as DDV_CreateDisplayFromIndex2, but by default no extra gap char.
+*******************************************************************************/
+ return(DDV_CreateDisplayFromIndex2(sap, mpplp, LineSize, ddop, FALSE));
+}
+
+
+NLM_EXTERN Boolean DDV_CreateDisplayFromIndex2(SeqAlignPtr sap, MsaParaGPopListPtr mpplp,
+ Int2 LineSize, DDV_Disp_OptPtr ddop, Boolean WantExtraGapChar)
+{
+ return(DDV_CreateDisplayFromIndex_EX2(sap, mpplp,
+ LineSize, ddop, (Int4) -1, (Int4) -1, WantExtraGapChar));
+}
+
+
+static Boolean DDV_PopulateDisplayForDisc(SeqAlignPtr sap,MsaParaGPopListPtr mpplp,
+ Int4 nBsp,Int4 LineSize,DDV_Disp_OptPtr ddop,Int4 TotLength,ValNodePtr vnp_head,
+ Boolean OverrideDiscJustification, Boolean ForceLeft)
+{
+/*-------------------------------------------------------------
+ Added OverrideDiscJustification:
+ Set this true for single block alignment. In that case,
+ the first unaligned region will be right-justified and
+ the second unaligned region will be left-justified.
+
+ Added ForceLeft:
+ Set this true for single unaligned region alignment.
+ In that case, the unaligned region will be left-aligned.
+-------------------------------------------------------------*/
+Int4 cumulpop,StartLetter,n,nPgp,from_bsp,to_bsp,MaxLength,
+ BspLength=0,BspStart,BspStop,AbsPos;
+Boolean more,bFirstMtdp,bFirstPgp,IsGap;
+ValNodePtr vnp,vnp2,vnp3,vnp_para,vnp_mtdp=NULL;
+ValNodePtr PNTR vnp_list;
+ParaGPtr pgp;
+SeqIdPtr sip;
+DescriDispPtr ddp;
+MsaTxtDispPtr mtdp_pgp;
+AlnMsgPtr amp;
+UAMsgPtr uamp;
+Uint1 strand = Seq_strand_unknown;
+Uint1 strand_tmp, Justification;
+Int4 PassCount;
+
+ /*now, use the previous descriptor to build the ParaG List*/
+ mpplp->sap=sap;
+ mpplp->nBsp = nBsp;
+ mpplp->LengthAli = TotLength;
+ mpplp->DisplayType = DDV_DISP_HORZ;
+ amp = AlnMsgNew();
+ vnp_list = (ValNodePtr PNTR)MemNew((mpplp->nBsp)*sizeof(ValNodePtr));
+ if (!vnp_list || !amp){
+ /*delete the descriptor*/
+ ValNodeFreeData(vnp_head);
+ return(FALSE);
+ }
+
+ cumulpop=0;
+
+ /*loop on each sequence*/
+ for (n = 1; n<=(mpplp->nBsp); n++){
+ sip = AlnMgrGetNthSeqIdPtr(mpplp->sap, n);
+ /*for each sequence, use the descriptors to build the ParaG list*/
+ bFirstPgp=TRUE;
+ bFirstMtdp=TRUE;
+ StartLetter=0;AbsPos=0;/*disp coord*/
+ nPgp=0;
+ vnp=vnp_head;
+ PassCount = 0;
+ while(vnp){
+ ddp=(DescriDispPtr)vnp->data.ptrvalue;
+ if (ddp->TextStyle==MSA_TXT_STYLE_REG_ALIGN){/*aligned*/
+ /*initialize the amp struct for the current aligned region*/
+ amp = AlnMsgReNew(amp);
+ amp->place = 0;
+ amp->from_m = ddp->from;
+ amp->to_m=ddp->to;
+ amp->which_master=0;
+ amp->row_num=n;
+ amp->send_space = FALSE;
+ more=TRUE;
+ AlnMgrGetNextAlnBit(mpplp->sap, amp);
+ while (more){
+ /*list of TxT descriptors*/
+ mtdp_pgp = (MsaTxtDispPtr)MemNew(sizeof(MsaTxtDisp));
+ mtdp_pgp->IsGap = (Boolean)(amp->gap);
+ if (mtdp_pgp->IsGap){/*disp coord*/
+ mtdp_pgp->from=AbsPos;
+ mtdp_pgp->to=mtdp_pgp->from+(amp->to_b-amp->from_b);
+ mtdp_pgp->TextStyle = ddop->AGapStyle;
+ }
+ else{/*BSP coord*/
+ mtdp_pgp->from = amp->from_b;
+ mtdp_pgp->to = amp->to_b;
+ mtdp_pgp->TextStyle = MSA_TXT_STYLE_SEQ;
+ }
+ mtdp_pgp->strand = amp->strand;
+ mtdp_pgp->IsUnAligned=FALSE;
+ strand=amp->strand;
+ /*add the new node*/
+ if (bFirstMtdp){
+ vnp2=ValNodeAddPointer(NULL,0,(Pointer)mtdp_pgp);
+ vnp_mtdp=vnp2;
+ bFirstMtdp=FALSE;
+ }
+ else{
+ vnp2=ValNodeAddPointer(&vnp2,0,(Pointer)mtdp_pgp);
+ }
+ more=AlnMgrGetNextAlnBit(mpplp->sap, amp);
+ AbsPos+=(mtdp_pgp->to-mtdp_pgp->from+1);
+ }
+ }
+ else{/*unaligned*/
+ switch(ddop->DispDiscStyle){/*user's display choice*/
+ case MSA_TXT_STYLE_1:/*just put a little spacer*/
+ mtdp_pgp = (MsaTxtDispPtr)MemNew(sizeof(MsaTxtDisp));
+ mtdp_pgp->from = StartLetter;/*put DISP coord*/
+ mtdp_pgp->to = mtdp_pgp->from+(ddp->to-ddp->from);
+ mtdp_pgp->IsGap = TRUE;
+ mtdp_pgp->TextStyle = MSA_TXT_STYLE_1;
+ mtdp_pgp->strand = strand;
+ mtdp_pgp->IsUnAligned=TRUE;
+ /*add the new node*/
+ if (bFirstMtdp){
+ vnp2=ValNodeAddPointer(NULL,0,(Pointer)mtdp_pgp);
+ vnp_mtdp=vnp2;
+ bFirstMtdp=FALSE;
+ }
+ else{
+ vnp2=ValNodeAddPointer(&vnp2,0,(Pointer)mtdp_pgp);
+ }
+ break;
+ case MSA_TXT_STYLE_2:/*display the unaligned sequence*/
+ MaxLength=ddp->UAMaxlength;
+
+ if (ddp->UAnum>0){/*within SAP*/
+ AlnMgrGetNthUnalignedForNthRow(sap, ddp->UAnum, n, &BspStart,
+ &BspStop);
+ }
+ else{/*Tails of the SAP*/
+ if (AlnMgrGetNthRowTail(sap,n,
+ (Uint1)(ddp->UAnum==(Int4)-1 ? LEFT_TAIL : RIGHT_TAIL),
+ &BspStart,&BspStop,&strand_tmp)==FALSE){
+ BspStart=(Int4)-1;
+ BspStop=(Int4)-1;
+ BspLength=0;
+ }
+
+ }
+
+ if (BspStart!=(Int4)-1 && BspStop!=(Int4)-1){
+ BspLength=BspStop-BspStart+1;
+ }
+ /*init the analysis process of an UA region*/
+ switch(ddp->UAnum){
+ case (Int4)-1:/*left tail*/
+ Justification = ForceLeft ? DISP_JUST_LEFT : DISP_JUST_RIGHT;
+ uamp=UAMgrIntUAMsg(MaxLength,BspLength,BspStart,BspStop,
+ ddp->from,ddp->to, Justification, strand);
+ break;
+ case (Int4)-2:/*right tail*/
+ uamp=UAMgrIntUAMsg(MaxLength,BspLength,BspStart,BspStop,
+ ddp->from,ddp->to,DISP_JUST_LEFT, strand);
+ break;
+ default:/*within SAP*/
+ Justification = ddop->DiscJustification;
+ if (OverrideDiscJustification) {
+ if (PassCount==0) {Justification = DISP_JUST_RIGHT;}
+ if (PassCount==2) {Justification = DISP_JUST_LEFT;}
+ }
+ uamp=UAMgrIntUAMsg(MaxLength,BspLength,BspStart,BspStop,
+ ddp->from,ddp->to, Justification, strand);
+ break;
+ }
+ /*analyse the content of the UA region*/
+ while(UAMgrGetNextUAbit(uamp, BspStart, BspStop)){
+ /*get data*/
+ UAMgrUAMsgGetInfo(uamp,&from_bsp,&to_bsp,&IsGap);
+ /*list of TxT descriptors*/
+ mtdp_pgp = (MsaTxtDispPtr)MemNew(sizeof(MsaTxtDisp));
+ mtdp_pgp->IsGap = IsGap;
+ if (mtdp_pgp->IsGap){/*disp coord*/
+ mtdp_pgp->TextStyle = ddop->UAGapStyle;
+ mtdp_pgp->from=AbsPos;
+ mtdp_pgp->to=mtdp_pgp->from+(to_bsp-from_bsp);
+ }
+ else{/*BSP coord*/
+ mtdp_pgp->from = from_bsp;
+ mtdp_pgp->to = to_bsp;
+ mtdp_pgp->TextStyle = MSA_TXT_STYLE_SEQ;
+ }
+ mtdp_pgp->strand = strand;
+ mtdp_pgp->IsUnAligned=TRUE;
+ /*add the new node*/
+ if (bFirstMtdp){
+ vnp2=ValNodeAddPointer(NULL,0,(Pointer)mtdp_pgp);
+ vnp_mtdp=vnp2;
+ bFirstMtdp=FALSE;
+ }
+ else{
+ vnp2=ValNodeAddPointer(&vnp2,0,(Pointer)mtdp_pgp);
+ }
+ AbsPos+=(mtdp_pgp->to-mtdp_pgp->from+1);
+ }
+ uamp=UAMgrDelUAMsg(&uamp);
+ break;
+ }
+ }
+ cumulpop+=(ddp->to-ddp->from+1);
+ StartLetter+=(ddp->to-ddp->from+1);
+ if (cumulpop==LineSize || vnp->next==NULL){
+ /*new ParaG*/
+ pgp=(ParaGPtr)MemNew(sizeof(ParaG));
+ pgp->StartLine=n-1;
+ pgp->nLines=1;
+ pgp->StartLetter=nPgp*LineSize;
+ pgp->StopLetter=_min_(pgp->StartLetter+LineSize-1,mpplp->LengthAli-1);
+ pgp->sip=SeqIdDup(sip);
+ pgp->ScaleStyle=SCALE_POS_NONE;
+ pgp->ptxtList=vnp_mtdp;
+ if (bFirstPgp){
+ vnp3=ValNodeAddPointer(NULL,0,(Pointer)pgp);
+ vnp_para=vnp3;
+ bFirstPgp=FALSE;
+ }
+ else{
+ vnp3=ValNodeAddPointer(&vnp3,0,(Pointer)pgp);
+ }
+ bFirstMtdp=TRUE;
+ cumulpop=0;
+ nPgp++;
+ }
+ vnp=vnp->next;
+ PassCount++;
+ }/*while() on the descriptor list*/
+ vnp_list[n-1]=vnp_para;
+ SeqIdFree(sip);
+ }/*for() on the bsp */
+
+ /*delete the descriptor*/
+ ValNodeFreeData(vnp_head);
+
+ mpplp->TableHead = vnp_list;
+ /*just for debugging purpose*/
+ /*display_ParaG_content(mpplp,LineSize);*/
+ DDV_LocateParaG(mpplp->TableHead,mpplp->nBsp);
+ MemFree(amp);
+
+ return(TRUE);
+}
+
+NLM_EXTERN Boolean DDV_CreateDisplay_DiscAlign(SeqAlignPtr sap,
+ MsaParaGPopListPtr mpplp, Int2 LineSize,DDV_Disp_OptPtr ddop) {
+/*******************************************************************************
+* same as DDV_CreateDisplay_DiscAlign2, but by default no extra gap char.
+*******************************************************************************/
+ return(DDV_CreateDisplay_DiscAlign2(sap, mpplp, LineSize, ddop, FALSE));
+}
+
+
+/*******************************************************************************
+
+ Function : DDV_CreateDisplay_DiscAlign2()
+
+ Purpose : create a display for a Disc. SeqAlign
+
+ Return value : FALSE if failure
+
+*******************************************************************************/
+NLM_EXTERN Boolean DDV_CreateDisplay_DiscAlign2(SeqAlignPtr sap,
+ MsaParaGPopListPtr mpplp, Int2 LineSize,DDV_Disp_OptPtr ddop, Boolean WantExtraGapChar)
+{
+Int4 nBsp,TotLength;
+ValNodePtr vnp_head;
+
+ /*descriptor*/
+ nBsp = AlnMgrGetNumRows(sap);
+ vnp_head=UABuildDescriptor2(sap,nBsp,LineSize,ddop,&TotLength,
+ ddop->ShowLeftTail,ddop->ShowRightTail, WantExtraGapChar);
+ if (vnp_head==NULL)
+ return(FALSE);
+
+ /*build the display*/
+ return(DDV_PopulateDisplayForDisc(sap,mpplp,nBsp,LineSize,ddop,
+ TotLength,vnp_head, FALSE, FALSE));
+}
+
+/*******************************************************************************
+
+ Function : DDV_BuildDisp_BlockEditor()
+
+ Purpose : create a display for a Disc. SeqAlign
+
+ Return value : FALSE if failure
+
+*******************************************************************************/
+NLM_EXTERN Boolean DDV_BuildDisp_BlockEditor(SeqAlignPtr sap,
+ MsaParaGPopListPtr mpplp, Int4 block_num)
+{
+Int4 nBsp,TotLength;
+ValNodePtr vnp_head;
+DDV_Disp_Opt ddo;
+
+ /*descriptor*/
+ nBsp = AlnMgrGetNumRows(sap);
+ vnp_head=UABuildDescriptorForBlockEditor(sap,nBsp,
+ block_num,LIMIT_EDITOR_SIZE,&TotLength);
+
+ if (vnp_head==NULL)
+ return(FALSE);
+
+ DDV_InitDDESAPdispStyles(&ddo);
+ /*build the display*/
+ return(DDV_PopulateDisplayForDisc(sap,mpplp,nBsp,LIMIT_EDITOR_SIZE,&ddo,
+ TotLength,vnp_head, FALSE, FALSE));
+}
+
+/*******************************************************************************
+
+ Function : UABitDescrInit()
+
+ Purpose : init a UABitDescr data block
+
+ Return value : -
+
+*******************************************************************************/
+static void UABitDescrInit(UABitDescrPtr ubd,Int4 Start,Int4 Stop,Boolean IsGap)
+{
+ ubd->from=Start;
+ ubd->to=Stop;
+ ubd->IsGap=IsGap;
+}
+
+/*******************************************************************************
+
+ Function : UAMgrInitBitList()
+
+ Purpose : init the descriptor of an UA region
+
+ Return value : -
+
+*******************************************************************************/
+static void UAMgrInitBitList(UAMsgPtr uamp, Int4 MaxLength, Int4 BspLength,
+ Int4 BspStart,Int4 BspStop)
+{
+Int4 halfBspLengthSeqL,halfBspLengthSeqR,halfBspLengthDesc,start_middle,stop_middle;
+
+ /*just a gap*/
+ if (BspStart==(Int4)-1 && BspStop==(Int4)-1){
+ UABitDescrInit(&uamp->ubd[0],0,MaxLength-1,TRUE);
+ UABitDescrInit(&uamp->ubd[1],(Int4)-1,(Int4)-1,FALSE);
+ UABitDescrInit(&uamp->ubd[2],(Int4)-1,(Int4)-1,FALSE);
+ return;
+ }
+ /*only sequence*/
+ if (BspLength==MaxLength){
+ UABitDescrInit(&uamp->ubd[0],BspStart,BspStop,FALSE);
+ UABitDescrInit(&uamp->ubd[1],(Int4)-1,(Int4)-1,FALSE);
+ UABitDescrInit(&uamp->ubd[2],(Int4)-1,(Int4)-1,FALSE);
+ return;
+ }
+ /*additional data for DISP_JUST_CENTER and DISP_JUST_SPLIT*/
+ if (uamp->DispType==DISP_JUST_CENTER || uamp->DispType==DISP_JUST_SPLIT){
+ halfBspLengthSeqL=BspLength/2;
+ halfBspLengthSeqR=BspLength-halfBspLengthSeqL;
+ halfBspLengthDesc=MaxLength/2;
+ start_middle=halfBspLengthDesc-halfBspLengthSeqL;
+ stop_middle=start_middle+BspLength;
+ }
+
+ /*only one sequence letter and DISP_JUST_SPLIT : use DISP_JUST_LEFT*/
+ if (BspStart==BspStop && uamp->DispType==DISP_JUST_SPLIT){
+ uamp->DispType=DISP_JUST_LEFT;
+ }
+
+ switch(uamp->DispType){
+ case DISP_JUST_RIGHT:
+ UABitDescrInit(&uamp->ubd[0],0,MaxLength-BspLength-1,TRUE);
+ UABitDescrInit(&uamp->ubd[1],BspStart,BspStop,FALSE);
+ UABitDescrInit(&uamp->ubd[2],(Int4)-1,(Int4)-1,FALSE);
+ break;
+ case DISP_JUST_CENTER:
+ UABitDescrInit(&uamp->ubd[0],0,start_middle-1,TRUE);
+ UABitDescrInit(&uamp->ubd[1],BspStart,BspStop,FALSE);
+ UABitDescrInit(&uamp->ubd[2],stop_middle,MaxLength-1,TRUE);
+ break;
+ case DISP_JUST_SPLIT:
+ UABitDescrInit(&uamp->ubd[0],BspStart,BspStart+halfBspLengthSeqL-1,FALSE);
+ UABitDescrInit(&uamp->ubd[1],halfBspLengthSeqL,MaxLength-halfBspLengthSeqR-1,TRUE);
+ UABitDescrInit(&uamp->ubd[2],BspStart+halfBspLengthSeqL,BspStop,FALSE);
+ break;
+ case DISP_JUST_LEFT:
+ UABitDescrInit(&uamp->ubd[0],BspStart,BspStop,FALSE);
+ UABitDescrInit(&uamp->ubd[1],BspLength,MaxLength-1,TRUE);
+ UABitDescrInit(&uamp->ubd[2],(Int4)-1,(Int4)-1,FALSE);
+ default:
+ break;
+ }
+}
+
+
+/*******************************************************************************
+
+ Function : UAMgrIntUAMsg()
+
+ Purpose : constructor for a struct UAMsg
+
+ Note : from and to are in UnAligned region coord. system. Such a coord system
+ always starts at 0. Length = max length of the UA region
+
+ Return value : -
+
+*******************************************************************************/
+NLM_EXTERN UAMsgPtr UAMgrIntUAMsg( Int4 MaxLength, Int4 BspLength,
+ Int4 BspStart,Int4 BspStop,Int4 ddpFrom ,Int4 ddpTo , Uint1 DispType, Uint1 strand)
+{
+UAMsgPtr uamp=NULL;
+
+ uamp=(UAMsgPtr)MemNew(sizeof(UAMsg));
+ if (uamp){
+ uamp->DispType=DispType;
+ uamp->strand=strand;
+ uamp->from_a=uamp->currentPos=ddpFrom;
+ uamp->to_a=ddpTo;
+ UAMgrInitBitList(uamp,MaxLength,BspLength,BspStart,BspStop);
+ }
+ return(uamp);
+}
+
+/*******************************************************************************
+
+ Function : UAMgrDelUAMsg()
+
+ Purpose : destructor for UAMsg structure
+
+ Return value : -
+
+*******************************************************************************/
+NLM_EXTERN UAMsgPtr UAMgrDelUAMsg(UAMsgPtr PNTR uamp)
+{
+ if (*uamp)
+ MemFree(*uamp);
+ return(NULL);
+}
+
+/*******************************************************************************
+
+ Function : UAMgrUAMsgGetInfo()
+
+ Purpose : query function for a UAMsg structure
+
+ Note : from_bsp and to_bsp are in BSP coord system.
+
+ Return value : -
+
+*******************************************************************************/
+NLM_EXTERN void UAMgrUAMsgGetInfo(UAMsgPtr uamp,Int4Ptr from_bsp, Int4Ptr to_bsp,
+ BoolPtr IsGap)
+{
+ *from_bsp=uamp->from_r;
+ *to_bsp=uamp->to_r;
+ *IsGap=uamp->IsGap;
+}
+
+/*******************************************************************************
+
+ Function : UAMgrGetNextUAbit()
+
+ Purpose : analytical function to retrieve information about an unaligned
+ region. uamp must be init. before entering this function.
+
+*******************************************************************************/
+NLM_EXTERN Boolean UAMgrGetNextUAbit(UAMsgPtr uamp,Int4 BspStart,Int4 BspStop)
+{
+Uint1 i;
+Int4 from_a,to_a,cumul=0,diff,tmp;
+
+ if (uamp->currentPos>uamp->to_a) return(FALSE);
+ for (i=0;i<3;i++){
+ if (uamp->ubd[i].from!=(Int4)-1 && uamp->ubd[i].to!=(Int4)-1){
+ if (uamp->ubd[i].IsGap){/*disp coord*/
+ from_a=uamp->ubd[i].from;
+ to_a=uamp->ubd[i].to;
+ }
+ else{/*switch bsp coord to disp coord*/
+ from_a=cumul;
+ to_a=uamp->ubd[i].to-uamp->ubd[i].from+cumul;
+ }
+ if (uamp->currentPos>=from_a && uamp->currentPos<=to_a){
+ if (uamp->ubd[i].IsGap)
+ uamp->from_r=uamp->currentPos;
+ else
+ uamp->from_r=uamp->ubd[i].from+uamp->currentPos-cumul;
+ }
+ else{
+ cumul+=(to_a-from_a+1);
+ continue;
+ }
+ if (uamp->to_a>=from_a && uamp->to_a<=to_a){
+ uamp->to_r=_min_(uamp->to_a,to_a);
+ if (!uamp->ubd[i].IsGap)
+ uamp->to_r+=uamp->ubd[i].from-cumul;
+ }
+ else{
+ uamp->to_r=uamp->ubd[i].to;
+ }
+ uamp->currentPos+=(uamp->to_r-uamp->from_r+1);
+ uamp->IsGap=uamp->ubd[i].IsGap;
+ break;
+ }
+ }
+
+ /*if minus strand (nuc. only); reverse the values*/
+ if (uamp->strand==Seq_strand_minus && !uamp->IsGap){
+ diff=uamp->to_r-uamp->from_r;
+ uamp->from_r=uamp->from_r+(BspStop-uamp->from_r)-(uamp->from_r-BspStart);
+ uamp->to_r=uamp->from_r-diff;
+ tmp=uamp->to_r;
+ uamp->to_r=uamp->from_r;
+ uamp->from_r=tmp;
+ }
+
+ return(TRUE);
+}
+
+/*******************************************************************************
+
+ Function : DDV_BuildBspEntitiesTbl()
+
+ Purpose : build a table of eID, iID of each Bioseq of a SeqAlign.
+
+ Return value : a table of entities
+
+*******************************************************************************/
+NLM_EXTERN Uint4Ptr DDV_BuildBspEntitiesTbl(ValNodePtr PNTR TableHead,Int4 nBsp)
+{
+ValNodePtr vnp;
+ParaGPtr pgp;
+BioseqPtr bsp;
+Uint4Ptr entitiesTbl;
+Uint2 bsp_eID,bsp_iID;
+Int4 i;
+
+ entitiesTbl=(Uint4Ptr)MemNew(nBsp*sizeof(Uint4));
+ if (!entitiesTbl) return(NULL);
+
+ for (i=0;i<nBsp;i++){
+ vnp=TableHead[i];
+ if (vnp){
+ pgp=(ParaGPtr)vnp->data.ptrvalue;
+
+ bsp=BioseqLockById(pgp->sip);
+ if (bsp){
+ bsp_eID=ObjMgrGetEntityIDForPointer((Pointer)bsp);
+ bsp_iID = GetItemIDGivenPointer (bsp_eID,
+ OBJ_BIOSEQ, (Pointer) bsp);
+ entitiesTbl[i]=UDV_EncodeIdxFeat(bsp_eID,bsp_iID);
+ BioseqUnlock(bsp);
+ }
+ }
+ }
+ return(entitiesTbl);
+}
+
+/*******************************************************************************
+
+ Function : DDV_BuildTailDescriptor()
+
+ Purpose : build a descriptor for the unaligned left/right tails of a SeqAlign
+
+ Return value : the descriptor (see also TotLength; total size of the tail)
+
+*******************************************************************************/
+NLM_EXTERN ValNodePtr DDV_BuildTailDescriptor(SeqAlignPtr sap, Int4 nBsp,
+ Int2 LineSize,Uint1 which_tail,Int4Ptr TotLength,Int4Ptr cumulpop)
+{
+Int4 startcopy,stopcopy,pop,i,MaxLength,start,stop;
+Boolean bError;
+ValNodePtr vnp,vnp_head;
+DescriDispPtr ddp;
+Uint1 strand;
+
+ vnp_head=NULL;
+ bError=FALSE;
+ MaxLength=0;
+ /*get the size of the left UA region*/
+ for(i=0;i<nBsp;i++){
+ if (AlnMgrGetNthRowTail(sap,i+1,which_tail,&start,&stop,&strand)){
+ if (start!=(Int4)-1 && stop!=(Int4)-1){
+ MaxLength=MAX(MaxLength,ABS(stop-start)+1);
+ }
+ }
+ }
+ /*build a descriptor node for that region, if needed*/
+ if (MaxLength>0){
+ startcopy=0;
+ stopcopy=MaxLength;
+ *TotLength+=(stopcopy-startcopy);/*to be used for the display coord. system*/
+
+ while(startcopy<stopcopy){
+ /*store data*/
+ pop=_min_(stopcopy-startcopy,LineSize-(*cumulpop));
+ ddp=(DescriDispPtr)MemNew(sizeof(DescriDisp));
+ if (ddp==NULL) {
+ bError=TRUE;break;
+ }
+ ddp->from=startcopy;/*use relative coord, i.e. UA coord system*/
+ ddp->to=ddp->from+pop-1;
+ ddp->TextStyle=MSA_TXT_STYLE_REG_UNALIGN;
+ if (which_tail==LEFT_TAIL)
+ ddp->UAnum=(Int4)-1;/*UA region number; -1 means LEFT TAIL*/
+ else
+ ddp->UAnum=(Int4)-2;/*UA region number; -2 means RIGHT TAIL*/
+ ddp->UAMaxlength=stopcopy;
+ /*create a new node*/
+ if (vnp_head==NULL) {
+ vnp_head=ValNodeAddPointer(NULL,0,(Pointer)ddp);
+ vnp=vnp_head;
+ }
+ else vnp=ValNodeAddPointer(&vnp,0,(Pointer)ddp);
+
+ if (!vnp){
+ bError=TRUE;
+ break;
+ }
+ (*cumulpop)+=pop;
+ if ((*cumulpop)==LineSize) (*cumulpop)=0;
+ startcopy+=pop;
+ }
+ }
+
+ if (bError){
+ vnp_head=ValNodeFreeData(vnp_head);
+ }
+
+ return(vnp_head);
+}
+
+NLM_EXTERN ValNodePtr UABuildDescriptor(SeqAlignPtr sap, Int4 nBsp, Int2 LineSize,
+ DDV_Disp_OptPtr ddop, Int4Ptr TotLength,Boolean AddLeftUAPart,
+ Boolean AddRightUAPart) {
+/*******************************************************************************
+* same as UABuildDescriptor2, but by default no extra gap char.
+*******************************************************************************/
+ return(UABuildDescriptor2(sap, nBsp, LineSize, ddop, TotLength,
+ AddLeftUAPart, AddRightUAPart, FALSE));
+}
+
+
+/*******************************************************************************
+
+ Function : UABuildDescriptor2()
+
+ Purpose : build the descriptor of a SeqAlign. This function is ONLY designed
+ for discontinuous SeqAlign. The descriptor is a valnodelist. For
+ each node, the field data.ptrvalue is of type MsaTxtDispPtr. It
+ contains inportant info : start-stop of either an aligned or unaligned
+ region. In the first case, SeqAlign coord system is used, otherwise
+ UA coord system is used (UA=UnAligned). The descriptor should then
+ be used as a guide to populate ParaG for the display. Note that this
+ descriptor is a "pre"-layout of the ParaG structure : some descriptor's
+ nodes put together = a ParaG in size.
+
+ Return value : the descriptor (see also TotLength; total size of the SeqAlign,
+ display coordinates)
+
+*******************************************************************************/
+NLM_EXTERN ValNodePtr UABuildDescriptor2(SeqAlignPtr sap, Int4 nBsp, Int2 LineSize,
+ DDV_Disp_OptPtr ddop, Int4Ptr TotLength,Boolean AddLeftUAPart,
+ Boolean AddRightUAPart, Boolean WantExtraGapChar)
+{
+Int4 length,r,cumulpop,StartLetter,startcopy,stopcopy,pop,UAnum;
+Boolean bUnAligned,bError;
+ValNodePtr vnp,vnp_head,vnp2;
+DescriDispPtr ddp;
+
+
+ r=0;
+ cumulpop=0;
+ StartLetter=0;/*align coord*/
+ bError=FALSE;
+ vnp_head=NULL;
+ *TotLength=0;
+
+ /*build UnAligned left part, if needed*/
+ if (AddLeftUAPart && ddop->DispDiscStyle!=MSA_TXT_STYLE_1){
+ vnp_head=DDV_BuildTailDescriptor(sap,nBsp,LineSize,LEFT_TAIL,TotLength,
+ &cumulpop);
+ /*get the last node; will be used in the SAP loop (see below)*/
+ if (vnp_head){
+ vnp=vnp_head;
+ while(vnp->next){
+ vnp=vnp->next;
+ }
+ }
+ }
+
+ /*loop through each aligned and unaligned regions to build
+ a ValNode list of descriptors. These descriptors will be used to
+ generate the ParaG list*/
+ UAnum=0;
+ while(AlnMgrGetNextLengthBit(sap,&length,&r)){
+
+ startcopy=0;
+
+ if (length<=0){
+ bUnAligned=TRUE;
+ switch(ddop->DispDiscStyle){/*user's display choice*/
+ case MSA_TXT_STYLE_1:/*put a spacer between 2 align blocks*/
+ stopcopy=ddop->SpacerSize;
+ break;
+ case MSA_TXT_STYLE_2:/*put sequence between 2 align blocks*/
+ stopcopy=ABS(length);
+ /* give a small space no matter what */
+ /* took out small spaces SW 1/19/01 */
+ /* put it back in optionally, DIH, 1/25/01 */
+ if (WantExtraGapChar) {
+ if (stopcopy==0) stopcopy=1;
+ }
+ break;
+ }
+ UAnum++;
+ }
+ else if (length>0) {
+ bUnAligned=FALSE;
+ stopcopy=length;
+ }
+
+ *TotLength+=(stopcopy-startcopy);/*to be used for the display coord. system*/
+
+ while(startcopy<stopcopy){
+ /*store data*/
+ pop=_min_(stopcopy-startcopy,LineSize-cumulpop);
+ ddp=(DescriDispPtr)MemNew(sizeof(DescriDisp));
+ if (ddp==NULL) {
+ bError=TRUE;break;
+ }
+ if (bUnAligned==FALSE){
+ ddp->from=StartLetter;/*use align coord*/
+ ddp->to=ddp->from+pop-1;
+ ddp->TextStyle=MSA_TXT_STYLE_REG_ALIGN;
+ StartLetter+=pop;
+ }
+ else{
+ ddp->from=startcopy;/*use relative coord, i.e. UA coord system*/
+ ddp->to=ddp->from+pop-1;
+ ddp->TextStyle=MSA_TXT_STYLE_REG_UNALIGN;
+ ddp->UAnum=UAnum;/*UA region number*/
+ ddp->UAMaxlength=stopcopy;
+ }
+ /*create a new node*/
+ if (vnp_head==NULL) {
+ vnp_head=ValNodeAddPointer(NULL,0,(Pointer)ddp);
+ vnp=vnp_head;
+ }
+ else vnp=ValNodeAddPointer(&vnp,0,(Pointer)ddp);
+
+ if (!vnp){
+ bError=TRUE;
+ break;
+ }
+ cumulpop+=pop;
+ if (cumulpop==LineSize) cumulpop=0;
+ startcopy+=pop;
+ }
+ if (bError) break;
+ }
+
+ if (bError){
+ vnp_head=ValNodeFreeData(vnp_head);
+ goto erreur;
+ }
+
+ /*build UnAligned right part, if needed*/
+ if (AddRightUAPart && ddop->DispDiscStyle!=MSA_TXT_STYLE_1){
+ vnp2=DDV_BuildTailDescriptor(sap,nBsp,LineSize,RIGHT_TAIL,TotLength,
+ &cumulpop);
+ /*add vnp2 at the end of vnp_head*/
+ if (vnp2) {
+ vnp=vnp_head;
+ while(vnp->next){
+ vnp=vnp->next;
+ }
+ vnp->next=vnp2;
+ }
+ }
+
+/*debug only : print the content of the descriptor
+
+ vnp=vnp_head;
+ while(vnp){
+ ddp=(DescriDispPtr)vnp->data.ptrvalue;
+ printf("[%4i..%4i],%2i (%4i) ; ",ddp->from,ddp->to,ddp->TextStyle,
+ ddp->to-ddp->from+1);
+ if (ddp->TextStyle==MSA_TXT_STYLE_REG_UNALIGN){
+ printf("MaxLength = %i ; UAnum = %i\n",ddp->UAMaxlength,ddp->UAnum);
+ }
+ else{
+ printf("\n");
+ }
+ vnp=vnp->next;
+ }
+
+debug only - end*/
+
+erreur :
+ return(vnp_head);
+}
+
+/*******************************************************************************
+
+ Function : UABuildDescriptorForBlockEditor()
+
+ Purpose : build the descriptor of a SeqAlign for the block editor; i.e. the
+ descriptor contains the information about one aligned block along with
+ its two adjacent unaligned regions. See also the 'purpose' fo the function
+ UABuildDescriptor() above.
+
+ Return value : the descriptor (see also TotLength; total size of the SeqAlign,
+ display coordinates)
+
+*******************************************************************************/
+NLM_EXTERN ValNodePtr UABuildDescriptorForBlockEditor(SeqAlignPtr sap, Int4 nBsp,
+ Int4 block_num,Int4 LineSize,Int4Ptr TotLength)
+{
+Int4 length,r,cumulpop,StartLetter,startcopy,stopcopy,pop,UAnum,nBlock,
+ blockNum;
+Boolean bUnAligned,bError,bPopNow;
+ValNodePtr vnp,vnp_head,vnp2;
+DescriDispPtr ddp;
+
+
+ /*test if we have a Discontinuous SeqAlign*/
+ if (!AlnMgrIsSAPDiscAli(sap)) return(NULL);
+
+ /*get the number of block(s)*/
+ nBlock=AlnMgrGetNumAlnBlocks(sap);
+ if (block_num<0 || block_num>nBlock-1){
+ return(NULL);
+ }
+ r=cumulpop=UAnum=blockNum=0;
+ StartLetter=0;/*align coord*/
+ bError=FALSE;
+ vnp_head=NULL;
+ *TotLength=0;
+ /*if the user wants to edit the first block (block_num==0), I have
+ to use a special function to create the left-side part of the
+ descriptor*/
+ if (block_num==0){
+ vnp_head=DDV_BuildTailDescriptor(sap,nBsp,LIMIT_EDITOR_SIZE,
+ LEFT_TAIL,TotLength,&cumulpop);
+ if (vnp_head){
+ vnp=vnp_head;
+ while(vnp->next){
+ vnp=vnp->next;
+ }
+ }
+ }
+
+ while(AlnMgrGetNextLengthBit(sap,&length,&r)){
+
+ bPopNow=FALSE;
+ startcopy=0;
+
+ /*unaligned region ?*/
+ if (length<=0){
+ /*region adjacent to the block of interest ?*/
+ if (UAnum==block_num-1 || UAnum==block_num){
+ bUnAligned=TRUE;
+ stopcopy=ABS(length);
+ bPopNow=TRUE;
+ }
+ UAnum++;
+ }
+ else{/*aligned region*/
+ if (blockNum==block_num){
+ bUnAligned=FALSE;
+ stopcopy=length;
+ bPopNow=TRUE;
+ }
+ else{
+ StartLetter+=length;
+ }
+ blockNum++;
+ }
+
+ if (!bPopNow) continue;
+
+ *TotLength+=(stopcopy-startcopy);/*to be used for the display coord. system*/
+
+ while(startcopy<stopcopy){
+ /*store data*/
+ pop=_min_(stopcopy-startcopy,LineSize-cumulpop);
+ ddp=(DescriDispPtr)MemNew(sizeof(DescriDisp));
+ if (ddp==NULL) {
+ bError=TRUE;break;
+ }
+ if (bUnAligned==FALSE){
+ ddp->from=StartLetter;/*use align coord*/
+ ddp->to=ddp->from+pop-1;
+ ddp->TextStyle=MSA_TXT_STYLE_REG_ALIGN;
+ StartLetter+=pop;
+ }
+ else{
+ ddp->from=startcopy;/*use relative coord, i.e. UA coord system*/
+ ddp->to=ddp->from+pop-1;
+ ddp->TextStyle=MSA_TXT_STYLE_REG_UNALIGN;
+ ddp->UAnum=UAnum;/*UA region number*/
+ ddp->UAMaxlength=stopcopy;
+ }
+ /*create a new node*/
+ if (vnp_head==NULL) {
+ vnp_head=ValNodeAddPointer(NULL,0,(Pointer)ddp);
+ vnp=vnp_head;
+ }
+ else vnp=ValNodeAddPointer(&vnp,0,(Pointer)ddp);
+
+ if (!vnp){
+ bError=TRUE;
+ break;
+ }
+ cumulpop+=pop;
+ if (cumulpop==LineSize) cumulpop=0;
+ startcopy+=pop;
+ }
+ if (bError) break;
+ }
+
+ /*oups...*/
+ if (bError){
+ vnp_head=ValNodeFreeData(vnp_head);
+ goto erreur;
+ }
+
+
+ /*if the user wants to edit the last block (block_num==nBlock-1), I have
+ to use a special function to create the right-side part of the
+ descriptor*/
+ if (block_num==nBlock-1){
+ vnp2=DDV_BuildTailDescriptor(sap,nBsp,LIMIT_EDITOR_SIZE,
+ RIGHT_TAIL,TotLength,&cumulpop);
+ if (vnp2) {
+ vnp=vnp_head;
+ while(vnp->next){
+ vnp=vnp->next;
+ }
+ vnp->next=vnp2;
+ }
+ }
+
+erreur :
+ return(vnp_head);
+}
+
+/*******************************************************************************
+
+ Function : DDV_DumpSAPInAFile()
+
+ Purpose : write an Indexed SeqALign in a file (use the code of the Population
+ Viewer).
+
+ Return value : -
+
+*******************************************************************************/
+NLM_EXTERN void DDV_DumpSAPInAFile(MsaParaGPopListPtr mpplp,DDVOptionsBlockPtr dobp,
+ FILE *hFile,Uint4 option,DDV_ColorGlobal * gclr)
+{
+ByteStorePtr PNTR byteSpp;
+Int4Ptr PNTR matrix ;
+Int2 LineSize;
+
+ if (!mpplp || !hFile) return;
+
+ /*get the optional data*/
+ if (dobp){
+ LineSize=dobp->LineSize;
+ byteSpp=dobp->byteSpp;
+ matrix=dobp->matrix;
+ }
+ else{
+ LineSize=ParaG_Size;
+ byteSpp=NULL;
+ }
+
+ /*do the display */
+ DDV_AffichageParaG(mpplp,0,0,mpplp->LengthAli-1,mpplp->LengthAli,0,option,
+ LineSize,hFile,byteSpp,matrix,gclr,NULL);
+
+}
+
+/*******************************************************************************
+
+ Function : DDV_DumpSAPInFastaFile()
+
+ Purpose : write an Indexed SeqALign in a file (use FASTA format only).
+
+ Return value : -
+
+*******************************************************************************/
+NLM_EXTERN void DDV_DumpSAPInFastaFile(MsaParaGPopListPtr mpplp,DDVOptionsBlockPtr dobp,
+ FILE *fp,Boolean bPrintGap)
+{
+CharPtr szBuf,szSeq;
+ParaGPtr pgp;
+SeqIdPtr sip;
+ValNodePtr vnp;
+BioseqPtr bsp;
+Int4 i,j,n,LineSize,bspLength;
+Boolean bFirst,IsAA;
+Char letter;
+Char DefLine[255];
+
+ if (!mpplp || !fp) return;
+
+ if (dobp){
+ LineSize=dobp->LineSize;
+ }
+ else{
+ LineSize=ParaG_Size;
+ }
+
+ szBuf=(CharPtr)MemNew((LineSize+1)*sizeof(Char));
+ if (!szBuf) return;/*todo : error msg for the user*/
+
+ for(i=0;i<mpplp->nBsp;i++){
+ vnp=mpplp->TableHead[i];
+ n=0;
+ bFirst=TRUE;
+ while(vnp){
+ pgp=(ParaGPtr)vnp->data.ptrvalue;
+ sip=SeqIdFindBest(pgp->sip,0);
+ if (sip==NULL) sip=pgp->sip;
+ bsp=BioseqLockById(sip);
+ if (!bsp) return;/*todo : error msg for the user*/
+ bspLength=BioseqGetLen(bsp);
+ IsAA=ISA_aa(bsp->mol);
+ if (bFirst){
+ FastaId(bsp,DefLine,254);
+ fprintf(fp,">%s ",DefLine);
+ CreateDefLine(NULL, bsp, DefLine, 254, 0,NULL, NULL);
+ fprintf(fp,"%s\n",DefLine);
+ bFirst=FALSE;
+ }
+ BioseqUnlock(bsp);
+ szSeq=(CharPtr)MemNew((pgp->StopLetter-pgp->StartLetter+2)*sizeof(Char));
+ if (!szSeq) return;/*todo : error msg for the user*/
+ DDV_GetSequenceFromParaG(pgp,&szSeq,bspLength,IsAA,NULL,NULL,NULL);
+ j=0;
+ while(szSeq[j]){
+ letter=szSeq[j++];
+ if (isalpha(letter)){
+ szBuf[n++]=letter;
+ }
+ else{
+ if (bPrintGap)
+ szBuf[n++]=letter;
+ }
+ if (n==LineSize){
+ szBuf[n]='\0';
+ fprintf(fp,"%s\n",szBuf);
+ n=0;
+ }
+ }
+ MemFree(szSeq);
+ vnp=vnp->next;
+ if (vnp==NULL && n!=0){
+ szBuf[n]='\0';
+ fprintf(fp,"%s\n",szBuf);
+ }
+ }
+ }
+ MemFree(szBuf);
+}
+
+/*******************************************************************************
+
+ Function : DDV_InitDefSAPdispStyles_BLAST()
+
+ Purpose : set the default styles for SeqAligns.
+
+ Return value : -
+
+*******************************************************************************/
+static void DDV_InitDefSAPdispStyles_BLAST(DDV_Disp_OptPtr ddop)
+{
+ /*use colors*/
+ ddop->bUseColors=FALSE;
+ /*disc SAP styles*/
+ ddop->ShowLeftTail=FALSE;
+ ddop->ShowRightTail=FALSE;
+ ddop->DispDiscStyle=MSA_TXT_STYLE_2;
+ ddop->SpacerSize=SPACER_TXT_BLANK;
+ ddop->DiscJustification=DISP_JUST_LEFT;
+
+ ddop->UAGapStyle=MSA_TXT_STYLE_UAGAP;
+ ddop->AGapStyle=MSA_TXT_STYLE_GAP;
+
+ /*ruler style*/
+ ddop->RulerStyle=RulerStyle_Continue_Start;
+
+}
+
+
+/*******************************************************************************
+
+ Function : DDV_DisplayNewBLAST()
+
+ Purpose : build a default SeqAlign display for BLAST.
+
+ Parameters : sap; SeqAlign
+ disp_format; display formats (see pgppop.h)
+ disp_data; for future implementation
+ fp; to send the output
+
+ NOTE : this function uses the alignmgr.[ch] instead of blocks.[ch]
+
+ Return value : FALSE if failed
+
+*******************************************************************************/
+static Boolean DDV_DisplayNewBLAST(SeqAlignPtr sap, ValNodePtr mask,
+ Int4Ptr PNTR matrix,Uint4 disp_format,Pointer disp_data,FILE *fp)
+{
+MsaParaGPopList mppl;/*contains the data for the display*/
+Int2 LineSize;
+DDVOptionsBlockPtr dobp;
+ByteStorePtr PNTR byteSpp;
+DDV_ColorGlobal *layout;
+DDV_Disp_Opt ddo;
+Boolean bUseLayout;
+Uint1 what;
+
+ MemSet(&mppl,0,sizeof(MsaParaGPopList));
+ MemSet(&ddo,0,sizeof(DDV_Disp_Opt));
+ layout=NULL;
+
+ /*get the optional data*/
+ if (disp_data){
+ dobp=(DDVOptionsBlockPtr)disp_data;
+ LineSize=dobp->LineSize;
+ byteSpp=dobp->byteSpp;
+ bUseLayout=dobp->bUseLayout;
+ what=dobp->LayoutType;
+ }
+ else{
+ LineSize=ParaG_Size;
+ byteSpp=NULL;
+ bUseLayout=FALSE;
+ }
+
+ DDV_InitDefSAPdispStyles_BLAST(&ddo);
+
+ /*build the indexed SeqAlign and the ParaG structure*/
+ DDV_CreateDisplayFromIndex(sap, &mppl, LineSize,&ddo);
+
+ /*create the layout*/
+ if (bUseLayout){
+ layout = DDV_CreateColorGlobal(TRUE, (void *)sap);
+ if (layout){
+ if (dobp->LayoutType&DDV_USE_STDCLR){
+ DDV_InitColour_When_Start(sap,&mppl,&layout, FALSE);
+ }
+ if (dobp->LayoutType&DDV_USE_UALAYOUT || dobp->LayoutType&DDV_USE_NOMLAYOUT){
+ DDV_LayoutUAregion(sap,&mppl,&layout,
+ dobp->normlayout.rgb,dobp->normlayout.style,
+ dobp->UAlayout.rgb,dobp->UAlayout.style);
+ }
+ if (dobp->LayoutType&DDV_USE_ISOLAYOUT){
+ DDV_LayoutISOColors(layout,mppl.TableHead,mppl.nBsp,
+ 0,TRUE,matrix,dobp->ISOlayout.clr_ident,
+ dobp->ISOlayout.clr_simil,dobp->ISOlayout.clr_other,
+ dobp->ISOlayout.sty_ident,
+ dobp->ISOlayout.sty_simil,dobp->ISOlayout.sty_other);
+ }
+ if (dobp->LayoutType&DDV_USE_GAPLAYOUT){
+ DDV_LayoutGap(layout,mppl.TableHead[0],mppl.TableHead[1],1,
+ dobp->GAPlayout.style,dobp->GAPlayout.rgb);
+ DDV_LayoutGap(layout,mppl.TableHead[1],mppl.TableHead[0],0,
+ dobp->GAPlayout.style,dobp->GAPlayout.rgb);
+ }
+ if (dobp->LayoutType&DDV_USE_MASKLAYOUT){
+ DDV_LayoutMaskRegions(layout,mppl.TableHead[0],mask,0,
+ dobp->MASKlayout.style,dobp->MASKlayout.rgb);
+ }
+ }
+ }
+
+ /*do the display */
+ DDV_AffichageParaG(&mppl,0,0,mppl.LengthAli-1,mppl.LengthAli,0,disp_format,
+ LineSize,fp,byteSpp,matrix,layout,mask);
+
+ /*done... delete data*/
+ DDV_DeleteDisplayList(&mppl);
+ if (layout) DDV_DeleteColorGlobal(layout);
+
+
+ return(TRUE);
+}
+
+/*******************************************************************************
+
+ Function : DDV_BlastGetColorSchemaZero()
+
+ Purpose : BLAST color sheme 0 : standard b&w BLAST output
+
+*******************************************************************************/
+static void DDV_BlastGetColorSchemaZero(DDVOptionsBlockPtr dobp)
+{
+ memset(dobp,0,sizeof(DDVOptionsBlock));
+
+ dobp->bUseLayout=FALSE;
+}
+
+/*******************************************************************************
+
+ Function : DDV_BlastGetColorSchemaOne()
+
+ Purpose : BLAST color sheme 1 :
+ - masked regions in lowe case,
+ - everything else in upper case.
+
+*******************************************************************************/
+static void DDV_BlastGetColorSchemaOne(DDVOptionsBlockPtr dobp)
+{
+ memset(dobp,0,sizeof(DDVOptionsBlock));
+
+ dobp->bUseLayout=TRUE;
+
+ /* dobp->LayoutType=DDV_USE_MASKLAYOUT|DDV_USE_NOMLAYOUT; */
+
+ dobp->LayoutType=DDV_USE_UALAYOUT|DDV_USE_GAPLAYOUT;
+
+ dobp->UAlayout.style=DDV_TXTSTYLE_LOWERCASE;
+ dobp->GAPlayout.style=DDV_TXTSTYLE_LOWERCASE;
+
+ /* dobp->MASKlayout.style=DDV_TXTSTYLE_LOWERCASE; */
+}
+
+/*******************************************************************************
+
+ Function : DDV_BlastGetColorSchemaTwo()
+
+ Purpose : BLAST color sheme 2 :
+ - masked regions in lower case, gray letters,
+ - UnAligned regions in italic,
+ - everything else in upper case.
+
+*******************************************************************************/
+static void DDV_BlastGetColorSchemaTwo(DDVOptionsBlockPtr dobp)
+{
+ memset(dobp,0,sizeof(DDVOptionsBlock));
+
+ dobp->bUseLayout=TRUE;
+
+ dobp->LayoutType=DDV_USE_MASKLAYOUT|DDV_USE_NOMLAYOUT;
+ dobp->LayoutType|=DDV_USE_UALAYOUT;
+
+ dobp->UAlayout.style=DDV_TXTSTYLE_ITALIC|DDV_TXTSTYLE_LOWERCASE;
+ dobp->normlayout.style=DDV_TXTSTYLE_BOLD;
+
+ dobp->MASKlayout.style=DDV_TXTSTYLE_LOWERCASE|DDV_TXTSTYLE_COLOR;
+ dobp->MASKlayout.rgb[0]=102;
+ dobp->MASKlayout.rgb[1]=102;
+ dobp->MASKlayout.rgb[2]=102;
+}
+
+/*******************************************************************************
+
+ Function : DDV_BlastGetColorSchemaThree()
+
+ Purpose : BLAST color sheme 3 :
+ - masked regions in lower case, gray letters,
+ - UnAligned regions in italic,
+ - Identity/Similarity colors
+ - everything else in upper case.
+
+*******************************************************************************/
+static void DDV_BlastGetColorSchemaThree(DDVOptionsBlockPtr dobp)
+{
+ memset(dobp,0,sizeof(DDVOptionsBlock));
+
+ dobp->bUseLayout=TRUE;
+
+ dobp->LayoutType=DDV_USE_MASKLAYOUT;
+ dobp->LayoutType|=DDV_USE_UALAYOUT;
+ dobp->LayoutType|=DDV_USE_ISOLAYOUT;
+
+ dobp->UAlayout.style=DDV_TXTSTYLE_ITALIC|DDV_TXTSTYLE_LOWERCASE;
+
+ dobp->MASKlayout.style=DDV_TXTSTYLE_LOWERCASE;/*|DDV_TXTSTYLE_COLOR;
+ dobp->MASKlayout.rgb[0]=102;
+ dobp->MASKlayout.rgb[1]=102;
+ dobp->MASKlayout.rgb[2]=102;
+*/
+ dobp->ISOlayout.clr_ident=DDVCOL_ORANGE;
+ dobp->ISOlayout.clr_simil=DDVCOL_BLUE;
+ dobp->ISOlayout.clr_other=DDVCOL_BLACK;
+}
+
+/*******************************************************************************
+
+ Function : DDV_BlastGetColorSchemaFour()
+
+ Purpose : BLAST color sheme 4 = BLAST color schema 3 but with different colors
+
+*******************************************************************************/
+static void DDV_BlastGetColorSchemaFour(DDVOptionsBlockPtr dobp)
+{
+ memset(dobp,0,sizeof(DDVOptionsBlock));
+
+ dobp->bUseLayout=TRUE;
+
+ dobp->LayoutType=DDV_USE_MASKLAYOUT;
+ dobp->LayoutType|=DDV_USE_UALAYOUT;
+ dobp->LayoutType|=DDV_USE_ISOLAYOUT;
+
+ dobp->UAlayout.style=DDV_TXTSTYLE_ITALIC|DDV_TXTSTYLE_LOWERCASE;
+
+ dobp->MASKlayout.style=DDV_TXTSTYLE_LOWERCASE|DDV_TXTSTYLE_COLOR;
+ dobp->MASKlayout.rgb[0]=102;
+ dobp->MASKlayout.rgb[1]=102;
+ dobp->MASKlayout.rgb[2]=102;
+
+ dobp->ISOlayout.clr_ident=DDVCOL_BLUE;
+ dobp->ISOlayout.clr_simil=DDVCOL_BROWN;
+ dobp->ISOlayout.clr_other=DDVCOL_RED;
+}
+
+/*******************************************************************************
+
+ Function : DDV_BlastGetColorSchemaFive()
+
+ Purpose : BLAST color sheme 5 = BLAST color schema 3 but with different colors
+
+*******************************************************************************/
+static void DDV_BlastGetColorSchemaFive(DDVOptionsBlockPtr dobp)
+{
+ memset(dobp,0,sizeof(DDVOptionsBlock));
+
+ dobp->bUseLayout=TRUE;
+
+ dobp->LayoutType=DDV_USE_MASKLAYOUT;
+ dobp->LayoutType|=DDV_USE_UALAYOUT;
+ dobp->LayoutType|=DDV_USE_ISOLAYOUT;
+
+ dobp->UAlayout.style=DDV_TXTSTYLE_ITALIC|DDV_TXTSTYLE_LOWERCASE;
+
+ dobp->MASKlayout.style=DDV_TXTSTYLE_LOWERCASE|DDV_TXTSTYLE_COLOR;
+ dobp->MASKlayout.rgb[0]=102;
+ dobp->MASKlayout.rgb[1]=102;
+ dobp->MASKlayout.rgb[2]=102;
+
+ dobp->ISOlayout.clr_ident=DDVCOL_RED;
+ dobp->ISOlayout.clr_simil=DDVCOL_BLUE;
+ dobp->ISOlayout.clr_other=DDVCOL_BLACK;
+}
+
+/*******************************************************************************
+
+ Function : DDV_BlastGetColorSchemaSix()
+
+ Purpose : BLAST color sheme 6 = BLAST color schema 3 but with different colors
+
+*******************************************************************************/
+static void DDV_BlastGetColorSchemaSix(DDVOptionsBlockPtr dobp)
+{
+ memset(dobp,0,sizeof(DDVOptionsBlock));
+
+ dobp->bUseLayout=TRUE;
+
+ dobp->LayoutType=DDV_USE_MASKLAYOUT;
+ dobp->LayoutType|=DDV_USE_UALAYOUT;
+ dobp->LayoutType|=DDV_USE_ISOLAYOUT;
+
+ dobp->UAlayout.style=DDV_TXTSTYLE_ITALIC|DDV_TXTSTYLE_LOWERCASE;
+
+ dobp->MASKlayout.style=DDV_TXTSTYLE_LOWERCASE;/*|DDV_TXTSTYLE_COLOR;
+ dobp->MASKlayout.rgb[0]=102;
+ dobp->MASKlayout.rgb[1]=102;
+ dobp->MASKlayout.rgb[2]=102;
+*/
+ dobp->ISOlayout.clr_ident=DDVCOL_ORANGE;
+ dobp->ISOlayout.clr_simil=DDVCOL_BLUE;
+ dobp->ISOlayout.clr_other=DDVCOL_BLACK;
+
+ dobp->ISOlayout.sty_ident=DDV_TXTSTYLE_BOLD;
+}
+
+/*******************************************************************************
+
+ Function : DDV_DisplayBlastPairList()
+
+ Purpose : function to display a BLAST output.
+
+ Parameters : sap; seqalign
+ mask; list of masked regions in the query
+ fp; output file;
+ is_na; TRUE means nuc sequence
+ tx_option; some display options
+ ColorSchema; one of the available color schemes
+
+ Return value : FALSE if failure
+
+*******************************************************************************/
+NLM_EXTERN Boolean DDV_DisplayBlastPairList(SeqAlignPtr sap, ValNodePtr mask,
+ FILE *fp, Boolean is_na, Uint4 tx_option,Uint1 ColorSchema)
+{
+ DDVOptionsBlock dob;
+ SeqAlignPtr sap4;
+ SeqIdPtr new_id = NULL, old_id = NULL;
+ Int4Ptr PNTR matrix;
+ Uint4 option,i;
+ Boolean bRet, follower= FALSE;
+
+ if (!sap || !fp)
+ return(FALSE);
+
+ /*get the matrix*/
+ if (is_na == FALSE){
+ matrix=load_default_matrix();
+ if (!matrix)
+ return(FALSE);
+ } else {
+ matrix=NULL;
+ }
+
+ memset(&dob, '\0', sizeof(DDVOptionsBlock));
+
+ /*init display format*/
+ option =VIEW_FULLSEQ;
+
+ if (ColorSchema==DDV_BLAST_COLOR0 || ColorSchema==DDV_BLAST_COLOR1)
+ option|=DISP_FULL_TXT;
+ else
+ option|=DISP_FULL_HTML;
+
+ option|=DISP_BSP_COORD;
+ option|=SEQNAME_BLAST_STD;
+ option|=DISP_NOLINKONNAME;
+ option|=DISP_BLAST_STD;
+ option|=DISPE_COLOR;
+
+ /*get the color scheme layout*/
+ /*note that the following functions will set to 0 the entire dob structure, before
+ filling in its content with the layout information. All subsequent init. of dob
+ should be done after the following switch()*/
+ switch(ColorSchema){
+ case DDV_BLAST_COLOR0:
+ option|=DISP_BLAST_MIDLINE;
+ DDV_BlastGetColorSchemaZero(&dob);
+ break;
+ case DDV_BLAST_COLOR1:
+ option|=DISP_BLAST_MIDLINE;
+ DDV_BlastGetColorSchemaOne(&dob);
+ break;
+ case DDV_BLAST_COLOR2:
+ option|=DISP_BLAST_MIDLINE;
+ DDV_BlastGetColorSchemaTwo(&dob);
+ break;
+ case DDV_BLAST_COLOR3:
+ DDV_BlastGetColorSchemaThree(&dob);
+ break;
+ case DDV_BLAST_COLOR4:
+ DDV_BlastGetColorSchemaFour(&dob);
+ break;
+ case DDV_BLAST_COLOR5:
+ DDV_BlastGetColorSchemaFive(&dob);
+ break;
+ case DDV_BLAST_COLOR6:
+ DDV_BlastGetColorSchemaSix(&dob);
+ break;
+ }
+
+ dob.LineSize=(Int2)60;
+ dob.matrix=matrix;
+ bRet=TRUE;
+ sap4=sap;
+
+ while(sap4) {
+ /*build the Index*/
+ if (sap4->segtype == SAS_DISC){
+ if (!sap4 || !AlnMgrIndexSingleSeqAlign(sap4)){
+ bRet=FALSE;
+ break;
+ }
+ }
+ else{
+ if (!sap4 || !AlnMgrIndexSingleChildSeqAlign(sap4)){
+ bRet=FALSE;
+ break;
+ }
+ }
+
+ if (option&DISP_FULL_HTML){
+ fprintf(fp,"<pre>\n");
+ }
+ /* Attempt to print score for the alignment */
+ new_id = TxGetSubjectIdFromSeqAlign(sap4);
+ if(old_id != NULL) {
+ if(SeqIdMatch(new_id, old_id))
+ follower = TRUE;
+ }
+
+ /*separator*/
+ if (option&DISP_FULL_HTML)
+ fprintf(fp,"<HR WIDTH=\"400\">");
+
+ old_id = new_id;
+ if(!FormatScoreFromSeqAlign(sap4, tx_option, fp, matrix, follower)){
+ bRet=FALSE;
+ break;
+ }
+ follower = FALSE;
+ if (option&DISP_FULL_HTML){
+ fprintf(fp,"</pre>\n");
+ }
+
+ /*display a SeqAlign*/
+ if (!DDV_DisplayNewBLAST(sap4, mask, matrix, option, (Pointer) &dob, fp)){
+ bRet=FALSE;
+ break;
+ }
+ sap4 = sap4->next;
+ }
+
+ if (matrix){
+ for(i = 0; i<TX_MATRIX_SIZE; ++i)
+ MemFree(matrix[i]);
+ MemFree(matrix);
+ }
+
+ return(bRet);
+
+}
+
+/*******************************************************************************
+
+ Function : DDV_DisplayBlastSAP()
+
+ Purpose : test function to display a BLAST output.
+
+ Parameters : sap; seqalign
+ mask; list of masked regions in the query
+ fo; output file;
+ is_na; TRUE means nuc sequence
+ tx_option; some display options
+
+ Return value : -
+
+*******************************************************************************/
+static Boolean DDV_DisplayBlastSAP(SeqAlignPtr sap, ValNodePtr mask,
+ FILE *fp, Boolean is_na, Uint4 tx_option)
+{
+DDVOptionsBlock dob;
+SeqAlignPtr sap4;
+SeqIdPtr new_id = NULL, old_id = NULL;
+Int4Ptr PNTR matrix;
+Uint4 option,i;
+Boolean bRet, follower= FALSE;
+
+ if (!sap || !fp)
+ return(FALSE);
+
+ /*get the matrix*/
+ if (is_na == FALSE){
+ matrix=load_default_matrix();
+ if (!matrix)
+ return(FALSE);
+ } else {
+ matrix=NULL;
+ }
+
+ /*init display format*/
+ option =VIEW_FULLSEQ;
+ option|=DISP_FULL_HTML;
+ option|=DISP_BSP_COORD;
+ option|=SEQNAME_BLAST_STD;
+ option|=DISP_BLAST_STD;
+ option|=DISP_BLAST_MIDLINE;
+ option|=DISPE_COLOR;
+ dob.LineSize=(Int2)60;
+ dob.matrix=matrix;
+
+ bRet=TRUE;
+ sap4=sap;
+ while(sap4) {
+ /*build the Index*/
+ if (sap4->segtype == SAS_DISC){
+ if (!sap4 || !AlnMgrIndexSingleSeqAlign(sap4)){
+ bRet=FALSE;
+ break;
+ }
+ dob.bUseLayout=TRUE;
+ }
+ else{
+ if (!sap4 || !AlnMgrIndexSingleChildSeqAlign(sap4)){
+ bRet=FALSE;
+ break;
+ }
+ dob.bUseLayout=TRUE;
+ }
+
+ /*set the layout type, if needed*/
+ if (dob.bUseLayout){
+ /*basic layout*/
+ dob.LayoutType=DDV_USE_UALAYOUT;
+ dob.LayoutType|=DDV_USE_GAPLAYOUT;
+ dob.LayoutType|=DDV_USE_MASKLAYOUT;
+ /*dob.LayoutType|=DDV_USE_ISOLAYOUT;*/
+ /*ext. layout*/
+ dob.UAlayout.style=DDV_TXTSTYLE_LOWERCASE;
+ dob.UAlayout.style|=DDV_TXTSTYLE_ITALIC;
+ dob.UAlayout.style|=DDV_TXTSTYLE_COLOR;
+ dob.UAlayout.rgb[0]=255;
+ dob.UAlayout.rgb[1]=0;
+ dob.UAlayout.rgb[2]=0;
+ dob.GAPlayout.style=DDV_TXTSTYLE_LOWERCASE;
+ dob.GAPlayout.style|=DDV_TXTSTYLE_ITALIC;
+ dob.GAPlayout.style|=DDV_TXTSTYLE_COLOR;
+ dob.GAPlayout.rgb[0]=255;
+ dob.GAPlayout.rgb[1]=0;
+ dob.GAPlayout.rgb[2]=0;
+ dob.MASKlayout.style=DDV_TXTSTYLE_BOLD;
+ dob.MASKlayout.style|=DDV_TXTSTYLE_UNDERLINE;
+ dob.ISOlayout.clr_ident=DDVCOL_ORANGE;
+ dob.ISOlayout.clr_simil=DDVCOL_SKY;
+ dob.ISOlayout.clr_other=DDVCOL_BLACK;
+ }
+
+ if (option&DISP_FULL_HTML){
+ fprintf(fp,"<pre>\n");
+ }
+ /* Attempt to print score for the alignment */
+ new_id = TxGetSubjectIdFromSeqAlign(sap4);
+ if(old_id != NULL) {
+ if(SeqIdMatch(new_id, old_id))
+ follower = TRUE;
+ }
+
+ /*separator*/
+ fprintf(fp,"<HR WIDTH=\"400\">");
+ old_id = new_id;
+ if(!FormatScoreFromSeqAlign(sap4, tx_option, fp, matrix, follower)){
+ bRet=FALSE;
+ break;
+ }
+ follower = FALSE;
+ if (option&DISP_FULL_HTML){
+ fprintf(fp,"</pre>\n");
+ }
+
+ /*display a SeqAlign*/
+ if (!DDV_DisplayNewBLAST(sap4, mask, matrix, option, (Pointer) &dob, fp)){
+ bRet=FALSE;
+ break;
+ }
+ sap4 = sap4->next;
+ }
+
+ if (matrix){
+ for(i = 0; i<TX_MATRIX_SIZE; ++i)
+ MemFree(matrix[i]);
+ MemFree(matrix);
+ }
+
+ return(bRet);
+}
+/*******************************************************************************
+
+ Function : DDV_InitDefSAPdispStyles()
+
+ Purpose : set the default styles for SeqAligns.
+
+ Return value : -
+
+*******************************************************************************/
+NLM_EXTERN void DDV_InitDefSAPdispStyles(DDV_Disp_OptPtr ddop)
+{
+ /*use colors*/
+ ddop->bUseColors=TRUE;
+ /*disc SAP styles*/
+ ddop->ShowLeftTail=FALSE;
+ ddop->ShowRightTail=FALSE;
+ ddop->DispDiscStyle=MSA_TXT_STYLE_1;
+ ddop->SpacerSize=SPACER_TXT_BLANK;
+ ddop->DiscJustification=DISP_JUST_CENTER;
+ ddop->UAGapStyle=MSA_TXT_STYLE_UAGAP;
+ ddop->AGapStyle=MSA_TXT_STYLE_GAP;
+
+ /*ruler style*/
+ ddop->RulerStyle=RulerStyle_Continue_Start;
+}
+
+/*******************************************************************************
+
+ Function : DDV_InitCn3DSAPdispStyles()
+
+ Purpose : set the styles for Cn3D SeqAligns.
+
+ Return value : -
+
+*******************************************************************************/
+NLM_EXTERN void DDV_InitCn3DSAPdispStyles(DDV_Disp_OptPtr ddop)
+{
+ /*use colors*/
+ ddop->bUseColors=TRUE;
+ /*disc SAP styles*/
+ ddop->ShowLeftTail=TRUE;
+ ddop->ShowRightTail=TRUE;
+ ddop->DispDiscStyle=MSA_TXT_STYLE_2;
+ ddop->SpacerSize=0;
+ ddop->DiscJustification=DISP_JUST_SPLIT;
+ ddop->UAGapStyle=MSA_TXT_STYLE_UAGAP; /* use different unaligned gap chars ('~') */
+ ddop->AGapStyle=MSA_TXT_STYLE_GAP;
+
+ /*ruler style*/
+ ddop->RulerStyle=RulerStyle_Continue_Start;
+}
+
+/*******************************************************************************
+
+ Function : DDV_InitDDESAPdispStyles()
+
+ Purpose : set the styles for DDE (i.e. DDV used as an editor).
+
+ Return value : -
+
+*******************************************************************************/
+NLM_EXTERN void DDV_InitDDESAPdispStyles(DDV_Disp_OptPtr ddop)
+{
+ /*use colors*/
+ ddop->bUseColors=TRUE;
+ /*disc SAP styles*/
+ ddop->ShowLeftTail=TRUE;
+ ddop->ShowRightTail=TRUE;
+ ddop->DispDiscStyle=MSA_TXT_STYLE_2;
+ ddop->SpacerSize=0;
+ ddop->DiscJustification=DISP_JUST_LEFT;
+ ddop->UAGapStyle=MSA_TXT_STYLE_UAGAP;
+ ddop->AGapStyle=MSA_TXT_STYLE_GAP;
+
+ /*ruler style*/
+ ddop->RulerStyle=RulerStyle_Continue_Start;
+}
+
+/*******************************************************************************
+
+ Function : DDV_ReadSeqBin()
+
+ Purpose : read a sequence using Seq_code_ncbistdaa or Seq_code_ncbi4na
+
+ Return value : the sequence
+
+*******************************************************************************/
+NLM_EXTERN Uint1Ptr DDV_ReadSeqBin (SeqIdPtr sip, Int4 from, Int4 to,
+ Boolean IsProt,Int2 len,Uint1 strand)
+{
+SeqLocPtr slp;
+SeqPortPtr spp;
+Uint1Ptr btr;
+Uint1 residue;
+Uint2 i=0;
+
+ /*from always < than to*/
+ slp = SeqLocIntNew (from, to, strand, sip);
+ if (!slp) return(NULL);
+ spp = SeqPortNewByLoc (slp, (Uint1)(IsProt==TRUE ? Seq_code_ncbistdaa
+ : Seq_code_ncbi4na));
+ if (spp != NULL) {
+ btr = (Uint1Ptr) MemNew (len * sizeof(Uint1));
+ if (!btr) return(NULL);
+ while ((residue = SeqPortGetResidue(spp)) != SEQPORT_EOF) {
+ if (IS_residue(residue)) {
+ btr[i] = residue;
+ i++;
+ }
+ }
+ /*SeqPortRead(spp, btr, len);*/
+ SeqPortFree (spp);
+ }
+ SeqLocFree (slp);
+ return btr;
+}
+
+/*******************************************************************************
+
+ Function : DDV_SetStyle()
+
+ Purpose : set the layout of a single letter
+
+ Return value : -.
+
+*******************************************************************************/
+static void DDV_SetStyle(DDV_ColorCell * dccp,Uint1 style, Uint1 *rgb,
+ Boolean bAllowReset)
+{
+ if (style&DDV_TXTSTYLE_ITALIC){
+ dccp->UseItalic=TRUE;
+ }
+ else if (bAllowReset){
+ dccp->UseItalic=FALSE;
+ }
+
+ if (style&DDV_TXTSTYLE_BOLD){
+ dccp->UseBold=TRUE;
+ }
+ else if (bAllowReset){
+ dccp->UseBold=FALSE;
+ }
+
+ if (style&DDV_TXTSTYLE_UNDERLINE){
+ dccp->UseUnderline=TRUE;
+ }
+ else if (bAllowReset){
+ dccp->UseUnderline=FALSE;
+ }
+
+ if (style&DDV_TXTSTYLE_LOWERCASE){
+ dccp->LowerCase=TRUE;
+ }
+ else if(bAllowReset) {
+ dccp->LowerCase=FALSE;
+ }
+
+ if (style&DDV_TXTSTYLE_COLOR && rgb){
+ dccp->rgb[0]=rgb[0];
+ dccp->rgb[1]=rgb[1];
+ dccp->rgb[2]=rgb[2];
+ }
+}
+
+/*******************************************************************************
+
+ Function : DDV_SetStd_AA_UA_ClrEx()
+
+ Purpose : set the standard colours for a nuc or prot sequence;
+ or the same function can be used to layout UnAligned regions
+
+ Note: For performance issue this function set up the layout of
+ both aligned and unaligned regions at the same time
+
+ Return value : -
+
+*******************************************************************************/
+#define read_buf_size 3000
+static void DDV_SetStd_AA_UA_ClrEx(DDV_ColorGlobal *pColorGlobal, void *pData,
+ DDV_Range *pRange,Uint1 what)
+{
+DDVDataForColorFuncPtr ddfcfp;
+BioseqPtr bsp;
+Int4 bsp_length,i,from,to,limit;
+Boolean IsAA;
+Int4 dp;
+Uint1Ptr SeqBuf;
+Int2 len;
+Uint1 idx;
+DDV_ColorCell * dccp;
+
+ ddfcfp=(DDVDataForColorFuncPtr)pData;
+
+ if (!ddfcfp) return;
+
+ /*get bioseq size and type */
+ bsp=BioseqLockById(ddfcfp->sip);
+ if (bsp){
+ bsp_length=bsp->length;
+ IsAA=ISA_aa(bsp->mol);
+ BioseqUnlock(bsp);
+ }
+ else return;
+
+
+ /*compute the ends of the bioseq's region we want to analyse*/
+ if (ddfcfp->from!=(Int4)-1)
+ from=ddfcfp->from;
+ else
+ from=0;
+
+ if (ddfcfp->to!=(Int4)-1)
+ limit=ddfcfp->to;
+ else
+ limit=bsp_length-1;
+
+ to=from+read_buf_size-1;
+ if (to>limit) to=limit;
+
+ /*read the sequence by chunk of 'read_buf_size' letters*/
+ while(TRUE){
+ len=(Int2)(to-from+1);
+ /*get a sequence chunck ; from is always < than to*/
+ SeqBuf=DDV_ReadSeqBin (ddfcfp->sip, from, to, IsAA,len,ddfcfp->strand);
+ if (SeqBuf){/*scan each letter and get the appropriate colour*/
+ for(i=0;i<len;i++){
+ /*compute the correct position; depend on the strand*/
+ if (ddfcfp->strand==Seq_strand_minus)
+ dp=to-i;
+ else
+ dp=from+i;
+ /*first, query Color Manager*/
+ dccp=DDV_GetColor(pColorGlobal,NULL,ddfcfp->row+1,dp);
+ if (!dccp) return;
+ if(what & DDV_USE_STDCLR) {
+ if (IsAA)
+ idx=DDV_STD_AAColor[*(SeqBuf+i)];/*AA*/
+ else
+ idx=DDV_STD_NAColor[*(SeqBuf+i)];/*NA*/
+
+ if (ddfcfp->IsUnAligned)
+ DDV_SetStyle(dccp,ddfcfp->UAstyle,DDV_PaletteRGB[idx],TRUE);
+ else
+ DDV_SetStyle(dccp,ddfcfp->style,DDV_PaletteRGB[idx],TRUE);
+ }
+ else if(what & DDV_USE_UALAYOUT) {
+ if (ddfcfp->IsUnAligned)
+ DDV_SetStyle(dccp,ddfcfp->UAstyle,ddfcfp->UArgb,TRUE);
+ else
+ DDV_SetStyle(dccp,ddfcfp->style,DDV_PaletteRGB[DDVCOL_BLACK],TRUE);
+ }
+ /*set the colour*/
+ DDV_SetColor(pColorGlobal, NULL, ddfcfp->row+1, dp, dccp);
+ }
+ MemFree(SeqBuf);
+ }
+
+ /*compute the next chunk*/
+ from+=read_buf_size;
+ to+=read_buf_size;
+ if (to>limit) to=limit;
+ /*end ?*/
+ if (from>limit) break;
+ }
+
+}
+
+
+/*******************************************************************************
+
+ Function : DDV_InitColourSAP()
+
+ Purpose : init the colours for each Bsp of a SeqAlign
+
+ Parameters : sap; a (indexed) SeqAlign
+ global colour data struct (see ddvcolor.[ch] in api)
+ NoColor; don't color the bsp's, but do change the case.
+
+ Note : usually, this function is called when DDV loads a SeqAlign
+ For performance issue this function set up the layout of
+ both aligned and unaligned regions at the same time
+
+ Return value : FALSE is failure.
+
+*******************************************************************************/
+static Boolean DDV_InitColourSAP(SeqAlignPtr sap,MsaParaGPopListPtr mpplp,
+ DDV_ColorGlobal * * gclr,Uint1 what,Uint1 * pRGB,Uint1 style,
+ Uint1 * pUARGB,Uint1 UAstyle)
+{
+DDVDataForColorFunc ddfcf;
+SeqIdPtr sip;
+ValNodePtr vnp,vnp2;
+ParaGPtr pgp;
+MsaTxtDispPtr mtdp;
+Int4 n;
+
+ if (!sap)
+ return (FALSE);
+
+ if (!(*gclr)){
+ *gclr = DDV_CreateColorGlobal(FALSE, (void *) sap);
+ if (!(*gclr))
+ return(FALSE);
+ }
+
+ for(n=0;n<mpplp->nBsp;n++){
+ vnp=mpplp->TableHead[n];
+ while(vnp){
+ pgp=(ParaGPtr)vnp->data.ptrvalue;
+ if (pgp){
+ vnp2=pgp->ptxtList;
+ sip=pgp->sip;
+ while(vnp2){
+ mtdp = (MsaTxtDispPtr)vnp2->data.ptrvalue;
+ if(mtdp && mtdp->TextStyle==MSA_TXT_STYLE_SEQ){
+ ddfcf.sip=sip;
+ ddfcf.from=mtdp->from;
+ ddfcf.to=mtdp->to;
+ ddfcf.row=n;
+ ddfcf.strand=mtdp->strand;
+ ddfcf.IsUnAligned=mtdp->IsUnAligned;
+ ddfcf.style=style;
+ ddfcf.UAstyle=UAstyle;
+ if (pRGB){
+ ddfcf.rgb[0]=pRGB[0];
+ ddfcf.rgb[1]=pRGB[1];
+ ddfcf.rgb[2]=pRGB[2];
+ }
+ else{
+ ddfcf.rgb[0]=0;
+ ddfcf.rgb[1]=0;
+ ddfcf.rgb[2]=0;
+ }
+ if (pUARGB){
+ ddfcf.UArgb[0]=pUARGB[0];
+ ddfcf.UArgb[1]=pUARGB[1];
+ ddfcf.UArgb[2]=pUARGB[2];
+ }
+ else{
+ ddfcf.UArgb[0]=0;
+ ddfcf.UArgb[1]=0;
+ ddfcf.UArgb[2]=0;
+ }
+ DDV_SetStd_AA_UA_ClrEx(*gclr, (Pointer)&ddfcf, NULL, what);
+ }
+ vnp2=vnp2->next;
+ }
+ }
+ vnp=vnp->next;
+ }
+ }
+ return(TRUE);
+}
+
+/*******************************************************************************
+
+ Function : DDV_InitColour_When_Start()
+
+ Purpose : standard init function for Vibrant DDV ; see DDV_InitColourSAP()
+
+*******************************************************************************/
+NLM_EXTERN Boolean DDV_InitColour_When_Start(SeqAlignPtr sap,MsaParaGPopListPtr mpplp,
+ DDV_ColorGlobal * * gclr, Boolean NoColor)
+{
+ if(NoColor)
+ return(DDV_InitColourSAP(sap,mpplp,gclr,DDV_USE_STDCLR,NULL,0,NULL,0));
+ else
+ return(DDV_InitColourSAP(sap,mpplp,gclr,DDV_USE_STDCLR,NULL,
+ DDV_TXTSTYLE_COLOR,NULL,DDV_TXTSTYLE_COLOR|DDV_TXTSTYLE_LOWERCASE));
+}
+
+/*******************************************************************************
+
+ Function : DDV_LayoutUAregion()
+
+ Purpose : set a layout for UnAligned regions; see DDV_InitColourSAP()
+
+*******************************************************************************/
+NLM_EXTERN Boolean DDV_LayoutUAregion(SeqAlignPtr sap,MsaParaGPopListPtr mpplp,
+ DDV_ColorGlobal * * gclr,Uint1 * pRGB,Uint1 style,Uint1 * pUARGB,Uint1 UAstyle)
+{
+ return(DDV_InitColourSAP(sap,mpplp,gclr,DDV_USE_UALAYOUT,pRGB,style,pUARGB,UAstyle));
+}
+
+
+/*******************************************************************************
+
+ Function : UDV_BigEncodeIdxFeat4()
+
+ Purpose : encode two Uint4 into one Uint8
+
+*******************************************************************************/
+static Uint8 UDV_BigEncodeIdxFeat4 (Uint4 val1,Uint4 val2)
+{
+Uint4 index_g[2];
+
+ index_g[0]=val1;
+ index_g[1]=val2;
+
+ return *((Uint8Ptr) index_g);
+
+}
+
+/*******************************************************************************
+
+ Function : UDV_BigEncodeIdxFeat4()
+
+ Purpose : decode one Uint8 into two Uint4
+
+*******************************************************************************/
+static void UDV_BigDecodeIdxFeat4 (Uint8 index_g, Uint4Ptr val1, Uint4Ptr val2)
+{
+Uint4Ptr index_g2;
+
+ index_g2 = (Uint4Ptr) (&index_g);
+ if (val1) *val1 = (Uint4) index_g2 [0];
+ if (val2) *val2 = (Uint4) index_g2 [1];
+}
+
+/*******************************************************************************
+
+ Function : DDV_GetGapCoord()
+
+ Purpose : get the list of gaps given a ParaG.
+
+ Return value : -.
+
+*******************************************************************************/
+static void DDV_GetGapCoord(ParaGPtr pgp,ValNodePtr PNTR gap_list)
+{
+ValNodePtr vnp;
+MsaTxtDispPtr mtdp;
+
+ if (!pgp) return;
+ vnp=pgp->ptxtList;
+ while(vnp){
+ mtdp=(MsaTxtDispPtr)vnp->data.ptrvalue;
+ if (mtdp){
+ if(mtdp->IsGap && (mtdp->TextStyle==MSA_TXT_STYLE_GAP ||
+ mtdp->TextStyle==MSA_TXT_STYLE_2)){
+ ValNodeAddBigInt(gap_list,0,
+ UDV_BigEncodeIdxFeat4 ((Uint4)mtdp->from,(Uint4)mtdp->to));
+ }
+ }
+ vnp=vnp->next;
+ }
+}
+
+/*******************************************************************************
+
+ Function : DDV_AllGapInLowerCase()
+
+ Purpose : analyse sequences by pair and switch to lower case all residues
+ "aligned" with a gap.
+
+ Return value : -.
+
+*******************************************************************************/
+NLM_EXTERN void DDV_LayoutGap(DDV_ColorGlobal *pcg,ValNodePtr vnp_seq1,
+ ValNodePtr vnp_seq2,Int4 row2,Uint1 style,Uint1 *rgb)
+{
+DDV_ColorCell * dccp;
+ValNodePtr vnp1,vnp2,vnp3,vnp4;
+ParaGPtr pgp1,pgp2;
+Uint4 i,from,to;/*display coord.*/
+Int4 bsp_coord;
+DDV_ColorCell dcc;
+
+ if (pcg==NULL || vnp_seq1==NULL || vnp_seq2==NULL) return;
+ /*scan the first sequence to modify the second*/
+ vnp1=vnp_seq1;
+ vnp2=vnp_seq2;
+ vnp3=NULL;
+ while(vnp1){
+ /*is there a gap in the vnp1 ParaG*/
+ pgp1=(ParaGPtr)vnp1->data.ptrvalue;
+ pgp2=(ParaGPtr)vnp2->data.ptrvalue;
+ DDV_GetGapCoord(pgp1,&vnp3);
+ if (vnp3){
+ vnp4=vnp3;
+ while(vnp4){
+ UDV_BigDecodeIdxFeat4((Uint8)vnp4->data.bigintvalue,
+ &from, &to);
+ to++;
+ for (i=from;i<to;i++){
+ bsp_coord=(Int4)DDV_GetBspCoordGivenDispCoord(pgp2,(Int4)i);
+ if (bsp_coord>=0){
+ dccp=DDV_GetColor(pcg,NULL,row2+1,bsp_coord);
+ if (dccp){/*if there is already a color, just
+ update the required parameter*/
+ DDV_SetStyle(dccp,style,rgb,FALSE);
+ DDV_SetColor(pcg,NULL,row2+1,bsp_coord,dccp);
+ }
+ else{/*otherwise, set up a new layout for that letter*/
+ memset(&dcc,0,sizeof(DDV_ColorCell));
+ DDV_SetStyle(&dcc,style,rgb,FALSE);
+ DDV_SetColor(pcg, NULL, row2+1, bsp_coord, &dcc);
+ }
+ }
+ }
+ vnp4=vnp4->next;
+ }
+ }
+ vnp1=vnp1->next;
+ vnp2=vnp2->next;
+ if (vnp3)
+ vnp3=ValNodeFree(vnp3);
+ }
+}
+
+/*******************************************************************************
+
+ Function : DDV_LayoutMaskRegions()
+
+ Purpose : layout the masked regions of a sequence (usually the query sequence
+ of BLAST).
+
+ Return value : -.
+
+*******************************************************************************/
+NLM_EXTERN void DDV_LayoutMaskRegions(DDV_ColorGlobal *pcg,
+ ValNodePtr vnp_query,ValNodePtr mask,Int4 row,Uint1 style,Uint1 *rgb)
+{
+ DDV_ColorCell * dccp;
+ ValNodePtr vnp;
+ SeqLocPtr slp;
+ Int4 i,bsp_start,bsp_stop,mask_start,mask_stop,scan_from,
+ scan_to;
+ DDV_ColorCell dcc;
+
+ if (pcg==NULL || vnp_query==NULL || mask==NULL) return;
+
+ /*get sequence range*/
+ UDV_GetBspRangeinPGPList(vnp_query,&bsp_start,&bsp_stop);
+
+ /*scan the mask list*/
+ vnp=mask;
+ while(vnp) {
+ slp=(SeqLocPtr)vnp->data.ptrvalue;
+
+ if(slp == NULL)
+ return;
+
+ if(slp->choice == SEQLOC_PACKED_INT)
+ slp = slp->data.ptrvalue;
+ else if (slp->choice != SEQLOC_INT)
+ return;
+
+ while(slp) {
+
+ if(slp->choice != SEQLOC_INT) {
+ slp = slp->next;
+ continue;
+ }
+
+ mask_start=SeqLocStart(slp);
+ mask_stop=SeqLocStop(slp);
+
+ /*check if the masked region is in the bsp range*/
+ if (mask_stop>=bsp_start && mask_start<=bsp_stop){
+ scan_from=_max_(mask_start,bsp_start);
+ scan_to=_min_(mask_stop,bsp_stop)+1;
+ for(i=scan_from;i<scan_to;i++) {
+ dccp=DDV_GetColor(pcg,NULL,row+1,i);
+ if (dccp){/*if there is already a color, just
+ update the LowerCase parameter*/
+ DDV_SetStyle(dccp,style,rgb,FALSE);
+ DDV_SetColor(pcg,NULL,row+1,i,dccp);
+ } else{/*otherwies, set a new layout for that letter*/
+ memset(&dcc,0,sizeof(DDV_ColorCell));
+ DDV_SetStyle(&dcc,style,rgb,FALSE);
+ DDV_SetColor(pcg, NULL, row+1, i, &dcc);
+ }
+ }
+ }
+ slp = slp->next;
+ }
+ vnp=vnp->next;
+ }
+}
+
+/*******************************************************************************
+
+ Function : DDV_SetISOClr()
+
+ Purpose : layout the colors for ident/simil/other (I/S/O).
+
+*******************************************************************************/
+static void DDV_SetISOClr(DDV_ColorGlobal * pcg, ParaGPtr pgp,Int4 disp_coord,
+ Int4 row, Uint1 idx,Uint1 sty)
+{
+DDV_ColorCell * dccp;
+DDV_ColorCell dcc;
+Int4 bsp_coord;
+
+ bsp_coord=DDV_GetBspCoordGivenDispCoord(pgp,disp_coord);
+ if (bsp_coord>=0){
+ dccp=DDV_GetColor(pcg,NULL,row+1,bsp_coord);
+ if (dccp){/*if there is already a color, just
+ update the required parameter*/
+ dccp->rgb[0]=DDV_PaletteRGB[idx][0];
+ dccp->rgb[1]=DDV_PaletteRGB[idx][1];
+ dccp->rgb[2]=DDV_PaletteRGB[idx][2];
+ DDV_SetStyle(dccp,sty,NULL,FALSE);
+ DDV_SetColor(pcg,NULL,row+1,bsp_coord,dccp);
+ }
+ else{/*otherwise, set up a new layout for that letter*/
+ memset(&dcc,0,sizeof(DDV_ColorCell));
+ dcc.rgb[0]=DDV_PaletteRGB[idx][0];
+ dcc.rgb[1]=DDV_PaletteRGB[idx][1];
+ dcc.rgb[2]=DDV_PaletteRGB[idx][2];
+ DDV_SetStyle(&dcc,sty,NULL,FALSE);
+ DDV_SetColor(pcg, NULL, row+1, bsp_coord, &dcc);
+ }
+ }
+}
+
+/*******************************************************************************
+
+ Function : DDV_LayoutIdentColors()
+
+ Purpose : layout the colors for ident/simil/other (I/S/O).
+
+ Return value : -.
+
+*******************************************************************************/
+NLM_EXTERN void DDV_LayoutISOColors(DDV_ColorGlobal *pcg,ValNodePtr * row_list,Int4 nRow,
+ Int4 Master,Boolean bSetMaster,Int4Ptr * matrix,Uint1 IdentClr,Uint1 SimilClr,
+ Uint1 OtherClr,Uint1 IdentSty,Uint1 SimilSty,Uint1 OtherSty)
+{
+ValNodePtr * row;
+ValNodePtr vnp;
+ParaGPtr pgpQuery,pgpSubject;
+CharPtr szQuery,szComp;
+BioseqPtr bsp;
+Boolean IsAA;
+Int4 i,j,len,bspLength;
+Uint1 idx,sty;
+
+ row=(ValNodePtr *)MemNew(nRow*sizeof(ValNodePtr));
+ if (!row) return;
+ for (i=0;i<nRow;i++){
+ row[i]=row_list[i];
+ }
+
+ vnp=row_list[Master];
+ while(vnp){
+ /*get the master sequence*/
+ pgpQuery=(ParaGPtr)vnp->data.ptrvalue;
+ szQuery=(CharPtr)MemNew((pgpQuery->StopLetter-pgpQuery->StartLetter+3)*sizeof(Char));
+ if (!szQuery) goto error;
+ bsp=BioseqLockById(pgpQuery->sip);
+ if (!bsp) goto error;
+ bspLength=BioseqGetLen(bsp);
+ IsAA=ISA_aa(bsp->mol);
+ BioseqUnlock(bsp);
+ if (!DDV_GetSequenceFromParaG(pgpQuery,&szQuery,bspLength,IsAA,NULL,
+ NULL,NULL)) goto error;
+ /*lopp on each row, get the sequence, set the colors*/
+ for (i=0;i<nRow;i++){
+ if (i==Master) continue;
+ pgpSubject=(ParaGPtr)row[i]->data.ptrvalue;
+ szComp=DDV_GetBLASTCompLine_3(szQuery,pgpSubject,matrix);
+ if (szComp){
+ len=StringLen(szComp)+1;
+ for (j=0;j<len;j++){
+ if (isalpha(szComp[j]) || szComp[j]=='|'){
+ idx=IdentClr;
+ sty=IdentSty;
+ }
+ else if (szComp[j]=='+'){
+ idx=SimilClr;
+ sty=SimilSty;
+ }
+ else{
+ idx=OtherClr;
+ sty=OtherSty;
+ }
+ DDV_SetISOClr(pcg,pgpSubject,pgpSubject->StartLetter+j,i,idx,sty);
+ if (bSetMaster)
+ DDV_SetISOClr(pcg,pgpQuery,pgpQuery->StartLetter+j,0,idx,sty);
+ }
+ MemFree(szComp);
+ }
+ row[i]=row[i]->next;
+ }
+ szQuery=MemFree(szQuery);
+ vnp=vnp->next;
+ }
+error:
+
+ MemFree(row);
+ if (szQuery) MemFree(szQuery);
+}
+
+
+NLM_EXTERN MsaParaGPopListPtr DDE_CreateDisplayForBlock(SeqAlignPtr sap, Int4 BlockIndex) {
+/*----------------------------------------------------------------------------
+* allocate and fill the paragraphs for displaying 1 block of a
+* sequence alignment, plus the flanking unaligned regions.
+* BlockIndex is a 0-based block count.
+*
+* This function works by making a linked-list of 3 DescriDisp's:
+* head --> node1 --> node2 --> node3
+* || || ||
+* \/ \/ \/
+* unaligned aligned unaligned
+*
+* This is a descriptor for the display. This descriptor is passed
+* to DDV_PopulateDisplayForDisc to create the paragraphs.
+* Each node is easy to construct:
+*
+*
+* Aligned (A) UnAligned (UA)
+* ----------- --------------
+* from: SeqAlign coords 0
+* to: " " length-1
+* TextStyle: MSA_TXT_STYLE_REG_ALIGN MSA_TXT_STYLE_REG_UNALIGN
+* UAnum: 0 (explained below)
+* UAMaxLength: 0 length
+*
+*
+* UAnum, for unaligned regions, is determined as shown here:
+*
+* BlockIndex: 0 1 2
+* |<--UA-->|<--A-->|<--UA-->|<--A-->|<--UA-->|<--A-->|<--UA-->|
+* UAnum: -1 1 2 -2
+* where -1 and -2 are for the LEFT_TAIL and RIGHT_TAIL, respectively.
+*
+*
+* return a pointer to the paragraph list.
+* return NULL for unsuccessful completion.
+*---------------------------------------------------------------------------*/
+ ValNodePtr head = NULL;
+ DescriDispPtr ddp1, ddp2, ddp3;
+ Int4 i, NumRows, NumBlocks, Size, SaveSize, start, stop;
+ Int4 TotalLength=0;
+ Uint1 strand=Seq_strand_unknown;
+ DDV_Disp_Opt DisplayOptions;
+ MsaParaGPopListPtr pPopList;
+
+ /* index the seq align */
+/* if (!AlnMgrIndexSeqAlign(sap)) {
+ return(NULL);
+ } */
+
+ NumRows = AlnMgrGetNumRows(sap);
+ NumBlocks = AlnMgrGetNumAlnBlocks(sap);
+ if ((BlockIndex < 0) || (BlockIndex >= NumBlocks)) {
+ return(NULL);
+ }
+
+ /* figure out the length of the unaligned region preceeding the block */
+ SaveSize = 0;
+ for (i=0; i<NumRows; i++) {
+ if (BlockIndex == 0) {
+ AlnMgrGetNthRowTail(sap, i+1, LEFT_TAIL, &start, &stop, &strand);
+ }
+ else {
+ AlnMgrGetNthUnalignedForNthRow(sap, BlockIndex, i+1, &start, &stop);
+ }
+ if ((start == -1) && (stop == -1)) {Size = 0;}
+ else {Size = (stop-start)+1;}
+ if (Size > SaveSize) {SaveSize = Size;}
+ }
+ TotalLength += SaveSize;
+
+ /* make a node for this region */
+ ddp1 = MemNew(sizeof(DescriDisp));
+ ddp1->from = 0;
+ ddp1->to = SaveSize - 1;
+ ddp1->TextStyle = MSA_TXT_STYLE_REG_UNALIGN;
+ /* set UAnum to -1 for LEFT_TAIL */
+ ddp1->UAnum = (BlockIndex == 0) ? -1 : BlockIndex;
+ ddp1->UAMaxlength = SaveSize;
+ ddp1->strand = strand;
+ ddp1->IsGap = FALSE;
+
+ /* add it to the linked list */
+ ValNodeAddPointer(&head, 0, ddp1);
+
+ /* make node for aligned block and add it to linked list */
+ AlnMgrGetNthBlockRange(sap, BlockIndex+1, &start, &stop);
+ ddp2 = MemNew(sizeof(DescriDisp));
+ ddp2->from = start;
+ ddp2->to = stop;
+ ddp2->TextStyle = MSA_TXT_STYLE_REG_ALIGN;
+ ddp2->UAnum = 0;
+ ddp2->UAMaxlength = 0;
+ ddp2->strand = strand;
+ ddp2->IsGap = FALSE;
+ ValNodeAddPointer(&head, 0, ddp2);
+ TotalLength += (stop - start) + 1;
+
+ /* figure out the length of the unaligned region following the block */
+ SaveSize = 0;
+ for (i=0; i<NumRows; i++) {
+ if (BlockIndex == (NumBlocks-1)) {
+ AlnMgrGetNthRowTail(sap, i+1, RIGHT_TAIL, &start, &stop, &strand);
+ }
+ else {
+ AlnMgrGetNthUnalignedForNthRow(sap, BlockIndex+1, i+1, &start, &stop);
+ }
+ if ((start == -1) && (stop == -1)) {Size = 0;}
+ else {Size = (stop-start)+1;}
+ if (Size > SaveSize) {SaveSize = Size;}
+ }
+ TotalLength += SaveSize;
+
+ /* make a node for this region */
+ ddp3 = MemNew(sizeof(DescriDisp));
+ ddp3->from = 0;
+ ddp3->to = SaveSize - 1;
+ ddp3->TextStyle = MSA_TXT_STYLE_REG_UNALIGN;
+ /* set UAnum to -2 for RIGHT_TAIL */
+ ddp3->UAnum = (BlockIndex == (NumBlocks-1)) ? -2 : BlockIndex + 1;
+ ddp3->UAMaxlength = SaveSize;
+ ddp3->strand = strand;
+ ddp3->IsGap = FALSE;
+
+ /* add it to the linked list */
+ ValNodeAddPointer(&head, 0, ddp3);
+
+ /* create the paragraphs from the descriptor */
+ pPopList = MemNew(sizeof(MsaParaGPopList));
+ DDV_InitDDESAPdispStyles(&DisplayOptions);
+ if (DDV_PopulateDisplayForDisc(sap, pPopList, NumRows, TotalLength+10,
+ &DisplayOptions, TotalLength, head, TRUE, FALSE)) {
+ return(pPopList);
+ }
+ else {
+ return(NULL);
+ }
+}
+
+
+NLM_EXTERN MsaParaGPopListPtr DDE_CreateDisplayForUnAligned(SeqAlignPtr sap, Int4 UAIndex) {
+/*----------------------------------------------------------------------------
+* allocate and fill the paragraphs for displaying 1 unaligned
+* region of a sequence alignment. UAIndex is a 0-based count.
+* (UA = unaligned)
+*
+* This function works by making a linked-list of just 1 DescriDisp.
+* This is a descriptor for the display. This descriptor is passed
+* to DDV_PopulateDisplayForDisc to create the paragraphs.
+*
+* Each node is easy to construct:
+*
+* UnAligned (UA)
+* ---------------------------
+* from: 0
+* to: length-1
+* TextStyle: MSA_TXT_STYLE_REG_UNALIGN
+* UAnum: (explained below)
+* UAMaxLength: length
+*
+* UAnum is determined as shown here:
+*
+* UAIndex: 0 1 2 3
+* |<--UA-->|<--A-->|<--UA-->|<--A-->|<--UA-->|<--A-->|<--UA-->|
+* UAnum: -1 1 2 -2
+* where -1 and -2 are for the LEFT_TAIL and RIGHT_TAIL, respectively.
+*
+* return a pointer to the paragraph list.
+* return NULL for unsuccessful completion.
+*---------------------------------------------------------------------------*/
+ ValNodePtr head = NULL;
+ DescriDispPtr ddp1;
+ Int4 NumRows, NumBlocks;
+ Int4 i, Size, SaveSize, start, stop;
+ Int4 TotalLength=0;
+ Uint1 strand=Seq_strand_unknown;
+ DDV_Disp_Opt DisplayOptions;
+ MsaParaGPopListPtr pPopList;
+
+ /* index the seq align */
+/* if (!AlnMgrIndexSeqAlign(sap)) {
+ return(NULL);
+ } */
+
+ NumRows = AlnMgrGetNumRows(sap);
+ NumBlocks = AlnMgrGetNumAlnBlocks(sap);
+ if ((UAIndex < 0) || (UAIndex > NumBlocks)) {
+ return(NULL);
+ }
+
+ /* figure out the length of the unaligned region preceeding the block */
+ SaveSize = 0;
+ for (i=0; i<NumRows; i++) {
+ if (UAIndex == 0) {
+ AlnMgrGetNthRowTail(sap, i+1, LEFT_TAIL, &start, &stop, &strand);
+ }
+ else if (UAIndex == NumBlocks) {
+ AlnMgrGetNthRowTail(sap, i+1, RIGHT_TAIL, &start, &stop, &strand);
+ }
+ else {
+ AlnMgrGetNthUnalignedForNthRow(sap, UAIndex, i+1, &start, &stop);
+ }
+ if ((start == -1) && (stop == -1)) {Size = 0;}
+ else {Size = (stop-start)+1;}
+ if (Size > SaveSize) {SaveSize = Size;}
+ }
+ TotalLength += SaveSize;
+
+ /* make a node for this region */
+ ddp1 = MemNew(sizeof(DescriDisp));
+ ddp1->from = 0;
+ ddp1->to = SaveSize - 1;
+ ddp1->TextStyle = MSA_TXT_STYLE_REG_UNALIGN;
+ /* set UAnum to -1 for LEFT_TAIL, -2 for RIGHT_TAIL, or UAIndex */
+ if (UAIndex == 0) {ddp1->UAnum = -1;}
+ else if (UAIndex == NumBlocks) {ddp1->UAnum = -2;}
+ else {ddp1->UAnum = UAIndex;}
+ ddp1->UAMaxlength = SaveSize;
+ ddp1->strand = strand;
+ ddp1->IsGap = FALSE;
+
+ /* add it to the linked list */
+ ValNodeAddPointer(&head, 0, ddp1);
+
+ /* create the paragraphs from the descriptor */
+ pPopList = MemNew(sizeof(MsaParaGPopList));
+ DDV_InitDDESAPdispStyles(&DisplayOptions);
+ if (DDV_PopulateDisplayForDisc(sap, pPopList, NumRows, TotalLength+10,
+ &DisplayOptions, TotalLength, head, FALSE, TRUE)) {
+ return(pPopList);
+ }
+ else {
+ return(NULL);
+ }
+}
+
+
+NLM_EXTERN MsaParaGPopListPtr DDE_CreateDisplay(SeqAlignPtr sap, Int4 BlockIndex,
+ Boolean IsUnAligned, Int4* pNumBlocks) {
+/*----------------------------------------------------------------------------
+* build display, ruler, entitiesTbl for either an
+* unaligned region or an aligned block
+*---------------------------------------------------------------------------*/
+ MsaParaGPopListPtr mpplp;
+ Int4 from=-1, to;
+
+ if (IsUnAligned) {
+ mpplp = DDE_CreateDisplayForUnAligned(sap, BlockIndex);
+ *pNumBlocks = 0;
+ }
+ else {
+ mpplp = DDE_CreateDisplayForBlock(sap, BlockIndex);
+ *pNumBlocks = 1;
+ /* get the first align index of block */
+ AlnMgrGetNthBlockRange(sap, BlockIndex+1, &from, &to);
+ }
+ ASSERT(mpplp != NULL);
+
+ mpplp->entitiesTbl = DDV_BuildBspEntitiesTbl(mpplp->TableHead, mpplp->nBsp);
+ ASSERT(mpplp->entitiesTbl != NULL);
+
+ mpplp->RulerDescr = DDE_ReMakeRuler(mpplp, FALSE, from);
+ return(mpplp);
+}
+
diff --git a/ddv/ddvcreate.h b/ddv/ddvcreate.h
new file mode 100644
index 00000000..dc94153b
--- /dev/null
+++ b/ddv/ddvcreate.h
@@ -0,0 +1,303 @@
+/* $Id: ddvcreate.h,v 1.31 2001/01/29 20:35:49 hurwitz Exp $
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information (NCBI)
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government do not place any restriction on its use or reproduction.
+* We would, however, appreciate having the NCBI and the author cited in
+* any work or product based on this material
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* ===========================================================================
+*
+* File Name: ddvcreate.h
+*
+* Author: Sarah Wheelan
+*
+* Version Creation Date: 08/99
+*
+* $Revision: 1.31 $
+*
+* File Description:
+*
+* Modifications:
+* --------------------------------------------------------------------------
+* $Log: ddvcreate.h,v $
+* Revision 1.31 2001/01/29 20:35:49 hurwitz
+* make gap between aligned blocks optional
+*
+* Revision 1.30 2001/01/25 21:49:14 hurwitz
+* added option for extra gap char (tilde) between aligned blocks
+*
+* Revision 1.29 2000/09/08 21:50:39 hurwitz
+* made DDV_ReadSeqBin public
+*
+* Revision 1.28 2000/05/04 22:43:38 hurwitz
+* don't launch DDE on top of DDV, change some wording, redraw DDE after save to AlnMgr
+*
+* Revision 1.27 2000/04/21 23:00:50 hurwitz
+* can launch DDE from DDV
+*
+* Revision 1.26 2000/04/19 15:45:50 hurwitz
+* can create display for a block
+*
+* Revision 1.25 2000/03/31 21:33:07 durand
+* added new default color schemas for BLAST
+*
+* Revision 1.24 2000/03/28 13:33:27 durand
+* moved DDV_Disp_Opt data structure to pgppop.h
+*
+* Revision 1.23 2000/03/21 19:26:45 durand
+* adapt ddvcreate to be used by pgppop
+*
+* Revision 1.22 2000/03/20 13:46:23 durand
+* fixed a bug in BLAST functions; added DDV_BLAST_COLOR0 to produce a BLAST output without any layout
+*
+* Revision 1.21 2000/02/28 16:52:47 durand
+* wrote a new manager for unaligned regions
+*
+* Revision 1.20 2000/02/23 21:34:29 durand
+* allow custom display of gap characters
+*
+* Revision 1.19 2000/02/23 19:49:33 durand
+* use row number instead of SeqId for coloring
+*
+* Revision 1.18 2000/02/14 16:49:34 durand
+* add new options for BLAST output
+*
+* Revision 1.17 2000/02/02 14:44:31 durand
+* added function to create data structure for block editor, fixed some bugs
+*
+* Revision 1.16 2000/01/26 13:38:55 durand
+* update the GUI for the editor. Add functions to create the data to be used by the editor
+*
+* Revision 1.15 1999/12/20 20:20:41 lewisg
+* allow cn3d to do color and ddv to do case when both are running
+*
+* Revision 1.14 1999/12/20 14:45:37 durand
+* add new functions for the new BLAST outputs
+*
+* Revision 1.13 1999/12/08 22:42:17 durand
+* add the code to produce colored BLAST outputs
+*
+* Revision 1.12 1999/12/03 23:17:22 lewisg
+* Patrick's new global update msg, argument passing when launching ddv, experimental editing
+*
+* Revision 1.11 1999/12/03 15:11:49 durand
+* add DDV_AllGapInLowerCase declaration
+*
+* Revision 1.10 1999/11/24 21:26:30 vakatov
+* Fixed for the C++ and/or MSVC DLL compilation
+*
+* Revision 1.9 1999/11/17 22:43:57 durand
+* speed up the selection manager for large SeqAlign
+*
+* Revision 1.8 1999/11/09 17:08:59 durand
+* transfer some functions from ddvgraph to ddvcreate, so that ddvcreate remains Vibrant free and can be compiled with BLAST
+*
+* Revision 1.7 1999/11/03 21:29:48 durand
+* add CTRL and SHFT keys for mouse selection. redesign the loader functions of DDV to properly register the message callbacks
+*
+* Revision 1.6 1999/10/29 14:15:40 durand
+* add simple mouse selection functions
+*
+* Revision 1.5 1999/10/22 20:12:47 durand
+* add Export command (text, HTML and Phylip formats)
+*
+* Revision 1.4 1999/10/20 13:17:19 durand
+* add display for disc. SeqAlign tails
+*
+* Revision 1.3 1999/10/15 21:57:36 durand
+* add a UI for display options
+*
+* Revision 1.2 1999/10/12 15:01:29 lewisg
+* resolve confict with internal/ddv
+*
+* Revision 1.1 1999/09/30 14:10:26 durand
+* add ddv to toolkit
+*
+* Revision 1.5 1999/09/30 13:38:09 durand
+* DDV_CreateDisplayFromIndex takes ParaG_Size as an argument
+*
+*
+*
+* ==========================================================================
+*/
+#ifndef _DDVCREATE_
+#define _DDVCREATE_
+
+#include <ncbi.h>
+#include <alignmgr.h>
+#include <udvseq.h>
+#include <pgppop.h>
+#include <udvdef.h>
+#include <ddvcreate.h>
+
+#undef NLM_EXTERN
+#ifdef NLM_IMPORT
+#define NLM_EXTERN NLM_IMPORT
+#else
+#define NLM_EXTERN extern
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*******************************************************************************
+
+ structure
+
+*******************************************************************************/
+typedef struct uabitdescr{
+ Int4 from;
+ Int4 to;
+ Boolean IsGap;
+} UABitDescr, PNTR UABitDescrPtr;
+
+typedef struct uamsg{ /*UnAligned Messaging structure*/
+ Int4 from_a; /*asked coord.*/
+ Int4 to_a;
+ Int4 from_r; /*returned coord.*/
+ Int4 to_r;
+ Int4 currentPos;
+ Uint1 DispType;
+ Uint1 strand;
+ Boolean IsGap;
+ UABitDescr ubd[3];
+} UAMsg, PNTR UAMsgPtr;
+
+typedef struct descridisp {
+ Int4 from;
+ Int4 to;
+ Int4 UAnum;
+ Int4 UAMaxlength;
+ Boolean IsGap;
+ Uint1 TextStyle;
+ Uint1 strand;
+} DescriDisp, PNTR DescriDispPtr;
+
+/*******************************************************************************
+
+ defines
+
+*******************************************************************************/
+#define RulerStyle_One_Start ((Uint1)1)
+#define RulerStyle_Continue_Start ((Uint1)2)
+
+/*size limit of a seqalign for edition (number of columns)*/
+#define LIMIT_EDITOR_SIZE 10000
+
+#define DDV_BLAST_COLOR0 0
+#define DDV_BLAST_COLOR1 1
+#define DDV_BLAST_COLOR2 2
+#define DDV_BLAST_COLOR3 3
+#define DDV_BLAST_COLOR4 4
+#define DDV_BLAST_COLOR5 5
+#define DDV_BLAST_COLOR6 6
+
+/*******************************************************************************
+
+ functions
+
+*******************************************************************************/
+NLM_EXTERN Boolean DDV_CreateDisplayFromIndex(SeqAlignPtr sap, MsaParaGPopListPtr mpplp,
+ Int2 LineSize, DDV_Disp_OptPtr ddop);
+NLM_EXTERN Boolean DDV_CreateDisplayFromIndex2(SeqAlignPtr sap, MsaParaGPopListPtr mpplp,
+ Int2 LineSize, DDV_Disp_OptPtr ddop, Boolean WantExtraGapChar);
+
+NLM_EXTERN Boolean DDV_CreateDisplayFromIndex_EX(SeqAlignPtr sap, MsaParaGPopListPtr mpplp,
+ Int2 LineSize, DDV_Disp_OptPtr ddop,Int4 start, Int4 stop);
+NLM_EXTERN Boolean DDV_CreateDisplayFromIndex_EX2(SeqAlignPtr sap, MsaParaGPopListPtr mpplp,
+ Int2 LineSize, DDV_Disp_OptPtr ddop,Int4 start, Int4 stop, Boolean WantExtraGapChar);
+
+NLM_EXTERN Boolean DDV_CreateDisplay_DiscAlign(SeqAlignPtr sap,
+ MsaParaGPopListPtr mpplp, Int2 LineSize,DDV_Disp_OptPtr ddop);
+NLM_EXTERN Boolean DDV_CreateDisplay_DiscAlign2(SeqAlignPtr sap,
+ MsaParaGPopListPtr mpplp, Int2 LineSize,DDV_Disp_OptPtr ddop, Boolean WantExtraGapChar);
+
+NLM_EXTERN Boolean DDV_BuildDisp_BlockEditor(SeqAlignPtr sap,
+ MsaParaGPopListPtr mpplp, Int4 block_num);
+NLM_EXTERN UAMsgPtr UAMgrIntUAMsg( Int4 MaxLength, Int4 BspLength,
+ Int4 BspStart,Int4 BspStop, Int4 ddpFrom, Int4 ddpTo,Uint1 DispType, Uint1 strand);
+NLM_EXTERN UAMsgPtr UAMgrDelUAMsg(UAMsgPtr PNTR uamp);
+NLM_EXTERN void UAMgrUAMsgGetInfo(UAMsgPtr uamp,Int4Ptr from_bsp, Int4Ptr to_bsp,
+ BoolPtr IsGap);
+NLM_EXTERN Boolean UAMgrGetNextUAbit(UAMsgPtr uamp,Int4 BspStart,Int4 BspStop);
+
+NLM_EXTERN ValNodePtr UABuildDescriptor(SeqAlignPtr sap, Int4 nBsp, Int2 LineSize,
+ DDV_Disp_OptPtr ddop, Int4Ptr TotLength,Boolean AddLeftUAPart,
+ Boolean AddRightUAPart);
+NLM_EXTERN ValNodePtr UABuildDescriptor2(SeqAlignPtr sap, Int4 nBsp, Int2 LineSize,
+ DDV_Disp_OptPtr ddop, Int4Ptr TotLength,Boolean AddLeftUAPart,
+ Boolean AddRightUAPart, Boolean WantExtraGapChar);
+
+NLM_EXTERN ValNodePtr UABuildDescriptorForBlockEditor(SeqAlignPtr sap, Int4 nBsp,
+ Int4 block_num,Int4 LineSize,Int4Ptr TotLength);
+NLM_EXTERN ValNodePtr DDV_BuildTailDescriptor(SeqAlignPtr sap, Int4 nBsp, Int2 LineSize,
+ Uint1 which_tail,Int4Ptr TotLength,Int4Ptr cumulpop);
+NLM_EXTERN void DDV_InitDefSAPdispStyles(DDV_Disp_OptPtr ddop);
+NLM_EXTERN void DDV_InitCn3DSAPdispStyles(DDV_Disp_OptPtr ddop);
+NLM_EXTERN void DDV_InitDDESAPdispStyles(DDV_Disp_OptPtr ddop);
+NLM_EXTERN Uint4Ptr DDV_BuildBspEntitiesTbl(ValNodePtr PNTR TableHead,Int4 nBsp);
+NLM_EXTERN Uint1Ptr DDV_ReadSeqBin (SeqIdPtr sip, Int4 from, Int4 to,
+ Boolean IsProt,Int2 len,Uint1 strand);
+
+/*export functions*/
+NLM_EXTERN void DDV_DumpSAPInAFile(MsaParaGPopListPtr mpplp,DDVOptionsBlockPtr dobp,
+ FILE *hFile,Uint4 option, DDV_ColorGlobal *gclr);
+NLM_EXTERN void DDV_DumpSAPInFastaFile(MsaParaGPopListPtr mpplp,DDVOptionsBlockPtr dobp,
+ FILE *hFile,Boolean bPrintGap);
+
+/*BLAST stuffs; function to build new outputs*/
+NLM_EXTERN Boolean DDV_DisplayBlastPairList(SeqAlignPtr sap, ValNodePtr mask,
+ FILE *fp, Boolean is_na, Uint4 tx_option,Uint1 ColorScheme);
+
+/*layout manager stuff*/
+NLM_EXTERN Boolean DDV_InitColour_When_Start(SeqAlignPtr sap,MsaParaGPopListPtr mpplp,
+ DDV_ColorGlobal * * gclr, Boolean NoColor);
+NLM_EXTERN Boolean DDV_LayoutUAregion(SeqAlignPtr sap,MsaParaGPopListPtr mpplp,
+ DDV_ColorGlobal * * gclr,Uint1 * pRGB,Uint1 style,Uint1 * pUARGB,
+ Uint1 UAstyle);
+NLM_EXTERN void DDV_LayoutGap(DDV_ColorGlobal *pcg,ValNodePtr vnp_seq1,
+ ValNodePtr vnp_seq2,Int4 row2,Uint1 style,Uint1 *rgb);
+NLM_EXTERN void DDV_LayoutMaskRegions(DDV_ColorGlobal *pcg,
+ ValNodePtr vnp_query,ValNodePtr mask,Int4 row,Uint1 style,Uint1 *rgb);
+NLM_EXTERN void DDV_LayoutISOColors(DDV_ColorGlobal *pcg,ValNodePtr * row_list,Int4 nRow,
+ Int4 Master,Boolean bSetMaster,Int4Ptr * matrix,Uint1 IdentClr,Uint1 SimilClr,
+ Uint1 OtherClr,Uint1 IdentSty,Uint1 SimilSty,Uint1 OtherSty);
+
+/* create display for a single aligned block or an unaligned region */
+NLM_EXTERN MsaParaGPopListPtr DDE_CreateDisplayForBlock(SeqAlignPtr sap, Int4 BlockIndex);
+NLM_EXTERN MsaParaGPopListPtr DDE_CreateDisplayForUnAligned(SeqAlignPtr sap, Int4 UAIndex);
+NLM_EXTERN MsaParaGPopListPtr DDE_CreateDisplay(SeqAlignPtr sap, Int4 BlockIndex,
+ Boolean IsUnAligned, Int4* pNumBlocks);
+
+#ifdef __cplusplus
+}
+#endif
+
+#undef NLM_EXTERN
+#ifdef NLM_EXPORT
+#define NLM_EXTERN NLM_EXPORT
+#else
+#define NLM_EXTERN
+#endif
+
+#endif /* ndef _DDVCREATE_ */
+
diff --git a/ddv/ddvgraph.c b/ddv/ddvgraph.c
new file mode 100644
index 00000000..cfba0802
--- /dev/null
+++ b/ddv/ddvgraph.c
@@ -0,0 +1,1349 @@
+/* $Id: ddvgraph.c,v 1.40 2001/04/27 20:12:46 juran Exp $
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information (NCBI)
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government do not place any restriction on its use or reproduction.
+* We would, however, appreciate having the NCBI and the author cited in
+* any work or product based on this material
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* ===========================================================================
+*
+* File Name: ddvgraph.c
+*
+* Author: Patrick Durand
+*
+* Version Creation Date: 06/19/99
+*
+* $Revision: 1.40 $
+*
+* File Description: graphic engine of DeuxD-Viewer (DDV)
+*
+* Modifications:
+* --------------------------------------------------------------------------
+* $Log: ddvgraph.c,v $
+* Revision 1.40 2001/04/27 20:12:46 juran
+* Heed warnings: Make functions static. Block out 'dead code' (functions that aren't called anywhere in ncbi).
+*
+* Revision 1.39 2000/07/24 22:00:08 hurwitz
+* fixed bug that 1/2 characters were displayed sometimes
+*
+* Revision 1.38 2000/07/19 19:04:01 hurwitz
+* fixed bug that was causing overwrite of numbering over tick marks in DDE
+*
+* Revision 1.37 2000/07/07 22:43:55 lewisg
+* interface tweaks
+*
+* Revision 1.36 2000/07/07 22:31:14 lewisg
+* interface tweaks
+*
+* Revision 1.35 2000/05/16 19:43:00 hurwitz
+* grey out create block, delete block, undo, and redo as needed
+*
+* Revision 1.34 2000/05/09 22:24:06 hurwitz
+* extend ruler to cover tails even when there's only 1 aligned block in the alignment
+*
+* Revision 1.33 2000/05/09 19:53:17 hurwitz
+* extended ruler to cover tails
+*
+* Revision 1.32 2000/04/26 21:54:27 hurwitz
+* added save function to tell AlnMgr about edits made in DDE
+*
+* Revision 1.31 2000/04/05 20:52:35 hurwitz
+* added GUI control for shifting left and right alignment boundaries
+*
+* Revision 1.30 2000/03/29 23:57:04 hurwitz
+* temporary fix for DDE use before it's initialized
+*
+* Revision 1.29 2000/03/29 20:02:48 hurwitz
+* keep track of master during move row operations
+*
+* Revision 1.28 2000/03/24 20:34:59 lewisg
+* add blast from file, bug fixes, get rid of redundant code, etc.
+*
+* Revision 1.27 2000/02/23 19:49:33 durand
+* use row number instead of SeqId for coloring
+*
+* Revision 1.26 2000/02/15 15:31:46 lewisg
+* move DDVRulerDescr to pgppop
+*
+* Revision 1.25 2000/02/08 17:18:40 hurwitz
+* don't use char* szEditSeq
+*
+* Revision 1.24 2000/02/07 14:03:35 durand
+* replace BioseqUnlockById by BioseqUnlock
+*
+* Revision 1.23 2000/02/04 16:05:40 durand
+* add click action to select a row
+*
+* Revision 1.22 2000/02/03 15:56:47 hurwitz
+* added constructor and destructor for DDVRulerDescrPtr
+*
+* Revision 1.21 2000/02/02 14:44:31 durand
+* added function to create data structure for block editor, fixed some bugs
+*
+* Revision 1.20 2000/01/26 13:38:54 durand
+* update the GUI for the editor. Add functions to create the data to be used by the editor
+*
+* Revision 1.19 2000/01/24 16:11:13 lewisg
+* speed up seqid comparison in color manager, make fast windows version of SetColor()
+*
+* Revision 1.18 2000/01/10 15:09:46 durand
+* Use Entrez instead of ID1
+*
+* Revision 1.17 2000/01/05 21:11:14 durand
+* update mouse click actions and DrawSequence function for a better use from ddv and cn3d
+*
+* Revision 1.16 1999/12/29 22:55:03 lewisg
+* get rid of seqalign id
+*
+* Revision 1.15 1999/12/07 21:40:14 durand
+* add mouse modes menu and caret facility for the editor
+*
+* Revision 1.14 1999/11/29 15:26:25 durand
+* designed a new GUI to fix problems under MacOS, Linux and SGI
+*
+* Revision 1.13 1999/11/23 17:34:33 lewisg
+* SavePort added to redraw
+*
+* Revision 1.12 1999/11/18 14:37:14 durand
+* avoid flashing sequence during selection
+*
+* Revision 1.11 1999/11/09 17:09:00 durand
+* transfer some functions from ddvgraph to ddvcreate, so that ddvcreate remains Vibrant free and can be compiled with BLAST
+*
+* Revision 1.10 1999/11/03 21:29:49 durand
+* add CTRL and SHFT keys for mouse selection. redesign the loader functions of DDV to properly register the message callbacks
+*
+* Revision 1.9 1999/10/29 14:15:38 durand
+* add simple mouse selection functions
+*
+* Revision 1.8 1999/10/21 13:12:12 durand
+* fix a problem in panel draw callback
+*
+* Revision 1.7 1999/10/20 13:17:18 durand
+* add display for disc. SeqAlign tails
+*
+* Revision 1.5 1999/10/18 17:20:56 durand
+* fix a bug in the bsp coord mapping for minus strand
+*
+* Revision 1.4 1999/10/15 21:57:36 durand
+* add a UI for display options
+*
+* Revision 1.3 1999/10/12 15:01:29 lewisg
+* resolve confict with internal/ddv
+*
+* Revision 1.2 1999/10/02 15:11:21 durand
+* update the code to reuse more functions from UDV
+*
+* Revision 1.1 1999/09/30 14:10:26 durand
+* add ddv to toolkit
+*
+* Revision 1.16 1999/09/22 20:40:20 durand
+* update the drawing procedure to deal with discontinuous seqalign
+*
+* Revision 1.15 1999/09/22 13:17:15 wheelan
+* Changed DDV_InitColour_When_Start to use new AlnMgrGetNextNthSeqRange function (better for discontinuous)
+*
+* Revision 1.14 1999/09/20 13:39:04 durand
+* replace totsaps by alnsaps (new AlignMgr stuff)
+*
+* Revision 1.13 1999/09/16 13:07:07 durand
+* DDV is able to display bioseq coords along with seqalign coords
+*
+* Revision 1.11 1999/09/09 21:54:23 durand
+* create a display for disconitnuous SeqAlign
+*
+* Revision 1.10 1999/09/01 23:02:59 lewisg
+* binary search in color functions
+*
+* Revision 1.9 1999/08/06 14:32:18 wheelan
+* changes to support new alignmgr function names
+*
+* Revision 1.8 1999/08/04 18:01:47 wheelan
+* changes to support new seqalign indexing
+*
+* Revision 1.7 1999/07/22 15:25:27 durand
+* improve DDV_DrawSequence function
+*
+* Revision 1.6 1999/07/20 14:58:00 durand
+* use the Color Manager to display colored MSA
+*
+* Revision 1.5 1999/07/06 19:02:21 durand
+* update DDV_GetSequenceFromParaG
+*
+* Revision 1.4 1999/06/30 14:57:23 durand
+* update DDV loader functions
+*
+* Revision 1.3 1999/06/28 22:07:18 durand
+* add loader functions and clean the code with Lint and Purify
+*
+* Revision 1.2 1999/06/19 18:36:44 durand
+* update display procedure
+*
+* Revision 1.1 1999/06/19 17:21:05 durand
+* add Vibrant DDV code
+*
+*
+*
+* ==========================================================================
+*/
+
+#include <ncbi.h>
+#include <vibrant.h>
+#include <udviewer.h>
+#include <udvseq.h>
+#include <ddvcolor.h>
+#include <ddvmain.h>
+#include <ddvgraph.h>
+#include <ddvclick.h>
+#include <pgppop.h>
+#include <alignmgr.h>
+#include <ddvcreate.h>
+
+#undef WANTDEADCODE
+
+static void DDV_DrawAlignmentBoundaries(PaneL p, DdvMainPtr dmp);
+
+/*******************************************************************************
+
+ Function : DDV_ReorderParaG()
+
+ Purpose : reorder ParaG positions after style change(s)
+
+ Return value : -
+
+*******************************************************************************/
+#ifdef WANTDEADCODE
+static void DDV_ReorderParaG(ValNodePtr PNTR TableHead, Int4 nRow)
+{
+Int4 Startline=0,i,nLines;
+ParaGPtr pgp;
+ValNodePtr vnp;
+
+ for(i=0;i<nRow;i++){
+ vnp=TableHead[i];
+ pgp=(ParaGPtr)vnp->data.ptrvalue;
+ if (pgp->ScaleStyle==SCALE_POS_TOP)
+ nLines++;
+ nLines=1;
+ while(vnp){
+ pgp=(ParaGPtr)vnp->data.ptrvalue;
+ pgp->StartLine=Startline;
+ pgp->nLines=nLines;
+ vnp=vnp->next;
+ }
+ Startline+=nLines;
+ }
+}
+#endif
+
+/*******************************************************************************
+
+ Function : DDV_ChangeRulerStyleForSeq()
+
+ Purpose : change the ruler style for a row in the alignment; ie for a Seq.
+
+ Return value : -
+
+*******************************************************************************/
+#ifdef WANTDEADCODE
+static void DDV_ChangeRulerStyleForSeq(ValNodePtr PNTR TableHead,Int4 nRow,
+ Uint1 RulerStyle)
+{
+ParaGPtr pgp;
+ValNodePtr vnp;
+
+ vnp=TableHead[nRow];
+ while(vnp){
+ pgp=(ParaGPtr)vnp->data.ptrvalue;
+ pgp->ScaleStyle=RulerStyle;
+ vnp=vnp->next;
+ }
+}
+#endif
+
+/*******************************************************************************
+
+ Function : DDV_InvalRegion()
+
+ Purpose : invalidate a specific region of DDV panel
+
+ Note : disp_from,disp_to,disp_row are display coordinates.
+ disp_from,disp_to are zero-based.
+ disp_row is one-based
+
+ Return value : the sequence
+
+*******************************************************************************/
+extern void DDV_InvalRegion(PaneL hWndDDV,UnDViewerGraphDataPtr GrData,
+ Int4 disp_from,Int4 disp_to,Int4 disp_row,Boolean IsSelect)
+{
+DdvMainPtr dmp;
+RecT rcP,rc;
+Int2 from_x,to_x,from_y,to_y;
+WindoW temport;
+
+ dmp = (DdvMainPtr) GetObjectExtra(hWndDDV);
+ if (dmp==NULL) return;
+
+ /*convert disp coord to pixel positions*/
+ /*left of the first letter in the range*/
+ from_x=(Int2)((disp_from-GrData->udv_hscrl.ScrollPos)*GrData->udv_font.ColWidth);
+ /*right of the last letter in the range*/
+ to_x=(Int2)((disp_to-GrData->udv_hscrl.ScrollPos+1)*GrData->udv_font.ColWidth);
+ /*just above the row*/
+ from_y=(Int2)((disp_row-GrData->udv_vscrl.ScrollPos-1)*GrData->udv_font.LineHeight);
+ /*just below the row*/
+ to_y=(Int2)(from_y+2*GrData->udv_font.LineHeight);
+
+ /*adjust the values according to the PaneL RecT position*/
+ /*panel size*/
+ temport=SavePort(ParentWindow(hWndDDV));
+ Select(hWndDDV);
+ ObjectRect(hWndDDV,&rcP);
+ InsetRect(&rcP,4,4);
+ /*drawing region:*/
+ DDV_AdjustDrawingRect(&rcP,&(GrData->udv_font),dmp);
+
+ rcP.left+=GrData->udv_panel.cxName+GrData->udv_scale.cxLeftScale;
+ rcP.top+=3*GrData->udv_panel.cyScale/2;
+ from_x+=rcP.left-1;
+ to_x+=rcP.left;
+ from_y+=rcP.top+1;
+ to_y+=rcP.top;
+
+ rc.left=from_x-2;
+ rc.top=from_y-2;
+ rc.right=to_x+2;
+ rc.bottom=to_y+2;
+
+ /*InvalRect(&rc);*/
+ /*DDV_DrawPanelContent_H (hWndDDV,dmp,&rc,IsSelect);*/
+
+ if (!IsSelect){
+ /*printf("invalRect\n");*/
+ InvalRect(&rc);
+ }
+ else{
+ DDV_DrawPanelContent_H (hWndDDV,dmp,&rc,IsSelect);
+ }
+/* Update();*/
+ RestorePort(temport);
+}
+
+/*******************************************************************************
+
+ Function : DDV_GetBspRangeInSeg()
+
+ Purpose : scan a segment and get the region of a Bsp in the SeqAlign
+
+ Return value : the sequence
+
+*******************************************************************************/
+
+#ifdef WANTDEADCODE
+static void DDV_GetBspRangeInSeg(SegmentPtr segp,Int4Ptr start,Int4Ptr stop)
+{
+SegmentPtr segp2;
+Int4 from,to;
+
+ if (!segp) return;
+ from=INT4_MAX;
+ to=INT4_MIN;
+ segp2=segp;
+ while(segp2){
+ if (segp2->gap==0) {
+ from=MIN(from,segp2->from);
+ to=MAX(to,segp2->to);
+ }
+ segp2=segp2->bsp_next;
+ }
+ *start=from;
+ *stop=to;
+}
+#endif
+
+
+/*******************************************************************************
+
+ Function : DDV_GetCurrentDispRange()
+
+ Purpose : compute the size (row/col) of the DDV panel
+
+ Return value : see arguments (zero-based values)
+
+*******************************************************************************/
+extern void DDV_GetCurrentDispRange(PaneL hWndDDV,UnDViewerGraphDataPtr GrData,
+ Int4 LengthAli,Int4Ptr from_col,Int4Ptr to_col,Int4Ptr from_row,
+ Int4Ptr to_row)
+{
+
+ RecT rcP;
+ DdvMainPtr dmp;
+
+ dmp = (DdvMainPtr) GetObjectExtra(hWndDDV);
+ if (dmp==NULL) return;
+
+ /*panel size*/
+ ObjectRect(hWndDDV,&rcP);
+ InsetRect(&rcP,4,4);
+
+ /*drawing region:*/
+ DDV_AdjustDrawingRect(&rcP,&(GrData->udv_font),dmp);
+
+ rcP.left+=GrData->udv_panel.cxName+GrData->udv_scale.cxLeftScale;
+ rcP.top+=GrData->udv_panel.cyScale;
+
+ *from_col=0;
+ *to_col=(rcP.right-rcP.left)/GrData->udv_font.ColWidth-1;
+ *from_col+=GrData->udv_hscrl.ScrollPos;
+ *to_col+=GrData->udv_hscrl.ScrollPos;
+ if (*to_col>LengthAli) *to_col=LengthAli-1;
+ if (*from_col>LengthAli) *from_col=LengthAli-1;
+ *from_row=0;
+ *to_row=(rcP.bottom-rcP.top)/GrData->udv_font.LineHeight-1;
+ *from_row+=GrData->udv_vscrl.ScrollPos;
+ *to_row+=GrData->udv_vscrl.ScrollPos;
+ if (*from_row>(GrData->udv_panel.nTotLines-1)) *from_row=GrData->udv_panel.nTotLines-1;
+ if (*to_row>(GrData->udv_panel.nTotLines-1)) *to_row=GrData->udv_panel.nTotLines-1;
+
+}
+
+/*******************************************************************************
+
+ Function : DDV_GetRulerForEditor()
+
+ Purpose : create the ruler for the editor. This new descriptor is created
+ using the descriptor of the viewer.
+
+ Return value : an allocated data block ready for use by the editor. Null if
+ failure
+
+*******************************************************************************/
+NLM_EXTERN ValNodePtr DDV_GetRulerForEditor(ValNodePtr descr_head,Int4 from_disp,
+ Int4 to_disp)
+{
+DDVRulerDescrPtr drdp,prev_drdp,new_drdp;
+ValNodePtr vnp2,vnp3,vnpDesc;
+Int4 cumulDecr,drdp_size,beginCopy,endCopy,drdp_start_ali;
+Boolean bPop;
+
+ cumulDecr=0;
+ vnpDesc=NULL;
+ prev_drdp=NULL;
+
+ for(vnp2=descr_head;vnp2!=NULL;vnp2=vnp2->next){
+ drdp=(DDVRulerDescrPtr)vnp2->data.ptrvalue;
+ drdp_size=drdp->disp_stop-drdp->disp_start+1;
+
+ /*not yet in the region of interest ?*/
+ if (drdp->disp_stop<from_disp) {
+ cumulDecr+=drdp_size;
+ continue;
+ }
+
+ beginCopy=_max_(from_disp,drdp->disp_start);
+ endCopy=_min_(drdp->disp_stop,to_disp);
+
+ if (drdp->bUnAligned==FALSE)
+ drdp_start_ali=drdp->align_start+(beginCopy-drdp->disp_start);
+ else
+ drdp_start_ali=(Int4)-1;
+ /*in order to merge nodes of same type, i keep track of
+ the previous populated drdp node. Same style==yes, then
+ just extend to the right the previous node*/
+ if (prev_drdp){
+ if (prev_drdp->bUnAligned==drdp->bUnAligned){
+ prev_drdp->disp_stop=endCopy;
+ bPop=TRUE;
+ }
+ else{
+ bPop=FALSE;
+ }
+ }
+ else{
+ bPop=FALSE;
+ }
+ if (!bPop){
+ new_drdp=(DDVRulerDescrPtr)MemNew(sizeof(DDVRulerDescr));
+ if (!new_drdp) goto erreur;
+
+ new_drdp->disp_start=beginCopy;
+ new_drdp->disp_stop=endCopy;
+ new_drdp->align_start=drdp_start_ali;
+ new_drdp->bUnAligned=drdp->bUnAligned;
+ if (!vnpDesc){
+ vnp3=ValNodeAddPointer(&vnpDesc,0,(Pointer)new_drdp);
+ }
+ else{
+ vnp3=ValNodeAddPointer(&vnp3,0,(Pointer)new_drdp);
+ }
+ prev_drdp=new_drdp;
+ }
+ if (drdp->disp_stop>=to_disp) break;
+ cumulDecr+=drdp_size;
+ }
+
+ return(vnpDesc);
+erreur:
+ if (vnpDesc)
+ ValNodeFreeData(vnpDesc);
+ return(NULL);
+}
+
+
+/*******************************************************************************
+
+ Function : DDV_ComputeRuler()
+
+ Purpose : compute the Ruler descriptor (usefull for discontinuous align)
+
+ Parameters :
+
+ Return value : a list of RUler descriptor
+
+*******************************************************************************/
+extern ValNodePtr DDV_ComputeRuler(SeqAlignPtr sap,DDV_Disp_OptPtr ddop)
+{
+
+DDVRulerDescrPtr drdp;
+ValNodePtr vnp=NULL,vnp_head=NULL;
+Int4 disp_start=0,length,TotAliLength=0,r=0;
+Boolean bUnAligned;
+
+ /* make ruler for LEFT_TAIL */
+ if ((ddop->DispDiscStyle == MSA_TXT_STYLE_2) && (ddop->ShowLeftTail)) {
+ length = AlnMgrGetMaxTailLength(sap, LEFT_TAIL);
+ if (length) {
+ drdp=(DDVRulerDescrPtr)MemNew(sizeof(DDVRulerDescr));
+ drdp->disp_start=disp_start;
+ drdp->disp_stop=disp_start+length-1;
+ drdp->bUnAligned=TRUE;
+ drdp->align_start = -1;
+ disp_start += length;
+ vnp_head=ValNodeAddPointer(NULL,0,(Pointer)drdp);
+ vnp=vnp_head;
+ }
+ }
+
+ if (AlnMgrIsSAPDiscAli(sap)){
+ /* make ruler for multiple blocks */
+ while(AlnMgrGetNextLengthBit(sap,&length,&r)){
+ if (length<0){
+ bUnAligned=TRUE;
+ switch(ddop->DispDiscStyle){/*user's display choice*/
+ case MSA_TXT_STYLE_1:
+ length=ddop->SpacerSize;
+ break;
+ case MSA_TXT_STYLE_2:
+ length=ABS(length);
+ break;
+ }
+ }
+ else{
+ bUnAligned=FALSE;
+ }
+
+ drdp=(DDVRulerDescrPtr)MemNew(sizeof(DDVRulerDescr));
+ drdp->disp_start=disp_start;
+ drdp->disp_stop=disp_start+length-1;
+ drdp->bUnAligned=bUnAligned;
+
+ if (bUnAligned==FALSE)
+ drdp->align_start=TotAliLength;/*SeqAlign Coord*/
+ else
+ drdp->align_start=-1;/*drdp->disp_start;*//*Disp Coord*/
+
+ if (!vnp_head){
+ vnp_head=ValNodeAddPointer(NULL,0,(Pointer)drdp);
+ vnp=vnp_head;
+ }
+ else{
+ vnp=ValNodeAddPointer(&vnp,0,(Pointer)drdp);
+ }
+ disp_start+=length;
+ if (bUnAligned==FALSE)
+ TotAliLength+=length;
+ }
+ }
+
+ else if (sap->type == SAT_MASTERSLAVE){
+ /* make ruler for a single block */
+ drdp=(DDVRulerDescrPtr)MemNew(sizeof(DDVRulerDescr));
+ drdp->disp_start=disp_start;
+ length=AlnMgrGetAlnLength(sap,FALSE);
+ drdp->disp_stop=disp_start+length-1;
+ drdp->bUnAligned = FALSE;
+ drdp->align_start=0;
+ if (!vnp_head){
+ vnp_head=ValNodeAddPointer(NULL,0,(Pointer)drdp);
+ vnp=vnp_head;
+ }
+ else{
+ vnp=ValNodeAddPointer(&vnp,0,(Pointer)drdp);
+ }
+ }
+
+ /* make ruler for RIGHT_TAIL */
+ if ((ddop->DispDiscStyle == MSA_TXT_STYLE_2) && (ddop->ShowRightTail)) {
+ length = AlnMgrGetMaxTailLength(sap, RIGHT_TAIL);
+ if (length) {
+ drdp=(DDVRulerDescrPtr)MemNew(sizeof(DDVRulerDescr));
+ drdp->disp_start=disp_start;
+ drdp->disp_stop=disp_start+length-1;
+ drdp->bUnAligned=TRUE;
+ drdp->align_start = -1;
+ disp_start += length;
+ vnp = ValNodeAddPointer(&vnp,0,(Pointer)drdp);
+ }
+ }
+
+ return(vnp_head);
+}
+
+/*******************************************************************************
+
+ Function : DDV_DrawSequenceName()
+
+ Purpose : draw the name of the sequence (left column of the DDV panel)
+
+ Parameters : GrData; graphical data (font size, etc)
+ ScaleStyle;style of the ParaG scale
+ top, left; coord to start the draw
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_DrawSequenceName(UnDViewerGraphDataPtr GrData,ParaGPtr pgp,
+ Int2 top,Int2 left,Int4 cur_row,Int4 CurEditRow,Int4 CurMasterRow)
+{
+SeqIdPtr sip = NULL;
+RecT rc;
+Int2 x,y,decal=1,size;/*text position/size*/
+Char szAccess[21];
+BioseqPtr bsp;
+
+ /*get a name*/
+ bsp = BioseqLockById(pgp->sip);
+ if(bsp) {
+ sip = SeqIdFindBestAccession(bsp->id);
+ BioseqUnlock(bsp);
+ }
+ if (!sip)
+ sip = SeqIdFindBest(pgp->sip, 0);
+ SeqIdWrite(sip, szAccess,PRINTID_TEXTID_ACCESSION, 20);
+
+ /*compute position*/
+ if (pgp->ScaleStyle==SCALE_POS_TOP) decal++;
+
+ /*draw name*/
+ size=StringWidth(szAccess);
+ x=left/*-GrData->udv_scale.cxLeftScale*/-size;
+ y=top+decal*GrData->udv_font.LineHeight;
+ MoveTo(x,y);
+ if (cur_row==CurEditRow){
+ Magenta();
+ }
+ PaintString (szAccess);
+ if (cur_row==CurMasterRow){
+ Blue();
+ MoveTo(x,y);
+ LineTo(x+size,y);
+ }
+ /*draw a little box (for selection a full sequence)*/
+ left+=GrData->udv_font.cxChar;
+ top+=GrData->udv_font.cxChar/2;
+ LoadRect(&rc,left,top,left+GrData->udv_font.cxChar,
+ top+GrData->udv_font.cxChar);
+ Blue();
+ PaintOval(&rc);
+ Black();
+}
+
+
+/*****************************************************************************
+
+Function: DDV_DrawSequence()
+
+Purpose: draw a sequence within a ParaG
+
+Return value: -
+
+*****************************************************************************/
+static void DDV_DrawSequence(UnDViewerGraphDataPtr GrData,ParaGPtr pgp,
+ DDV_ColorGlobal *pColorGlobal,SeqIdPtr sip,RectPtr rc_pgp,
+ CharPtr szSeq,Int4 from,Int4 to,Uint1 ScaleStyle,
+ Int2 leftDecal,Uint1 strand,Boolean bUseColors,ValNodePtr vnp_bsp,
+ Int4 row,Boolean bSelect)
+{
+DDV_ColorCell *dclrp,*highlighClr;
+Int4 dp;
+Uint4 old_colour,new_colour,hlClr;
+Int2 decal=1,i,x,y,pos=0;
+Boolean isAlpha,bSelected,bGoTo;
+RecT rcSel;
+
+ if (!szSeq) return;
+
+ /*scale or not... to be or not to be ?*/
+ if (ScaleStyle==SCALE_POS_TOP) decal++;
+
+ /*compute the first letter's coordinate*/
+ x=rc_pgp->left+leftDecal-GrData->udv_font.cxChar/2;
+ y=rc_pgp->top+decal*GrData->udv_font.LineHeight;
+
+ i=from;/*if from!=0, means we don't draw the entire ParaG*/
+ to++;
+
+ /*get the selection(s)*/
+
+ if (pColorGlobal){/*use color*/
+ old_colour=new_colour=GetColorRGB(0,0,0);
+ highlighClr =
+ DDV_SearchColorCellbyName(pColorGlobal->pvnSpecialColors, "Highlight");
+ if (highlighClr)
+ hlClr = GetColorRGB (highlighClr->rgb[0], highlighClr->rgb[1],highlighClr->rgb[2]);
+ else
+ hlClr = GetColorRGB (255,255,0);
+ while(szSeq[i] && i<to){
+ /*if a letter, get the color*/
+ if (szSeq[i]!=' '){
+ if (isalpha(szSeq[i])){
+ isAlpha=TRUE;
+ dp=DDV_GetBspCoordGivenDispCoord(pgp,pgp->StartLetter+i);
+ bSelected=DDV_IsLetterSelected(vnp_bsp,dp);
+ if (dp==(Int4)-1)
+ dclrp=NULL;
+ else
+ dclrp=DDV_GetColor(pColorGlobal,NULL, row+1, dp);
+
+ if(bUseColors){
+ if (dclrp)
+ new_colour=GetColorRGB(dclrp->rgb[0],dclrp->rgb[1],dclrp->rgb[2]);
+ else
+ new_colour=GetColorRGB(0,0,0);
+ }
+ }
+ else {
+ bSelected=FALSE;
+ isAlpha=FALSE;
+ new_colour=GetColorRGB(0,0,0);
+ }
+ if (GrData->GotoLetter==pgp->StartLetter+i){
+ bGoTo=TRUE;bSelected=TRUE;
+ }
+ else{
+ bGoTo=FALSE;
+ }
+ if (bSelected){
+ if (bGoTo==FALSE){
+ if (bSelect)
+#ifdef WIN_MSWIN
+ Nlm_SetColorEx(hlClr);
+#else
+ Nlm_SetColor(hlClr);
+#endif
+ else White();
+ }
+ else{
+ Red();
+ }
+ rcSel.left=x-2;
+ rcSel.top=y-GrData->udv_font.LineHeight;
+ rcSel.bottom=y;
+ rcSel.right=rcSel.left+GrData->udv_font.ColWidth;
+ PaintRect(&rcSel);
+ /*FrameRect(&rcSel);*/
+ }
+ if ((bUseColors && new_colour!=old_colour) || bSelected) {
+#ifdef WIN_MSWIN
+ Nlm_SetColorEx(new_colour);
+#else
+ Nlm_SetColor(new_colour);
+#endif
+ old_colour=new_colour;
+ }
+ MoveTo(x,y);
+ if (isAlpha && dclrp)
+ PaintChar((dclrp->LowerCase ? TO_LOWER(szSeq[i]) : szSeq[i]));
+ else
+ PaintChar(szSeq[i]);
+ }
+ i++;
+ x+=GrData->udv_font.ColWidth;
+ }
+ }
+ else{/*B&W display mode*/
+ Black();
+ while(szSeq[i] && i<to){
+ /*if a letter, get the color*/
+ if (szSeq[i]!=' '){
+ MoveTo(x,y);
+ PaintChar(szSeq[i]);
+ }
+ i++;
+ x+=GrData->udv_font.ColWidth;
+ }
+ }
+
+ Black();
+}
+
+/*****************************************************************************
+
+Function: DDV_DrawParaG()
+
+Purpose: draw a ParaG given from, to (seqalign coord) and a position (rc_pgp)
+
+Return value: -
+
+*****************************************************************************/
+static void DDV_DrawParaG(RectPtr rc_pgp,ParaGPtr pgp,Int4 from,Int4 to,
+ UnDViewerGraphDataPtr GrData,DDV_ColorGlobal *pColorGlobal,
+ DDV_Disp_OptPtr ddop,ValNodePtr vnp_bsp,Int4 row,Boolean bSelect)
+{
+CharPtr szSeq;
+BioseqPtr bsp;
+SeqIdPtr sip;
+Int4 bspLength,bsp_start,bsp_stop,from_pgp,to_pgp;
+Int2 decal,diff;
+Boolean IsAA;
+Uint1 strand;
+MsaTxtDispPtr mtdp;
+ValNodePtr vnp;
+
+ /*get some bsp info*/
+ /*sip=SeqIdFindBest(pgp->sip,0);
+ if (sip==NULL)*/
+ sip=pgp->sip;
+ bsp=BioseqLockById(sip);
+ if (!bsp) return;
+ bspLength=BioseqGetLen(bsp);
+ IsAA=ISA_aa(bsp->mol);
+ BioseqUnlock(bsp);
+
+ szSeq=(CharPtr)MemNew((pgp->StopLetter-pgp->StartLetter+2)*sizeof(Char));
+ /*get a sequence to draw*/
+ DDV_GetSequenceFromParaG(pgp,&szSeq,bspLength,IsAA,&strand,&bsp_start,&bsp_stop);
+
+ if (pgp->ScaleStyle==SCALE_POS_TOP){
+ vnp=pgp->ptxtList;
+ decal=0;
+ while(vnp){
+ mtdp=(MsaTxtDispPtr)vnp->data.ptrvalue;
+ diff=(Int2)(mtdp->to-mtdp->from+1);
+ if (mtdp->TextStyle == MSA_TXT_STYLE_SEQ){
+ UDV_Draw_scale(
+ GrData,
+ FALSE,
+ FALSE,
+ pgp->ScaleStyle,
+ (Int4)decal,
+ (Int4)decal+diff,
+ rc_pgp,
+ (Int2)(GrData->udv_font.ColWidth/2)+
+ (Int2)(decal*GrData->udv_font.ColWidth),
+ bspLength,
+ mtdp->from,
+ FALSE,
+ GrData->udv_font.ColWidth,(Uint4)DDV_DISP_HORZ);
+ }
+ decal+=diff;
+ vnp=vnp->next;
+ }
+ }
+
+ if (szSeq){/*draw the sequence*/
+ from_pgp=_max_(pgp->StartLetter,from);
+ to_pgp=_min_(pgp->StopLetter,to);
+ DDV_DrawSequence(GrData,
+ pgp,
+ pColorGlobal,
+ sip,
+ rc_pgp,
+ szSeq,
+ from_pgp-pgp->StartLetter,
+ to_pgp-pgp->StartLetter,
+ pgp->ScaleStyle,
+ (Int2)(GrData->udv_font.ColWidth/2+
+ (Int2)(from_pgp-pgp->StartLetter)*GrData->udv_font.ColWidth),
+ strand,
+ ddop->bUseColors,
+ vnp_bsp,
+ row,
+ bSelect);
+ if (pgp->szEditSeq==NULL)/*viewer deletes allocated char array*/
+ MemFree(szSeq);
+ }
+}
+
+/*****************************************************************************
+
+Function: DDV_ComputeColWidth()
+
+Purpose: compute the width of a single column
+
+Return value: the height
+
+*****************************************************************************/
+extern Int2 DDV_ComputeColWidth(Int2 cxChar)
+{
+ return(cxChar+2);
+}
+
+/*******************************************************************************
+
+ Function : DDV_AdjustDrawingRect()
+
+ Purpose : adjust the Panel Rect using the size of a letter ; in that way,
+ I get a RecT where it's possible to avoid the display of half letters
+ (on the borders of the RecT).
+
+ Parameters : rcP;panel RecT
+ udv_font; font information
+
+ Return value : none
+
+*******************************************************************************/
+extern void DDV_AdjustDrawingRect(RecT * rcP, UDVFontDataPtr udv_font, DdvMainPtr dmp)
+{
+ Int4 temp;
+
+ rcP->left=(rcP->left/udv_font->ColWidth)*udv_font->ColWidth + udv_font->ColWidth;
+
+/* rcP->right=(rcP->right/udv_font->ColWidth)*udv_font->ColWidth-2; */
+ /* bug fix, DIH, 7/24/00 */
+ temp = rcP->right - (dmp->GrData.udv_panel.cxName + dmp->GrData.udv_scale.cxLeftScale);
+ temp = (temp/udv_font->ColWidth)*udv_font->ColWidth - 2;
+ rcP->right = temp + (dmp->GrData.udv_panel.cxName + dmp->GrData.udv_scale.cxLeftScale);
+
+ rcP->top=(rcP->top/udv_font->LineHeight)*udv_font->LineHeight + udv_font->LineHeight;
+ rcP->bottom=(rcP->bottom/udv_font->LineHeight)*udv_font->LineHeight;
+}
+
+
+/*******************************************************************************
+
+ Function : DDV_DrawPanelContent_H()
+
+ Purpose : draw the panel of DDV viewer (case 1: full horz display)
+
+ Parameters : p;handle of the panel
+ dmp; main data block
+
+ Return value : none
+
+*******************************************************************************/
+extern void DDV_DrawPanelContent_H (PaneL p,DdvMainPtr dmp,RecT PNTR MyUpdateRect,
+ Boolean bSelect)
+{
+ParaGPtr pgp,/*ParaG data*/
+ first_pgp;/*used to get info from the first pgp of a row*/
+ValNodePtr vnp,/*used to scan ParaGand Ruler Descriptor*/
+ vnp_pgp,/*used to get info from the first pgp of a row*/
+ vnp_bsp=NULL;/*selected region(s) of one bioseq*/
+SelStructPtr ssp;/*used to get the selected region(s)*/
+BioseqPtr bsp;
+Int4 i,/*just for a loop*/
+ from_row,/*first row to draw*/
+ to_row,/*the last row to draw*/
+ top_offset=0,/*offset from top (pixel)*/
+ left_offset,/*offset from right (pixel)*/
+ from_col,/*draw column from_col...*/
+ to_col,/*...to column to_col*/
+ from_pgp,/*within a ParaG, draw 'from'... */
+ to_pgp,/*... 'to'*/
+ nLinesDraw,/*number of lines drawn*/
+ nColsDraw,/*number of col. drawn*/
+ nTotRow,/*total number of row to draw*/
+ start_i=0,/*first ParaG to draw*/
+ start_ruler,/*beginning of the display ruler*/
+ curMasterRow;
+RecT rcP;/*size of the DDV panel*/
+RecT rcD;/*size of the drawing panel*/
+RecT rcI;/*size of the invalidated rect*/
+RecT rc_pgp;/*location of a ParaG on the Panel*/
+Int2 length_pgp,/* i.e. 'length' letters to draw*/
+ x,y;/*caret position (edit mode only)*/
+Uint2 bsp_eID,/*...*/
+ bsp_iID;/*... identifiers of a bioseq in the SeqAlign*/
+Boolean bNotDrawCol;
+DdvMainWinPtr mWin_d;
+DDVRulerDescrPtr drdp;
+
+ if (dmp->hParent){
+ mWin_d=(DdvMainWinPtr)GetObjectExtra(dmp->hParent);
+ if (mWin_d->Show_logo){
+ UDV_Logo_onDraw(p);
+ return;
+ }
+ }
+
+ /*some checks before a core dump...*/
+ if (!dmp->MSA_d.pgp_l.TableHead) return;
+
+ /*restrict panel drawing area: 'add' little margins*/
+ ObjectRect((Handle) p, &rcP);
+ InsetRect(&rcP,4,4);
+
+ /*3D border to resize the cxName field*/
+ LtGray();
+
+ MoveTo((Int2)(dmp->GrData.udv_panel.cxName-1),rcP.top);
+ LineTo((Int2)(dmp->GrData.udv_panel.cxName-1),rcP.bottom);
+
+ LtGray();
+ MoveTo((Int2)(dmp->GrData.udv_panel.cxName+1),rcP.top);
+ LineTo((Int2)(dmp->GrData.udv_panel.cxName+1),rcP.bottom);
+ LtGray();
+ MoveTo((Int2)(dmp->GrData.udv_panel.cxName+2),rcP.top);
+ LineTo((Int2)(dmp->GrData.udv_panel.cxName+2),rcP.bottom);
+
+ Black();
+ MoveTo((Int2)(dmp->GrData.udv_panel.cxName+3),rcP.top);
+ LineTo((Int2)(dmp->GrData.udv_panel.cxName+3),rcP.bottom);
+
+ /*drawing region:*/
+ DDV_AdjustDrawingRect(&rcP,&(dmp->GrData.udv_font),dmp);
+
+ /* debugging */
+/* UDV_draw_rectangle(rcP, TRUE); */
+
+ rcD=rcI=rcP;
+ rcP.left+=dmp->GrData.udv_panel.cxName+dmp->GrData.udv_scale.cxLeftScale;
+ top_offset=dmp->GrData.udv_vscrl.ScrollPos*dmp->GrData.udv_font.LineHeight;
+ left_offset=dmp->GrData.udv_hscrl.ScrollPos*dmp->GrData.udv_font.ColWidth;
+
+ /*set the font*/
+ SelectFont(dmp->GrData.udv_font.hFnt);
+
+ rcD=rcP;
+ ClipRect(&rcD);
+ /*display the master numerical ruler*/
+ from_col=dmp->GrData.udv_hscrl.ScrollPos;
+ to_col=dmp->GrData.udv_hscrl.ScrollPos+dmp->GrData.udv_hscrl.ScrollPage;
+ if (to_col==0) to_col=dmp->MSA_d.pgp_l.LengthAli;
+ if (to_col>dmp->MSA_d.pgp_l.LengthAli) to_col=dmp->MSA_d.pgp_l.LengthAli;
+ rcD.top+=dmp->GrData.udv_panel.cyScale/2;
+
+ /*get the first node of the Ruler descriptor, then get the start value*/
+ drdp=(DDVRulerDescrPtr)dmp->MSA_d.pgp_l.RulerDescr->data.ptrvalue;
+ start_ruler=drdp->disp_start;
+ UDV_Draw_scale(
+ &dmp->GrData,
+ dmp->GrData.udv_scale.ShowMajorTick,
+ dmp->GrData.udv_scale.ShowMMinorTick,
+ (Uint1)dmp->GrData.udv_scale.ScalePosition,
+ from_col+start_ruler,
+ to_col+start_ruler,
+ &rcD,
+ (Int2)(dmp->GrData.udv_font.ColWidth/2)+
+ (Int2)((from_col-dmp->GrData.udv_hscrl.ScrollPos)*
+ dmp->GrData.udv_font.ColWidth),
+ dmp->MSA_d.pgp_l.LengthAli+start_ruler-1,
+ from_col+start_ruler,
+ FALSE,
+ dmp->GrData.udv_font.ColWidth,(Uint4)DDV_DISP_HORZ);
+
+ /*go at the bottom of the scale*/
+ ResetClip();
+
+ rcP.top+=3*dmp->GrData.udv_panel.cyScale/2;
+ rcD=rcP;
+ rcD.left=rcI.left;
+
+ /*compute the region to draw (invalidate rect only)*/
+ from_col=(MyUpdateRect->left-rcP.left)/dmp->GrData.udv_font.ColWidth-2;
+ to_col=(MyUpdateRect->right-rcP.left)/dmp->GrData.udv_font.ColWidth+2;
+ if (from_col<0 && to_col<0) bNotDrawCol=TRUE;
+ else bNotDrawCol=FALSE;
+ if (from_col<0) from_col=0;
+ if (to_col<0) to_col=0;
+ from_col+=dmp->GrData.udv_hscrl.ScrollPos;
+ to_col+=dmp->GrData.udv_hscrl.ScrollPos;
+ if (to_col>dmp->MSA_d.pgp_l.LengthAli) to_col=dmp->MSA_d.pgp_l.LengthAli;
+ if (from_col>dmp->MSA_d.pgp_l.LengthAli) from_col=dmp->MSA_d.pgp_l.LengthAli;
+ from_row=(MyUpdateRect->top-rcP.top)/dmp->GrData.udv_font.LineHeight-1;
+ to_row=(MyUpdateRect->bottom-rcP.top)/dmp->GrData.udv_font.LineHeight+1;
+ if (from_row<0 && to_row<0) return;
+ if (from_row<0) from_row=0;
+ if (to_row<0) to_row=0;
+ from_row+=dmp->GrData.udv_vscrl.ScrollPos;
+ to_row+=dmp->GrData.udv_vscrl.ScrollPos;
+ if (from_row>dmp->GrData.udv_panel.nTotLines) from_row=dmp->GrData.udv_panel.nTotLines;
+ if (to_row>dmp->GrData.udv_panel.nTotLines) to_row=dmp->GrData.udv_panel.nTotLines;
+ nTotRow=to_row-from_row;
+
+ /*find the first ParaG to draw*/
+ for(i=0;i<dmp->MSA_d.pgp_l.nBsp;i++){
+ if (!(pgp=(ParaGPtr)(dmp->MSA_d.pgp_l.TableHead[i]->data.ptrvalue))) continue;
+ if ((pgp->StartLine<=to_row)&&((pgp->StartLine+pgp->nLines)>=from_row)){
+ start_i=i;break;
+ }
+ }
+
+ ClipRect(&rcD);
+
+ /* get the row of the master */
+ if (dmp->dsp == NULL) {
+ curMasterRow = 0;
+ }
+ else {
+ curMasterRow = DDE_GetIndexOfMaster(dmp->dsp);
+ }
+
+ /*draw the names*/
+ nLinesDraw=0;
+ for(i=start_i;i<dmp->MSA_d.pgp_l.nBsp;i++){
+ if (!(pgp=(ParaGPtr)(dmp->MSA_d.pgp_l.TableHead[i]->data.ptrvalue))) continue;
+ if ((pgp->StartLine<=to_row)&&(pgp->StartLine>=from_row)){
+ nLinesDraw+=pgp->nLines;
+ DDV_DrawSequenceName(&dmp->GrData,pgp,
+ (Int2)(pgp->StartLine*dmp->GrData.udv_font.LineHeight-
+ top_offset+rcP.top),
+ (Int2)(dmp->GrData.udv_panel.cxName-3),
+ i, dmp->deri.curEditRow, curMasterRow);
+ }
+ else nLinesDraw+=pgp->nLines;
+ if (nLinesDraw>to_row) break;
+ }
+ ResetClip();
+
+ if (bNotDrawCol) return;
+
+ ClipRect(&rcP);
+ nLinesDraw=0;
+ /*get the selection(s)*/
+
+ ssp=ObjMgrGetSelected();
+
+ /*draw ParaG*/
+ for(i=start_i;i<dmp->MSA_d.pgp_l.nBsp;i++){/*draw line by line...*/
+ if (!(pgp=(ParaGPtr)(dmp->MSA_d.pgp_l.TableHead[i]->data.ptrvalue))) continue;
+ nColsDraw=0;
+ if (vnp_bsp){
+ vnp_bsp=ValNodeFree(vnp_bsp);
+ }
+ /*for each line, get the selected region(s)*/
+ if (ssp!=NULL){
+ vnp_pgp=dmp->MSA_d.pgp_l.TableHead[i];
+ first_pgp=(ParaGPtr)(vnp_pgp->data.ptrvalue);
+ if (first_pgp){
+ bsp=BioseqLockById(first_pgp->sip);
+ if (bsp){
+ bsp_eID=ObjMgrGetEntityIDForPointer((Pointer)bsp);
+ bsp_iID = GetItemIDGivenPointer (bsp_eID,
+ OBJ_BIOSEQ, (Pointer) bsp);
+ if (bsp_eID!=0 && bsp_iID!=0){
+ vnp_bsp=DDV_GetSelectedRegions(ssp,bsp_eID,bsp_iID);
+ }
+ BioseqUnlock(bsp);
+ }
+ }
+ }
+ /*...col. by col.*/
+ for(vnp=dmp->MSA_d.pgp_l.TableHead[i];vnp!=NULL;vnp=vnp->next){
+ if (!(pgp=(ParaGPtr)(vnp->data.ptrvalue))) continue;
+ if ((pgp->StartLetter>=from_col && pgp->StartLetter<=to_col)||
+ (pgp->StopLetter>=from_col && pgp->StopLetter<=to_col)||
+ (pgp->StartLetter<=from_col && pgp->StopLetter>=to_col)){
+
+ from_pgp=pgp->StartLetter;
+ to_pgp=pgp->StopLetter;
+
+ length_pgp=to_pgp-from_pgp+1;/*+1 to surround the last letter*/
+ rc_pgp.top=(Int2)(pgp->StartLine*dmp->GrData.udv_font.LineHeight-
+ top_offset+rcP.top);
+ rc_pgp.bottom=(Int2)(rc_pgp.top+pgp->nLines*
+ dmp->GrData.udv_font.LineHeight);
+ rc_pgp.left=(Int2)(from_pgp*dmp->GrData.udv_font.ColWidth-
+ left_offset+rcP.left);
+ rc_pgp.right=(Int2)(rc_pgp.left+length_pgp*
+ dmp->GrData.udv_font.ColWidth);
+ /*highlight a goto position ?*/
+ if (dmp->dtd.row==i+1 && dmp->dtd.col!=0){
+ dmp->GrData.GotoLetter=dmp->dtd.col-1;
+ }
+ else{
+ dmp->GrData.GotoLetter=(Int4)-1;
+ }
+ DDV_DrawParaG(&rc_pgp,pgp,from_col,to_col,&dmp->GrData,
+ dmp->Globals.colorp,&(dmp->ddo),vnp_bsp,i,bSelect);
+ }
+ else{
+ nColsDraw+=(pgp->StopLetter-pgp->StartLetter);
+ }
+ if(nColsDraw>to_col)break;
+ }
+ nLinesDraw+=pgp->nLines;
+ if (nLinesDraw>nTotRow) break;
+ }
+ /*display the caret; edit mode only*/
+ if (dmp->MouseMode==DDV_MOUSEMODE_EDIT){
+ x=(Int2)(dmp->dci.new_col*dmp->GrData.udv_font.ColWidth-
+ left_offset+rcP.left);
+ y=(Int2)(dmp->dci.new_row*dmp->GrData.udv_font.LineHeight-
+ top_offset+rcP.top)-1;
+ Red();
+ MoveTo(x+dmp->GrData.udv_font.ColWidth,y);
+ LineTo(x+dmp->GrData.udv_font.ColWidth,
+ y-dmp->GrData.udv_font.LineHeight/2);
+ MoveTo(x+dmp->GrData.udv_font.ColWidth-1,y);
+ LineTo(x+dmp->GrData.udv_font.ColWidth-1,
+ y-dmp->GrData.udv_font.LineHeight/2);
+ MoveTo(x+dmp->GrData.udv_font.ColWidth/2,y+1);
+ LineTo(x+3*dmp->GrData.udv_font.ColWidth/2,y+1);
+ MoveTo(x+dmp->GrData.udv_font.ColWidth/2,y+2);
+ LineTo(x+3*dmp->GrData.udv_font.ColWidth/2,y+2);
+ Black();
+ }
+ ResetClip();
+
+ if (dmp->bEditor) {
+ /* this is for allowing edits of the alignment boundaries */
+ DDV_DrawAlignmentBoundaries(p, dmp);
+ }
+
+ return;
+}
+
+static void DDV_DrawAlignmentBoundaries(PaneL p, DdvMainPtr dmp) {
+/*******************************************************************************
+ draw vertical bars at the top of the panel showing the alignment
+ boundaries, and horizontal lines connecting them.
+*******************************************************************************/
+ Int4 LeftHPos, RightHPos;
+ Int4 TopVPos, BotVPos;
+ Int4 i, NumBlocks;
+ RecT rcP, rcBanner;
+ DdvMainWinPtr mWin_d;
+
+ ObjectRect(p, &rcP);
+ DDV_GetVPixelPosOfEmptySpace(dmp, rcP, &TopVPos, &BotVPos);
+ rcBanner = rcP;
+ rcBanner.left += dmp->GrData.udv_panel.cxName + dmp->GrData.udv_scale.cxLeftScale;
+ rcBanner.top = TopVPos;
+ rcBanner.bottom = BotVPos;
+ rcBanner.left -= 4;
+ ClipRect(&rcBanner);
+ EraseRect(&rcBanner);
+
+ /* for each aligned block, draw a semi-rectangle on top of it */
+ NumBlocks = DDE_GetNumBlocks(dmp->dsp->pEdit);
+ for (i=0; i<NumBlocks; i++) {
+ LeftHPos = DDV_GetHPixelPosGivenColNumber(dmp, rcP, DDE_GetAlignStart(dmp->dsp->pEdit, i));
+ LeftHPos -= dmp->GrData.udv_font.ColWidth;
+ RightHPos = DDV_GetHPixelPosGivenColNumber(dmp, rcP, DDE_GetAlignStop(dmp->dsp->pEdit, i));
+ UDV_draw_vertical_bar(rcBanner, LeftHPos, FALSE);
+ UDV_draw_vertical_bar(rcBanner, RightHPos, FALSE);
+ UDV_draw_horizontal_bar(TopVPos, LeftHPos, RightHPos);
+ }
+
+ ResetClip();
+
+ /* grey out either "create block" or "delete block" option */
+ if (dmp->hParent){
+ mWin_d = (DdvMainWinPtr) GetObjectExtra(dmp->hParent);
+ if (NumBlocks == 0) {
+ Disable(mWin_d->MainMenu.DeleteBlock);
+ Enable(mWin_d->MainMenu.CreateBlock);
+ }
+ else {
+ Enable(mWin_d->MainMenu.DeleteBlock);
+ Disable(mWin_d->MainMenu.CreateBlock);
+ }
+ }
+
+}
+
+
+extern void DDV_GreyOut(DdvMainWinPtr mWin_d, Boolean Start, Boolean End) {
+/*******************************************************************************
+ grey out "undo" if Start is TRUE.
+ grey out "redo" if End is TRUE.
+*******************************************************************************/
+ if (Start) { Disable(mWin_d->MainMenu.Prev); }
+ else { Enable(mWin_d->MainMenu.Prev); }
+ if (End) { Disable(mWin_d->MainMenu.Next); }
+ else { Enable(mWin_d->MainMenu.Next); }
+}
+
+
+/*******************************************************************************
+
+ Function : DDV_DrawPanelContent_V()
+
+ Purpose : draw the panel of DDV viewer (case 2: full vert display)
+
+ Parameters : p;handle of the panel
+ dmp; main data block
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_DrawPanelContent_V (PaneL p,DdvMainPtr dmp)
+{/*not yet implemented*/
+ return;
+}
+
+/*******************************************************************************
+
+ Function : DDV_DrawPanelContent()
+
+ Purpose : draw the panel of DDV viewer
+
+ Parameters : p;handle of the panel
+ dmp; main data block
+
+ Return value : none
+
+*******************************************************************************/
+extern void DDV_DrawPanelContent (PaneL p,DdvMainPtr dmp)
+{
+ if (dmp->MSA_d.pgp_l.DisplayType==DDV_DISP_HORZ)
+ DDV_DrawPanelContent_H (p,dmp,&updateRect,TRUE);
+ else
+ DDV_DrawPanelContent_V (p,dmp);
+ return;
+}
+
+/*******************************************************************************
+
+ Function : DDV_DrawViewer()
+
+ Purpose : callback for the viewer panel
+
+ Parameters : handle of the panel
+
+ Return value : none
+
+*******************************************************************************/
+extern void DDV_DrawViewer (PaneL p)
+{
+
+DdvMainPtr dmp;
+
+ /*get the application data*/
+ dmp = (DdvMainPtr) GetObjectExtra(p);
+ if (dmp==NULL) return;
+
+ if (dmp->MSA_d.pgp_l.DisplayType==DDV_DISP_HORZ)
+ DDV_DrawPanelContent_H (p,dmp,&updateRect,TRUE);
+ else
+ DDV_DrawPanelContent_V (p,dmp);
+}
diff --git a/ddv/ddvgraph.h b/ddv/ddvgraph.h
new file mode 100644
index 00000000..46d019a2
--- /dev/null
+++ b/ddv/ddvgraph.h
@@ -0,0 +1,171 @@
+/* $Id: ddvgraph.h,v 1.14 2000/07/24 22:00:08 hurwitz Exp $
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information (NCBI)
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government do not place any restriction on its use or reproduction.
+* We would, however, appreciate having the NCBI and the author cited in
+* any work or product based on this material
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* ===========================================================================
+*
+* File Name: ddvgraph.h
+*
+* Author: Patrick Durand
+*
+* Version Creation Date: 06/19/99
+*
+* $Revision: 1.14 $
+*
+* File Description:
+*
+* Modifications:
+* --------------------------------------------------------------------------
+* $Log: ddvgraph.h,v $
+* Revision 1.14 2000/07/24 22:00:08 hurwitz
+* fixed bug that 1/2 characters were displayed sometimes
+*
+* Revision 1.13 2000/07/08 20:43:58 vakatov
+* Get all "#include" out of the 'extern "C" { }' scope; other cleanup...
+*
+* Revision 1.12 2000/05/16 19:43:01 hurwitz
+* grey out create block, delete block, undo, and redo as needed
+*
+* Revision 1.11 2000/02/15 15:31:47 lewisg
+* move DDVRulerDescr to pgppop
+*
+* Revision 1.10 2000/02/03 15:56:47 hurwitz
+* added constructor and destructor for DDVRulerDescrPtr
+*
+* Revision 1.9 2000/01/26 13:38:54 durand
+* update the GUI for the editor. Add functions to create the data to be used by the editor
+*
+* Revision 1.8 1999/11/18 14:37:15 durand
+* avoid flashing sequence during selection
+*
+* Revision 1.7 1999/11/09 17:09:00 durand
+* transfer some functions from ddvgraph to ddvcreate, so that ddvcreate remains Vibrant free and can be compiled with BLAST
+*
+* Revision 1.6 1999/11/03 21:29:49 durand
+* add CTRL and SHFT keys for mouse selection. redesign the loader functions of DDV to properly register the message callbacks
+*
+* Revision 1.5 1999/10/29 14:15:39 durand
+* add simple mouse selection functions
+*
+* Revision 1.4 1999/10/20 13:17:18 durand
+* add display for disc. SeqAlign tails
+*
+* Revision 1.3 1999/10/15 21:57:36 durand
+* add a UI for display options
+*
+* Revision 1.2 1999/10/12 15:07:52 durand
+* resolve problems with CVS
+*
+* Revision 1.1 1999/09/30 14:10:27 durand
+* add ddv to toolkit
+*
+* Revision 1.7 1999/09/22 20:40:20 durand
+* update the drawing procedure to deal with discontinuous seqalign
+*
+* Revision 1.6 1999/09/09 21:54:24 durand
+* create a display for disconitnuous SeqAlign
+*
+* Revision 1.5 1999/08/04 18:01:51 wheelan
+* changes to support new seqalign indexing
+*
+* Revision 1.4 1999/07/27 13:11:44 durand
+* transfer defines to udvdef.h
+*
+* Revision 1.3 1999/07/20 14:58:01 durand
+* use the Color Manager to display colored MSA
+*
+* Revision 1.2 1999/06/21 20:33:28 durand
+* add display type
+*
+* Revision 1.1 1999/06/19 17:21:07 durand
+* add Vibrant DDV code
+*
+*
+*
+* ==========================================================================
+*/
+
+#ifndef _DDVGRAPH_
+#define _DDVGRAPH_
+
+#include <udviewer.h>
+#include <udvdef.h>
+#include <ddvmain.h>
+#include <ddvcolor.h>
+
+#undef NLM_EXTERN
+#ifdef NLM_IMPORT
+#define NLM_EXTERN NLM_IMPORT
+#else
+#define NLM_EXTERN extern
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/******************************************************************************
+
+ structures
+
+******************************************************************************/
+
+/******************************************************************************
+
+ defines
+
+******************************************************************************/
+
+/******************************************************************************
+
+ Exported functions
+
+******************************************************************************/
+
+extern Int2 DDV_ComputeColWidth(Int2 cxChar);
+extern void DDV_DrawPanelContent (PaneL p,DdvMainPtr dmp);
+extern void DDV_DrawViewer (PaneL p);
+extern void DDV_InvalRegion(PaneL hWndDDV,UnDViewerGraphDataPtr GrData,
+ Int4 disp_from,Int4 disp_to,Int4 disp_row,Boolean IsSelect);
+extern void DDV_GetCurrentDispRange(PaneL hWndDDV,UnDViewerGraphDataPtr GrData,
+ Int4 LengthAli,Int4Ptr from_col,Int4Ptr to_col,Int4Ptr from_row,
+ Int4Ptr to_row);
+NLM_EXTERN ValNodePtr DDV_GetRulerForEditor(ValNodePtr descr_head,Int4 from_disp,
+ Int4 to_disp);
+extern ValNodePtr DDV_ComputeRuler(SeqAlignPtr sap,DDV_Disp_OptPtr ddop);
+extern void DDV_AdjustDrawingRect(RecT * rcP,UDVFontDataPtr udv_font, DdvMainPtr dmp);
+extern void DDV_DrawPanelContent_H (PaneL p,DdvMainPtr dmp,RecT PNTR MyUpdateRect,
+ Boolean bSelect);
+extern void DDV_GreyOut(DdvMainWinPtr mWin_d, Boolean Start, Boolean End);
+
+#ifdef __cplusplus
+}
+#endif
+
+#undef NLM_EXTERN
+#ifdef NLM_EXPORT
+#define NLM_EXTERN NLM_EXPORT
+#else
+#define NLM_EXTERN
+#endif
+
+#endif /* ndef _DDVGRAPH_ */
diff --git a/ddv/ddvlib.dsp b/ddv/ddvlib.dsp
new file mode 100644
index 00000000..d9146111
--- /dev/null
+++ b/ddv/ddvlib.dsp
@@ -0,0 +1,126 @@
+# Microsoft Developer Studio Project File - Name="ddvlib" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=ddvlib - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "ddvlib.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "ddvlib.mak" CFG="ddvlib - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "ddvlib - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE "ddvlib - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "ddvlib - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "ddvlib___Win32_Debug"
+# PROP BASE Intermediate_Dir "ddvlib___Win32_Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "ddvlib___Win32_Debug"
+# PROP Intermediate_Dir "ddvlib___Win32_Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /W2 /Gm /GX /ZI /Od /I ".." /I "..\ddv" /I "..\cn3d" /I "..\access" /I "..\asnstat" /I "..\connect\lbapi" /I "..\connect" /I "..\asnlib" /I "..\vibrant" /I "..\biostruc" /I "..\object" /I "..\api" /I "..\cdromlib" /I "..\desktop" /I "..\tools" /I "..\corelib" /I "..\network\taxon1\common" /I "..\network\vibnet" /I "..\network\entrez\client" /I "..\network\nsclilib" /I "..\network\medarch\client" /I "..\network\id1arch" /I "..\network\taxon1\taxon2" /I "..\network\blast3\client" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# SUBTRACT CPP /Fr
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF "$(CFG)" == "ddvlib - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "ddvlib___Win32_Release"
+# PROP BASE Intermediate_Dir "ddvlib___Win32_Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "ddvlib___Win32_Release"
+# PROP Intermediate_Dir "ddvlib___Win32_Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W2 /Gm /GX /ZI /Od /I ".." /I "..\ddv" /I "..\cn3d" /I "..\access" /I "..\asnstat" /I "..\connect\lbapi" /I "..\connect" /I "..\asnlib" /I "..\vibrant" /I "..\biostruc" /I "..\object" /I "..\api" /I "..\cdromlib" /I "..\desktop" /I "..\tools" /I "..\corelib" /I "..\network\taxon1\common" /I "..\network\vibnet" /I "..\network\entrez\client" /I "..\network\nsclilib" /I "..\network\medarch\client" /I "..\network\id1arch" /I "..\network\taxon1\taxon2" /I "..\network\blast3\client" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# SUBTRACT BASE CPP /Fr
+# ADD CPP /nologo /W2 /Gm /GX /Zi /I ".." /I "..\ddv" /I "..\cn3d" /I "..\access" /I "..\asnstat" /I "..\connect\lbapi" /I "..\connect" /I "..\asnlib" /I "..\vibrant" /I "..\biostruc" /I "..\object" /I "..\api" /I "..\cdromlib" /I "..\desktop" /I "..\tools" /I "..\corelib" /I "..\network\taxon1\common" /I "..\network\vibnet" /I "..\network\entrez\client" /I "..\network\nsclilib" /I "..\network\medarch\client" /I "..\network\id1arch" /I "..\network\taxon1\taxon2" /I "..\network\blast3\client" /D "_LIB" /D "WIN32" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ENDIF
+
+# Begin Target
+
+# Name "ddvlib - Win32 Debug"
+# Name "ddvlib - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\ddvclick.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\ddvgraph.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\ddvopen.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\ddvpanel.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\ddvclick.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ddvgraph.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ddvopen.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ddvpanel.h
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/ddv/ddvmain.c b/ddv/ddvmain.c
new file mode 100644
index 00000000..d2ee2443
--- /dev/null
+++ b/ddv/ddvmain.c
@@ -0,0 +1,447 @@
+/* $Id: ddvmain.c,v 1.26 2000/07/17 13:32:33 lewisg Exp $
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information (NCBI)
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government do not place any restriction on its use or reproduction.
+* We would, however, appreciate having the NCBI and the author cited in
+* any work or product based on this material
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* ===========================================================================
+*
+* File Name: ddvmain.c
+*
+* Author: Patrick Durand
+*
+* Version Creation Date: 06/19/99
+*
+* $Revision: 1.26 $
+*
+* File Description: starter module of DeuxD-Viewer (DDV). Onlu use to
+* start DDV as a standalone software.
+*
+* Modifications:
+* --------------------------------------------------------------------------
+* $Log: ddvmain.c,v $
+* Revision 1.26 2000/07/17 13:32:33 lewisg
+* move DDV_args out of the library
+*
+* Revision 1.25 2000/07/17 12:38:53 kans
+* DDV_myargs is extern in header, instantiated in ddvpanel.c, since it is accessed from that library file
+*
+* Revision 1.24 2000/07/14 22:24:55 lewisg
+* fix scroll, click, visual c++ build bugs. add command line arg parse to ddv
+*
+* Revision 1.23 2000/07/05 19:23:13 lewisg
+* add two panes to ddv, update msvc project files
+*
+* Revision 1.22 2000/06/06 14:44:16 hurwitz
+* fixed bug that SetAppProperty(dde_nogaps)
+*
+* Revision 1.21 2000/05/31 23:07:26 hurwitz
+* made NoGaps a runtime parameter, fixed bug with vertical scroll of show/hide list, save edits query is not performed if nothing to save
+*
+* Revision 1.20 2000/04/21 23:00:50 hurwitz
+* can launch DDE from DDV
+*
+* Revision 1.19 2000/04/17 13:30:43 durand
+* removed g_hParent and unused functions DDV_LaunchAlignViewer and DDV_LaunchAlignEditor
+*
+* Revision 1.18 2000/03/30 21:58:06 durand
+* made standalone DDV a viewer, not the editor
+*
+* Revision 1.17 2000/03/21 14:22:42 durand
+* fixed a problem with menus setup
+*
+* Revision 1.16 2000/03/16 18:38:38 durand
+* fixed the starter function for the GUI
+*
+* Revision 1.15 2000/02/04 16:05:41 durand
+* add click action to select a row
+*
+* Revision 1.14 2000/02/02 14:44:32 durand
+* added function to create data structure for block editor, fixed some bugs
+*
+* Revision 1.13 2000/01/26 13:38:55 durand
+* update the GUI for the editor. Add functions to create the data to be used by the editor
+*
+* Revision 1.12 2000/01/11 15:29:48 durand
+* add a cast to use EntrezSeqEntryGet instead of ID1SeqEntryGet
+*
+* Revision 1.11 2000/01/11 15:05:23 durand
+* remove network stuff
+*
+* Revision 1.10 2000/01/10 15:09:46 durand
+* Use Entrez instead of ID1
+*
+* Revision 1.9 2000/01/05 21:11:14 durand
+* update mouse click actions and DrawSequence function for a better use from ddv and cn3d
+*
+* Revision 1.8 1999/12/03 23:17:23 lewisg
+* Patrick's new global update msg, argument passing when launching ddv, experimental editing
+*
+* Revision 1.7 1999/11/29 15:26:25 durand
+* designed a new GUI to fix problems under MacOS, Linux and SGI
+*
+* Revision 1.6 1999/11/04 22:11:38 durand
+* add the Desktop to DDV. Add a better set of cleanup functions when closing DDV. Before creating color tables, try to get them from the SeqAlign
+*
+* Revision 1.5 1999/10/29 14:15:40 durand
+* add simple mouse selection functions
+*
+* Revision 1.4 1999/10/23 21:20:45 lewisg
+* move g_hParent to ddvopen.c
+*
+* Revision 1.3 1999/10/23 14:54:33 durand
+* resolve external symbol g_hParent
+*
+* Revision 1.2 1999/10/22 14:19:43 durand
+* update the code for the startup functions of DDV drawing panel
+*
+* Revision 1.1 1999/09/30 14:10:27 durand
+* add ddv to toolkit
+*
+* Revision 1.7 1999/09/23 19:06:50 lewisg
+* increase maxtemp number of cached sequences
+*
+* Revision 1.6 1999/09/23 17:44:32 lewisg
+* increase maxtemp number of cached sequences
+*
+* Revision 1.5 1999/07/01 15:28:28 durand
+* validate function loaders of DDV
+*
+* Revision 1.2 1999/06/28 22:07:18 durand
+* add loader functions and clean the code with Lint and Purify
+*
+* Revision 1.1 1999/06/19 17:21:05 durand
+* add Vibrant DDV code
+*
+*
+*
+* ==========================================================================
+*/
+
+#include <ncbi.h>
+#include <accentr.h>
+#include <udviewer.h>
+#include <ddvopen.h>
+#include <ddvmain.h>
+#include <ddvpanel.h>
+#include <vibrant.h>
+#include <netcnfg.h>
+
+extern Args DDV_myargs[NUMARGS] = {
+ /*0*/ { "Gaps allowed", "T", NULL, NULL, TRUE, 'g', ARG_BOOLEAN, 0.0,0,NULL},
+ /*1*/ { "Allow Edits", "T", NULL, NULL, TRUE , 'e', ARG_BOOLEAN, 0.0,0,NULL},
+};
+
+/*******************************************************************************
+
+ Function : DDV_ConfigAccepted()
+
+ Purpose : Entrez Network COnfiguration Dialog Box; accept a new config
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_ConfigAccepted(void)
+{
+ SetAppParam("DDV", "SETTINGS", "NETWORKAVAILABLE", "TRUE");
+ Message(MSG_OK, "Setting will take affect when you restart DDV");
+}
+
+/*******************************************************************************
+
+ Function : DDV_ConfigAccepted()
+
+ Purpose : Entrez Network COnfiguration Dialog Box; close dlg without modif.
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_ConfigCancelled(void)
+{
+}
+
+/*******************************************************************************
+
+ Function : DDV_ConfigTurnedOff()
+
+ Purpose : Entrez Network COnfiguration Dialog Box; cancel Entrez connection
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_ConfigTurnedOff(void)
+{
+ SetAppParam("DDV", "SETTINGS", "NETWORKAVAILABLE", "FALSE");
+ Message(MSG_OK, "Setting will take affect when you restart DDV");
+}
+
+/*******************************************************************************
+
+ Function : DDV_ConfigNetwork()
+
+ Purpose : call the Entrez Network COnfiguration Dialog Box
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_ConfigNetwork(IteM i)
+{
+DdvMainWinPtr dmwp;
+WindoW hParent;
+
+ /*get main data block*/
+ hParent=(WindoW)ParentWindow(i);
+ if (!hParent) return;
+ dmwp=(DdvMainWinPtr)GetObjectExtra(hParent);
+
+ if (dmwp->UseNetwork) ShowNetConfigForm(NULL,
+ NULL, DDV_ConfigAccepted, DDV_ConfigCancelled, DDV_ConfigTurnedOff, TRUE);
+ else ShowNetConfigForm(NULL, NULL, DDV_ConfigAccepted, DDV_ConfigCancelled,
+ DDV_ConfigTurnedOff, FALSE);
+}
+
+/*******************************************************************************
+
+ Function : DDV_StartEntrez()
+
+ Purpose : start connection to Entrez Server.
+
+ Return value : -
+
+*******************************************************************************/
+static Boolean DDV_StartEntrez(Boolean UseNetwork)
+{
+Boolean bRet;
+
+ bRet=FALSE;
+
+ if (!UseNetwork) {
+ bRet=FALSE;
+ }
+ else{
+ if (!EntrezIsInited()) {
+ if(EntrezBioseqFetchEnable(szAppName, FALSE)) {
+ if (EntrezInit(szAppName, TRUE, NULL))
+ bRet=TRUE;
+ else
+ bRet=FALSE;
+ }
+ else {
+ bRet=FALSE;
+ }
+ }
+ else{
+ bRet=TRUE;
+ }
+ }
+ return(bRet);
+}
+
+
+/*****************************************************************************
+
+Function: DDV_UseNetwork()
+
+Purpose: Determines if DDV should use the network
+
+Returns: TRUE if yes
+
+*****************************************************************************/
+static Boolean DDV_UseNetwork(void)
+{
+Char str[64];
+
+ if (GetAppParam
+ ("DDV", "SETTINGS", "NETWORKAVAILABLE", NULL, str, sizeof(str))) {
+ if (StringICmp(str, "TRUE") == 0) return TRUE;
+ }
+ return FALSE;
+}
+
+/*******************************************************************************
+
+ Function : DDV_StartMainWin_Master()
+
+ Purpose : start DDV main window as a standalone application. Never use this
+ function for other purpose. If you want to start DDV as a slave, take a
+ look at the functions below.
+
+ Parameters : mWin_d; main program data
+ ldp; logo data
+
+ Return value : handle to the DDV main window
+
+*******************************************************************************/
+static WindoW DDV_StartMainWin_Master(DdvMainWinPtr mWin_d,UDVLogoDataPtr ldp)
+{
+Int2 Margins;
+WindoW w;
+Boolean bRet;
+
+ /*main window*/
+ Margins=10*stdCharWidth;
+
+ w=DocumentWindow(Margins,Margins ,-10,-10,
+ szAppName,
+ DDV_WinMainProgQuit,
+ DDV_WinMainResize);
+
+ if (w==NULL){
+ Message (MSG_ERROR, "Viewer creation failed.");
+ return(NULL);
+ }
+
+ SetObjectExtra (w, (Pointer)mWin_d, (FreeProc)DDV_WinMainCleanup);
+ SetAppProperty("UDVLogoData",(Pointer)ldp);
+
+ mWin_d->hWndMain=w;
+ /*this is an autonomous viewer*/
+ mWin_d->AutonomeViewer=TRUE;
+
+ /*use the Network ?*/
+ mWin_d->UseNetwork=TRUE;/*DDV_UseNetwork();*/
+
+ bRet=DDV_CreateViewerPanel(w,mWin_d,NULL,FALSE); /*FALSE for viewer */
+ if (!bRet) return(NULL);
+
+ /*init logo_panel*/
+ LogoFontCreate(&ldp->f1,&ldp->f2,&ldp->f3);
+ StringCpy(ldp->szTitle,"DDV");
+ StringCpy(ldp->szDesc,", a MSA viewer/editor");
+ mWin_d->Show_logo=TRUE;
+
+ /*set the function to get a gi over the network*/
+ mWin_d->fetchSepProc=(UdvFetchSeqEntryProc)EntrezSeqEntryGet;
+ mWin_d->NetCfgMenuProc=DDV_ConfigNetwork;
+ mWin_d->NetStartProc=DDV_StartEntrez;
+
+ return(w);
+}
+
+/*******************************************************************************
+
+ Function : Main()
+
+ Purpose : Entry point of the software
+
+ Parameters :
+
+ Return value :
+
+*******************************************************************************/
+
+Int2 Main(void)
+{
+UDVLogoDataPtr ldp;
+Boolean UseNetwork;
+WindoW w;
+DdvMainWinPtr mWin_d;/*main window data*/
+ObjMgrPtr omp = NULL;
+Boolean NoGaps;
+
+ if ( !Nlm_GetArgsSilent("DDV 1.0", NUMARGS, DDV_myargs) ) return 1;
+
+ ErrSetMessageLevel(SEV_WARNING);
+ ErrSetOptFlags(EO_SHOW_CODES);
+ ErrSetOptFlags(EO_XLATE_CODES);
+
+ /*init some important stuffs*/
+ UseLocalAsnloadDataAndErrMsg();
+
+ if (! AllObjLoad()){
+ Message (MSG_ERROR, "AsnObjLoad() failed.");
+ return(1);
+ }
+
+ if (! SubmitAsnLoad()){
+ Message (MSG_ERROR, "SeqSubmitLoad() failed.");
+ return(1);
+ }
+
+ if (!SeqCodeSetLoad ()){
+ Message (MSG_ERROR, "SeqCodeSetLoad () failed.");
+ return(1);
+ }
+
+ if (!GeneticCodeTableLoad()){
+ Message (MSG_ERROR, "GeneticCodeTableLoad() failed.");
+ return(1);
+ }
+
+ if (!FeatDefSetLoad()){
+ Message (MSG_ERROR, "FeatDefSeqLoad() failed.");
+ return(1);
+ }
+
+ /*init data blocks*/
+ mWin_d=(DdvMainWinPtr)MemNew(sizeof(DdvMainWin));
+ if (!mWin_d){
+ Message (MSG_ERROR, "Viewer creation failed.");
+ return(1);
+ }
+
+ /* look for "nogaps" runtime parameter */
+ NoGaps = (Boolean)DDV_myargs[0].intvalue;
+ SetAppProperty("dde_nogaps",(void*)&NoGaps);
+
+ mWin_d->EditAllowed = (Boolean)DDV_myargs[1].intvalue;
+
+ /*init data blocks*/
+ ldp=(UDVLogoDataPtr)MemNew(sizeof(UDVLogoData));
+ if (ldp){
+ MemSet(ldp,0,sizeof(UDVLogoData));
+ }
+ else{
+ Message (MSG_ERROR, "Viewer creation failed.");
+ return(1);
+ }
+
+ /*OBjMgr Callback Function declaration*/
+/* REG_DDV_AUTO_EDIT; */
+ REG_DDV_AUTO_VIEW;
+ REGISTER_UDV_AUTONOMOUS;
+ REG_DDV_SLA_EDIT;
+
+ /* increment maximum # of objects held in memory */
+ omp = ObjMgrWriteLock();
+ if(omp != NULL ) omp->maxtemp = DDV_MAXTEMP;
+ ObjMgrUnlock();
+
+ w=DDV_StartMainWin_Master(mWin_d,ldp);
+ if (w==NULL) goto fin;
+
+ ProcessUpdatesFirst(FALSE);
+ UseNetwork=mWin_d->UseNetwork;
+
+ /*display main window*/
+ RealizeWindow(w);
+ Show(w);
+
+ /*enter loop events*/
+ ProcessEvents();
+fin:
+ /*close network connection, if needed*/
+ if (UseNetwork && EntrezIsInited()) EntrezBioseqFetchDisable();
+ /*clean up*/
+ if (ldp) MemFree(ldp);
+ RemoveAppProperty("UDVLogoData");
+ return(0);
+}
+
diff --git a/ddv/ddvmain.h b/ddv/ddvmain.h
new file mode 100644
index 00000000..ecb22d90
--- /dev/null
+++ b/ddv/ddvmain.h
@@ -0,0 +1,398 @@
+/* $Id: ddvmain.h,v 1.44 2000/07/17 13:32:33 lewisg Exp $
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information (NCBI)
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government do not place any restriction on its use or reproduction.
+* We would, however, appreciate having the NCBI and the author cited in
+* any work or product based on this material
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* ===========================================================================
+*
+* File Name: ddvmain.h
+*
+* Author: Patrick Durand
+*
+* Version Creation Date: 06/19/99
+*
+* $Revision: 1.44 $
+*
+* File Description:
+*
+* Modifications:
+* --------------------------------------------------------------------------
+* $Log: ddvmain.h,v $
+* Revision 1.44 2000/07/17 13:32:33 lewisg
+* move DDV_args out of the library
+*
+* Revision 1.43 2000/07/17 12:38:53 kans
+* DDV_myargs is extern in header, instantiated in ddvpanel.c, since it is accessed from that library file
+*
+* Revision 1.42 2000/07/14 22:24:56 lewisg
+* fix scroll, click, visual c++ build bugs. add command line arg parse to ddv
+*
+* Revision 1.41 2000/07/12 22:22:42 hurwitz
+* added delete block to DDV
+*
+* Revision 1.40 2000/07/10 14:38:07 lewisg
+* move seqalign and sequentry data from window to panels
+*
+* Revision 1.39 2000/07/08 20:43:58 vakatov
+* Get all "#include" out of the 'extern "C" { }' scope; other cleanup...
+*
+* Revision 1.38 2000/07/05 19:23:13 lewisg
+* add two panes to ddv, update msvc project files
+*
+* Revision 1.37 2000/07/05 18:42:16 hurwitz
+* added split block function to DDV
+*
+* Revision 1.36 2000/06/30 22:31:51 hurwitz
+* added merge block function for DDV
+*
+* Revision 1.35 2000/06/27 20:46:38 hurwitz
+* fixed bugs with select rectangle, added select row option
+*
+* Revision 1.34 2000/06/15 17:33:18 hurwitz
+* used view seqAlignPtr to get original (bug fix), and started working on left/right/center justify for DDE
+*
+* Revision 1.33 2000/05/19 13:48:31 hurwitz
+* made a version of DDE that doesn't allow aligned gaps, changed wording for adding new rows
+*
+* Revision 1.32 2000/05/15 23:39:34 lewisg
+* shred cblast, add menu items for gapped/ungapped, fix pdbheaders
+*
+* Revision 1.31 2000/04/26 21:54:27 hurwitz
+* added save function to tell AlnMgr about edits made in DDE
+*
+* Revision 1.30 2000/04/21 23:00:50 hurwitz
+* can launch DDE from DDV
+*
+* Revision 1.29 2000/04/18 19:50:24 lewisg
+* add deselect menu item
+*
+* Revision 1.28 2000/04/17 13:30:43 durand
+* removed g_hParent and unused functions DDV_LaunchAlignViewer and DDV_LaunchAlignEditor
+*
+* Revision 1.27 2000/04/10 21:41:26 lewisg
+* move alignment menus into ddv, udv from cn3d
+*
+* Revision 1.26 2000/04/10 20:58:42 hurwitz
+* added GUI controls for DeleteBlock in DDE
+*
+* Revision 1.25 2000/04/07 16:21:08 hurwitz
+* made delete block faster, added delete block to edit menu
+*
+* Revision 1.24 2000/03/27 22:15:05 lewisg
+* add show/hide row dialog
+*
+* Revision 1.23 2000/03/25 00:22:09 hurwitz
+* put DDE_StackPtr in DDV_Main, add to stack inside DDE api's, added insert char, delete char, home and end keyboard control
+*
+* Revision 1.22 2000/03/14 22:08:21 hurwitz
+* undo and redo working properly, restore-original function added
+*
+* Revision 1.21 2000/03/10 23:01:43 hurwitz
+* added undo and redo functions, first pass
+*
+* Revision 1.20 2000/03/06 22:45:58 hurwitz
+* can shift right boundary of an aligned block left and right, DDVRuler updates added
+*
+* Revision 1.19 2000/03/01 22:49:41 lewisg
+* import bioseq, neatlyindex, get rid of dead code
+*
+* Revision 1.18 2000/02/04 16:05:41 durand
+* add click action to select a row
+*
+* Revision 1.17 2000/01/26 13:38:55 durand
+* update the GUI for the editor. Add functions to create the data to be used by the editor
+*
+* Revision 1.16 2000/01/12 21:52:17 durand
+* add import function; update menus when DDV is loaded from Cn3D
+*
+* Revision 1.15 2000/01/11 15:05:23 durand
+* remove network stuff
+*
+* Revision 1.14 2000/01/10 15:09:45 durand
+* Use Entrez instead of ID1
+*
+* Revision 1.13 1999/12/20 20:20:41 lewisg
+* allow cn3d to do color and ddv to do case when both are running
+*
+* Revision 1.12 1999/12/07 21:40:14 durand
+* add mouse modes menu and caret facility for the editor
+*
+* Revision 1.11 1999/12/03 23:17:23 lewisg
+* Patrick's new global update msg, argument passing when launching ddv, experimental editing
+*
+* Revision 1.10 1999/11/29 15:26:25 durand
+* designed a new GUI to fix problems under MacOS, Linux and SGI
+*
+* Revision 1.9 1999/11/09 17:09:00 durand
+* transfer some functions from ddvgraph to ddvcreate, so that ddvcreate remains Vibrant free and can be compiled with BLAST
+*
+* Revision 1.8 1999/11/03 21:29:48 durand
+* add CTRL and SHFT keys for mouse selection. redesign the loader functions of DDV to properly register the message callbacks
+*
+* Revision 1.7 1999/10/29 14:15:40 durand
+* add simple mouse selection functions
+*
+* Revision 1.6 1999/10/23 14:54:34 durand
+* resolve external symbol g_hParent
+*
+* Revision 1.5 1999/10/22 20:12:47 durand
+* add Export command (text, HTML and Phylip formats)
+*
+* Revision 1.4 1999/10/22 14:19:43 durand
+* update the code for the startup functions of DDV drawing panel
+*
+* Revision 1.3 1999/10/20 13:17:19 durand
+* add display for disc. SeqAlign tails
+*
+* Revision 1.2 1999/10/15 21:57:36 durand
+* add a UI for display options
+*
+* Revision 1.1 1999/09/30 14:10:27 durand
+* add ddv to toolkit
+*
+* Revision 1.7 1999/09/23 19:06:50 lewisg
+* increase maxtemp number of cached sequences
+*
+* Revision 1.6 1999/09/21 14:19:08 durand
+* add mouse click management layout
+*
+* Revision 1.5 1999/09/09 21:55:07 durand
+* instantiate the Fle|Close command of DDV
+*
+* Revision 1.4 1999/07/20 14:58:01 durand
+* use the Color Manager to display colored MSA
+*
+* Revision 1.3 1999/06/30 14:57:21 durand
+* update DDV loader functions
+*
+* Revision 1.2 1999/06/28 22:07:21 durand
+* add loader functions and clean the code with Lint and Purify
+*
+* Revision 1.1 1999/06/19 17:21:07 durand
+* add Vibrant DDV code
+*
+*
+*
+* ==========================================================================
+*/
+
+#ifndef _DDVMAIN_
+#define _DDVMAIN_
+
+#include <ncbi.h>
+#include <vibrant.h>
+#include <ddvopen.h>
+#include <pgppop.h>
+#include <ddvcolor.h>
+#include <ddvcreate.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/******************************************************************************
+
+ ERROR / Information messages from DDV_OPEN module
+
+******************************************************************************/
+#define DVV_MSG_M_OK 1
+
+/******************************************************************************
+
+ defines
+
+******************************************************************************/
+
+/* maximum number of sequences to hold in memory */
+#define DDV_MAXTEMP 500
+/*caret style */
+#define DDV_CARET_BAR 1
+/*mouse mode*/
+#define DDV_MOUSEMODE_QUERY 0
+#define DDV_MOUSEMODE_SELECT 1
+#define DDV_MOUSEMODE_EDIT 2
+#define DDV_MOUSEMODE_CREATEBLOCK 3
+#define DDV_MOUSEMODE_LAUNCHEDITOR 4
+#define DDV_MOUSEMODE_SELECT_ONE_ROW 5
+#define DDV_MOUSEMODE_MERGEBLOCKS1 6
+#define DDV_MOUSEMODE_MERGEBLOCKS2 7
+#define DDV_MOUSEMODE_SPLITBLOCK 8
+#define DDV_MOUSEMODE_DELETEBLOCK 9
+
+/*timer control*/
+#define DDV_SET_TIMER 1
+#define DDV_TEST_TIMER 2
+/*action associated with the timer*/
+#define DDV_INVAL_REGION 1
+#define DDV_NOTHING 2
+
+/******************************************************************************
+
+ Data structures
+
+******************************************************************************/
+/*used to display the caret (editor mode only)*/
+typedef struct ddvcaretinfo{
+ Int4 old_row;/*zero-based values; display coordinates*/
+ Int4 old_col;
+ Int4 new_row;/*zero-based values; display coordinates*/
+ Int4 new_col;
+ Uint1 style; /*see DDV_CARET_* defines */
+} DDVCaretInfo, PNTR DDVCaretInfoPtr;
+
+/*used to remember the selected row (editor mode only)*/
+typedef struct ddveditrowinfo{
+ Int4 curEditRow;/*zero-based values; row for applying delete, move*/
+ Int4 curMasterRow;/*zero-based values; this row is the master*/
+} DDVEditRowInfo, PNTR DDVEditRowInfoPtr;
+
+typedef struct ddv_global{
+ DDV_ColorGlobal * colorp;
+} DDV_Global, PNTR DDV_GlobalPtr;
+
+typedef struct ddvmenu {
+ /*file menu*/
+ MenU File;
+ IteM FileOpen;/*open file command*/
+ IteM EntrezOpen;/*open from ID1 command*/
+ IteM FileClose;/*close file command*/
+ IteM SaveEdits;/* save changes made in editor*/
+ IteM FileExport;/*export a seqalign*/
+ IteM ImportSeq;/* import a sequence */
+ IteM ImportNucSeqAlign;/* import a nuc SeqAlign */
+ IteM ImportProtSeqAlign;/* import a prot SeqAlign */
+ IteM Hide;/* show/hide dialog */
+ IteM QuitViewer;/*close the viewer*/
+ /*Edit menu*/
+ MenU Edit;
+ IteM DeleteRow;
+ IteM MoveRowLeft;
+ IteM MoveRowRight;
+ IteM LeftBoundaryLeft;
+ IteM LeftBoundaryRight;
+ IteM RightBoundaryLeft;
+ IteM RightBoundaryRight;
+ IteM DeleteBlock;
+ IteM CreateBlock;
+ IteM Prev;
+ IteM Next;
+ IteM Orig;
+ /*Align menu */
+ MenU Align;
+ MenU AddRow;
+ MenU FromFile;
+ MenU FromNet;
+ IteM Deselect;
+ IteM BlastFile;
+ IteM BlastNet;
+ /*Options menu*/
+ MenU Options;
+ IteM DispStyles;/*display styles*/
+ ChoicE MouseMode;/*mouse mode (query, selection, edit)*/
+ ChoicE Justify;/*justify (left, right, center)*/
+ IteM ShowLowerPanel;
+ IteM ConfigNet;/*Entrez Network Conf. dlg*/
+ IteM LaunchEditor;
+ IteM MergeBlocks;
+ IteM SplitBlock;
+ IteM DeleteDDVBlock;
+ } DdvMenu, PNTR DdvMenuPtr;
+
+typedef struct ddvmsadata {
+ MsaParaGPopList pgp_l;/*ParaG list*/
+ Uint2 entityID;/*currently displayed SeqAlign*/
+ Uint2 itemID;/* */
+ } DdvMSAData, PNTR DdvMSADataPtr;
+
+typedef struct ddvmainwin {
+ Boolean UseNetwork;
+ /*main win menu*/
+ DdvMenu MainMenu;/*menu command list*/
+ ButtoN gotoBtn;
+ TexT gotoValRow;
+ TexT gotoValCol;
+ GrouP StatusGroup;
+ GrouP StatusGroupLower;
+ Boolean Show_logo;
+ FonT f1; /*tree fonts used to display the software logo*/
+ FonT f2;
+ FonT f3;
+ /*viewer data used only when AutonomeViewer is TRUE */
+ Boolean AutonomeViewer;/*viewer is standalone ?*/
+ WindoW hWndMain;/*handle to the main window*/
+ PaneL hWndDDV;/*handle of the current DDV panel*/
+ PaneL hUpperPanel;/*handle of the upper DDV panel (the multiple)*/
+ PaneL hLowerPanel;/*handle of the DDV panel (the pairwise) */
+ PrompT InfoPanel;
+ PrompT UpperInfoPanel;
+ PrompT LowerInfoPanel;
+ /*use to open a file*/
+ UdvFetchSeqEntryProc fetchSepProc;/*function to get a gi over the Network*/
+ Nlm_ItmActnProc NetCfgMenuProc;
+ StartNetworkProc NetStartProc;
+ Boolean EditAllowed; /* editing is allowed */
+ }DdvMainWin,PNTR DdvMainWinPtr;
+
+typedef struct ddvtimerdata {
+ Int4 col;/*one-based; disp coord*/
+ Int4 row;/*one-based; disp coord*/
+ Int2 delay;
+ Uint1 status;
+ Uint1 action;
+}DdvTimerData, PNTR DdvTimerDataPtr;
+
+typedef struct ddvmain {
+ WindoW hParent;
+ PaneL hWndDDV;/*panel's handle*/
+ UnDViewerGraphData GrData;/*graphical data*/
+ DdvMSAData MSA_d;/*data to display*/
+ DDV_Global Globals;/*shared color data, among others*/
+ UDV_mouse_select ms;/*mouse selection info*/
+ DDV_Disp_Opt ddo;
+ DDVCaretInfo dci;/*caret position and style (editor only)*/
+ DDVEditRowInfo deri;/*some rows info to apply edit commands*/
+ DdvTimerData dtd;/*last goto position*/
+ Uint1 MouseMode;
+ Uint1 SavedMouseMode;
+ Uint2 userkey;
+ Uint2 procid;
+ Uint2 proctype;
+ Int4 MasterViewer;/*the viewer launching ddv*/
+ Boolean bEditor;/*true if use DDV with editor functions*/
+ DDE_StackPtr dsp;/*data for editor*/
+ Int4 BlockIndex;/*the first block of merge 2 blocks*/
+ Int4 SaveCol;/*col where split line is drawn*/
+ /*SAP list when open a File or fetch an DB entry*/
+ ValNodePtr vnp_ali;/*SeqAlign List*/
+ DdvOpenData dod;/*what is open in DDV*/
+ } DdvMain, PNTR DdvMainPtr;
+
+#define NUMARGS 2
+extern Args DDV_myargs[NUMARGS];
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ndef _DDVMAIN_ */
+
diff --git a/ddv/ddvopen.c b/ddv/ddvopen.c
new file mode 100644
index 00000000..7cebf215
--- /dev/null
+++ b/ddv/ddvopen.c
@@ -0,0 +1,3441 @@
+/* $Id: ddvopen.c,v 1.96 2001/04/26 16:41:20 juran Exp $
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information (NCBI)
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government do not place any restriction on its use or reproduction.
+* We would, however, appreciate having the NCBI and the author cited in
+* any work or product based on this material
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* ===========================================================================
+*
+* File Name: ddvopen.c
+*
+* Author: Patrick Durand
+*
+* Version Creation Date: 06/19/99
+*
+* $Revision: 1.96 $
+*
+* File Description: code to open a SeqAlign (file & Net) and code of the
+* message callback for DeuxD-Viewer (DDV).
+*
+* Modifications:
+* --------------------------------------------------------------------------
+* $Log: ddvopen.c,v $
+* Revision 1.96 2001/04/26 16:41:20 juran
+* Squelch warnings.
+*
+* Revision 1.95 2000/07/17 17:46:48 hurwitz
+* made it so show/hide dialog only updates view when ok is clicked
+*
+* Revision 1.94 2000/07/14 22:24:56 lewisg
+* fix scroll, click, visual c++ build bugs. add command line arg parse to ddv
+*
+* Revision 1.92 2000/07/05 19:23:13 lewisg
+* add two panes to ddv, update msvc project files
+*
+* Revision 1.91 2000/06/16 14:57:03 lewisg
+* move entrez calls out of desktop
+*
+* Revision 1.90 2000/06/15 17:33:18 hurwitz
+* used view seqAlignPtr to get original (bug fix), and started working on left/right/center justify for DDE
+*
+* Revision 1.89 2000/06/15 16:01:07 hurwitz
+* rewrote section that calls ViewMgr_Attach when SeqAlign is not editable but IBMable
+*
+* Revision 1.88 2000/06/13 18:23:55 hurwitz
+* made ViewMgr_MakeMultiple routine, call this on each launch of DDE rather than launch of DDV
+*
+* Revision 1.87 2000/06/12 23:02:40 hurwitz
+* enable launch of DDE from Cn3D, swith from DDV_ComputeRuler to DDE_ReMakeRuler, get rid of styles option for DDE
+*
+* Revision 1.86 2000/06/08 20:04:38 hurwitz
+* made warning about converting to true multiple alignment into a Message window, and other small fixes
+*
+* Revision 1.85 2000/06/07 19:09:36 hurwitz
+* made DDE_ReMakeRuler work with linked list of ParaGs
+*
+* Revision 1.84 2000/06/06 14:44:16 hurwitz
+* fixed bug that SetAppProperty(dde_nogaps)
+*
+* Revision 1.83 2000/06/02 19:57:03 hurwitz
+* added a query dialog when converting from pairwise multiple to true multiple, bug fix of double freeing of a seqAlignPtr
+*
+* Revision 1.82 2000/06/01 14:40:08 hurwitz
+* temp fix: when DDV is launched as slave, don't allow aligned gaps
+*
+* Revision 1.81 2000/05/31 23:07:26 hurwitz
+* made NoGaps a runtime parameter, fixed bug with vertical scroll of show/hide list, save edits query is not performed if nothing to save
+*
+* Revision 1.80 2000/05/24 21:43:00 hurwitz
+* getting hide/show rows to work with DDV and DDE together
+*
+* Revision 1.79 2000/05/23 22:00:14 hurwitz
+* working on launch of DDE from DDV
+*
+* Revision 1.78 2000/05/15 23:39:34 lewisg
+* shred cblast, add menu items for gapped/ungapped, fix pdbheaders
+*
+* Revision 1.77 2000/05/15 22:00:36 hurwitz
+* put save-edits query into DDV_SlaveQuit where it belongs
+*
+* Revision 1.76 2000/05/12 21:18:13 hurwitz
+* added window asking if user wants to save unsaved edits for dde
+*
+* Revision 1.75 2000/05/12 16:15:25 hurwitz
+* reverted to not doing IntersectOnMaster for DDE, now determined by call to ViewMgr_Attach
+*
+* Revision 1.74 2000/05/11 16:28:44 wheelan
+* made DDV_ShredAln NLM_EXTERN
+*
+* Revision 1.73 2000/05/10 22:03:29 thiessen
+* temporary fix for CN3D_[TRIM,SHRED] not defined
+*
+* Revision 1.72 2000/05/10 16:47:25 wheelan
+* added CN3D_SHRED and CN3D_TRIM options; added ddv_shred_aln
+*
+* Revision 1.71 2000/05/09 14:21:54 wheelan
+* added ddv_truncate_overlaps
+*
+* Revision 1.70 2000/05/08 16:29:27 wheelan
+* change to ungapped BLAST
+*
+* Revision 1.69 2000/05/04 22:43:38 hurwitz
+* don't launch DDE on top of DDV, change some wording, redraw DDE after save to AlnMgr
+*
+* Revision 1.68 2000/05/03 17:48:30 hurwitz
+* keep DDV in same column when DDE does a save
+*
+* Revision 1.67 2000/05/03 16:16:51 hurwitz
+* fixed bug fix from yesterday
+*
+* Revision 1.66 2000/05/02 19:50:38 hurwitz
+* fixed some bugs with launching DDE from DDV, added new alnMgr fn for positioning DDE on proper column
+*
+* Revision 1.65 2000/04/28 14:43:37 hurwitz
+* send message to DDV after edits in DDE are accepted by AlnMgr
+*
+* Revision 1.64 2000/04/27 22:21:58 lewisg
+* misc bugs/features
+*
+* Revision 1.63 2000/04/27 19:57:59 hurwitz
+* scroll to aligned block on launch of DDE
+*
+* Revision 1.62 2000/04/27 13:33:41 durand
+* SpacerSize min value fixed to 1; update view when SpacerSize is changed
+*
+* Revision 1.61 2000/04/21 23:00:50 hurwitz
+* can launch DDE from DDV
+*
+* Revision 1.60 2000/04/20 23:27:43 lewisg
+* misc bug fixes
+*
+* Revision 1.59 2000/04/19 15:45:50 hurwitz
+* can create display for a block
+*
+* Revision 1.58 2000/04/17 13:30:43 durand
+* removed g_hParent and unused functions DDV_LaunchAlignViewer and DDV_LaunchAlignEditor
+*
+* Revision 1.57 2000/04/11 14:08:33 durand
+* removed a debug line
+*
+* Revision 1.56 2000/04/10 20:33:40 lewisg
+* fix show/hide for blast multiple, make blast multiple API generic
+*
+* Revision 1.55 2000/04/10 19:53:14 durand
+* allowed ddv to display NULL SeqAlign
+*
+* Revision 1.54 2000/04/08 00:37:32 lewisg
+* multiple seqentries, NEWSEQ message, etc.
+*
+* Revision 1.53 2000/04/07 15:03:08 durand
+* added use of UPDATE_TYPE_NEWSEQ; DDV now rebuilt EntitiesTable after an update msg
+*
+* Revision 1.52 2000/04/04 17:51:54 lewisg
+* fix various seq import bugs
+*
+* Revision 1.51 2000/03/29 23:38:06 lewisg
+* hide/show, fixes to saving and opening
+*
+* Revision 1.50 2000/03/29 19:26:10 lewisg
+* use blast2seqs instead of bandalign
+*
+* Revision 1.49 2000/03/27 22:15:06 lewisg
+* add show/hide row dialog
+*
+* Revision 1.48 2000/03/27 18:07:48 hurwitz
+* page up and page down working, give panel focus on launch
+*
+* Revision 1.47 2000/03/24 20:34:58 lewisg
+* add blast from file, bug fixes, get rid of redundant code, etc.
+*
+* Revision 1.46 2000/03/22 20:31:34 durand
+* added system menus for slave DDV
+*
+* Revision 1.45 2000/03/21 14:21:46 durand
+* fixed a problem with menus setup
+*
+* Revision 1.44 2000/03/20 19:26:53 kans
+* need to create menus before other window contents - Mac menu bar for windows is actually in content area
+*
+* Revision 1.43 2000/03/16 14:11:59 durand
+* set corretly mouse mode menu
+*
+* Revision 1.42 2000/03/02 21:11:06 lewisg
+* use bandalign for import sequence, make standalone ddv use viewmgr, make dialogs modal, send color update
+*
+* Revision 1.41 2000/03/02 15:43:10 durand
+* use MovableModalWindow for dialog boxes
+*
+* Revision 1.40 2000/03/01 22:49:41 lewisg
+* import bioseq, neatlyindex, get rid of dead code
+*
+* Revision 1.39 2000/02/28 20:15:32 durand
+* if DDV is started from Cn3D, DDV doesn't set up anymore letters layout
+*
+* Revision 1.38 2000/02/15 22:40:57 lewisg
+* add ability to launch udv so that it colors by row, fixes to colormgr, track rows from viewmgr, fix visual c projects
+*
+* Revision 1.37 2000/02/07 21:14:08 durand
+* added a generic answer to Update messages
+*
+* Revision 1.36 2000/02/07 14:03:35 durand
+* replace BioseqUnlockById by BioseqUnlock
+*
+* Revision 1.35 2000/02/05 01:32:22 lewisg
+* add viewmgr, move place freeing is done in ddv, modify visual c++ projects
+*
+* Revision 1.34 2000/02/04 16:05:40 durand
+* add click action to select a row
+*
+* Revision 1.33 2000/02/02 14:44:32 durand
+* added function to create data structure for block editor, fixed some bugs
+*
+* Revision 1.32 2000/01/26 13:38:53 durand
+* update the GUI for the editor. Add functions to create the data to be used by the editor
+*
+* Revision 1.31 2000/01/18 22:49:16 lewisg
+* send OM_MSG_FLUSH to ddv/udv, tweak CPK coloration, misc bugs
+*
+* Revision 1.30 2000/01/12 21:52:16 durand
+* add import function; update menus when DDV is loaded from Cn3D
+*
+* Revision 1.29 2000/01/11 15:05:23 durand
+* remove network stuff
+*
+* Revision 1.28 2000/01/10 15:09:46 durand
+* Use Entrez instead of ID1
+*
+* Revision 1.27 2000/01/05 21:11:14 durand
+* update mouse click actions and DrawSequence function for a better use from ddv and cn3d
+*
+* Revision 1.26 1999/12/30 21:08:45 lewisg
+* bioseq import dialog
+*
+* Revision 1.25 1999/12/30 13:45:50 beloslyu
+* fix comment
+*
+* Revision 1.24 1999/12/29 22:55:03 lewisg
+* get rid of seqalign id
+*
+* Revision 1.23 1999/12/23 19:22:06 durand
+* modify default options for DDV when loaded from Cn3D
+*
+* Revision 1.22 1999/12/21 15:27:24 durand
+* avoid to quit Cn3D when closing DDV
+*
+* Revision 1.21 1999/12/20 20:20:41 lewisg
+* allow cn3d to do color and ddv to do case when both are running
+*
+* Revision 1.20 1999/12/07 21:40:13 durand
+* add mouse modes menu and caret facility for the editor
+*
+* Revision 1.19 1999/12/06 16:19:19 durand
+* add GoTo facility to DDV
+*
+* Revision 1.18 1999/12/03 23:17:23 lewisg
+* Patrick's new global update msg, argument passing when launching ddv, experimental editing
+*
+* Revision 1.17 1999/11/30 18:19:47 durand
+* fix a problem with function declaration DDV_CloseData
+*
+* Revision 1.16 1999/11/29 15:26:26 durand
+* designed a new GUI to fix problems under MacOS, Linux and SGI
+*
+* Revision 1.15 1999/11/17 22:43:58 durand
+* speed up the selection manager for large SeqAlign
+*
+* Revision 1.14 1999/11/09 17:09:00 durand
+* transfer some functions from ddvgraph to ddvcreate, so that ddvcreate remains Vibrant free and can be compiled with BLAST
+*
+* Revision 1.13 1999/11/04 22:11:38 durand
+* add the Desktop to DDV. Add a better set of cleanup functions when closing DDV. Before creating color tables, try to get them from the SeqAlign
+*
+* Revision 1.12 1999/11/03 21:29:47 durand
+* add CTRL and SHFT keys for mouse selection. redesign the loader functions of DDV to properly register the message callbacks
+*
+* Revision 1.11 1999/10/29 19:04:21 durand
+* move DDVUpdateMSG in objmgr.h
+*
+* Revision 1.10 1999/10/29 14:15:39 durand
+* add simple mouse selection functions
+*
+* Revision 1.9 1999/10/23 21:20:45 lewisg
+* move g_hParent to ddvopen.c
+*
+* Revision 1.8 1999/10/23 14:54:34 durand
+* resolve external symbol g_hParent
+*
+* Revision 1.7 1999/10/22 14:19:43 durand
+* update the code for the startup functions of DDV drawing panel
+*
+* Revision 1.6 1999/10/20 18:37:31 lewisg
+* add messagefunc for slave mode
+*
+* Revision 1.5 1999/10/20 13:17:18 durand
+* add display for disc. SeqAlign tails
+*
+* Revision 1.4 1999/10/16 15:02:25 durand
+* fixes due to toolkit build failed
+*
+* Revision 1.3 1999/10/15 21:57:36 durand
+* add a UI for display options
+*
+* Revision 1.2 1999/10/12 15:01:29 lewisg
+* resolve confict with internal/ddv
+*
+* Revision 1.1 1999/09/30 14:10:28 durand
+* add ddv to toolkit
+*
+* Revision 1.14 1999/09/30 13:38:10 durand
+* DDV_CreateDisplayFromIndex takes ParaG_Size as an argument
+*
+* Revision 1.13 1999/09/16 13:07:52 durand
+* add File|Close and File|Open|Network commands
+*
+* Revision 1.12 1999/09/09 21:55:06 durand
+* instantiate the Fle|Close command of DDV
+*
+* Revision 1.11 1999/09/02 17:36:07 durand
+* reconcile ddvopen.c
+*
+* Revision 1.10 1999/08/19 17:15:27 wheelan
+* added messages to indicate timing of index building vs color tables
+*
+* Revision 1.9 1999/08/04 18:02:12 wheelan
+* changes to support new seqalign indexing
+*
+* Revision 1.8 1999/07/29 12:43:07 durand
+* update DDV_GetAndCheckSeqAlign
+*
+* Revision 1.7 1999/07/20 17:18:23 durand
+* update DDV_GetAndCheckSeqAlign for PopSet Viewer
+*
+* Revision 1.6 1999/07/20 14:58:01 durand
+* use the Color Manager to display colored MSA
+*
+* Revision 1.5 1999/07/01 15:28:29 durand
+* validate function loaders of DDV
+*
+* Revision 1.2 1999/06/28 22:07:19 durand
+* add loader functions and clean the code with Lint and Purify
+*
+* Revision 1.1 1999/06/19 17:21:05 durand
+* add Vibrant DDV code
+*
+*
+*
+* ==========================================================================
+*/
+
+#include <ncbi.h>
+#include <vibrant.h>
+#include <salfiles.h>
+#include <pgppop.h>
+#include <udviewer.h>
+#include <ddvopen.h>
+#include <ddvpanel.h>
+#include <ddvmain.h>
+#include <ddvgraph.h>
+#include <ddvcreate.h>
+#include <objmgr.h>
+#include <gather.h>
+#include <ddvcolor.h>
+#include <samutil.h>
+#include <blast.h>
+#include <viewmgr.h>
+#include <actutils.h>
+
+/*extern WindoW g_hParent = NULL;*/
+static void DDV_RegisterMsgFuncOnBsp(Uint2 bsp_eID,DdvMainPtr dmp);
+
+static void DDV_Convert(ButtoN g);
+static void DDV_NoConvert(ButtoN g);
+
+/*local struct used only by the Download sequence dialog box*/
+ typedef struct ddvnetopen {
+ WindoW hWndMain; /*main window*/
+ TexT Entry; /*Entrez entry*/
+ PopuP AccessType; /*database type*/
+ ButtoN ok; /*ok button*/
+ UDVMainMenuPtr mmp; /*main menu*/
+ } DDVNetOpen, PNTR DDVNetOpenPtr;
+
+
+/*******************************************************************************
+
+ Function : DDV_GetSelectedRegions()
+
+ Purpose : get the selected region(s) of one bioseq.
+
+ Parameters : om_ssp;list of selected regions (usually this field points to
+ ObjMgr data)
+ bsp_eID,bsp_iID; bioseq identifiers.
+
+ Return value : list of selected regions on the bioseq bsp_eID,bsp_iID
+
+*******************************************************************************/
+extern ValNodePtr DDV_GetSelectedRegions(SelStructPtr om_ssp, Uint2 bsp_eID,
+ Uint2 bsp_iID)
+{
+SelStructPtr ssp;
+SeqLocPtr slp,slp2;
+ValNodePtr bsp_vnp=NULL,vnp;
+
+ if (om_ssp==NULL || bsp_eID==0 || bsp_iID==0) return(NULL);
+
+ ssp=om_ssp;
+
+ while(ssp){
+ if (ssp->entityID==bsp_eID && ssp->itemID==bsp_iID &&
+ ssp->itemtype==OBJ_BIOSEQ && ssp->regiontype==OM_REGION_SEQLOC){
+ slp=(SeqLocPtr)ssp->region;
+ while(slp){
+ slp2=slp->next;
+ slp->next=NULL;
+ if (!bsp_vnp){
+ vnp=ValNodeAddPointer(NULL,0,(Pointer)slp);
+ if (!vnp) return(NULL);
+ bsp_vnp=vnp;
+ }
+ else{
+ vnp=ValNodeAddPointer(&vnp,0,(Pointer)slp);
+ if (!vnp){
+ if (bsp_vnp) ValNodeFree(bsp_vnp);
+ return(NULL);
+ }
+ }
+ slp->next=slp2;
+ slp=slp->next;
+ }
+ }
+ ssp=ssp->next;
+ }
+ return(bsp_vnp);
+}
+
+/*******************************************************************************
+
+ Function : DDV_IsLetterSelected()
+
+ Purpose : check if a bsp_pos is selected (vnp_bsp is usually built with
+ DDV_GetSelectedRegions() function)
+
+ Return value : TRUE if bsp_pos is selected
+
+*******************************************************************************/
+extern Boolean DDV_IsLetterSelected(ValNodePtr vnp_bsp, Int4 bsp_pos)
+{
+Boolean bSelected=FALSE;
+ValNodePtr vnp;
+SeqLocPtr slp;
+Int4 bsp_start,bsp_stop;
+ if (vnp_bsp==NULL || bsp_pos==(Int4)-1) return(FALSE);
+
+ vnp=vnp_bsp;
+
+ while(vnp){
+ slp=(SeqLocPtr)vnp->data.ptrvalue;
+ bsp_start=SeqLocStart(slp);
+ bsp_stop=SeqLocStop(slp);
+ if (bsp_pos>=bsp_start && bsp_pos<=bsp_stop){
+ bSelected=TRUE;
+ break;
+ }
+ vnp=vnp->next;
+ }
+
+ return(bSelected);
+}
+
+/*******************************************************************************
+
+ Function : DDV_CheckBSPEntitiesInPgp()
+
+ Purpose : check if entityID,itemID Object is in the current paragraph
+
+ Return value : TRUE if success
+
+*******************************************************************************/
+/*static Boolean DDV_CheckBSPEntities(Uint4Ptr entitiesTbl,Int4 nRowBsp,
+ Int4 nBsp,Uint2 eID,Uint2 iID)
+{
+Uint2 bsp_eID,bsp_iID;
+Int4 i;
+Boolean bRet=FALSE;
+
+ for (i=0;i<nBsp;i++){
+ UDV_DecodeIdxFeat (entitiesTbl[i], &bsp_eID,&bsp_iID);
+ }
+ bsp=BioseqLockById(pgp->sip);
+ if (bsp){
+ bsp_eID=ObjMgrGetEntityIDForPointer((Pointer)bsp);
+ bsp_iID = GetItemIDGivenPointer (bsp_eID,
+ OBJ_BIOSEQ, (Pointer) bsp);
+
+ if (bsp_eID==eID && bsp_iID==iID) bRet=TRUE;
+ BioseqUnlock(bsp);
+ }
+ return(bRet);
+}
+*/
+/*******************************************************************************
+
+ Function : DDV_CheckBSPEntitiesInDisplay()
+
+ Purpose : check if entityID,itemID Object is in the current DDV display
+
+ Return value : TRUE if object found
+
+*******************************************************************************/
+static Boolean DDV_CheckBSPEntitiesInDisplay(MsaParaGPopListPtr mpplp,
+ Uint2 entityID,Uint2 itemID)
+{
+Uint2 bsp_eID,bsp_iID;
+Int4 i;
+Boolean bRet=FALSE;
+
+ /*scan the ParaG list to find the Bioseq*/
+ for (i=0;i<mpplp->nBsp;i++){
+ UDV_DecodeIdxFeat (mpplp->entitiesTbl[i], &bsp_eID,&bsp_iID);
+ if (bsp_eID==entityID && bsp_iID==itemID) {
+ bRet=TRUE;
+ break;
+ }
+ }
+ return(bRet);
+}
+
+/*******************************************************************************
+
+ Function : DDV_GetBspListGivenIDs()
+
+ Purpose : analyse the ParaG struct and get a list of row(s) containing the
+ BSP identified by eID and iID
+
+ Return value : list of row number (one-based values)
+
+*******************************************************************************/
+static Int4Ptr DDV_GetBspListGivenIDs(MsaParaGPopListPtr mpplp,
+ Uint2 entityID,Uint2 itemID,Int4Ptr nFound)
+{
+Int4 i;
+Int4Ptr pList=NULL;
+Uint2 bsp_eID,bsp_iID;
+
+ *nFound=0;
+
+ /*scan the ParaG list to find all the ref. of the Bioseq
+ (entityID,itemID) in the ParaG list*/
+ for (i=0;i<mpplp->nBsp;i++){
+ UDV_DecodeIdxFeat (mpplp->entitiesTbl[i], &bsp_eID,&bsp_iID);
+ if (bsp_eID==entityID && bsp_iID==itemID) {
+ if (!pList){
+ pList=(Int4Ptr)MemNew(sizeof(Int4));
+ }
+ else{
+ pList=(Int4Ptr)MemExtend((void *)pList,
+ ((*nFound)+1)*sizeof(Int4), (*nFound)*sizeof(Int4));
+ }
+ if (!pList) {*nFound=0;return(NULL);}
+
+
+ pList[*nFound]=i+1;
+ (*nFound)++;
+ }
+
+ }
+ return(pList);
+}
+
+/*******************************************************************************
+
+ Function : DDV_MSG_SELECT()
+
+ Purpose : manage OM_MSG_SELECT & OM_MSG_DESELECT message
+
+ Return value : OM_MSG_RET_OK if success
+
+*******************************************************************************/
+static Int2 DDV_MSG_SELECT(OMMsgStructPtr ommsp,Boolean IsSelectMsg)
+{
+DdvMainPtr dmp; /*DDV panel data*/
+OMUserDataPtr omudp;/*user data set when registering DDV panel*/
+Int4Ptr bsp_List=NULL;
+ParaGPtr pgp;
+
+Boolean bRet;
+SeqLocPtr slp;
+Int4 from_col,to_col,from_row,to_row,bsp_start,bsp_stop,nBspInstances=0,i,
+ row_num;
+
+ omudp = (OMUserDataPtr)(ommsp->omuserdata);
+ if (omudp == NULL) return(OM_MSG_RET_ERROR);
+
+ dmp=(DdvMainPtr)omudp->userdata.ptrvalue;
+ if (dmp == NULL) return(OM_MSG_RET_ERROR);
+
+ if (ommsp->itemtype != OBJ_BIOSEQ) return(OM_MSG_RET_OK);
+ if (ommsp->regiontype!=OM_REGION_SEQLOC) return(OM_MSG_RET_OK);
+
+ /*Am I concern by that Bioseq ?*/
+ bRet=DDV_CheckBSPEntitiesInDisplay(&(dmp->MSA_d.pgp_l),ommsp->entityID,
+ ommsp->itemID);
+
+ if (bRet==FALSE) return(OM_MSG_RET_OK); /* some other viewer */
+
+ /*get the disp coord range*/
+ DDV_GetCurrentDispRange(dmp->hWndDDV,&(dmp->GrData),dmp->MSA_d.pgp_l.LengthAli,
+ &from_col,&to_col,&from_row,&to_row);
+
+ /*get the occurence(s) (row(s) #) for that bioseq*/
+ bsp_List=DDV_GetBspListGivenIDs(&(dmp->MSA_d.pgp_l),ommsp->entityID,
+ ommsp->itemID,&nBspInstances);
+
+ if (bsp_List==NULL || nBspInstances==0) return(OM_MSG_RET_ERROR);
+
+ /*scan the SeqLoc list to figure out if it's currently on the screen*/
+ slp=(SeqLocPtr)ommsp->region;
+ while(slp){/*for each SeqLoc, I try to see what region(s) has (have) to be
+ uptdated*/
+ for(i=0;i<nBspInstances;i++){
+ row_num=bsp_List[i]-1;
+ bsp_start=DDV_GetDispCoordGivenBspCoord(dmp->MSA_d.pgp_l.TableHead[row_num],
+ SeqLocStart(slp));
+ bsp_stop=DDV_GetDispCoordGivenBspCoord(dmp->MSA_d.pgp_l.TableHead[row_num],
+ SeqLocStop(slp));
+ if (bsp_start!=(Int4)-1 && bsp_stop!=(Int4)-1){
+ pgp=(ParaGPtr)(dmp->MSA_d.pgp_l.TableHead[row_num]->data.ptrvalue);
+
+ row_num=pgp->StartLine+
+
+ (pgp->ScaleStyle==SCALE_POS_NONE ? (Int4)0 : (Int4)1);
+
+ DDV_InvalRegion(dmp->hWndDDV,&(dmp->GrData),
+ _max_(bsp_start,from_col),_min_(bsp_stop,to_col),
+ row_num,IsSelectMsg);
+
+ }
+ }
+ slp=slp->next;
+ }
+ return(OM_MSG_RET_OK);
+}
+
+/*******************************************************************************
+
+ Function : DDV_MSG_UPDATE_CaretPos()
+
+ Purpose : update the position of the caret (edit mode only)
+
+ Return value : OM_MSG_RET_OK if success
+
+*******************************************************************************/
+static Int2 DDV_MSG_UPDATE_CaretPos(OMMsgStructPtr ommsp)
+{
+DdvMainPtr dmp; /*DDV panel data*/
+OMUserDataPtr omudp;/*user data set when registering DDV panel*/
+Boolean bRet;
+Int4 from_col,to_col,from_row,to_row;
+
+ omudp = (OMUserDataPtr)(ommsp->omuserdata);
+ if (omudp == NULL) return(OM_MSG_RET_ERROR);
+
+ dmp=(DdvMainPtr)omudp->userdata.ptrvalue;
+ if (dmp == NULL) return(OM_MSG_RET_ERROR);
+
+ /*Am I concern by that Bioseq ?*/
+ bRet=DDV_CheckBSPEntitiesInDisplay(&(dmp->MSA_d.pgp_l),ommsp->entityID,
+ ommsp->itemID);
+
+ if (bRet==FALSE) return(OM_MSG_RET_ERROR);
+
+ /*get the disp coord range*/
+ DDV_GetCurrentDispRange(dmp->hWndDDV,&(dmp->GrData),dmp->MSA_d.pgp_l.LengthAli,
+ &from_col,&to_col,&from_row,&to_row);
+
+ /*switch to one-bsed value because dmp->dci values are one-based values*/
+ from_row++;
+ to_row++;
+ /*hide the caret from old coordinates*/
+ if (dmp->dci.old_col>=from_col && dmp->dci.old_col<=to_col &&
+ dmp->dci.old_row>=from_row && dmp->dci.old_row<=to_row){
+ DDV_InvalRegion(dmp->hWndDDV,&(dmp->GrData),
+ dmp->dci.old_col,dmp->dci.old_col+1,
+ dmp->dci.old_row,FALSE);
+ }
+ /*show caret on new coordinates*/
+ if (dmp->dci.new_col>=from_col && dmp->dci.new_col<=to_col &&
+ dmp->dci.new_row>=from_row && dmp->dci.new_row<=to_row){
+ DDV_InvalRegion(dmp->hWndDDV,&(dmp->GrData),
+ dmp->dci.new_col,dmp->dci.new_col+1,
+ dmp->dci.new_row,FALSE);
+ }
+ return(OM_MSG_RET_OK);
+}
+
+/*******************************************************************************
+
+ Function : DDV_MSG_UPDATE_DelBSP()
+
+ Purpose : rebuilt a display after deletion of one BSP
+
+ Return value : OM_MSG_RET_OK if success
+
+*******************************************************************************/
+static Int2 DDV_MSG_UPDATE_DelBSP(OMMsgStructPtr ommsp)
+{
+DdvMainPtr dmp; /*DDV panel data*/
+OMUserDataPtr omudp;/*user data set when registering DDV panel*/
+
+ omudp = (OMUserDataPtr)(ommsp->omuserdata);
+ if (omudp == NULL) return(OM_MSG_RET_ERROR);
+
+ dmp=(DdvMainPtr)omudp->userdata.ptrvalue;
+ if (dmp == NULL) return(OM_MSG_RET_ERROR);
+
+ /*delete the current display*/
+ if (dmp->MSA_d.pgp_l.TableHead)
+ DDV_DeleteDisplayList(&dmp->MSA_d.pgp_l);
+ if (dmp->MSA_d.pgp_l.RulerDescr)
+ ValNodeFreeData(dmp->MSA_d.pgp_l.RulerDescr);
+ if (dmp->MSA_d.pgp_l.entitiesTbl)
+ MemFree(dmp->MSA_d.pgp_l.entitiesTbl);
+ dmp->MSA_d.pgp_l.TableHead=NULL;
+ dmp->MSA_d.pgp_l.RulerDescr=NULL;
+ /*rebuild a new one*/
+ if (!DDV_CreateDisplayFromIndex(dmp->MSA_d.pgp_l.sap,
+ &(dmp->MSA_d.pgp_l),ParaG_Size,&(dmp->ddo)))
+ return(OM_MSG_RET_ERROR);
+
+ dmp->MSA_d.pgp_l.entitiesTbl=
+ DDV_BuildBspEntitiesTbl(dmp->MSA_d.pgp_l.TableHead,
+ dmp->MSA_d.pgp_l.nBsp);
+ if (!dmp->MSA_d.pgp_l.entitiesTbl)
+ return(OM_MSG_RET_ERROR);
+ /*build the Master Ruler descriptor*/
+/* dmp->MSA_d.pgp_l.RulerDescr=DDV_ComputeRuler(dmp->MSA_d.pgp_l.sap,&(dmp->ddo)); */
+ dmp->MSA_d.pgp_l.RulerDescr = DDE_ReMakeRuler(&(dmp->MSA_d.pgp_l), FALSE, 0);
+
+ /*delete old tables*/
+ if(dmp->MasterViewer != SAMVIEWCN3D) {
+ DDV_ClearColor(dmp->Globals.colorp);
+ /*build new tables*/
+ if (!DDV_InitColour_When_Start(dmp->MSA_d.pgp_l.sap,
+ &(dmp->MSA_d.pgp_l),&(dmp->Globals.colorp), FALSE)){
+ dmp->ddo.bUseColors=FALSE;
+ }
+ }
+
+ DDV_SortPGPLineNum(dmp->MSA_d.pgp_l.TableHead,dmp->MSA_d.pgp_l.nBsp);
+ DDV_WhatSize(dmp);
+ /* DDV_SetupWin(dmp->hWndDDV,TRUE,NULL); */
+ DDV_Resize_DDV(dmp->hWndDDV,TRUE);
+ Update();
+
+ return(OM_MSG_RET_OK);
+}
+/*******************************************************************************
+
+ Function : DDV_MSG_UPDATE_ViewMgr()
+
+ Purpose : rebuild a display after update message from the ViewMgr
+
+ Return value : OM_MSG_RET_OK if success
+
+*******************************************************************************/
+static Int2 DDV_MSG_UPDATE_ViewMgr(OMMsgStructPtr ommsp)
+{
+DdvMainPtr dmp; /*DDV panel data*/
+OMUserDataPtr omudp;/*user data set when registering DDV panel*/
+BaR hsb;
+Int4 HPos;
+
+ omudp = (OMUserDataPtr)(ommsp->omuserdata);
+ if (omudp == NULL) return(OM_MSG_RET_ERROR);
+
+ dmp=(DdvMainPtr)omudp->userdata.ptrvalue;
+ if (dmp == NULL) return(OM_MSG_RET_ERROR);
+
+ if (dmp->bEditor) return(OM_MSG_RET_OK);
+
+ /* get the current column */
+ hsb = GetSlateHScrollBar((SlatE) dmp->hWndDDV);
+ HPos = GetBarValue(hsb);
+
+ /*delete the current display*/
+ if (dmp->MSA_d.pgp_l.TableHead)
+ DDV_DeleteDisplayList(&dmp->MSA_d.pgp_l);
+ if (dmp->MSA_d.pgp_l.RulerDescr)
+ ValNodeFreeData(dmp->MSA_d.pgp_l.RulerDescr);
+ if (dmp->MSA_d.pgp_l.entitiesTbl)
+ MemFree(dmp->MSA_d.pgp_l.entitiesTbl);
+ dmp->MSA_d.pgp_l.TableHead=NULL;
+ dmp->MSA_d.pgp_l.RulerDescr=NULL;
+ /*rebuild a new one*/
+ if (!DDV_CreateDisplayFromIndex(dmp->MSA_d.pgp_l.sap,
+ &(dmp->MSA_d.pgp_l),ParaG_Size,&(dmp->ddo)))
+ return(OM_MSG_RET_ERROR);
+
+ dmp->MSA_d.pgp_l.entitiesTbl=
+ DDV_BuildBspEntitiesTbl(dmp->MSA_d.pgp_l.TableHead,
+ dmp->MSA_d.pgp_l.nBsp);
+ if (!dmp->MSA_d.pgp_l.entitiesTbl)
+ return(OM_MSG_RET_ERROR);
+
+ /* build the Master Ruler descriptor */
+ /* Patrick's ComputeRuler isn't working right, so I substituted mine -- Dave H. */
+ /* dmp->MSA_d.pgp_l.RulerDescr=DDV_ComputeRuler(dmp->MSA_d.pgp_l.sap,&(dmp->ddo)); */
+ dmp->MSA_d.pgp_l.RulerDescr = DDE_ReMakeRuler(&(dmp->MSA_d.pgp_l), FALSE, 0);
+
+ /*delete old tables*/
+ if(dmp->MasterViewer != SAMVIEWCN3D) {
+ DDV_ClearColor(dmp->Globals.colorp);
+ /*build new tables*/
+ if (!DDV_InitColour_When_Start(dmp->MSA_d.pgp_l.sap,
+ &(dmp->MSA_d.pgp_l),&(dmp->Globals.colorp), FALSE)){
+ dmp->ddo.bUseColors=FALSE;
+ }
+ }
+
+ DDV_SortPGPLineNum(dmp->MSA_d.pgp_l.TableHead,dmp->MSA_d.pgp_l.nBsp);
+ DDV_WhatSize(dmp);
+ DDV_Resize_DDV(dmp->hWndDDV,TRUE); /* DDV_SetupWin(dmp->hWndDDV,TRUE,NULL); */
+
+ /* put col back to where it was */
+ SetValue(hsb, HPos);
+
+ Update();
+
+ return(OM_MSG_RET_OK);
+}
+
+/*******************************************************************************
+
+ Function : DDV_MSG_UPDATE_Layout()
+
+ Purpose : manage the OM_MSG_UPDATE message
+
+ Return value : OM_MSG_RET_OK if success
+
+*******************************************************************************/
+static Int2 DDV_MSG_UPDATE_Layout(PaneL hWndDDV, DDVUpdateLayoutDataPtr dumdp)
+{
+DdvMainPtr dmp;
+Int4 j;
+Boolean bResetScrolls=FALSE,
+ bRebuildDisplay=FALSE,
+ bSwitchColors=FALSE,
+ bUpdateColors=FALSE;
+Uint1 oldSpacerSize;
+
+ if (!hWndDDV || !dumdp)
+ return(OM_MSG_RET_OK);
+
+ dmp = (DdvMainPtr) GetObjectExtra(hWndDDV);
+
+ if (!dmp)
+ return(OM_MSG_RET_OK);
+
+ if (!Visible(hWndDDV))
+ return(OM_MSG_RET_OK);
+
+ oldSpacerSize=dmp->ddo.SpacerSize;
+ dmp->ddo.SpacerSize=dumdp->SpacerSize;
+
+ /*rebuild the display, if needed*/
+ if ((dmp->ddo.DispDiscStyle!=dumdp->DispDiscStyle) ||
+ (oldSpacerSize!=dumdp->SpacerSize) ||
+ (dmp->ddo.DiscJustification!=dumdp->DiscJustification) ||
+ (dmp->ddo.ShowLeftTail!=dumdp->ShowLeftTail)||
+ (dmp->ddo.ShowRightTail!=dumdp->ShowRightTail)){
+
+ if((dmp->ddo.ShowLeftTail!=dumdp->ShowLeftTail)||
+ (dmp->ddo.ShowRightTail!=dumdp->ShowRightTail)||
+ (dmp->ddo.DispDiscStyle!=dumdp->DispDiscStyle)){
+ bUpdateColors=TRUE;
+ }
+ /*update the styles*/
+ dmp->ddo.DispDiscStyle=dumdp->DispDiscStyle;
+ dmp->ddo.DiscJustification=dumdp->DiscJustification;
+ dmp->ddo.ShowLeftTail=dumdp->ShowLeftTail;
+ dmp->ddo.ShowRightTail=dumdp->ShowRightTail;
+
+ /*delete the current display*/
+ if (dmp->MSA_d.pgp_l.TableHead)
+ DDV_DeleteDisplayList(&dmp->MSA_d.pgp_l);
+ if (dmp->MSA_d.pgp_l.RulerDescr)
+ ValNodeFreeData(dmp->MSA_d.pgp_l.RulerDescr);
+ if (dmp->MSA_d.pgp_l.entitiesTbl)
+ MemFree(dmp->MSA_d.pgp_l.entitiesTbl);
+
+ dmp->MSA_d.pgp_l.TableHead=NULL;
+ dmp->MSA_d.pgp_l.RulerDescr=NULL;
+ /*rebuild a new one*/
+ if (!DDV_CreateDisplayFromIndex(dmp->MSA_d.pgp_l.sap,
+ &(dmp->MSA_d.pgp_l),ParaG_Size,&(dmp->ddo)))
+ return(OM_MSG_RET_ERROR);
+
+ dmp->MSA_d.pgp_l.entitiesTbl=
+ DDV_BuildBspEntitiesTbl(dmp->MSA_d.pgp_l.TableHead,
+ dmp->MSA_d.pgp_l.nBsp);
+ if (!dmp->MSA_d.pgp_l.entitiesTbl)
+ return(OM_MSG_RET_ERROR);
+ /*build the Master Ruler descriptor*/
+/* dmp->MSA_d.pgp_l.RulerDescr=DDV_ComputeRuler(dmp->MSA_d.pgp_l.sap,&(dmp->ddo)); */
+ dmp->MSA_d.pgp_l.RulerDescr = DDE_ReMakeRuler(&(dmp->MSA_d.pgp_l), FALSE, 0);
+
+ /*init the colours*/
+ if(bUpdateColors){
+ if(dmp->MasterViewer != SAMVIEWCN3D ) {
+ /*delete old tables*/
+ DDV_ClearColor(dmp->Globals.colorp);
+ /*build new tables*/
+ if (!DDV_InitColour_When_Start(dmp->MSA_d.pgp_l.sap,
+ &(dmp->MSA_d.pgp_l),&(dmp->Globals.colorp),FALSE)){
+ dmp->ddo.bUseColors=FALSE;
+ }
+ }
+ }
+ bResetScrolls=TRUE;
+ bRebuildDisplay=TRUE;
+ }
+
+ /*set the ruler styles*/
+ if(dumdp->nSeq && dumdp->SeqList){
+ for(j=0;j<dumdp->nSeq;j++){
+ switch(dumdp->RulerStyle){
+ case SCALE_POS_TOP:
+ DDV_SetRulerAttribInPGP(dmp->MSA_d.pgp_l.TableHead[dumdp->SeqList[j]-1],
+ SCALE_POS_TOP);
+ break;
+ case SCALE_POS_NONE:
+ DDV_SetRulerAttribInPGP(dmp->MSA_d.pgp_l.TableHead[dumdp->SeqList[j]-1],
+ SCALE_POS_NONE);
+ break;
+ default:
+ DDV_SetRulerAttribInPGP(dmp->MSA_d.pgp_l.TableHead[dumdp->SeqList[j]-1],
+ SCALE_POS_NONE);
+ break;
+ }
+ }
+ bRebuildDisplay=TRUE;
+ }
+
+ /*colors*/
+ if(dmp->ddo.bUseColors!=dumdp->bUseColors){
+ dmp->ddo.bUseColors=dumdp->bUseColors;
+ bSwitchColors=TRUE;
+ }
+
+ /*redraw if needed*/
+ if (bRebuildDisplay){
+ DDV_SortPGPLineNum(dmp->MSA_d.pgp_l.TableHead,dmp->MSA_d.pgp_l.nBsp);
+ DDV_WhatSize(dmp);
+ DDV_Resize_DDV(hWndDDV,bResetScrolls); /* DDV_SetupWin(hWndDDV,bResetScrolls,NULL);*/
+ Update();
+ }
+ else if (bSwitchColors){
+ RecT rcP;
+ WindoW temport;
+
+ temport=SavePort(ParentWindow(hWndDDV));
+ Select(hWndDDV);
+
+ ObjectRect(hWndDDV,&rcP);
+ InvalRect(&rcP);
+ RestorePort(temport);
+ /*Update();*/
+ }
+
+
+ return(OM_MSG_RET_OK);
+}
+
+/*******************************************************************************
+
+ Function : DDV_MSG_FLUSH()
+
+ Purpose : kill the viewer in response to a OM_MSG_FLUSH message
+
+ Return value : OM_MSG_RET_OK if success
+
+*******************************************************************************/
+static Int2 DDV_MSG_FLUSH(OMMsgStructPtr ommsp)
+{
+DdvMainPtr dmp; /*DDV panel data*/
+OMUserDataPtr omudp;/*user data set when registering DDV panel*/
+/*ParaGPtr pgp;
+BioseqPtr bsp;
+Int4 i;
+Uint2 bsp_eID;*/
+
+
+ omudp = (OMUserDataPtr)(ommsp->omuserdata);
+ if (omudp == NULL) return(OM_MSG_RET_ERROR);
+
+ dmp=(DdvMainPtr)omudp->userdata.ptrvalue;
+ if (dmp == NULL) return(OM_MSG_RET_ERROR);
+
+ if (dmp->MSA_d.entityID==ommsp->entityID &&
+ ((dmp->MSA_d.itemID==ommsp->itemID && ommsp->itemtype==OBJ_SEQALIGN)
+ ||(ommsp->itemID == 0 && ommsp->itemtype==0))){
+ Remove(dmp->hParent);
+ DDV_CleanupDDVPdata_g(dmp);
+ /* for(i=0;i<dmp->MSA_d.pgp_l.nBsp;i++){
+ pgp=(ParaGPtr)(dmp->MSA_d.pgp_l.TableHead[i]->data.ptrvalue);
+ bsp=BioseqLockById(pgp->sip);
+ if (bsp != NULL){
+ bsp_eID=ObjMgrGetEntityIDForPointer((Pointer)bsp);
+ BioseqUnlock(bsp);
+ if (bsp_eID>0 && bsp_eID!=dmp->MSA_d.entityID){
+ ObjMgrFreeUserData(bsp_eID,dmp->procid,dmp->proctype,dmp->userkey);
+ }
+ }
+ }
+
+ ObjMgrFreeUserData(dmp->MSA_d.entityID,dmp->procid,dmp->proctype,dmp->userkey);*/
+ }
+ return(OM_MSG_RET_OK);
+}
+
+/*******************************************************************************
+
+ Function : DDV_SimpleUpdateAnswer()
+
+ Purpose : simple answer to an Update Msg; just redraw the window
+
+ Parameters : see Toolkit
+
+ Return value : see Toolkit
+
+*******************************************************************************/
+static void DDV_SimpleUpdateAnswer(OMMsgStructPtr ommsp)
+{
+RecT rcP;
+WindoW temport;
+DdvMainPtr dmp; /*DDV panel data*/
+OMUserDataPtr omudp;/*user data set when registering DDV panel*/
+
+ omudp = (OMUserDataPtr)(ommsp->omuserdata);
+ if (omudp == NULL) return;
+
+ dmp=(DdvMainPtr)omudp->userdata.ptrvalue;
+ if (dmp == NULL) return;
+
+ temport=SavePort(ParentWindow(dmp->hWndDDV));
+ Select(dmp->hWndDDV);
+
+ ObjectRect(dmp->hWndDDV,&rcP);
+ InvalRect(&rcP);
+ RestorePort(temport);
+}
+
+/*******************************************************************************
+
+ Function : DDV_UpdateRegMsgFunc()
+
+ Purpose : register a MsgCallback in response to an OM_MSG_UPDATE, after
+ SeqImport
+
+*******************************************************************************/
+static void DDV_UpdateRegMsgFunc(OMMsgStructPtr ommsp,Uint2 bsp_eID)
+{
+DdvMainPtr dmp; /*DDV panel data*/
+OMUserDataPtr omudp;/*user data set when registering DDV panel*/
+
+ omudp = (OMUserDataPtr)(ommsp->omuserdata);
+ if (omudp == NULL) return;
+
+ dmp=(DdvMainPtr)omudp->userdata.ptrvalue;
+ if (dmp == NULL) return;
+
+ DDV_RegisterMsgFuncOnBsp(bsp_eID,dmp);
+}
+
+/*******************************************************************************
+
+ Function : DDV_OM_MsgFunc()
+
+ Purpose : ObjMgr message loop of the DDV viewer/editor
+
+ Parameters : see Toolkit
+
+ Return value : see Toolkit
+
+*******************************************************************************/
+static Int2 LIBCALLBACK DDV_OM_MsgFunc (OMMsgStructPtr ommsp)
+{
+Int2 nRet=OM_MSG_RET_OK;
+
+ switch (ommsp->message)
+ {
+ case OM_MSG_DEL:
+ break;
+ case OM_MSG_CREATE:
+ break;
+ case OM_MSG_UPDATE:{
+ DDVUpdateMSGPtr dump;
+
+ dump = (DDVUpdateMSGPtr)(ommsp->procmsgdata);
+
+ /*generic UPDATE msg*/
+ if (!dump){
+ DDV_SimpleUpdateAnswer(ommsp);
+ break;
+ }
+
+ /*specific UPDATE msg*/
+ switch(dump->type){
+ case UPDATE_TYPE_LAYOUT:{
+ DDVUpdateLayoutDataPtr dumdp;
+
+ dumdp=(DDVUpdateLayoutDataPtr)dump->data;
+
+ if (!dumdp)
+ break;
+
+ nRet=DDV_MSG_UPDATE_Layout(dumdp->ddv_panel,dumdp);
+ break;
+ }
+ case UPDATE_TYPE_EDIT_DELBSP:
+ nRet=DDV_MSG_UPDATE_DelBSP(ommsp);
+ break;
+ case UPDATE_TYPE_VIEWMGR:
+ nRet=DDV_MSG_UPDATE_ViewMgr(ommsp);
+ break;
+ case UPDATE_TYPE_CARETPOS:
+ nRet=DDV_MSG_UPDATE_CaretPos(ommsp);
+ break;
+ case UPDATE_TYPE_NEWSEQ:
+ if (dump->data)
+ DDV_UpdateRegMsgFunc(ommsp,*((Uint2 *)dump->data));
+ break;
+ default :
+ DDV_SimpleUpdateAnswer(ommsp);
+ }
+
+ break;
+ }
+ case OM_MSG_SELECT:
+ nRet=DDV_MSG_SELECT(ommsp,TRUE);
+ break;
+ case OM_MSG_DESELECT:
+ nRet=DDV_MSG_SELECT(ommsp,FALSE);
+ break;
+ case OM_MSG_CACHED:
+ break;
+ case OM_MSG_UNCACHED:
+ break;
+ case OM_MSG_TO_CLIPBOARD:
+ break;
+ case OM_MSG_SETCOLOR:
+ break;
+ case OM_MSG_FLUSH:
+ DDV_MSG_FLUSH(ommsp);
+ break;
+ default:
+ break;
+ }
+
+ return (nRet);
+}
+
+/*******************************************************************************
+
+ Function : DDV_RegisterMsgFuncOnBsp()
+
+ Purpose : register a MsgFunc for a bsp.
+
+*******************************************************************************/
+static void DDV_RegisterMsgFuncOnBsp(Uint2 bsp_eID,DdvMainPtr dmp)
+{
+OMUserDataPtr omudp;
+
+ if (bsp_eID==0 || dmp==NULL) return;
+
+ omudp = ObjMgrAddUserData (bsp_eID,dmp->procid,dmp->proctype,dmp->userkey);
+ if (omudp != NULL) {
+ omudp->messagefunc = DDV_OM_MsgFunc;
+ omudp->userdata.ptrvalue = (Pointer)dmp;
+ }
+}
+
+/*******************************************************************************
+
+ Function : DDV_RegMsgFuncForBsp()
+
+ Purpose : given the display data structure (nBsp & TableHead), register a
+ MsgFunc callback for each bioseq of a SeqAlign.
+
+ Parameters : TableHead; entry point of the display data structure (ParaG list)
+ nBsp; number of sequences in the SeqAlign
+ master_eID; entityID of the object containing the SeqAlign
+ procID; identifier of the viewer (usually DDV)
+ userkey; userkey of the viewer (usually DDV)
+
+ Return value : -
+
+*******************************************************************************/
+static void DDV_RegMsgFuncForBsp(ValNodePtr PNTR TableHead,DdvMainPtr dmp,Int4 nBsp,
+ Uint2 master_eID, Uint2 procID, Uint2 procType, Uint2 userkey)
+{
+OMUserDataPtr omudp,omudp_tmp;
+ParaGPtr pgp;
+BioseqPtr bsp;
+Int4 i;
+Boolean bFound;
+Uint2 bsp_eID;
+
+ if (!TableHead || nBsp==0 || master_eID==0 || procID==0
+ || procType==0 ||userkey==0) return;
+
+ for(i=0;i<nBsp;i++){
+ pgp=(ParaGPtr)(dmp->MSA_d.pgp_l.TableHead[i]->data.ptrvalue);
+ bsp=BioseqLockById(pgp->sip);
+ if (bsp){
+ bsp_eID=ObjMgrGetEntityIDForPointer((Pointer)bsp);
+ if (bsp_eID>0 && bsp_eID!=master_eID){
+ omudp=ObjMgrGetUserData(bsp_eID,procID,procType,userkey);
+ if (omudp){
+ /*scan the user data associated with that bioseq and try to
+ find if a Msg Func is already attached for DDV*/
+ omudp_tmp=omudp;
+ bFound=FALSE;
+ while(omudp_tmp){
+ if (omudp_tmp->procid==procID &&
+ omudp_tmp->proctype==procType &&
+ omudp_tmp->userkey==userkey &&
+ omudp_tmp->messagefunc==DDV_OM_MsgFunc){
+
+ bFound=TRUE;
+ break;
+ }
+ omudp_tmp=omudp_tmp->next;
+ }
+ }
+ else{/*add the Msg Callaback and DDV main data block to the bioseq*/
+ bFound=FALSE;
+ }
+ if (bFound==FALSE){
+ DDV_RegisterMsgFuncOnBsp(bsp_eID,dmp);
+ }
+ }
+ BioseqUnlock(bsp);
+ }
+ }
+}
+
+static void DDV_Convert(ButtoN g) {
+/*----------------------------------------------------------------------------
+* just need to quit the pop-up window
+*---------------------------------------------------------------------------*/
+ WindoW hDialog;
+
+ hDialog = (WindoW)ParentWindow(g);
+ if (!hDialog) return;
+ Remove(hDialog);
+ return;
+}
+
+
+static void DDV_NoConvert(ButtoN g) {
+/*----------------------------------------------------------------------------
+* quit the pop-up window and close the file
+*---------------------------------------------------------------------------*/
+ WindoW hDialog;
+ DdvMainPtr dmp;
+
+ hDialog = (WindoW)ParentWindow(g);
+ if (!hDialog) return;
+ Remove(hDialog);
+
+ dmp = (DdvMainPtr) GetObjectExtra(hDialog);
+ DDV_FileCloseIt(dmp->hParent);
+ return;
+}
+
+
+/*******************************************************************************
+
+ Function : DDV_StartPanel_Slave()
+
+ Purpose : start DDV main window as a slave module: init 'dmp' data structure
+ (if needed), create the DDV panel, prepare a display from 'sap'.
+
+ Parameters : sap; pointer to a SeqAlign
+ input_entityID,input_itemID; identity of the SeqAlign
+ dmp; main data of DDV. May be NULL
+ hParent; parent window for DDV. Must not be NULL
+ bSetAppProp; if TRUE, use SetAppProperty().
+ bInitGraph; if TRUE, initialize the graphical data for DDV
+ bEditor; if TRUE, start the editor mode. Otherwise, a simple
+ viewer will ba started
+ rcPp; the RecT that defines the size of the panel. can be NULL.
+
+ Note : This function assumes that DDV will be placed inside an existing
+ parent window provided by the host application.
+
+ Return value : handle to the DDV panel
+
+*******************************************************************************/
+static Boolean DDV_StartPanel_Slave(DdvMainPtr dmp, SeqAlignPtr sap,
+ Uint2* pInput_entityID, Uint2* pInput_itemID, Boolean bEditor)
+{
+DDV_ColorGlobal * dcgp;
+MsaParaGPopListPtr mpplp;
+BaR hsb;
+Int4 HPos, Col, IsEditable;
+DdvMainWinPtr mWin_d;
+Boolean* pNoGaps;
+Boolean NoGaps;
+char Str[1024];
+MsgAnswer Answer;
+Boolean Attached = FALSE;
+
+ WatchCursor();
+
+ if (!dmp->bEditor) {
+ mWin_d = (DdvMainWinPtr) GetObjectExtra(dmp->hParent);
+ Enable(mWin_d->MainMenu.LaunchEditor);
+ IsEditable = AlnMgrIsEditable(sap);
+ if (!IsEditable) {
+ if (AlnMgrIsIBMable(sap)) {
+ Str[0] = 0;
+ StringCat(Str, "This file is a multiple pairwise alignment.\n");
+ StringCat(Str, "To edit this file, it needs to be converted\n");
+ StringCat(Str, "to a true multiple alignment.\n");
+ StringCat(Str, "Should it be converted?");
+ mWin_d->Show_logo=TRUE;
+ Answer = Message(MSG_YN, "%s", Str);
+ mWin_d->Show_logo=FALSE;
+ if (Answer == ANS_YES) {
+ if (ViewMgr_Attach(sap, TRUE, TRUE, *pInput_entityID, *pInput_itemID) < 1)
+ return (FALSE);
+ Attached = TRUE;
+ }
+ else {
+ Disable(mWin_d->MainMenu.LaunchEditor);
+ }
+ }
+ }
+ else if (IsEditable == AM_EDITGAPS) {
+ pNoGaps = (Boolean*) GetAppProperty("dde_nogaps");
+ if (pNoGaps == NULL) NoGaps = TRUE;
+ else NoGaps = *pNoGaps;
+ if (NoGaps) {
+ Str[0] = 0;
+ StringCat(Str, "This alignment can't be edited\n");
+ StringCat(Str, "because it has aligned gaps\n");
+ StringCat(Str, "and DDV is running in NoGaps mode");
+ Message(MSG_OK, "%s", Str);
+ Disable(mWin_d->MainMenu.LaunchEditor);
+ }
+ }
+ }
+
+ if (!Attached) {
+ if (ViewMgr_Attach(sap, FALSE, FALSE, *pInput_entityID, *pInput_itemID) < 1)
+ return (FALSE);
+ }
+
+ /*if we have a NULL SeqAlign, switch the display style to show
+ the sequences, not a spacer*/
+ if (AlnMgrIsSAPNULL(sap)){
+ dmp->ddo.DispDiscStyle=MSA_TXT_STYLE_2;
+ dmp->ddo.SpacerSize=SPACER_TXT_BLANK;
+ dmp->ddo.DiscJustification=DISP_JUST_LEFT;
+ }
+
+ if (bEditor) {
+ dmp->dsp = (DDE_StackPtr) GetAppProperty("ddeinterndata");
+ if (dmp->dsp == NULL) {return(FALSE);}
+ mpplp = dmp->dsp->pEdit->pPopList;
+ /* copy paragraphs from DDE_Stack into the ones that are displayed */
+ MemCopy(&(dmp->MSA_d.pgp_l),mpplp,sizeof(MsaParaGPopList));
+ }
+ else {
+ if (!DDV_CreateDisplayFromIndex(sap,&(dmp->MSA_d.pgp_l),ParaG_Size,
+ &(dmp->ddo))) return(FALSE);
+ dmp->MSA_d.pgp_l.entitiesTbl=
+ DDV_BuildBspEntitiesTbl(dmp->MSA_d.pgp_l.TableHead,
+ dmp->MSA_d.pgp_l.nBsp);
+ if (!dmp->MSA_d.pgp_l.entitiesTbl) return(FALSE);
+ /*build the Master Ruler descriptor*/
+/* dmp->MSA_d.pgp_l.RulerDescr=DDV_ComputeRuler(sap,&(dmp->ddo)); */
+ dmp->MSA_d.pgp_l.RulerDescr = DDE_ReMakeRuler(&(dmp->MSA_d.pgp_l), FALSE, 0);
+ }
+
+ dmp->MSA_d.entityID=*pInput_entityID;
+ dmp->MSA_d.itemID=*pInput_itemID;
+
+/*
+#if defined(_DEBUG_DDE)
+{
+ MsaParaGPopListPtr mpplp;
+ mpplp = DDV_CreateDataForEditor(&(dmp->MSA_d.pgp_l), 0, dmp->MSA_d.pgp_l.LengthAli-1);
+ MemCopy(&(dmp->MSA_d.pgp_l),mpplp,sizeof(MsaParaGPopList));
+ dmp->dsp = DDE_NewStack(mpplp);
+}
+#endif
+*/
+
+ /*get the color stuff from the sap object. Usually I can do that
+ when DDV is loaded from Cn3D*/
+ dcgp=DDV_GetColorGlobal((Pointer) sap);
+
+ /*init the colours*/
+ if (dcgp==NULL){
+ if (!DDV_InitColour_When_Start(dmp->MSA_d.pgp_l.sap,&(dmp->MSA_d.pgp_l),
+ &(dmp->Globals.colorp),FALSE)){
+ dmp->ddo.bUseColors=FALSE;
+ }
+ }
+ else dmp->Globals.colorp = dcgp;
+
+ /*set the initial position of the caret (edit mode)*/
+ dmp->dci.old_row=1;
+ dmp->dci.new_row=1;
+ dmp->dci.old_col=0;
+ dmp->dci.new_col=0;
+
+
+ /*relation between align size and display type; compute nTotLines for example*/
+ DDV_WhatSize(dmp);
+
+ ArrowCursor();
+ DDV_Resize_DDV(dmp->hWndDDV,TRUE); /*DDV_SetupWin (dmp->hWndDDV,TRUE,NULL); */
+ /*Update();*/
+
+ CaptureSlateFocus((SlatE)dmp->hWndDDV);
+
+ /* scroll display horizontally so aligned region is shown at position 5 */
+ if (DDE_GetNumBlocks2(&(dmp->MSA_d.pgp_l))) {
+ hsb = GetSlateHScrollBar((SlatE) dmp->hWndDDV);
+ HPos = GetBarValue(hsb);
+ if (bEditor) {
+ Col = DDE_GetAlignStart(dmp->dsp->pEdit, 0);
+ }
+ else {
+ Col = 0;
+ if (dmp->ddo.ShowLeftTail) {
+ Col = AlnMgrGetMaxTailLength(sap, LEFT_TAIL);
+ }
+ }
+ SetValue(hsb, HPos+Col-5);
+ }
+
+ /* only enable left/right/center justify for an unaligned region in the editor */
+ if (bEditor) {
+ mWin_d = (DdvMainWinPtr) GetObjectExtra(dmp->hParent);
+ if (dmp->dsp->IsUnAligned) {
+ Enable(mWin_d->MainMenu.Justify);
+ }
+ else {
+ Disable(mWin_d->MainMenu.Justify);
+ }
+ }
+
+ return(TRUE);
+}
+
+
+/*******************************************************************************
+
+ Function : DDV_ObjRegMasterDDV()
+
+ Purpose : call by ObjMgr to start DDV panel
+
+ Parameters : see Toolkit
+
+ Note : this callback is only used by the standalone DDV. Never use this
+ callback for other purpose.
+
+ Return value : see Toolkit
+
+*******************************************************************************/
+static Int2 DDV_ObjRegMasterDDV (Pointer data,Boolean bEditor)
+{
+OMProcControlPtr ompcp;
+SeqAlignPtr sap=NULL;
+OMUserDataPtr omudp;
+DdvMainPtr dmp;
+
+ /*retrieve data*/
+ ompcp = (OMProcControlPtr) data;
+
+ if (ompcp == NULL || ompcp->proc == NULL) {
+ ErrPostEx (SEV_ERROR, 0, 0, "Data NULL [1]");
+ return OM_MSG_RET_ERROR;
+ }
+ /*only accept a SeqALign*/
+ switch (ompcp->input_itemtype) {
+ case OBJ_SEQALIGN :
+ sap = (SeqAlignPtr) ompcp->input_data;
+ break;
+ default :
+ return OM_MSG_RET_ERROR;
+ }
+ /*oups... nothing to deal with*/
+ if (sap == NULL) {
+ ErrPostEx (SEV_ERROR, 0, 0, "Data NULL [2]");
+ return OM_MSG_RET_ERROR;
+ }
+
+ dmp = (DdvMainPtr) GetAppProperty("ddvinterndata");
+ if (!dmp) goto error;
+ if (!DDV_StartPanel_Slave(dmp, sap, &ompcp->input_entityID,
+ &ompcp->input_itemID, bEditor)) goto error;
+
+
+ /*attach a Msg Func on the current seqalign*/
+ dmp->userkey=OMGetNextUserKey();
+ dmp->procid=ompcp->proc->procid;
+ dmp->proctype=ompcp->proc->proctype;
+ omudp = ObjMgrAddUserData (ompcp->input_entityID, ompcp->proc->procid,
+ (bEditor==TRUE ? OMPROC_EDIT : OMPROC_VIEW),dmp->userkey);
+ if (omudp == NULL)
+ goto error;
+ omudp->messagefunc = DDV_OM_MsgFunc;
+ omudp->userdata.ptrvalue = (Pointer)dmp;
+
+ /*attach a Msg Func on each Bioseq of the current seqalign*/
+ DDV_RegMsgFuncForBsp(dmp->MSA_d.pgp_l.TableHead,dmp,dmp->MSA_d.pgp_l.nBsp,
+ ompcp->input_entityID, dmp->procid,dmp->proctype,dmp->userkey);
+
+ DDV_EnableGotoTBItems(dmp->hParent,TRUE);
+ return(OM_MSG_RET_DONE);
+
+error:
+ /*show the logo window*/
+ /*mWin_d->Show_logo=TRUE;*/
+ Update ();
+ ArrowCursor();
+ return(OM_MSG_RET_ERROR);
+}
+
+/*******************************************************************************
+
+ Function : DDV_ObjRegMasterEditDDV()
+
+ Purpose : call by ObjMgr to start DDV as a standalone editor
+
+ Parameters : see Toolkit
+
+ Return value : see Toolkit
+
+*******************************************************************************/
+extern Int2 LIBCALLBACK DDV_ObjRegMasterEditDDV (Pointer data)
+{
+ return(DDV_ObjRegMasterDDV(data,TRUE));
+}
+
+/*******************************************************************************
+
+ Function : DDV_ObjRegMasterViewDDV()
+
+ Purpose : call by ObjMgr to start DDV as a standalone viewer
+
+ Parameters : see Toolkit
+
+ Return value : see Toolkit
+
+*******************************************************************************/
+extern Int2 LIBCALLBACK DDV_ObjRegMasterViewDDV (Pointer data)
+{
+ return(DDV_ObjRegMasterDDV(data,FALSE));
+}
+
+
+/*******************************************************************************
+
+ Function : DDV_ObjRegSlaveDDV()
+
+ Purpose : call by DDV_ObjRegSlaveEditDDV() & DDV_ObjRegSlaveViewDDV(), below
+
+*******************************************************************************/
+static Int2 DDV_ObjRegSlaveDDV(Pointer data,Boolean bEditor)
+{
+OMProcControlPtr ompcp;
+SeqAlignPtr sap=NULL;
+WindoW hParent=NULL;
+DdvMainWinPtr mWin_d;
+OMUserDataPtr omudp = NULL;
+DdvMainPtr dmp;
+SAM_ViewGlobal *vgp;
+
+
+ /*retrieve data*/
+ ompcp = (OMProcControlPtr) data;
+ if (ompcp == NULL || ompcp->proc == NULL) {
+ ErrPostEx (SEV_ERROR, 0, 0, "Data NULL [1]");
+ return OM_MSG_RET_ERROR;
+ }
+
+ /*only accept a SeqALign*/
+ switch (ompcp->input_itemtype) {
+ case OBJ_SEQALIGN :
+ sap = (SeqAlignPtr) ompcp->input_data;
+ break;
+ default :
+ return OM_MSG_RET_ERROR;
+ }
+
+ /*oups... nothing to deal with*/
+ if (sap == NULL) {
+ ErrPostEx (SEV_ERROR, 0, 0, "Data NULL [2]");
+ return OM_MSG_RET_ERROR;
+ }
+
+ /*start the slave module*/
+ /* get parameters from launching program */
+ vgp = GetAppProperty(SAM_ViewString);
+ if(vgp == NULL) hParent=DDV_StartMainWin_Slave(NULL,bEditor);
+ else hParent=DDV_StartMainWin_Slave(vgp,bEditor);
+
+ if (hParent){
+ RealizeWindow(hParent);
+ Show(hParent);
+ mWin_d=(DdvMainWinPtr)GetObjectExtra(hParent);
+ dmp = (DdvMainPtr) GetObjectExtra(mWin_d->hWndDDV);
+ if(vgp != NULL) dmp->MasterViewer = vgp->MasterViewer;
+
+ if(dmp->MasterViewer == SAMVIEWCN3D) {
+ mWin_d->UseNetwork = TRUE;
+ mWin_d->NetStartProc = vgp->NetStartProc;
+ }
+
+ if (!DDV_StartPanel_Slave(dmp, sap, &ompcp->input_entityID,
+ &ompcp->input_itemID, bEditor))
+ goto error;
+
+ /*when the user will close DDV, DDV won't delete any data excepts
+ its internal data structure*/
+ dmp->dod.choice=DDV_OPENTYPE_NOTRESP;
+
+ /*attach a Msg Func on the current seqalign*/
+ dmp->userkey=OMGetNextUserKey();
+ dmp->procid=ompcp->proc->procid;
+ dmp->proctype=ompcp->proc->proctype;
+ omudp = ObjMgrAddUserData (ompcp->input_entityID, ompcp->proc->procid,
+ (bEditor==TRUE ? OMPROC_EDIT : OMPROC_VIEW),dmp->userkey);
+ if (omudp == NULL)
+ goto error;
+ omudp->messagefunc = DDV_OM_MsgFunc;
+ omudp->userdata.ptrvalue = (Pointer)dmp;
+ /*attach a Msg Func on each Bioseq of the current seqalign*/
+ DDV_RegMsgFuncForBsp(dmp->MSA_d.pgp_l.TableHead,dmp,dmp->MSA_d.pgp_l.nBsp,
+ ompcp->input_entityID, dmp->procid,dmp->proctype,dmp->userkey);
+ DDV_EnableGotoTBItems(hParent,TRUE);
+ }
+ else {
+ goto error;
+ }
+
+ return(OM_MSG_RET_DONE);
+
+error:
+ if (hParent) Remove(hParent);
+ return(OM_MSG_RET_ERROR);
+}
+
+/*******************************************************************************
+
+ Function : DDV_ObjRegSlaveEditDDV()
+
+ Purpose : call by ObjMgr to start DDV as a slave, editor mode on a SeqAlign
+
+ Parameters : see Toolkit
+
+ Return value : see Toolkit
+
+*******************************************************************************/
+extern Int2 LIBCALLBACK DDV_ObjRegSlaveEditDDV (Pointer data)
+{
+ return(DDV_ObjRegSlaveDDV(data,TRUE));
+}
+
+/*******************************************************************************
+
+ Function : DDV_ObjRegSlaveViewDDV()
+
+ Purpose : call by ObjMgr to start DDV as a slave, editor mode on a SeqAlign
+
+ Parameters : see Toolkit
+
+ Return value : see Toolkit
+
+*******************************************************************************/
+extern Int2 LIBCALLBACK DDV_ObjRegSlaveViewDDV (Pointer data)
+{
+ return(DDV_ObjRegSlaveDDV(data,FALSE));
+}
+
+/*******************************************************************************
+
+ Function : DDV_GetAndCheckSeqAlign()
+
+ Purpose : given a file OR a GI OR a SeqEntry , retrieve SeqAlign(s)
+
+ Parameters : fp; a handle of an open file
+ gi; a GI numger
+ sep2; a SeqEntry
+ fetchSepProc; fetch procedure of the user (only if GI!=0)
+
+ Return value : a list of nodes. For each node, data.intvalue is an entityID
+ of a SeqAlign
+
+*******************************************************************************/
+extern ValNodePtr DDV_GetAndCheckSeqAlign(FILE *fp,Int4 gi,SeqEntryPtr sep2,
+ UdvFetchSeqEntryProc fetchSepProc,DdvOpenDataPtr dodp,Uint2Ptr entityID)
+{
+SeqEntryPtr sep=NULL;
+ValNodePtr head = NULL,vnp_ali=NULL;
+Pointer dataptr=NULL;
+Uint2 datatype=0;
+Uint2 nRet=DVV_MSG_M_OK;
+
+ *entityID=0;
+ if (fp!=NULL){/*open a file*/
+ /*Read the file (it can contain several objects)*/
+ while ((dataptr = ReadAsnFastaOrFlatFile (fp, &datatype, NULL, FALSE,
+ FALSE, TRUE, FALSE)) != NULL) {
+ ValNodeAddPointer (&head, datatype, dataptr);
+ }
+ /*scan the first node of the head list*/
+ datatype = head->choice;
+ dataptr = head->data.ptrvalue;
+ *entityID=ObjMgrRegister(datatype,dataptr);
+ AssignIDsInEntity (*entityID,0,NULL);
+ switch(datatype){
+ case OBJ_SEQENTRY:
+ case OBJ_SEQALIGN:
+ case OBJ_SEQANNOT:
+ case OBJ_BIOSEQ:
+ case OBJ_BIOSEQSET:
+ DDV_GetSeqAlign(dataptr,datatype,&vnp_ali);
+ break;
+ default:
+ break;
+ }
+ if (dodp){
+ dodp->choice=DDV_OPENTYPE_FILE;
+ dodp->vnp=head;
+ }
+ } else if (gi!=0){/*retrieve a Network Entry given a GI*/
+ if (fetchSepProc) {/*fetch the SeqEntry*/
+ sep=fetchSepProc(gi, 0);
+ if (!sep) {
+ nRet=DVV_MSG_O_E_READGI;
+ goto error;
+ }
+ *entityID=ObjMgrGetEntityIDForPointer((Pointer)sep);
+ AssignIDsInEntity (*entityID,0,NULL);
+ SeqEntryExplore(sep,(Pointer)&vnp_ali,DDV_SearchAli);
+ if (dodp){
+ dodp->choice=DDV_OPENTYPE_GI;
+ dodp->sep=sep;
+ }
+ } else {
+ nRet=DVV_MSG_O_E_NOFETCHFUNC;
+ goto error;
+ }
+ } else if (sep2!=NULL){/*analyse a SeqEntry*/
+ *entityID=ObjMgrGetEntityIDForPointer((Pointer)sep2);
+ AssignIDsInEntity (*entityID,0,NULL);
+ SeqEntryExplore(sep2,(Pointer)&vnp_ali,DDV_SearchAli);
+ if (dodp){
+ dodp->choice=DDV_OPENTYPE_SEP;
+ dodp->sep=sep2;
+ }
+ } else {
+ nRet=DVV_MSG_O_E_NOTHINGTODO;
+ goto error;
+ }
+
+ /*register for ObjMgr*/
+ if (!vnp_ali) {
+ nRet=DVV_MSG_O_E_BADTYPE;
+ goto error;
+ }
+
+
+ return(vnp_ali);
+
+error:
+ /*to add : Msg Handler with nRet*/
+ return(NULL);
+}
+
+/*******************************************************************************
+
+ Function : DDV_FOpenTextProc()
+
+ Purpose : manage File name edit control of the FileOpen dialog box
+
+ Parameters : t; edit control
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_FOpenTextProc(TexT t)
+{
+Char szFName[PATH_MAX]={""};
+WindoW hOpenDlg;
+DlgFileOpenDataPtr dfodp;
+
+ hOpenDlg=(WindoW)ParentWindow(t);
+
+ if (!hOpenDlg) return;
+
+ dfodp = (DlgFileOpenDataPtr) GetObjectExtra (hOpenDlg);
+
+ if (dfodp==NULL) return;
+
+ GetTitle(t, szFName, sizeof(szFName)-1);
+
+ if (StringLen(szFName) == 0)
+ Disable(dfodp->Ok);
+ else Enable(dfodp->Ok);
+
+ return;
+}
+
+/*******************************************************************************
+
+ Function : DDV_FOpenBrowseProc()
+
+ Purpose : manage browse button of the FileOpen dialog box
+
+ Parameters : g; button
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_FOpenBrowseProc(ButtoN g)
+{
+DlgFileOpenDataPtr dfodp;
+WindoW hOpenDlg;
+Char path[PATH_MAX]={""};
+
+ hOpenDlg=(WindoW)ParentWindow(g);
+
+ if (!hOpenDlg) return;
+
+ dfodp = (DlgFileOpenDataPtr) GetObjectExtra (hOpenDlg);
+
+ if (dfodp==NULL) return;
+ if (!dfodp->FNameEditCtrl) return;
+
+ if (GetInputFileName (path, sizeof(path), NULL, NULL)){
+ SetTitle(dfodp->FNameEditCtrl, path);
+ DDV_FOpenTextProc(dfodp->FNameEditCtrl);
+ }
+
+ return;
+}
+
+/*******************************************************************************
+
+ Function : DDV_FOpenCancelProc()
+
+ Purpose : manage cancel button of the FileOpen dialog box
+
+ Parameters : g; button
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_FOpenCancelProc(ButtoN g)
+{
+WindoW hOpenDlg;
+DlgFileOpenDataPtr dfodp;
+DdvMainWinPtr mWin_d;
+
+ hOpenDlg=(WindoW)ParentWindow(g);
+
+ if (!hOpenDlg) return;
+ dfodp = (DlgFileOpenDataPtr) GetObjectExtra (hOpenDlg);
+
+ if (dfodp){
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (dfodp->parent);
+ if (mWin_d) Enable(mWin_d->MainMenu.FileOpen);
+ }
+
+ Remove(hOpenDlg);
+}
+
+/*******************************************************************************
+
+ Function : DDV_FOpenAcceptProc()
+
+ Purpose : manage ok button of the FileOpen dialog box
+
+ Parameters : g; button
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_FOpenAcceptProc(ButtoN g)
+{
+WindoW hOpenDlg;
+DlgFileOpenDataPtr dfodp;
+DdvMainPtr dmp;
+DdvMainWinPtr mWin_d;
+Char szFName[PATH_MAX]={""};
+Boolean isBinary;
+FILE *fp;
+ValNodePtr vnp_ali=NULL;
+Uint2 nRet=DVV_MSG_M_OK,The_entityID;
+Int2 procval;
+
+ hOpenDlg=(WindoW)ParentWindow(g);
+
+ if (!hOpenDlg) return;
+ dfodp = (DlgFileOpenDataPtr) GetObjectExtra (hOpenDlg);
+
+ if (dfodp){
+
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (dfodp->parent);
+ if (mWin_d!=NULL){
+ /*try to connect Entrez; if failure, still ok : the user can
+ use DDV with a local file. Otherwise he/she will be in trouble ;-)*/
+ if (mWin_d->AutonomeViewer && mWin_d->NetStartProc){
+ mWin_d->NetStartProc(mWin_d->UseNetwork);
+ }
+
+ Enable(mWin_d->MainMenu.FileOpen);
+ /*file name*/
+ GetTitle(dfodp->FNameEditCtrl, szFName, sizeof(szFName));
+
+ /*file reading mode*/
+ if (GetValue(dfodp->ReadMode)==2) isBinary=TRUE;
+ else isBinary=FALSE;
+
+ Remove(hOpenDlg);
+
+ /* open the i/o files in the correct mode */
+ if ((fp = FileOpen (szFName, isBinary?"rb":"r")) == NULL){
+ nRet=DVV_MSG_O_E_OPENFILEFAIL;
+ goto error;
+ }
+ /*restrieve a list of registered seqalign(s)*/
+ WatchCursor();
+ /*delete old data, if needed*/
+ dmp=(DdvMainPtr)GetObjectExtra(mWin_d->hWndDDV);
+ DDV_CleanupDDVPdata_g(dmp);
+ DDV_CloseData(mWin_d,FALSE);
+
+ vnp_ali=DDV_GetAndCheckSeqAlign(fp,0,NULL,mWin_d->fetchSepProc,&(dmp->dod),
+ &The_entityID);
+ ArrowCursor();
+ if (vnp_ali && The_entityID!=0){
+ Uint2 entityID,itemID;
+ SeqAlignPtr sap;
+
+ /*get the first SeqAlign in the list and load the viewer panel*/
+ dmp->vnp_ali=vnp_ali;
+
+ if(mWin_d->Show_logo){
+ mWin_d->Show_logo=FALSE;
+ }
+ sap=(SeqAlignPtr)vnp_ali->data.ptrvalue;
+ entityID=sap->idx.entityID;
+ itemID=sap->idx.itemID;
+ SetAppProperty("ddvinterndata",(void *)dmp);
+ procval=GatherProcLaunch ((dmp->bEditor==TRUE? OMPROC_EDIT : OMPROC_VIEW), FALSE,
+ entityID, itemID, OBJ_SEQALIGN, 0, 0, OBJ_SEQALIGN, 0);
+ if ((procval = OM_MSG_RET_ERROR))
+ mWin_d->Show_logo=TRUE;
+ RemoveAppProperty("ddvinterndata");
+ }
+ FileClose(fp);
+ }
+ }
+
+error:
+ return;
+}
+
+/*******************************************************************************
+
+ Function : DDV_OpenFile()
+
+ Purpose : callback of the File|Open command
+
+ Parameters : i; command item
+
+ Return value : none
+
+*******************************************************************************/
+extern void DDV_OpenFile(IteM i)
+{
+DlgFileOpenDataPtr dfodp;
+DdvMainWinPtr mWin_d;
+WindoW hWinMain,hOpenDlg;
+GrouP g,g4;
+ButtoN b1;
+TexT t1;
+
+ hWinMain=(WindoW)ParentWindow(i);
+
+ if (!hWinMain) return;
+
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (hWinMain);
+
+ if (mWin_d==NULL) return;
+
+ dfodp=(DlgFileOpenDataPtr)MemNew(sizeof(DlgFileOpenData));
+ if (!dfodp) return;
+ MemSet(dfodp,0,sizeof(DlgFileOpenData));
+
+ hOpenDlg = MovableModalWindow(-30, -20, -10, -10,
+ "DDV - Open a local file", NULL);
+ g = NormalGroup(hOpenDlg, 2, 1, "File name:", systemFont, NULL);
+ SetGroupMargins(g, 10, 10);
+ SetGroupSpacing(g, 10, 20);
+ t1 = DialogText(g,"",25, DDV_FOpenTextProc);
+ PushButton(g, " browse...", DDV_FOpenBrowseProc);
+
+ g = HiddenGroup(hOpenDlg, 3, 1, NULL);
+ SetGroupMargins(g, 10, 10);
+ SetGroupSpacing(g, 30, 30);
+
+ g4 = NormalGroup(g, 2, 1, "File type", systemFont, NULL);
+ SetGroupMargins(g4, 10, 10);
+ RadioButton(g4, "Ascii");
+ RadioButton(g4, "Binary");
+ SetValue(g4, 1);
+
+ b1 = DefaultButton(g, "OK", DDV_FOpenAcceptProc);
+ PushButton(g, "Cancel", DDV_FOpenCancelProc);
+
+ Disable(b1);
+
+ dfodp->parent=hWinMain;
+ dfodp->FNameEditCtrl=t1;
+ dfodp->Ok=b1;
+ dfodp->ReadMode=g4;
+
+ SetObjectExtra (hOpenDlg, (Pointer) dfodp, StdCleanupExtraProc);
+
+ Select(hOpenDlg);
+ Show(hOpenDlg);
+
+ /*allow only one FOpen dlg at a time*/
+ /*UDV_set_PullMenus(&vmp->MainMenu,FALSE);*/
+}
+
+/*******************************************************************************
+
+ Function : DDV_NetOpen_cancelProc()
+
+ Purpose : manage ok button of the Network open dialog box
+
+ Parameters : g; button
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_NetOpen_cancelProc(ButtoN g)
+{
+WindoW hOpenDlg;
+DDVNetOpenPtr dnop;
+
+ hOpenDlg=(WindoW)ParentWindow(g);
+
+ if (!hOpenDlg) return;
+
+ dnop = (DDVNetOpenPtr) GetObjectExtra (hOpenDlg);
+
+ if (dnop==NULL) return;
+
+ Remove(hOpenDlg);
+}
+
+/*******************************************************************************
+
+ Function : DDV_IsInt()
+
+ Purpose : test if an entry access code is a GI number, i.e. an Int
+
+ Parameters : t; edit control
+
+ Return value : none
+
+*******************************************************************************/
+static Boolean DDV_IsInt(CharPtr szAccess)
+{
+Int2 i=0;
+
+ while(szAccess[i]){
+ if (!IS_DIGIT(szAccess[i])){
+ Message (MSG_OK, "Not a GI number.");
+ return(FALSE);
+ }
+ i++;
+ }
+ return(TRUE);
+}
+
+/*******************************************************************************
+
+ Function : DDV_NetOpen_okProc()
+
+ Purpose : manage ok button of the Network open dialog box
+
+ Parameters : g; button
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_NetOpen_okProc(ButtoN g)
+{
+WindoW hOpenDlg;
+DDVNetOpenPtr dnop;
+Char szAccess[50]={""};
+Int2 AccessType,procval;
+Int4 uid=0;
+DdvMainWinPtr mWin_d;
+ValNodePtr vnp_ali;
+MonitorPtr mon;
+DdvMainPtr dmp;
+Uint2 The_entityID;
+
+ hOpenDlg=(WindoW)ParentWindow(g);
+
+ if (!hOpenDlg) return;
+
+ dnop = (DDVNetOpenPtr) GetObjectExtra (hOpenDlg);
+
+ if (dnop==NULL) return;
+
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (dnop->hWndMain);
+ if (mWin_d==NULL) return;
+
+ dmp=(DdvMainPtr)GetObjectExtra(mWin_d->hWndDDV);
+
+ Hide(hOpenDlg);
+
+ /*retrieve a Gi*/
+ GetTitle(dnop->Entry, szAccess, sizeof(szAccess));
+
+ if (StringHasNoText (szAccess)) {
+ Message (MSG_OK, "Please enter a GI number");
+ Show (hOpenDlg);
+ Select (hOpenDlg);
+ Select (dnop->Entry);
+ return;
+ }
+
+ AccessType=GetValue(dnop->AccessType);
+ if (!StrToLong(szAccess,&uid))
+ uid=0;
+ /*Connect ID1 with a valid UID*/
+ if (uid==0){
+ ArrowCursor();
+ Message (MSG_OK, "Unable to find your record in the database.");
+ Show (hOpenDlg);
+ Select (hOpenDlg);
+ Select (dnop->Entry);
+ return;
+ }
+ else{
+ /*delete old data, if needed*/
+ DDV_CleanupDDVPdata_g(dmp);
+ DDV_CloseData(mWin_d,FALSE);
+
+ WatchCursor();
+
+ mon = MonitorStrNewEx (szAppName, 30, FALSE);
+ MonitorStrValue (mon, "Retrieving your record...");
+ Update ();
+
+ vnp_ali=DDV_GetAndCheckSeqAlign(NULL,uid,NULL,mWin_d->fetchSepProc,
+ &(dmp->dod),&The_entityID);
+
+ ArrowCursor();
+
+ MonitorFree (mon);
+
+ if (vnp_ali && The_entityID!=0){
+ Uint2 entityID,itemID;
+ SeqAlignPtr sap;
+
+ /*get the first SeqAlign in the list and load the viewer panel*/
+ dmp->vnp_ali=vnp_ali;
+
+ if(mWin_d->Show_logo){
+ /*Hide(mWin_d->Logo_Panel);*/
+ mWin_d->Show_logo=FALSE;
+ }
+ sap=(SeqAlignPtr)vnp_ali->data.ptrvalue;
+ entityID=sap->idx.entityID;
+ itemID=sap->idx.itemID;
+ SetAppProperty("ddvinterndata",(void *)dmp);
+ procval=GatherProcLaunch ((dmp->bEditor==TRUE? OMPROC_EDIT : OMPROC_VIEW), FALSE,
+ entityID, itemID, OBJ_SEQALIGN, 0, 0, OBJ_SEQALIGN, 0);
+ if ((procval = OM_MSG_RET_ERROR))
+ mWin_d->Show_logo=TRUE;
+ RemoveAppProperty("ddvinterndata");
+ }
+ }
+
+ Remove(hOpenDlg);
+}
+
+/*******************************************************************************
+
+ Function : DDV_NetOpen_access()
+
+ Purpose : manage Accession edit control of the Download dialog box
+
+ Parameters : t; edit control
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_NetOpen_access(TexT t)
+{
+Char szAccess[50]={""};
+WindoW hOpenDlg;
+DDVNetOpenPtr dnop;
+
+ hOpenDlg=(WindoW)ParentWindow(t);
+
+ if (!hOpenDlg) return;
+
+ dnop = (DDVNetOpenPtr) GetObjectExtra (hOpenDlg);
+
+ if (dnop==NULL) return;
+
+ GetTitle(t, szAccess, sizeof(szAccess));
+
+ if (StringLen(szAccess) == 0)
+ Disable(dnop->ok);
+ else Enable(dnop->ok);
+
+ return;
+}
+
+/*******************************************************************************
+
+ Function : DDV_OpenNetwork()
+
+ Purpose : callback of the File|Network command
+
+ Parameters : i; command item
+
+ Return value : none
+
+*******************************************************************************/
+extern void DDV_OpenNetwork(IteM i)
+{
+DdvMainWinPtr mWin_d;
+WindoW hWinMain,hOpenDlg;
+GrouP g,c;
+DDVNetOpenPtr dnopp;
+
+ hWinMain=(WindoW)ParentWindow(i);
+
+ if (!hWinMain) return;
+
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (hWinMain);
+
+ if (mWin_d==NULL) return;
+
+ dnopp=(DDVNetOpenPtr)MemNew(sizeof(DDVNetOpen));
+ if (!dnopp) return;
+
+ /*init the Network, if needed*/
+ if (mWin_d->AutonomeViewer && mWin_d->NetStartProc){
+ if (!mWin_d->NetStartProc(mWin_d->UseNetwork)) return;
+ }
+
+ hOpenDlg = MovableModalWindow(-30, -20, -10, -10,
+ "DDV - Fetch a network entry", NULL);
+ SetGroupSpacing (hOpenDlg, 10, 10);
+
+ dnopp->hWndMain=hWinMain;
+
+ /*accesion*/
+ g = NormalGroup (hOpenDlg, 3, 0, "Entry", systemFont,NULL);
+
+#ifdef WIN_MAC
+ dnopp->AccessType = PopupList (g, TRUE, NULL);
+#endif
+
+#ifndef WIN_MAC
+ dnopp->AccessType = PopupList (g, FALSE, NULL);
+#endif
+
+ PopupItem(dnopp->AccessType,"PopSet");
+
+ SetValue (dnopp->AccessType, 1);
+
+ dnopp->Entry = DialogText (g, "", 10, DDV_NetOpen_access);
+
+ c = HiddenGroup (hOpenDlg, 4, 0, NULL);
+ SetGroupSpacing (c, 10, 2);
+ dnopp->ok=DefaultButton (c, "Retrieve", DDV_NetOpen_okProc);
+ Disable (dnopp->ok);
+ PushButton (c, "Cancel", DDV_NetOpen_cancelProc);
+
+ SetObjectExtra (hOpenDlg, (Pointer) dnopp, StdCleanupExtraProc);
+
+ /*display*/
+ AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, NULL);
+ RealizeWindow (hOpenDlg);
+ Show (hOpenDlg);
+ Select (hOpenDlg);
+ Update ();
+}
+
+NLM_EXTERN void DDV_SlaveQuit(WindoW hWinMain)
+{
+ DdvMainWinPtr mWin_d;
+ DdvMainPtr dmp;
+ WindoW hDialog;
+ GrouP g1, g2;
+ Boolean QuitElseWhere = FALSE;
+
+ mWin_d = (DdvMainWinPtr) GetObjectExtra((Handle)hWinMain);
+ if (mWin_d==NULL) return;
+
+ /* if there are unsaved edits, ask the user if they'd like to save */
+ dmp = (DdvMainPtr)GetObjectExtra(mWin_d->hWndDDV);
+ if (dmp->bEditor) {
+ if (dmp->dsp->SomethingToSave) {
+ QuitElseWhere = TRUE;
+ hDialog = MovableModalWindow(-30, -20, -10, -10, "DDE - Save Query", NULL);
+ g1 = HiddenGroup(hDialog, 1, 1, NULL);
+ StaticPrompt(g1, "Save Changes?", 0, stdLineHeight, systemFont, 'c');
+ g2 = HiddenGroup(hDialog, 3, 1, NULL);
+ PushButton(g2, "Yes", DDV_Save);
+ PushButton(g2, "No", DDV_NoSave);
+ PushButton(g2, "Cancel", DDV_Cancel);
+ SetObjectExtra (hDialog, (Pointer)hWinMain, NULL);
+ Select(hDialog);
+ Show(hDialog);
+ }
+ }
+ if (!QuitElseWhere) {
+ if (mWin_d->AutonomeViewer)
+ QuitProgram(); /*standalone DDV*/
+ else
+ Remove(hWinMain);/*slave viewer : just kill the main window*/
+ }
+}
+
+/*******************************************************************************
+
+ Function : DDV_StartMainWin_Slave()
+
+ Purpose : start DDV main window as a slave module: init 'dmp' data structure,
+ set 'DDV_MAIN_DATA' property, start a dlg (the parent window of DDV
+ panel).
+
+ Parameters : vgp; sets defaults for non-autonomous viewers
+
+ Return value : handle to the DDV main window
+
+*******************************************************************************/
+extern WindoW DDV_StartMainWin_Slave(SAM_ViewGlobal *vgp,Boolean bEditor)
+{
+Int2 Margins;
+DdvMainWinPtr mWin_d;
+WindoW w;
+Boolean bRet;
+Char AppName[40];
+
+ /* use "DDE" for editor, "DDV" for viewer, for title */
+ if (bEditor) {StringCpy(AppName, szAppName2);}
+ else {StringCpy(AppName, szAppName);}
+
+ /*init data blocks*/
+ mWin_d=(DdvMainWinPtr)MemNew(sizeof(DdvMainWin));
+ if (!mWin_d) return(NULL);
+
+ /*main window*/
+ Margins=15*stdCharWidth;
+ if(vgp == NULL)
+ w=DocumentWindow(Margins,Margins ,-10, -10,
+ AppName,
+ DDV_SlaveQuit,
+ DDV_WinMainResize);
+ else
+ w=DocumentWindow(vgp->Rect.left,vgp->Rect.top ,-10, -10,
+ AppName,
+ DDV_SlaveQuit,
+ DDV_WinMainResize);
+
+ if (!w) return(NULL);
+
+ SetObjectExtra (w, (Pointer) mWin_d, (FreeProc)DDV_WinMainCleanup);
+ mWin_d->hWndMain=w;
+ /*this is a slave editor/viewer*/
+ mWin_d->AutonomeViewer=FALSE;
+
+ /*build GUI*/
+ bRet=DDV_CreateViewerPanel(w,mWin_d, vgp, bEditor);
+
+ if (!bRet) return(NULL);
+
+ mWin_d->Show_logo=FALSE;
+
+ return(w);
+}
+
+
+static Boolean DDV_DigitsOnly(Char* str)
+{
+ while(*str) {
+ if (!isdigit(*str))
+ return FALSE;
+ str++;
+ }
+ return TRUE;
+}
+
+/*******************************************************************************
+
+ Function : DDV_ImportEnableProc
+
+ Purpose : this function does the actual bioseq import. note that it doesn't
+ require a vibrant dialog to operate, only that idp is filled out
+
+ Return value : none
+
+*******************************************************************************/
+
+static void DDV_ImportEnableProc(TexT t)
+{
+ Char str[32];
+ WindoW hImportDlg;
+ DDV_ImportDialog *idp;
+
+ hImportDlg= (WindoW)ParentWindow(t);
+ if(hImportDlg == NULL) return;
+ idp = (DDV_ImportDialog *) GetObjectExtra(hImportDlg);
+ if(idp == NULL) return;
+
+ GetTitle(idp->DDV_tAccession, str, sizeof(str));
+ if (StringLen(str) == 0) {
+ Disable(idp->DDV_bImportAccept);
+ } else {
+ Enable(idp->DDV_bImportAccept);
+ if(DDV_DigitsOnly(str)) SetValue(idp->DDV_gAccType, 2);
+ else SetValue(idp->DDV_gAccType, 1);
+ }
+ return;
+}
+
+static SeqAlignPtr ddv_truncate_overlaps (SeqAlignPtr sap)
+{
+ AMAlignIndexPtr amaip;
+ DenseDiagPtr ddp;
+ DenseDiagPtr ddp_head;
+ DenseDiagPtr ddp_prev;
+ DenseSegPtr dsp1;
+ DenseSegPtr dsp2;
+ Int4 i;
+ SeqAlignPtr salp;
+ Int4 start1;
+ Int4 start2;
+ Int4 stop1;
+ Int4 stop2;
+ Int4 tmp;
+
+ if (sap == NULL) return(NULL);
+ if (sap->saip == NULL) return(NULL);
+ if (sap->saip->indextype != INDEX_PARENT) return(NULL);
+
+ amaip = (AMAlignIndexPtr)(sap->saip);
+ for (i=0; i<amaip->numsaps-1; i++)
+ {
+ AlnMgrGetNthSeqRangeInSA(amaip->saps[i], 1, &start1, &stop1);
+ AlnMgrGetNthSeqRangeInSA(amaip->saps[i+1], 1, &start2, &stop2);
+ if (start2 <= stop1)
+ {
+ dsp1 = (DenseSegPtr)(amaip->saps[i]->segs);
+ dsp2 = (DenseSegPtr)(amaip->saps[i+1]->segs);
+ dsp1->lens[0] = dsp1->lens[0] - (stop1-start2)/2;
+ tmp = dsp1->starts[0]+dsp1->lens[0];
+ tmp = tmp - dsp2->starts[0];
+ dsp2->starts[1] = tmp + dsp2->starts[1];
+ dsp2->starts[0] = dsp1->starts[0]+dsp1->lens[0];
+ dsp2->lens[0] = stop2 - dsp2->starts[0] + 1;
+ SAIndexFree(amaip->saps[i]->saip);
+ SAIndexFree(amaip->saps[i+1]->saip);
+ amaip->saps[i]->saip = amaip->saps[i+1]->saip = NULL;
+ AlnMgrIndexSingleChildSeqAlign(amaip->saps[i]);
+ AlnMgrIndexSingleChildSeqAlign(amaip->saps[i+1]);
+ }
+ AlnMgrGetNthSeqRangeInSA(amaip->saps[i], 2, &start1, &stop1);
+ AlnMgrGetNthSeqRangeInSA(amaip->saps[i+1], 2, &start2, &stop2);
+ if (start2 <= stop1)
+ {
+ dsp1 = (DenseSegPtr)(amaip->saps[i]->segs);
+ dsp2 = (DenseSegPtr)(amaip->saps[i+1]->segs);
+ dsp1->lens[0] = dsp1->lens[0] - (stop1-start2)/2;
+ tmp = dsp1->starts[1]+dsp1->lens[0];
+ tmp = tmp - dsp2->starts[1];
+ dsp2->starts[0] = tmp + dsp2->starts[0];
+ dsp2->starts[1] = dsp1->starts[1]+dsp1->lens[0];
+ dsp2->lens[0] = stop2 - dsp2->starts[1] + 1;
+ SAIndexFree(amaip->saps[i]->saip);
+ SAIndexFree(amaip->saps[i+1]->saip);
+ amaip->saps[i]->saip = amaip->saps[i+1]->saip = NULL;
+ AlnMgrIndexSingleChildSeqAlign(amaip->saps[i]);
+ AlnMgrIndexSingleChildSeqAlign(amaip->saps[i+1]);
+ }
+ }
+ ddp_head = ddp_prev = NULL;
+ for (i=0; i<amaip->numsaps; i++)
+ {
+ ddp = DenseDiagNew();
+ AlnMgrGetNthSeqRangeInSA(amaip->saps[i], 1, &start1, &stop1);
+ AlnMgrGetNthSeqRangeInSA(amaip->saps[i], 2, &start2, &stop2);
+ dsp1 = (DenseSegPtr)(amaip->saps[i]->segs);
+ ddp->starts = (Int4Ptr)MemNew(2*sizeof(Int4));
+ ddp->dim = 2;
+ ddp->id = dsp1->ids;
+ dsp1->ids = NULL;
+ ddp->starts[0] = start1;
+ ddp->starts[1] = start2;
+ ddp->len = stop1 - start1 + 1;
+ if (ddp_head != NULL)
+ {
+ ddp_prev->next = ddp;
+ ddp_prev = ddp;
+ } else
+ ddp_head = ddp_prev = ddp;
+ }
+ salp = SeqAlignNew();
+ salp->dim = 2;
+ salp->segtype = SAS_DENDIAG;
+ salp->type = SAT_DIAGS;
+ salp->segs = (Pointer)(ddp_head);
+ SeqAlignFree(sap);
+ return salp;
+}
+
+NLM_EXTERN SeqAlignPtr DDV_ShredAln(SeqAlignPtr sap)
+{
+ AMAlignIndexPtr amaip;
+ AlnMsgPtr amp1;
+ AlnMsgPtr amp2;
+ DenseDiagPtr ddp;
+ DenseDiagPtr ddp_head;
+ DenseDiagPtr ddp_prev;
+ Int4 i;
+ Boolean more1;
+ Boolean more2;
+ SeqAlignPtr salp;
+
+ if (sap == NULL || sap->saip == NULL || sap->saip->indextype != INDEX_PARENT)
+ return NULL;
+ amaip = (AMAlignIndexPtr)(sap->saip);
+ if (amaip->numrows > 2)
+ return NULL;
+ amp1 = AlnMsgNew();
+ amp2 = AlnMsgNew();
+ ddp_head = ddp_prev = NULL;
+ for (i=0; i<amaip->numsaps; i++)
+ {
+ amp1 = AlnMsgReNew(amp1);
+ amp2 = AlnMsgReNew(amp2);
+ amp1->from_m = amp2->from_m = 0;
+ amp1->to_m = amp2->to_m = -1;
+ amp1->row_num = 1;
+ amp2->row_num = 2;
+ while ((more1 = AlnMgrGetNextAlnBit(amaip->saps[i], amp1)) && (more2 = AlnMgrGetNextAlnBit(amaip->saps[i], amp2)))
+ {
+ if (amp1->gap == 0 && amp2->gap == 0)
+ {
+ ddp = DenseDiagNew();
+ ddp->dim = 2;
+ ddp->starts = (Int4Ptr)MemNew(2*sizeof(Int4));
+ ddp->strands = (Uint1Ptr)MemNew(2*sizeof(Uint1));
+ ddp->id = AlnMgrGetNthSeqIdPtr(sap, 1);
+ ddp->id->next = AlnMgrGetNthSeqIdPtr(sap, 2);
+ ddp->starts[0] = amp1->from_b;
+ ddp->starts[1] = amp2->from_b;
+ ddp->len = amp1->to_b - amp1->from_b + 1;
+ ddp->strands[0] = AlnMgrGetNthStrand(sap, 1);
+ ddp->strands[1] = AlnMgrGetNthStrand(sap, 2);
+ if (ddp_head != NULL)
+ {
+ ddp_prev->next = ddp;
+ ddp_prev = ddp;
+ } else
+ ddp_head = ddp_prev = ddp;
+ }
+ }
+ }
+ salp = SeqAlignNew();
+ salp->type = SAT_DIAGS;
+ salp->segtype = SAS_DENDIAG;
+ salp->dim = 2;
+ salp->segs = (Pointer)(ddp_head);
+ SeqAlignFree(sap);
+ AlnMsgFree(amp1);
+ AlnMsgFree(amp2);
+ return salp;
+}
+
+/*******************************************************************************
+
+ Function : DDV_DoAlign
+
+ Purpose : this function does the actual bioseq import. note that it doesn't
+ require a vibrant dialog to operate, only that idp is filled out
+
+ Return value : none
+
+*******************************************************************************/
+
+NLM_EXTERN void DDV_DoAlign(DDV_ImportDialog *idp)
+{
+ Char str[32];
+ Bioseq *bsp1 = NULL, *bsp2 = NULL;
+ SeqId si;
+ SeqAlign *sap, *salp;
+ Int4 value, i;
+ ValNode *pvn;
+ ErrSev sev;
+
+ if(idp->mode & DDVIMP2SE) {
+ value = GetValue(idp->DDV_lsip); /*one-base value*/
+ for(pvn = idp->pvnSips, i = 1; i != value && pvn != NULL;
+ i++, pvn = pvn->next) continue;
+ if(pvn != NULL)
+ bsp1 = BioseqLockById((SeqId *)pvn->data.ptrvalue);
+ } else bsp1 = BioseqLockById(idp->sip);
+ if (bsp1 == NULL) {
+ Message (MSG_ERROR, "Unable to load sequence");
+ goto out2;
+ }
+
+ if(idp->mode & DDVIMPNET) {
+ si.choice = SEQID_GI;
+ GetTitle(idp->DDV_tAccession, str, sizeof(str));
+ if(GetValue(idp->DDV_gAccType) == 1 && idp->AccessionCB)
+ si.data.intvalue = idp->AccessionCB(str, ISA_aa(bsp1->mol));
+ else si.data.intvalue = atoi(str);
+ if (si.data.intvalue <= 0) {
+ Message (MSG_ERROR, "Unable to understand accession");
+ goto out2;
+ }
+ bsp2 = BioseqLockById(&si);
+ } else bsp2 = BioseqLockById((SeqId *)idp->sipslave->data.ptrvalue);
+ if(bsp2 == NULL) {
+ Message (MSG_ERROR, "Unable to load sequence");
+ BioseqUnlock(bsp1);
+ goto out2;
+ }
+ idp->bsp = bsp2;
+
+ if(ISA_aa(bsp1->mol) != ISA_aa(bsp2->mol) ||
+ ISA_na(bsp1->mol) != ISA_na(bsp1->mol)) {
+ Message (MSG_ERROR, "Sequences to be aligned not of same type");
+ BioseqUnlock(bsp1);
+ BioseqUnlock(bsp2);
+ goto out2;
+ }
+
+ sev = ErrSetMessageLevel(SEV_FATAL);
+
+/* sap = ACT_GlobalAlignSimple(bsp1, bsp2, TRUE); */
+ if(ISA_aa(bsp1->mol))
+ sap = DDV_Blast2Seqs(bsp1, bsp2, idp->Gap, "blastp");
+ else
+ sap = DDV_Blast2Seqs(bsp1, bsp2, idp->Gap, "blastn");
+
+ ErrSetMessageLevel(sev);
+ BioseqUnlock(bsp1);
+ BioseqUnlock(bsp2);
+
+ if(sap == NULL) {
+ Message (MSG_OK, "Not able to align the sequence");
+ goto out2;
+ }
+
+ SAM_ReplaceGI(sap);
+ AlnMgrIndexSeqAlign(sap);
+
+ if(idp->Gap) {
+ AlnMgrMakeMultipleByScore(sap);
+ AlnMgrDeleteHidden(sap, FALSE);
+ salp = DDV_ShredAln(sap);
+ } else {
+ AlnMgrMakeMultipleByScoreEx(sap, 10);
+ AlnMgrDeleteHidden(sap, FALSE);
+ salp = ddv_truncate_overlaps(sap);
+ }
+
+ if(idp->callback) idp->callback(idp, idp->sap, salp);
+ /*SeqAlignFree(sap);*/
+
+out2:
+ MemFree(idp->userdata);
+ ValNodeFree(idp->pvnSips); /* don't free the data */
+ ValNodeFree(idp->sipslave);
+}
+
+/*******************************************************************************
+
+ Function : DDV_ImportAcceptProc
+
+ Purpose : fired by clicking OK in the bioseq import dialog
+
+ Return value : none
+
+*******************************************************************************/
+
+static void DDV_ImportAcceptProc(ButtoN b)
+{
+ WindoW hImportDlg;
+ DDV_ImportDialog *idp;
+
+ hImportDlg= (WindoW)ParentWindow(b);
+ if(hImportDlg == NULL) goto out;
+ idp = (DDV_ImportDialog *) GetObjectExtra(hImportDlg);
+ if(idp == NULL) goto out;
+
+ WatchCursor();
+ DDV_DoAlign(idp);
+ ArrowCursor();
+
+out:
+ Remove(hImportDlg);
+ return;
+}
+
+/*******************************************************************************
+
+ Function : DDV_ImportCB
+
+ Purpose : callback for import bioseq dialog. used to clean up after the
+ import
+
+ Return value : none
+
+*******************************************************************************/
+
+NLM_EXTERN void DDV_ImportCB(DDV_ImportDialog *idp, SeqAlign *salpdest,
+ SeqAlign *salp)
+{
+ if (salpdest == NULL || salp == NULL) return;
+ SeqAlignSetFree(salp->next);
+ salp->next = NULL;
+ ViewMgr_Add(salpdest, salp);
+}
+
+/*******************************************************************************
+
+ Function : DDV_ImportCancelProc
+
+ Purpose : cancel function for the import bioseq dialog
+
+ Return value : none
+
+*******************************************************************************/
+
+static void DDV_ImportCancelProc(ButtoN b)
+{
+ WindoW hImportDlg;
+ DDV_ImportDialog *idp;
+
+ hImportDlg= (WindoW)ParentWindow(b);
+ if(hImportDlg == NULL) return;
+ idp = (DDV_ImportDialog *) GetObjectExtra(hImportDlg);
+ if(idp == NULL) return;
+ MemFree(idp->userdata);
+
+ Remove(idp->DDV_wImport);
+ return;
+}
+
+/*******************************************************************************
+
+ Function : DDV_ImportBioseqDlg
+
+ Purpose : dialog to import a bioseq into a seqalign. Note that it has
+ several modes listed in ddvopen.h
+
+ Return value : none
+
+*******************************************************************************/
+
+NLM_EXTERN void DDV_ImportBioseqDlg(DDV_ImportDialog *idp)
+{
+ GrouP g, hg;
+ ButtoN b;
+ DDVUpdateMSG *dump;
+ ValNode *pvn;
+ Char szName[21]={""};
+
+ if(idp == NULL) return;
+
+ /* check if we have the right data for each mode */
+ if(idp->mode == DDVIMPSE2SA
+ && (idp->sip == NULL || idp->sap == NULL || idp->sipslave == NULL)) return;
+ else if (idp->mode == DDVIMPSE2SE
+ && (idp->pvnSips == NULL || idp->sipslave == NULL)) return;
+ else if (idp->mode == DDVIMPNET2SA
+ && (idp->sap == NULL || idp->sip == NULL)) return;
+ else if (idp->mode == DDVIMPNET2SE
+ && idp->pvnSips == NULL) return;
+
+ idp->DDV_wImport = NULL;
+ idp->DDV_gAccType = NULL;
+ idp->DDV_bImportAccept = NULL;
+ idp->DDV_tAccession = NULL;
+ dump = MemNew(sizeof(DDVUpdateMSG));
+ if(dump == NULL) {
+ MemFree(idp);
+ return;
+ }
+ idp->userdata = dump;
+ dump->data = NULL;
+ dump->type=UPDATE_TYPE_EDIT_DELBSP;
+
+ idp->DDV_wImport = MovableModalWindow(-30, -20, -10, -10,
+ "Import sequence using BLAST", NULL);
+ Nlm_SetObjectExtra (idp->DDV_wImport, (Nlm_VoidPtr)idp, StdCleanupExtraProc);
+
+ if(idp->mode & DDVIMP2SE) {
+ hg = HiddenGroup(idp->DDV_wImport, 1, 4, NULL);
+ g = NormalGroup(hg, 1, 2, "Choose sequence to align to:", systemFont, NULL);
+ idp->DDV_lsip = SingleList(g,10,6,NULL);
+
+ for(pvn = idp->pvnSips; pvn != NULL; pvn = pvn->next) {
+ SeqIdWrite((SeqId *)pvn->data.ptrvalue,szName,
+ PRINTID_TEXTID_ACCESSION, 10);
+ ListItem(idp->DDV_lsip, szName);
+ }
+ SetValue(idp->DDV_lsip, 1);
+ } else hg = HiddenGroup(idp->DDV_wImport, 1, 3, NULL);
+
+ if(idp->mode & DDVIMPNET) {
+ g = NormalGroup(hg, 1, 2, " Enter sequence identifier:", systemFont, NULL);
+ idp->DDV_tAccession = DialogText(g, "", 10, (TxtActnProc) DDV_ImportEnableProc);
+ idp->DDV_gAccType =
+ NormalGroup(hg, 1, 2, " accession type", systemFont, NULL);
+ RadioButton(idp->DDV_gAccType, "Accession");
+ RadioButton(idp->DDV_gAccType, "gi");
+ }
+
+ g = HiddenGroup(hg, 2, 1, NULL);
+ SetGroupSpacing(g, 15, 15);
+ idp->DDV_bImportAccept =
+ DefaultButton(g, "OK", (BtnActnProc) DDV_ImportAcceptProc);
+ b = PushButton(g, "Cancel", (BtnActnProc) DDV_ImportCancelProc);
+
+ if(idp->mode & DDVIMPNET) {
+ SetValue(idp->DDV_gAccType, 1);
+ Disable(idp->DDV_bImportAccept);
+ Select(idp->DDV_tAccession);
+ }
+ Show(idp->DDV_wImport);
+ return;
+}
+
+/*******************************************************************************
+
+ Function : DDV_ImportBioseq
+
+ Purpose : sets up dialog to import a bioseq into a seqalign
+
+ Return value : none
+
+*******************************************************************************/
+
+NLM_EXTERN void DDV_ImportBioseq(IteM i)
+{
+ DDV_ImportDialog *idp;
+ DdvMainPtr dmp; /*DDV panel data*/
+ DdvMainWinPtr mWin_d;
+ WindoW hWinMain;
+
+ idp = MemNew(sizeof(DDV_ImportDialog));
+ if(idp == NULL) return;
+
+ hWinMain=(WindoW)ParentWindow(i);
+ if (hWinMain==NULL) return;
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (hWinMain);
+ if (mWin_d==NULL) return;
+
+ if (mWin_d->NetStartProc) mWin_d->NetStartProc(mWin_d->UseNetwork);
+
+ if (mWin_d->hWndDDV==NULL) return;
+ dmp = (DdvMainPtr) GetObjectExtra(mWin_d->hWndDDV);
+ if (dmp==NULL) return;
+
+ if(dmp->MSA_d.pgp_l.sap == NULL) return;
+
+ idp->sap = dmp->MSA_d.pgp_l.sap;
+ idp->sip = AlnMgrFindMaster(idp->sap);
+ if(idp->sip == NULL) {
+ Message (MSG_ERROR, "Alignment must have master sequence");
+ MemFree(idp);
+ return;
+ }
+
+ idp->callback = DDV_ImportCB;
+ idp->mode = DDVIMPNET2SA;
+
+ DDV_ImportBioseqDlg(idp);
+}
+
+
+NLM_EXTERN SeqAlign *DDV_Blast2Seqs(Bioseq *bsp1, Bioseq *bsp2, Boolean gapped,
+ Char *progname)
+{
+ BLAST_OptionsBlkPtr options;
+ SeqAlign *salp;
+
+ if(bsp1 == NULL || bsp2 == NULL || progname == NULL) return NULL;
+ options = BLASTOptionNew(progname, gapped);
+ if(options == NULL) return NULL;
+/* options->discontinuous = FALSE; */
+ salp = BlastTwoSequences(bsp1, bsp2, progname, options);
+ BLASTOptionDelete(options);
+ return salp;
+}
+
+
+/*******************************************************************************
+
+ Function : DDV_ImportSeqAlign(), DDV_ImportNucSeqAlign() and DDV_ImportProtSeqAlign()
+
+ Purpose : import a sequence alignment of text type
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_ImportSeqAlign(Boolean is_prot,IteM i)
+{
+WindoW hWinMain;
+DdvMainPtr dmp;
+DdvMainWinPtr mWin_d;
+SeqEntryPtr sep;
+ValNodePtr vnp_ali;
+SeqAlignPtr sap;
+Uint2 The_entityID,entityID,itemID;
+Int2 procval;
+
+ hWinMain=(WindoW)ParentWindow(i);
+
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (hWinMain);
+
+ sep=ReadAnyAlignment(is_prot,NULL);
+
+ if (sep!=NULL && mWin_d!=NULL){
+ /*try to connect Entrez; if failure, still ok : the user can
+ use DDV with a local file. Otherwise he/she will be in trouble ;-)*/
+ if (mWin_d->AutonomeViewer && mWin_d->NetStartProc){
+ mWin_d->NetStartProc(mWin_d->UseNetwork);
+ }
+ /*delete old data, if needed*/
+ dmp=(DdvMainPtr)GetObjectExtra(mWin_d->hWndDDV);
+ DDV_CleanupDDVPdata_g(dmp);
+ DDV_CloseData(mWin_d,FALSE);
+
+ vnp_ali=DDV_GetAndCheckSeqAlign(NULL,0,sep,mWin_d->fetchSepProc,&(dmp->dod),
+ &The_entityID);
+ if (vnp_ali && The_entityID!=0){
+
+ /*get the first SeqAlign in the list and load the viewer panel*/
+ dmp->vnp_ali=vnp_ali;
+
+ if(mWin_d->Show_logo){
+ mWin_d->Show_logo=FALSE;
+ }
+ sap=(SeqAlignPtr)vnp_ali->data.ptrvalue;
+ entityID=sap->idx.entityID;
+ itemID=sap->idx.itemID;
+ SetAppProperty("ddvinterndata",(void *)dmp);
+ procval=GatherProcLaunch ((dmp->bEditor==TRUE? OMPROC_EDIT : OMPROC_VIEW), FALSE, entityID, itemID,
+ OBJ_SEQALIGN, 0, 0, OBJ_SEQALIGN, 0);
+ if ((procval = OM_MSG_RET_ERROR))
+ mWin_d->Show_logo=TRUE;
+ RemoveAppProperty("ddvinterndata");
+ }
+ }
+ else{
+ ErrPostEx (SEV_ERROR, 0, 0, "We do not support this format yet");
+ }
+}
+
+extern void DDV_ImportNucSeqAlign(IteM i)
+{
+ DDV_ImportSeqAlign(FALSE,i);
+}
+
+extern void DDV_ImportProtSeqAlign(IteM i)
+{
+ DDV_ImportSeqAlign(TRUE,i);
+}
+
+static Int4 DDV_GetLastRow(DDV_HideDialog *hdp)
+{
+ int i, max=0;
+
+ for (i = 1; i <= hdp->numrows; i++) {
+ if (ViewMgr_TRow2VRow(hdp->salp, i) > 0) {
+ max = i;
+ }
+ }
+ return(max);
+}
+
+static void DDV_SetHideList(DDV_HideDialog *hdp)
+{
+ int i;
+
+ for(i = 1; i <= hdp->numrows; i++) {
+ if(ViewMgr_TRow2VRow(hdp->salp, i) > 0)
+ SetItemStatus(hdp->DDV_lsip, i, TRUE);
+ else SetItemStatus(hdp->DDV_lsip, i, FALSE);
+ }
+ SetItemStatus(hdp->DDV_lsip, hdp->amaip->master, TRUE);
+}
+
+static void DDV_HideList(Nlm_LisT l)
+/*******************************************************************************
+* this function is called each time an item from the list is clicked.
+* it sets the status for each row, making sure not to allow the
+* master to be hidden, nor the number of rows to be less than 2.
+*******************************************************************************/
+{
+ WindoW hHideDlg;
+ DDV_HideDialog *hdp;
+ Int4 i, LastRow, count = 0;
+
+ hHideDlg = (WindoW)ParentWindow(l);
+ if(hHideDlg == NULL) return;
+ hdp = (DDV_HideDialog *) GetObjectExtra(hHideDlg);
+ if(hdp == NULL) return;
+
+ /* get row count, and last displayed row */
+ for(i = 1; i <= hdp->numrows; i++) {
+ if (GetItemStatus(hdp->DDV_lsip, i)) {
+ count++;
+ LastRow = i;
+ }
+ }
+
+ /* don't let number of rows fall below 2 */
+ if (count < 2) {
+ if (hdp->LastValidRow == -1) {
+ SetItemStatus(hdp->DDV_lsip, DDV_GetLastRow(hdp), TRUE);
+ }
+ else {
+ SetItemStatus(hdp->DDV_lsip, hdp->LastValidRow, TRUE);
+ }
+ }
+ else {
+ /* each time a row is clicked, update the last saved row */
+ hdp->LastValidRow = LastRow;
+ }
+
+ /* don't let master be hidden */
+ if (!GetItemStatus(hdp->DDV_lsip, 1)) {
+ SetItemStatus(hdp->DDV_lsip, 1, TRUE);
+ }
+}
+
+
+static void DDV_HideAcceptProc(ButtoN b)
+{
+ WindoW hHideDlg;
+ DDV_HideDialog *hdp;
+ Int4 i;
+ Boolean status;
+
+ hHideDlg = (WindoW)ParentWindow(b);
+ if(hHideDlg == NULL) return;
+ hdp = (DDV_HideDialog *) GetObjectExtra(hHideDlg);
+ if(hdp == NULL) return;
+
+ for(i = 1; i <= hdp->numrows; i++) {
+ status = GetItemStatus(hdp->DDV_lsip, i);
+ ViewMgr_SetHidden(hdp->salp, !status, i);
+ }
+ ViewMgr_Update(hdp->salp);
+ DDV_SetHideList(hdp);
+
+ MemFree(hdp->userdata);
+ Remove(hdp->DDV_wHide);
+}
+
+
+/*******************************************************************************
+
+ Function : DDV_HideDlg
+
+ Purpose : dialog to import a bioseq into a seqalign. Note that it has
+ several modes listed in ddvopen.h
+
+ Return value : none
+
+*******************************************************************************/
+
+NLM_EXTERN void DDV_HideDlg(DDV_HideDialog *hdp)
+{
+ GrouP g, hg;
+ ButtoN b;
+ DDVUpdateMSG *dump;
+ Char szName[181], szName2[161];
+ Int4 i;
+ SeqId *sip;
+ Bioseq *bsp;
+
+ if(hdp == NULL) return;
+ hdp->DDV_wHide = NULL;
+
+ hdp->target = ViewMgr_GetBeginIndexed(hdp->salp);
+
+ if(hdp->target == NULL) return;
+ if( AlnMgrCheckAlignForParent(hdp->target) != AM_PARENT) return;
+ hdp->amaip = (AMAlignIndexPtr)(hdp->target->saip);
+ if (!hdp->amaip) return;
+
+ dump = MemNew(sizeof(DDVUpdateMSG));
+ if(dump == NULL) {
+ MemFree(hdp);
+ return;
+ }
+ hdp->userdata = dump;
+ dump->data = NULL;
+ dump->type=UPDATE_TYPE_EDIT_DELBSP;
+
+ hdp->DDV_wHide = MovableModalWindow(-30, -20, -10, -10,
+ "Hide/Show Sequences", NULL);
+ /* need to do something more than std cleanup. also for blast dialog */
+ Nlm_SetObjectExtra (hdp->DDV_wHide, (void *)hdp, StdCleanupExtraProc);
+
+ hg = HiddenGroup(hdp->DDV_wHide, 1, 2, NULL);
+ g = NormalGroup(hg, 1, 2, "Choose sequences to show:", systemFont, NULL);
+ hdp->DDV_lsip = MultiList(g,40, 6, DDV_HideList);
+
+ hdp->numrows = AlnMgrGetNumRows(hdp->target);
+
+ for(i = 1; i <= hdp->numrows; i++) {
+ sip = AlnMgrGetNthSeqIdPtr(hdp->target, i);
+ if(sip == NULL) continue;
+ bsp=BioseqLockById(sip);
+ if(bsp == NULL) continue;
+ sip = SeqIdFindBestAccession(bsp->id);
+ SeqIdWrite(sip, szName, PRINTID_TEXTID_ACCESSION, 10);
+ CreateDefLine(NULL,bsp,szName2,157,0,NULL,NULL);
+ BioseqUnlock(bsp);
+ StrNCat(szName, " - ", 180);
+ StrNCat(szName, szName2, 180);
+ ListItem(hdp->DDV_lsip, szName);
+ }
+ DDV_SetHideList(hdp);
+
+ g = HiddenGroup(hg, 2, 1, NULL);
+ SetGroupSpacing(g, 15, 15);
+ b = DefaultButton(g, "OK", (BtnActnProc) DDV_HideAcceptProc);
+
+ Show(hdp->DDV_wHide);
+
+ /* set scroll to upper left */
+ SetOffset(hdp->DDV_lsip, 0, 0);
+
+ return;
+}
+
+NLM_EXTERN void DDV_HideDlgItem(IteM i)
+{
+ DDV_HideDialog *hdp;
+ DdvMainPtr dmp; /*DDV panel data*/
+ DdvMainWinPtr mWin_d;
+ WindoW hWinMain;
+
+ hdp = MemNew(sizeof(DDV_HideDialog));
+ if(hdp == NULL) return;
+
+ /* init LastValidRow to something illegal */
+ hdp->LastValidRow = -1;
+
+ hWinMain=(WindoW)ParentWindow(i);
+ if (hWinMain==NULL) return;
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (hWinMain);
+ if (mWin_d==NULL) return;
+
+ if (mWin_d->hWndDDV==NULL) return;
+ dmp = (DdvMainPtr) GetObjectExtra(mWin_d->hWndDDV);
+ if (dmp==NULL) return;
+
+ if(dmp->MSA_d.pgp_l.sap == NULL) return;
+
+ hdp->salp = dmp->MSA_d.pgp_l.sap;
+
+ DDV_HideDlg(hdp);
+}
+
+
+/*******************************************************************************
+
+ Function : DDV_GetCharBufferForEditor()
+
+ Purpose : get a char buffer from a row of a SeqAlign, given display coords
+
+ Return value : an allocated char buffer ready for use by the editor. Null if
+ failure
+
+*******************************************************************************/
+NLM_EXTERN void DDV_GetCharBufferForEditor(ParaGPtr pgp,CharPtr szEditSeq)
+{
+BioseqPtr bsp;
+Int4 bspLength;
+Boolean IsAA;
+
+ /*get sequence size and type*/
+ bsp=BioseqLockById(pgp->sip);
+ if (!bsp) return;
+ bspLength=BioseqGetLen(bsp);
+ IsAA=ISA_aa(bsp->mol);
+ BioseqUnlock(bsp);
+
+ /*get the sequence*/
+ DDV_GetSequenceFromParaG(pgp,&szEditSeq,bspLength,IsAA,NULL,NULL,NULL);
+
+}
+
+/*******************************************************************************
+
+ Function : DDV_GetMtdpListForEditor()
+
+ Purpose : get the descriptor for a row of a SeqAlign, given display coords
+
+ Note : in plain english, this function creates the pTxtList ValNode for
+ a ParaG designed to be used in the editor.
+
+ Return value : a valnode ready for use by the editor. Null if
+ failure.
+
+*******************************************************************************/
+NLM_EXTERN ValNodePtr DDV_GetMtdpListForEditor(ValNodePtr row,Int4 from_disp,
+ Int4 to_disp)
+{
+MsaTxtDispPtr mtdp,new_mtdp,prev_mtdp;
+ValNodePtr vnp,vnp2,vnp3,vnpTxt;
+ParaGPtr pgp;
+Int4 cumulMtdp,beginCopy,endCopy,mtdp_size,mtdp_from_disp,
+ mtdp_to_disp,mtdp_from,mtdp_to;
+Boolean bPop;
+
+
+
+ prev_mtdp=NULL;
+ vnpTxt=NULL;
+ for (vnp=row;vnp!=NULL;vnp=vnp->next){
+ pgp=(ParaGPtr)vnp->data.ptrvalue;
+ /*not yet in the first ParaG ?*/
+ if (pgp->StopLetter<from_disp) {
+ continue;
+ }
+ /*get the mtdp nodes*/
+ cumulMtdp=0;
+ for(vnp2=pgp->ptxtList;vnp2!=NULL;vnp2=vnp2->next){
+ mtdp=(MsaTxtDispPtr)vnp2->data.ptrvalue;
+ mtdp_size=mtdp->to-mtdp->from+1;
+ /*convert mtdp coordinates (can Bioseq coord, gap coord, etc.)
+ to display coordinates*/
+ mtdp_from_disp=pgp->StartLetter+cumulMtdp;
+ mtdp_to_disp=mtdp_from_disp+mtdp_size-1;
+ if (mtdp_to_disp<from_disp) {
+ cumulMtdp+=mtdp_size;
+ continue;
+ }
+ beginCopy=_max_(from_disp,mtdp_from_disp);
+ endCopy=_min_(mtdp_to_disp,to_disp);
+
+ /*convert display coordinates back to mtdp coordinates*/
+ mtdp_from=mtdp->from+(beginCopy-mtdp_from_disp);
+ mtdp_to=mtdp->from+(endCopy-mtdp_from_disp);
+
+ /*in order to merge nodes of same type, i keep track of
+ the previous populated mtdp node. Same style==yes, then
+ just extend to the right the previous node*/
+ if (prev_mtdp){
+ if (prev_mtdp->TextStyle==mtdp->TextStyle){
+ prev_mtdp->to=mtdp_to;
+ bPop=TRUE;
+ }
+ else{
+ bPop=FALSE;
+ }
+ }
+ else{
+ bPop=FALSE;
+ }
+ if (!bPop){
+ new_mtdp=(MsaTxtDispPtr)MemNew(sizeof(MsaTxtDisp));
+ if (!new_mtdp) goto erreur;
+ MemCopy(new_mtdp,mtdp,sizeof(MsaTxtDisp));
+ new_mtdp->from=mtdp_from;
+ new_mtdp->to=mtdp_to;
+ if (!vnpTxt){
+ vnp3=ValNodeAddPointer(&vnpTxt,0,(Pointer)new_mtdp);
+ }
+ else{
+ vnp3=ValNodeAddPointer(&vnp3,0,(Pointer)new_mtdp);
+ }
+ prev_mtdp=new_mtdp;
+ }
+ if (mtdp_to_disp>=to_disp) break;
+ cumulMtdp+=mtdp_size;
+ }
+ /*done ?*/
+ if (pgp->StopLetter>=to_disp) break;
+ }
+ return(vnpTxt);
+
+erreur:
+ if (vnpTxt){
+ DDV_DeleteTxtList(&vnpTxt);
+ }
+ return(NULL);
+}
+
+/*******************************************************************************
+
+ Function : DDV_CreateDataForEditor()
+
+ Purpose : create a MsaParaGPopListPtr intended to be used by the editor
+
+ Return value : an allocated data block ready for use by the editor. Null if
+ failure
+
+*******************************************************************************/
+NLM_EXTERN MsaParaGPopListPtr DDV_CreateDataForEditor(MsaParaGPopListPtr mpplp,
+ Int4 from_disp,Int4 to_disp)
+{
+MsaParaGPopListPtr new_mpplp;
+
+ParaGPtr pgp,old_pgp;
+Int4 i,iNewAliSize,diff;
+
+ if (from_disp<0 || from_disp>=mpplp->LengthAli || from_disp>to_disp ||
+ to_disp<0 || to_disp>=mpplp->LengthAli){
+ return(NULL);
+ }
+
+ diff=to_disp-from_disp;
+ iNewAliSize = diff+50;
+
+ if (iNewAliSize<1 || iNewAliSize>LIMIT_EDITOR_SIZE)
+ return(NULL);
+
+ new_mpplp=(MsaParaGPopListPtr)MemNew(sizeof(MsaParaGPopList));
+ if (!new_mpplp) return(NULL);
+
+ /*table of ParaG list (each cell of that table corresponds to one row
+ of the seqalign to display*/
+ new_mpplp->TableHead=(ValNodePtr *)MemNew(mpplp->nBsp*sizeof(ValNodePtr));
+ if (!new_mpplp->TableHead) {
+ MemFree(new_mpplp);
+ return(NULL);
+ }
+ /*allocate the new ParaG list; for the editor there is a single ParaG for
+ each row (for the viewer there are usually n ParaGs for each row. For the
+ editor, the ParaG size = to_disp-from_disp+50 (whereas in the viewer a
+ ParaG size = ParaG_Size (usually 70; see pgppop.h)*/
+ for (i=0;i<mpplp->nBsp;i++){
+ /*allocations*/
+ pgp=(ParaGPtr)MemNew(sizeof(ParaG));
+ if (!pgp) goto erreur;
+ pgp->szEditSeq=(CharPtr)MemNew(iNewAliSize*sizeof(Char));
+ if (pgp->szEditSeq==NULL) goto erreur;
+ /*get the ParaG line descriptor */
+ pgp->ptxtList=DDV_GetMtdpListForEditor(mpplp->TableHead[i],from_disp,
+ to_disp);
+ if (!pgp->ptxtList) goto erreur;
+ /*get the char buffer*/
+ old_pgp=(ParaGPtr)mpplp->TableHead[i]->data.ptrvalue;
+ pgp->sip = old_pgp->sip;
+ DDV_GetCharBufferForEditor(pgp,pgp->szEditSeq);
+ if (*(pgp->szEditSeq)=='\0') goto erreur;
+ /*copy/init values*/
+ pgp->StartLetter = 0;
+ pgp->StopLetter = diff;
+ pgp->NumOrder = i;
+ pgp->StartLine = i;
+ pgp->nLines = 1;
+ pgp->ScaleStyle=SCALE_POS_NONE;
+ /*store pgp*/
+ new_mpplp->TableHead[i]=(ValNodePtr)MemNew(sizeof(ValNode));
+ if (!new_mpplp->TableHead[i]) goto erreur;
+ new_mpplp->TableHead[i]->data.ptrvalue=(Pointer)pgp;
+ }
+
+ /*seqali size and type*/
+ new_mpplp->LengthAli=diff+1;
+ new_mpplp->nBsp=mpplp->nBsp;
+ new_mpplp->sap=mpplp->sap;
+ new_mpplp->DisplayType=mpplp->DisplayType;
+
+ /*entities table*/
+ new_mpplp->entitiesTbl=(Uint4Ptr)MemNew(new_mpplp->nBsp*sizeof(Uint4));
+ if (new_mpplp->entitiesTbl==NULL) goto erreur;
+ MemCopy(new_mpplp->entitiesTbl,mpplp->entitiesTbl,
+ new_mpplp->nBsp*sizeof(Uint4));
+ /*ruler descriptor*/
+ new_mpplp->RulerDescr=DDV_GetRulerForEditor(mpplp->RulerDescr,from_disp,
+ to_disp);
+ if (new_mpplp->RulerDescr==NULL) goto erreur;
+ return(new_mpplp);
+
+erreur : /*serious problem*/
+ if (new_mpplp->entitiesTbl)
+ MemFree(new_mpplp->entitiesTbl);
+ if (new_mpplp->RulerDescr)
+ ValNodeFreeData(new_mpplp->RulerDescr);
+ DDV_DeleteDisplayList(new_mpplp);
+ MemFree(new_mpplp);
+ return(NULL);
+}
+
+
diff --git a/ddv/ddvopen.h b/ddv/ddvopen.h
new file mode 100644
index 00000000..9f4900b8
--- /dev/null
+++ b/ddv/ddvopen.h
@@ -0,0 +1,336 @@
+/* $Id: ddvopen.h,v 1.23 2000/07/17 17:46:48 hurwitz Exp $
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information (NCBI)
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government do not place any restriction on its use or reproduction.
+* We would, however, appreciate having the NCBI and the author cited in
+* any work or product based on this material
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* ===========================================================================
+*
+* File Name: ddvopen.h
+*
+* Author: Patrick Durand
+*
+* Version Creation Date: 06/19/99
+*
+* $Revision: 1.23 $
+*
+* File Description:
+*
+* Modifications:
+* --------------------------------------------------------------------------
+* $Log: ddvopen.h,v $
+* Revision 1.23 2000/07/17 17:46:48 hurwitz
+* made it so show/hide dialog only updates view when ok is clicked
+*
+* Revision 1.22 2000/07/08 20:43:58 vakatov
+* Get all "#include" out of the 'extern "C" { }' scope; other cleanup...
+*
+* Revision 1.21 2000/06/16 14:57:03 lewisg
+* move entrez calls out of desktop
+*
+* Revision 1.20 2000/05/15 23:39:34 lewisg
+* shred cblast, add menu items for gapped/ungapped, fix pdbheaders
+*
+* Revision 1.19 2000/05/15 22:00:36 hurwitz
+* put save-edits query into DDV_SlaveQuit where it belongs
+*
+* Revision 1.18 2000/05/11 16:28:44 wheelan
+* made DDV_ShredAln NLM_EXTERN
+*
+* Revision 1.17 2000/04/17 13:30:42 durand
+* removed g_hParent and unused functions DDV_LaunchAlignViewer and DDV_LaunchAlignEditor
+*
+* Revision 1.16 2000/04/08 00:37:32 lewisg
+* multiple seqentries, NEWSEQ message, etc.
+*
+* Revision 1.15 2000/03/27 22:15:08 lewisg
+* add show/hide row dialog
+*
+* Revision 1.14 2000/03/24 20:34:58 lewisg
+* add blast from file, bug fixes, get rid of redundant code, etc.
+*
+* Revision 1.13 2000/01/26 13:38:54 durand
+* update the GUI for the editor. Add functions to create the data to be used by the editor
+*
+* Revision 1.12 2000/01/12 21:52:17 durand
+* add import function; update menus when DDV is loaded from Cn3D
+*
+* Revision 1.11 1999/12/30 21:08:45 lewisg
+* bioseq import dialog
+*
+* Revision 1.10 1999/12/29 22:55:03 lewisg
+* get rid of seqalign id
+*
+* Revision 1.9 1999/12/20 20:20:41 lewisg
+* allow cn3d to do color and ddv to do case when both are running
+*
+* Revision 1.8 1999/12/03 23:17:23 lewisg
+* Patrick's new global update msg, argument passing when launching ddv, experimental editing
+*
+* Revision 1.7 1999/11/29 15:26:26 durand
+* designed a new GUI to fix problems under MacOS, Linux and SGI
+*
+* Revision 1.6 1999/11/03 21:29:47 durand
+* add CTRL and SHFT keys for mouse selection. redesign the loader functions of DDV to properly register the message callbacks
+*
+* Revision 1.5 1999/10/29 19:04:21 durand
+* move DDVUpdateMSG in objmgr.h
+*
+* Revision 1.4 1999/10/29 14:15:39 durand
+* add simple mouse selection functions
+*
+* Revision 1.3 1999/10/20 13:17:18 durand
+* add display for disc. SeqAlign tails
+*
+* Revision 1.2 1999/10/16 15:02:25 durand
+* fixes due to toolkit build failed
+*
+* Revision 1.1 1999/09/30 14:10:28 durand
+* add ddv to toolkit
+*
+* Revision 1.8 1999/09/28 17:29:41 durand
+* add include of udviewer.h
+*
+* Revision 1.7 1999/09/16 13:07:53 durand
+* add File|Close and File|Open|Network commands
+*
+* Revision 1.6 1999/09/09 21:55:06 durand
+* instantiate the Fle|Close command of DDV
+*
+* Revision 1.5 1999/07/29 12:43:07 durand
+* update DDV_GetAndCheckSeqAlign
+*
+* Revision 1.4 1999/07/01 15:28:29 durand
+* validate function loaders of DDV
+*
+* Revision 1.2 1999/06/28 22:07:21 durand
+* add loader functions and clean the code with Lint and Purify
+*
+* Revision 1.1 1999/06/19 17:21:07 durand
+* add Vibrant DDV code
+*
+*
+*
+* ==========================================================================
+*/
+
+#ifndef _DDVOPEN_
+#define _DDVOPEN_
+
+#include <ncbi.h>
+#include <udviewer.h>
+#include <samutil.h>
+#include <accentr.h>
+#include <pgppop.h>
+#include <alignmgr.h>
+
+#undef NLM_EXTERN
+#ifdef NLM_IMPORT
+#define NLM_EXTERN NLM_IMPORT
+#else
+#define NLM_EXTERN extern
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/******************************************************************************
+
+ ERROR / Information messages from DDV_OPEN module
+
+******************************************************************************/
+#define DVV_MSG_O_I_NOMAINDATA 2000
+#define DVV_MSG_O_E_READFILE 2001
+#define DVV_MSG_O_E_READGI 2002
+#define DVV_MSG_O_E_NOFETCHFUNC 2003
+#define DVV_MSG_O_E_BADTYPE 2004
+#define DVV_MSG_O_E_NOTHINGTODO 2005
+#define DVV_MSG_O_E_OPENFILEFAIL 2006
+
+/******************************************************************************
+
+ other defines
+
+******************************************************************************/
+ /*use only by the standalone version of DDV */
+#define REG_DDV_AUTO_EDIT ObjMgrProcLoad(OMPROC_EDIT, \
+ "DDV", "MSA_Editor", OBJ_SEQALIGN, 0, OBJ_SEQALIGN, 0, \
+ NULL, DDV_ObjRegMasterEditDDV, 0)
+#define REG_DDV_AUTO_VIEW ObjMgrProcLoad(OMPROC_VIEW, \
+ "DDV", "MSA_Viewer", OBJ_SEQALIGN, 0, OBJ_SEQALIGN, 0, \
+ NULL, DDV_ObjRegMasterViewDDV, 0)
+
+ /*slave 1 : the editor in a separate window*/
+#define REG_DDV_SLA_EDIT ObjMgrProcLoad(OMPROC_EDIT, \
+ "DDV", "MSA_Editor", OBJ_SEQALIGN, 0, OBJ_SEQALIGN, 0, \
+ NULL, DDV_ObjRegSlaveEditDDV, 0)
+
+ /*slave 2 : the viewer in a separate window*/
+#define REG_DDV_SLA_VIEW ObjMgrProcLoad(OMPROC_VIEW, \
+ "DDV", "MSA_Viewer", OBJ_SEQALIGN, 0, OBJ_SEQALIGN, 0, \
+ NULL, DDV_ObjRegSlaveViewDDV, 0)
+
+/*the following are used to delete data when closing DDV*/
+#define DDV_OPENTYPE_NOTRESP ((Uint1)1)/*if DDV is not responsible to delete
+ data when closing*/
+#define DDV_OPENTYPE_FILE ((Uint1)2)/*if ReadAsnFastaOrFlatFile was used*/
+#define DDV_OPENTYPE_SEP ((Uint1)3)/*if get a SEP*/
+#define DDV_OPENTYPE_GI ((Uint1)4)/*if fetch GI from DB was used*/
+
+/******************************************************************************
+
+ Data structures
+
+******************************************************************************/
+typedef struct dlgfileopendata {/*use to manage the FileOpen dialog box*/
+ WindoW parent; /*main window of the application*/
+ TexT FNameEditCtrl; /*handle of the file text control*/
+ ButtoN Ok; /*handle of the Ok button*/
+ GrouP ReadMode; /*handle of the file type control*/
+} DlgFileOpenData, PNTR DlgFileOpenDataPtr;
+
+typedef struct ddvopendata {
+ Uint1 choice;
+ SeqEntryPtr sep;
+ ValNodePtr vnp;
+ } DdvOpenData, PNTR DdvOpenDataPtr;
+
+typedef struct ddvupdatelayoutdata{
+ /*color display ?*/
+ Boolean bUseColors;
+ /*styles for a disc. seqalign*/
+ Boolean ShowLeftTail;
+ Boolean ShowRightTail;
+ Uint1 DispDiscStyle;
+ Uint1 SpacerSize;
+ Uint1 DiscJustification;
+ /*style for sequences*/
+ Int4 nSeq; /*number of rows (sequences) to update*/
+ Int4Ptr SeqList; /*list of row number; one-based array*/
+ Uint1 RulerStyle;
+ /*DDV panel handle*/
+ PaneL ddv_panel;
+ }DDVUpdateLayoutData, PNTR DDVUpdateLayoutDataPtr;
+
+struct _DDV_ImportDialog;
+typedef void (*DDV_ImportProcCB)(struct _DDV_ImportDialog *idp, SeqAlign *salpdest,
+ SeqAlign *salp);
+
+typedef Int4 (*DDV_AccessionCB)(CharPtr string, Boolean IsAmino);
+
+/* for the BLAST import dialog */
+typedef struct _DDV_ImportDialog {
+ WindoW DDV_wImport; /*the import dialog*/
+ GrouP DDV_gAccType; /*the type of accession*/
+ ButtoN DDV_bImportAccept; /*accept button*/
+ TexT DDV_tAccession; /* the accession */
+ LisT DDV_lsip; /* list box of sips */
+ SeqId *sip; /* the master sequence */
+ SeqAlign *sap; /* the seqalign to add to */
+ SeqId *sipslave; /* the slave sequence if it exists */
+ void *userdata; /* for the update message */
+ DDV_ImportProcCB callback; /* called after alignment created */
+ ValNode *pvnSips; /* list of sips to blast against */
+ Int4 mode; /* see below */
+ SeqEntry *sep; /* used to pass new seqentry to call back */
+ Bioseq *bsp; /* the bioseq being added */
+ Boolean Gap; /* should the alignment used gapped blast? */
+ DDV_AccessionCB AccessionCB; /* converts accession to gi */
+} DDV_ImportDialog;
+
+/* import to sequence to seqalign */
+#define DDVIMPSE2SA 0x0
+/* import sequence to sequence */
+#define DDVIMPSE2SE 0x1
+#define DDVIMP2SE 0x1
+/* import net sequence to seqalign */
+#define DDVIMPNET2SA 0x2
+#define DDVIMPNET 0x2
+/* import net sequence to sequence */
+#define DDVIMPNET2SE 0x3
+
+struct _DDV_HideDialog;
+typedef void (*DDV_HideProcCB)(struct _DDV_HideDialog *hdp);
+
+typedef struct _DDV_HideDialog {
+ WindoW DDV_wHide; /*the show/hide dialog*/
+ LisT DDV_lsip; /* multilist box of sips */
+ SeqAlign *salp; /* the seqalign that is shown/hid */
+ SeqAlign *target; /* the original seqalign */
+ AMAlignIndexPtr amaip; /* target index */
+ void *userdata; /* for the update message */
+ DDV_HideProcCB callback; /* called on every show/hide */
+ Int4 numrows; /* true number of rows in target seqalign */
+ Int4 LastValidRow; /* must be 2 valid rows in list, this and master */
+} DDV_HideDialog;
+
+/******************************************************************************
+
+ Extern functions
+
+******************************************************************************/
+extern Int2 LIBCALLBACK DDV_ObjRegMasterEditDDV (Pointer data);
+extern Int2 LIBCALLBACK DDV_ObjRegMasterViewDDV (Pointer data);
+extern Int2 LIBCALLBACK DDV_ObjRegSlaveEditDDV (Pointer data);
+extern Int2 LIBCALLBACK DDV_ObjRegSlaveViewDDV (Pointer data);
+extern void DDV_OpenFile(IteM i);
+extern void DDV_OpenNetwork(IteM i);
+extern ValNodePtr DDV_GetAndCheckSeqAlign(FILE *fp,Int4 gi,SeqEntryPtr sep2,
+ UdvFetchSeqEntryProc fetchSepProc,DdvOpenDataPtr dodp,Uint2Ptr entityID);
+extern WindoW DDV_StartMainWin_Slave(SAM_ViewGlobal *vgp,Boolean bEditor);
+
+extern ValNodePtr DDV_GetSelectedRegions(SelStructPtr om_slp, Uint2 bsp_eID,
+ Uint2 bsp_iID);
+extern Boolean DDV_IsLetterSelected(ValNodePtr vnp_bsp, Int4 bsp_pos);
+
+NLM_EXTERN void DDV_ImportBioseqDlg(DDV_ImportDialog *idp);
+NLM_EXTERN void DDV_ImportBioseq(IteM i);
+NLM_EXTERN SeqAlignPtr DDV_ShredAln(SeqAlignPtr sap);
+NLM_EXTERN void DDV_DoAlign(DDV_ImportDialog *idp);
+NLM_EXTERN void DDV_ImportCB(DDV_ImportDialog *idp, SeqAlign *salpdest,
+ SeqAlign *salp);
+NLM_EXTERN SeqAlign *DDV_Blast2Seqs(Bioseq *bsp1, Bioseq *bsp2, Boolean gapped,
+ Char *progname);
+extern void DDV_ImportNucSeqAlign(IteM i);
+extern void DDV_ImportProtSeqAlign(IteM i);
+NLM_EXTERN void DDV_HideDlgItem(IteM i);
+NLM_EXTERN void DDV_HideDlg(DDV_HideDialog *hdp);
+NLM_EXTERN void DDV_GetCharBufferForEditor(ParaGPtr pgp,CharPtr szEditSeq);
+NLM_EXTERN ValNodePtr DDV_GetMtdpListForEditor(ValNodePtr row,Int4 from_disp,
+ Int4 to_disp);
+NLM_EXTERN MsaParaGPopListPtr DDV_CreateDataForEditor(MsaParaGPopListPtr mpplp,
+ Int4 from_disp,Int4 to_disp);
+NLM_EXTERN void DDV_SlaveQuit(WindoW w);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#undef NLM_EXTERN
+#ifdef NLM_EXPORT
+#define NLM_EXTERN NLM_EXPORT
+#else
+#define NLM_EXTERN
+#endif
+
+#endif /* ndef _DDVOPEN_ */
diff --git a/ddv/ddvpanel.c b/ddv/ddvpanel.c
new file mode 100644
index 00000000..0b73b966
--- /dev/null
+++ b/ddv/ddvpanel.c
@@ -0,0 +1,3674 @@
+/* $Id: ddvpanel.c,v 1.107 2000/08/30 14:31:28 hurwitz Exp $
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information (NCBI)
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government do not place any restriction on its use or reproduction.
+* We would, however, appreciate having the NCBI and the author cited in
+* any work or product based on this material
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* ===========================================================================
+*
+* File Name: ddvpanel.c
+*
+* Author: Patrick Durand
+*
+* Version Creation Date: 06/19/99
+*
+* $Revision: 1.107 $
+*
+* File Description: window management module of DeuxD-Viewer (DDV)
+*
+* Modifications:
+* --------------------------------------------------------------------------
+* $Log: ddvpanel.c,v $
+* Revision 1.107 2000/08/30 14:31:28 hurwitz
+* quick fix so build does not crash
+*
+* Revision 1.106 2000/07/25 20:30:23 hurwitz
+* bug fixes: panel update when file is closed, double-click launches UDV from DDE, seqName agrees in status line and left col
+*
+* Revision 1.105 2000/07/24 22:00:09 hurwitz
+* fixed bug that 1/2 characters were displayed sometimes
+*
+* Revision 1.104 2000/07/20 22:25:57 hurwitz
+* bug fix. mouse-mode query working again
+*
+* Revision 1.103 2000/07/19 19:04:02 hurwitz
+* fixed bug that was causing overwrite of numbering over tick marks in DDE
+*
+* Revision 1.102 2000/07/17 13:32:33 lewisg
+* move DDV_args out of the library
+*
+* Revision 1.101 2000/07/17 12:38:53 kans
+* DDV_myargs is extern in header, instantiated in ddvpanel.c, since it is accessed from that library file
+*
+* Revision 1.100 2000/07/14 22:24:56 lewisg
+* fix scroll, click, visual c++ build bugs. add command line arg parse to ddv
+*
+* Revision 1.99 2000/07/12 22:22:41 hurwitz
+* added delete block to DDV
+*
+* Revision 1.98 2000/07/10 14:38:08 lewisg
+* move seqalign and sequentry data from window to panels
+*
+* Revision 1.97 2000/07/07 22:31:14 lewisg
+* interface tweaks
+*
+* Revision 1.96 2000/07/05 19:23:13 lewisg
+* add two panes to ddv, update msvc project files
+*
+* Revision 1.95 2000/07/05 18:42:16 hurwitz
+* added split block function to DDV
+*
+* Revision 1.94 2000/06/30 22:31:51 hurwitz
+* added merge block function for DDV
+*
+* Revision 1.93 2000/06/29 23:15:13 hurwitz
+* leave single space between aligned blocks with no unaligned sequence between them, no auto-merge of adjacent aligned blocks
+*
+* Revision 1.92 2000/06/27 20:46:38 hurwitz
+* fixed bugs with select rectangle, added select row option
+*
+* Revision 1.91 2000/06/22 20:56:51 hurwitz
+* assorted bug fixes
+*
+* Revision 1.90 2000/06/20 19:35:11 hurwitz
+* use indexed seqAlign when necessary, make multiple when redrawing
+*
+* Revision 1.89 2000/06/15 20:26:05 hurwitz
+* added left/right/center justify for DDE
+*
+* Revision 1.88 2000/06/15 17:33:18 hurwitz
+* used view seqAlignPtr to get original (bug fix), and started working on left/right/center justify for DDE
+*
+* Revision 1.87 2000/06/15 16:01:07 hurwitz
+* rewrote section that calls ViewMgr_Attach when SeqAlign is not editable but IBMable
+*
+* Revision 1.86 2000/06/12 23:02:40 hurwitz
+* enable launch of DDE from Cn3D, swith from DDV_ComputeRuler to DDE_ReMakeRuler, get rid of styles option for DDE
+*
+* Revision 1.85 2000/06/08 20:04:39 hurwitz
+* made warning about converting to true multiple alignment into a Message window, and other small fixes
+*
+* Revision 1.84 2000/06/02 19:57:03 hurwitz
+* added a query dialog when converting from pairwise multiple to true multiple, bug fix of double freeing of a seqAlignPtr
+*
+* Revision 1.83 2000/05/31 23:07:26 hurwitz
+* made NoGaps a runtime parameter, fixed bug with vertical scroll of show/hide list, save edits query is not performed if nothing to save
+*
+* Revision 1.82 2000/05/25 21:40:43 hurwitz
+* rows hidden in DDV are hidden in DDE, can save edits when rows are hidden in DDE
+*
+* Revision 1.81 2000/05/24 21:43:00 hurwitz
+* getting hide/show rows to work with DDV and DDE together
+*
+* Revision 1.80 2000/05/23 22:00:15 hurwitz
+* working on launch of DDE from DDV
+*
+* Revision 1.79 2000/05/19 13:48:31 hurwitz
+* made a version of DDE that doesn't allow aligned gaps, changed wording for adding new rows
+*
+* Revision 1.78 2000/05/16 19:43:01 hurwitz
+* grey out create block, delete block, undo, and redo as needed
+*
+* Revision 1.77 2000/05/15 23:39:34 lewisg
+* shred cblast, add menu items for gapped/ungapped, fix pdbheaders
+*
+* Revision 1.76 2000/05/15 22:00:36 hurwitz
+* put save-edits query into DDV_SlaveQuit where it belongs
+*
+* Revision 1.75 2000/05/12 21:18:13 hurwitz
+* added window asking if user wants to save unsaved edits for dde
+*
+* Revision 1.74 2000/05/10 21:54:54 hurwitz
+* free memory when DDE is closed
+*
+* Revision 1.73 2000/05/10 16:17:00 hurwitz
+* can show tails for just 1 aligned block
+*
+* Revision 1.72 2000/05/09 17:56:49 hurwitz
+* bug fix of vertical scrolling problem
+*
+* Revision 1.71 2000/05/08 22:48:33 hurwitz
+* on launch of DDE, merge nodes that are same MsaTxtDisp alignment and gap
+*
+* Revision 1.70 2000/05/05 20:24:13 hurwitz
+* some bug fixes, also redraw proper block in DDE after a save operation that causes a merge of 2 blocks
+*
+* Revision 1.69 2000/05/04 22:43:38 hurwitz
+* don't launch DDE on top of DDV, change some wording, redraw DDE after save to AlnMgr
+*
+* Revision 1.68 2000/04/28 14:43:37 hurwitz
+* send message to DDV after edits in DDE are accepted by AlnMgr
+*
+* Revision 1.67 2000/04/27 22:24:36 lewisg
+* misc bugs
+*
+* Revision 1.66 2000/04/27 20:05:54 kans
+* added stub functions for Sequin
+*
+* Revision 1.65 2000/04/27 19:57:59 hurwitz
+* scroll to aligned block on launch of DDE
+*
+* Revision 1.64 2000/04/27 15:38:02 hurwitz
+* changed wording on menu
+*
+* Revision 1.63 2000/04/27 13:33:42 durand
+* SpacerSize min value fixed to 1; update view when SpacerSize is changed
+*
+* Revision 1.62 2000/04/26 21:54:27 hurwitz
+* added save function to tell AlnMgr about edits made in DDE
+*
+* Revision 1.61 2000/04/21 23:00:50 hurwitz
+* can launch DDE from DDV
+*
+* Revision 1.60 2000/04/18 19:50:26 lewisg
+* add deselect menu item
+*
+* Revision 1.59 2000/04/17 21:46:56 lewisg
+* do not do double index on viewmgr update, rename menus
+*
+* Revision 1.58 2000/04/10 21:41:26 lewisg
+* move alignment menus into ddv, udv from cn3d
+*
+* Revision 1.57 2000/04/10 20:58:42 hurwitz
+* added GUI controls for DeleteBlock in DDE
+*
+* Revision 1.56 2000/04/07 16:21:08 hurwitz
+* made delete block faster, added delete block to edit menu
+*
+* Revision 1.55 2000/03/31 19:33:50 durand
+* added DDV_ShowHideUnAlignGap for import seq. debugging purpose
+*
+* Revision 1.54 2000/03/27 22:15:08 lewisg
+* add show/hide row dialog
+*
+* Revision 1.53 2000/03/25 00:22:09 hurwitz
+* put DDE_StackPtr in DDV_Main, add to stack inside DDE api's, added insert char, delete char, home and end keyboard control
+*
+* Revision 1.52 2000/03/23 00:00:00 hurwitz
+* DDE api's are called with stack now
+*
+* Revision 1.51 2000/03/21 14:29:49 durand
+* fixed a problem with menus setup
+*
+* Revision 1.49 2000/03/20 22:22:48 hurwitz
+* added more checks to verify subroutine, 1 bug fix
+*
+* Revision 1.48 2000/03/17 16:15:30 durand
+* added ASN.1 SeqAlign and SeqAnoot export
+*
+* Revision 1.47 2000/03/16 20:53:48 thiessen
+* removed C++ style comment
+*
+* Revision 1.46 2000/03/16 15:51:32 hurwitz
+* added function to create an aligned block
+*
+* Revision 1.45 2000/03/16 14:11:59 durand
+* set corretly mouse mode menu
+*
+* Revision 1.44 2000/03/14 22:08:21 hurwitz
+* undo and redo working properly, restore-original function added
+*
+* Revision 1.43 2000/03/10 23:01:43 hurwitz
+* added undo and redo functions, first pass
+*
+* Revision 1.42 2000/03/09 22:28:40 hurwitz
+* added shift block and delete block, a bug fix too
+*
+* Revision 1.41 2000/03/08 22:02:07 hurwitz
+* added verify function, debugging, handle align_start != 0
+*
+* Revision 1.40 2000/03/06 22:45:58 hurwitz
+* can shift right boundary of an aligned block left and right, DDVRuler updates added
+*
+* Revision 1.39 2000/03/02 15:43:11 durand
+* use MovableModalWindow for dialog boxes
+*
+* Revision 1.38 2000/03/01 22:49:41 lewisg
+* import bioseq, neatlyindex, get rid of dead code
+*
+* Revision 1.37 2000/02/29 21:13:06 hurwitz
+* added low level functions for shifting left and right the left alignment boundary
+*
+* Revision 1.36 2000/02/28 16:28:39 hurwitz
+* added functions for deleting an aligned gap
+*
+* Revision 1.35 2000/02/24 23:37:00 hurwitz
+* added ability to insert gaps
+*
+* Revision 1.34 2000/02/18 16:06:22 hurwitz
+* for editing multiple sequence alignments: shift row right now working
+*
+* Revision 1.33 2000/02/14 20:58:57 hurwitz
+* added functions for editing multiple sequence alignments: hide/show row, move row, shift row left
+*
+* Revision 1.32 2000/02/08 14:10:42 durand
+* made extern the functions DDV_UpdateHScrollVal and
+*
+* Revision 1.31 2000/02/07 14:03:35 durand
+* replace BioseqUnlockById by BioseqUnlock
+*
+* Revision 1.30 2000/02/05 01:32:22 lewisg
+* add viewmgr, move place freeing is done in ddv, modify visual c++ projects
+*
+* Revision 1.29 2000/02/04 16:05:41 durand
+* add click action to select a row
+*
+* Revision 1.28 2000/01/26 13:38:55 durand
+* update the GUI for the editor. Add functions to create the data to be used by the editor
+*
+* Revision 1.27 2000/01/18 22:49:16 lewisg
+* send OM_MSG_FLUSH to ddv/udv, tweak CPK coloration, misc bugs
+*
+* Revision 1.26 2000/01/12 21:52:17 durand
+* add import function; update menus when DDV is loaded from Cn3D
+*
+* Revision 1.25 2000/01/12 15:49:42 durand
+* add About dlg box and fix a bug in selection
+*
+* Revision 1.24 2000/01/11 15:05:23 durand
+* remove network stuff
+*
+* Revision 1.23 2000/01/10 15:09:45 durand
+* Use Entrez instead of ID1
+*
+* Revision 1.22 1999/12/23 19:22:07 durand
+* modify default options for DDV when loaded from Cn3D
+*
+* Revision 1.21 1999/12/21 15:27:24 durand
+* avoid to quit Cn3D when closing DDV
+*
+* Revision 1.20 1999/12/20 20:20:41 lewisg
+* allow cn3d to do color and ddv to do case when both are running
+*
+* Revision 1.19 1999/12/07 21:40:14 durand
+* add mouse modes menu and caret facility for the editor
+*
+* Revision 1.18 1999/12/06 16:19:19 durand
+* add GoTo facility to DDV
+*
+* Revision 1.17 1999/12/03 23:17:23 lewisg
+* Patrick's new global update msg, argument passing when launching ddv, experimental editing
+*
+* Revision 1.16 1999/11/30 18:19:48 durand
+* fix a problem with function declaration DDV_CloseData
+*
+* Revision 1.15 1999/11/30 17:28:59 durand
+* fix a problem of redeclaration of the function DDV_CloseData
+*
+* Revision 1.14 1999/11/30 14:17:31 durand
+* fix a bug occuring when deleting a SeqAlign
+*
+* Revision 1.13 1999/11/29 15:26:26 durand
+* designed a new GUI to fix problems under MacOS, Linux and SGI
+*
+* Revision 1.12 1999/11/17 22:43:59 durand
+* speed up the selection manager for large SeqAlign
+*
+* Revision 1.11 1999/11/04 22:11:37 durand
+* add the Desktop to DDV. Add a better set of cleanup functions when closing DDV. Before creating color tables, try to get them from the SeqAlign
+*
+* Revision 1.10 1999/11/03 21:29:48 durand
+* add CTRL and SHFT keys for mouse selection. redesign the loader functions of DDV to properly register the message callbacks
+*
+* Revision 1.9 1999/10/29 19:04:59 durand
+* move DDVUpdateMSG in objmgr.h
+*
+* Revision 1.8 1999/10/29 14:15:38 durand
+* add simple mouse selection functions
+*
+* Revision 1.7 1999/10/22 20:12:47 durand
+* add Export command (text, HTML and Phylip formats)
+*
+* Revision 1.6 1999/10/20 15:01:16 durand
+* bug fixed when closing Display Styles DlgBox
+*
+* Revision 1.5 1999/10/20 13:17:19 durand
+* add display for disc. SeqAlign tails
+*
+* Revision 1.4 1999/10/16 15:02:25 durand
+* fixes due to toolkit build failed
+*
+* Revision 1.3 1999/10/15 21:57:36 durand
+* add a UI for display options
+*
+* Revision 1.2 1999/10/02 15:11:20 durand
+* update the code to reuse more functions from UDV
+*
+* Revision 1.1 1999/09/30 14:10:29 durand
+* add ddv to toolkit
+*
+* Revision 1.9 1999/09/21 14:19:08 durand
+* add mouse click management layout
+*
+* Revision 1.8 1999/09/16 13:07:53 durand
+* add File|Close and File|Open|Network commands
+*
+* Revision 1.7 1999/09/09 21:55:06 durand
+* instantiate the Fle|Close command of DDV
+*
+* Revision 1.6 1999/07/20 14:58:02 durand
+* use the Color Manager to display colored MSA
+*
+* Revision 1.5 1999/07/01 15:28:29 durand
+* validate function loaders of DDV
+*
+* Revision 1.2 1999/06/28 22:07:19 durand
+* add loader functions and clean the code with Lint and Purify
+*
+* Revision 1.1 1999/06/19 17:21:06 durand
+* add Vibrant DDV code
+*
+*
+*
+* ==========================================================================
+*/
+
+#include <ncbi.h>
+#include <vibrant.h>
+#include <udviewer.h>
+#include <ddvpanel.h>
+#include <ddvopen.h>
+#include <ddvmain.h>
+#include <ddvgraph.h>
+#include <ddvclick.h>
+#include <ddvcreate.h>
+#include <alignmgr.h>
+#include <objmgr.h>
+#include <pgppop.h>
+#include <vsm.h>
+#include <salfiles.h>
+#include <viewmgr.h>
+
+Char szAppName[]="DDV";
+Char szAppName2[]="DDE";
+
+/*local text*/
+static Char szAbout[]="DeuxD-Viewer : A sequence alignment viewer for GenBank\n\
+Version 1.0\n\nInformation Engineering Branch\n\
+NCBI - NLM - NIH, Bldg 38A\n\
+8600 Rockville Pike\n\
+Bethesda, MD 20894 - USA\n\n\
+info@ncbi.nlm.nih.gov";
+
+#ifdef DEBUG_DDV
+static void DDV_ShowHideUnAlignGap(IteM i);
+#endif
+static void DDV_ExportTexte(IteM i);
+static void UDV_GotoBtnProc(ButtoN g);
+static void DDV_DeleteRow(IteM i);
+static void DDV_MoveRowLeft(IteM i);
+static void DDV_MoveRowRight(IteM i);
+static void DDV_MoveLeftBoundaryLeft(IteM i);
+static void DDV_MoveLeftBoundaryRight(IteM i);
+static void DDV_MoveRightBoundaryLeft(IteM i);
+static void DDV_MoveRightBoundaryRight(IteM i);
+static void DDV_DeleteBlock(IteM i);
+static void DDV_CreateBlock(IteM i);
+static void DDV_Prev(IteM i);
+static void DDV_Next(IteM i);
+static void DDV_Orig(IteM i);
+static void DDV_DoEditFunction(IteM i, Int4 WhichOne);
+static void DDV_LaunchEditor(IteM i);
+static void DDV_MergeBlocks(IteM i);
+static void DDV_SplitBlock(IteM i);
+static void DDV_DeleteBlock2(IteM i);
+static void DDV_CallSaveEdits(IteM i);
+
+/*******************************************************************************
+
+ Function : DDV_AboutProc()
+
+ Purpose : about dialog box
+
+ Parameters : -
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_AboutProc(IteM i)
+{
+ MsgAlert(KEY_OK, SEV_INFO, "About DeuxD-Viewer",szAbout);
+}
+
+/*******************************************************************************
+
+ Function : DDV_EnableGotoTBItems()
+
+ Purpose : enable/disable the controls for "GoTo col,row" toolbar
+
+ Return value : none
+
+*******************************************************************************/
+typedef void (*MyEnaDisable) (Handle a);
+extern void DDV_EnableGotoTBItems(WindoW hParent,Boolean bEnable)
+{
+DdvMainWinPtr dmwp;
+MyEnaDisable my_func;
+
+ dmwp=(DdvMainWinPtr)GetObjectExtra(hParent);
+ if (!dmwp) return;
+
+ if (bEnable)
+ my_func=Enable;
+ else
+ my_func=Disable;
+
+ my_func(dmwp->gotoBtn);
+ my_func(dmwp->gotoValCol);
+ my_func(dmwp->gotoValRow);
+}
+
+
+/*******************************************************************************
+
+ Function : DDV_WhatSize()
+
+ Purpose : compute nTotLines and nTotCol depending on the display type
+
+ Parameters : -
+
+ Return value : -
+
+*******************************************************************************/
+extern void DDV_WhatSize(DdvMainPtr dmp)
+{
+Int4 i;
+ParaGPtr pgp;
+
+ if (dmp==NULL) return;
+
+ dmp->GrData.udv_panel.nTotLines=0;
+
+ if (dmp->MSA_d.pgp_l.DisplayType==0) return;
+ if(dmp->MSA_d.pgp_l.DisplayType==DDV_DISP_HORZ){
+ for(i=0;i<dmp->MSA_d.pgp_l.nBsp;i++){
+ if (dmp->MSA_d.pgp_l.TableHead[i]->data.ptrvalue){
+ pgp=(ParaGPtr)(dmp->MSA_d.pgp_l.TableHead[i]->data.ptrvalue);
+ dmp->GrData.udv_panel.nTotLines+=pgp->nLines;
+ }
+ }
+ dmp->GrData.udv_panel.nTotCol=dmp->MSA_d.pgp_l.LengthAli;
+ }
+ else{/*full vertical display*/
+ /*not yet implemented*/
+ return;/*add to avoid a 'lint' warning*/
+ }
+}
+
+/*******************************************************************************
+
+ Function : DDV_CalcVHScrollPgUD()
+
+ Purpose : compute PageUp & Down (V & H Scrolls)
+
+ Parameters : cxyClient; either width of height of DDV panel
+ LineHeight; either width of a col. or height of one data line
+
+ Return value : PageUpDn
+
+*******************************************************************************/
+static Int4 DDV_CalcVHScrollPgUD(Int2 cxy_Client,Int2 LineColSize)
+{
+ return((Int4)(cxy_Client/LineColSize));
+}
+
+/*******************************************************************************
+
+ Function : DDV_UpdateVScrollVal()
+
+ Purpose : update the DDV VScroll bar
+
+ Parameters : p; handel of the DDV panel
+ bInit; TRUE only when the DDV is created
+ CurPos ; new position
+
+ Return value : none
+
+*******************************************************************************/
+extern void DDV_UpdateVScrollVal(PaneL p,Boolean bInit,Int4 CurPos)
+{
+BaR vsb;
+DdvMainPtr dmp;
+
+ dmp = (DdvMainPtr) GetObjectExtra((Handle)p);
+ /*GetAppProperty("DDV_MAIN_DATA");*/
+ if (dmp==NULL) return;
+
+ /*current scroll status*/
+ vsb = GetSlateVScrollBar ((SlatE) p);
+
+ if (bInit) CurPos=0;
+
+ /*given curpos (lineNumber) retrieve letter number*/
+
+ /*compute new values*/
+ dmp->GrData.udv_vscrl.ScrollPage=
+ DDV_CalcVHScrollPgUD((Int2)(dmp->GrData.udv_panel.cyClient-
+ 3*dmp->GrData.udv_panel.cyScale/2-5),
+ dmp->GrData.udv_font.LineHeight);
+
+ if (dmp->GrData.udv_panel.nTotLines>dmp->GrData.udv_vscrl.ScrollPage){
+ dmp->GrData.udv_vscrl.ScrollMax=dmp->GrData.udv_panel.nTotLines-
+ dmp->GrData.udv_vscrl.ScrollPage+3/**/;
+ }
+ else{
+ dmp->GrData.udv_vscrl.ScrollMax=0;
+ dmp->GrData.udv_vscrl.ScrollPos=0;
+ dmp->GrData.udv_vscrl.ScrollPage=0;
+ }
+
+ if (CurPos<0) CurPos=0;
+
+ if (CurPos>=dmp->GrData.udv_vscrl.ScrollMax)
+ dmp->GrData.udv_vscrl.ScrollPos=dmp->GrData.udv_vscrl.ScrollMax;
+ else dmp->GrData.udv_vscrl.ScrollPos=CurPos;
+
+ /*update scroll*/
+ CorrectBarMax(vsb,dmp->GrData.udv_vscrl.ScrollMax);
+ CorrectBarValue(vsb,dmp->GrData.udv_vscrl.ScrollPos);
+ CorrectBarPage(vsb,dmp->GrData.udv_vscrl.ScrollPage,
+ dmp->GrData.udv_vscrl.ScrollPage);
+
+}
+
+/*******************************************************************************
+
+ Function : DDV_UpdateHScrollVal()
+
+ Purpose : update the DDV HScroll bar
+
+ Parameters : p; handel of the DDV panel
+ bInit; TRUE only when the DDV is created
+ CurPos ; new position
+
+ Return value : none
+
+*******************************************************************************/
+extern void DDV_UpdateHScrollVal(PaneL p,Boolean bInit,Int4 CurPos)
+{
+BaR hsb;
+DdvMainPtr dmp;
+
+ dmp = (DdvMainPtr) GetObjectExtra((Handle)p);
+ if (dmp==NULL) return;
+
+ /*current scroll status*/
+ hsb = GetSlateHScrollBar ((SlatE) p);
+ if (!hsb) return;/*not always present*/
+
+ if (bInit) CurPos=0;
+
+ /*given curpos (lineNumber) retrieve letter number*/
+
+ /*compute new values*/
+ dmp->GrData.udv_hscrl.ScrollPage=
+ DDV_CalcVHScrollPgUD((Int2)(dmp->GrData.udv_panel.cxClient-
+ dmp->GrData.udv_panel.cxName),
+ dmp->GrData.udv_font.ColWidth);
+
+ if (dmp->GrData.udv_panel.nTotCol>dmp->GrData.udv_hscrl.ScrollPage){
+ dmp->GrData.udv_hscrl.ScrollMax=dmp->GrData.udv_panel.nTotCol-
+ dmp->GrData.udv_hscrl.ScrollPage+5/**/;
+ }
+ else{
+ dmp->GrData.udv_hscrl.ScrollMax=0;
+ dmp->GrData.udv_hscrl.ScrollPos=0;
+ dmp->GrData.udv_hscrl.ScrollPage=0;
+ }
+
+ if (CurPos<0) CurPos=0;
+
+ if (CurPos>=dmp->GrData.udv_hscrl.ScrollMax)
+ dmp->GrData.udv_hscrl.ScrollPos=dmp->GrData.udv_hscrl.ScrollMax;
+ else dmp->GrData.udv_hscrl.ScrollPos=CurPos;
+
+ /*update scroll*/
+ CorrectBarMax(hsb,dmp->GrData.udv_hscrl.ScrollMax);
+ CorrectBarValue(hsb,dmp->GrData.udv_hscrl.ScrollPos);
+ CorrectBarPage(hsb,dmp->GrData.udv_hscrl.ScrollPage,
+ dmp->GrData.udv_hscrl.ScrollPage);
+
+}
+
+
+/*****************************************************************************
+
+ Function : DDV_VHScrl()
+
+ Purpose : DD Viewer Horizontal/Vertical Scroll Bar function
+
+ Parameters : p; viewer
+ vdp; viewer data structure
+ newval; new value of the thumb
+ oldval; old value of the thumb
+ IsVscroll; TRUE means Vertical scrollbar
+
+ Note : this function can be used to scroll the panel for any reasons.
+
+ Return value : none
+
+*****************************************************************************/
+extern void DDV_VHScrl(PaneL p,UnDViewerGraphDataPtr gdp, Int4 newval, Int4 oldval,
+ Boolean IsVscroll)
+{
+ RecT rcP;
+ WindoW temport;
+ Int4 n,limit;
+ Int2 dx,dy;
+ DdvMainPtr dmp;
+
+ if (!gdp || !p) return;
+
+ dmp = (DdvMainPtr) GetObjectExtra(p);
+ if (dmp==NULL) return;
+
+ /*compute scroll offset*/
+ if (oldval>newval)n=oldval-newval;
+ else n=newval-oldval;
+
+ temport=SavePort(ParentWindow((WindoW)p));
+ Select(p);
+ ObjectRect(p,&rcP);
+ InsetRect(&rcP,4,4);
+ /*drawing region:*/
+ DDV_AdjustDrawingRect(&rcP, &(gdp->udv_font), dmp);
+
+ if (IsVscroll){/*Vertical scroll*/
+ gdp->udv_vscrl.ScrollPos=newval;
+ limit=(Int4)gdp->udv_vscrl.ScrollPage;
+ dx=0;
+ dy=(Int2)((oldval-newval)*gdp->udv_font.LineHeight);
+ rcP.top+=3*gdp->udv_panel.cyScale/2;
+ }
+ else{/*horizontal scroll*/
+ gdp->udv_hscrl.ScrollPos=newval;
+ limit=(Int4)gdp->udv_hscrl.ScrollPage;
+ dx=(Int2)((oldval-newval)*gdp->udv_font.ColWidth);
+ dy=0;
+ rcP.left+=(gdp->udv_panel.cxName+gdp->udv_scale.cxLeftScale);
+ }
+
+ ClipRect(&rcP);
+
+ if (n<limit){/*Line UP/Down or Column left/right*/
+ ScrollRect (&rcP, dx, dy);
+ }
+ else{/*Page Up/Down or Page left/right*/
+ InvalRect(&rcP);
+ }
+ ResetClip();
+ RestorePort(temport);
+ Update ();
+}
+
+/*****************************************************************************
+
+ Function : DDV_VScrlProc()
+
+ Purpose : DD Viewer Vertical Scroll Bar Callback
+
+ Parameters : see vibrant library
+
+ Return value : none
+
+*****************************************************************************/
+extern void DDV_VScrlProc (BaR sb, SlatE s, Int4 newval, Int4 oldval)
+{
+
+DdvMainPtr dmp;
+
+ /*get the application data*/
+ dmp = (DdvMainPtr) GetObjectExtra((Handle)s);
+ if (dmp==NULL) return;
+
+ DDV_VHScrl((PaneL)s,&(dmp->GrData),newval,oldval,TRUE);
+}
+
+/*****************************************************************************
+
+ Function : DDV_HScrlProc()
+
+ Purpose : DD Viewer Horizontal Scroll Bar Callback
+
+ Parameters : see vibrant library
+
+ Return value : none
+
+*****************************************************************************/
+extern void DDV_HScrlProc (BaR sb, SlatE s, Int4 newval, Int4 oldval)
+{
+
+DdvMainPtr dmp;
+
+ /*get the application data*/
+ dmp = (DdvMainPtr) GetObjectExtra((Handle)s);
+ if (dmp==NULL) return;
+
+ DDV_VHScrl((PaneL)s,&(dmp->GrData),newval,oldval,FALSE);
+}
+
+/*****************************************************************************
+
+Function: DDV_InitPanelData()
+
+Purpose: Init numerical values for DDViewer. Called one times at the
+ start of the soft.
+
+Return value: none (results are in sdp)
+
+*****************************************************************************/
+extern void DDV_InitPanelData(UDVPanelDataPtr pdp)
+{
+ pdp->cxClient=0;
+ pdp->cyClient=0;
+ pdp->nTotLines=0;
+ pdp->nTotCol=0;
+ pdp->nCharByLine=DDV_DEFAULT_PARAG_SIZE;
+ pdp->nBlockByLine=0;
+ pdp->ShowFeatures=FALSE;
+ pdp->ShowScale=TRUE;
+ pdp->ShowByBlock=FALSE;
+}
+
+/*****************************************************************************
+
+ Function : DDV_SetupWin()
+
+ Purpose : resize DD viewer panel
+
+ Parameters : w; handle of the DD viewer window
+ bInit; is the window new?
+
+*****************************************************************************/
+extern void DDV_SetupWin (WindoW w,Boolean bInit)
+{
+RecT rWin, rButton;
+RecT rStatus1, rStatus2, rPanel1, rPanel2;
+Int2 height,diff,gap,width;
+DdvMainWinPtr dmwp;
+
+ dmwp=(DdvMainWinPtr)GetObjectExtra(w);
+
+ ObjectRect(w,&rWin);
+ width= rWin.right-rWin.left;
+
+ GetPosition(dmwp->StatusGroup,&rStatus1);
+ diff=rStatus1.bottom-rStatus1.top;
+ gap= 4;
+
+ ObjectRect(dmwp->gotoBtn, &rButton);
+ height= rWin.bottom - rWin.top - rButton.bottom - gap;
+
+ if(GetStatus(dmwp->MainMenu.ShowLowerPanel)) {
+ Show(dmwp->LowerInfoPanel);
+ Show(dmwp->StatusGroupLower);
+ Show(dmwp->hLowerPanel);
+
+ rPanel1.right = width;
+ rPanel1.left = 0;
+ rPanel1.top = rButton.bottom + gap;
+ rPanel1.bottom = rPanel1.top + 2*height/3 - diff;
+
+ rStatus1.right = rPanel1.right;
+ rStatus1.left = rPanel1.left;
+ rStatus1.top = rPanel1.bottom;
+ rStatus1.bottom = rStatus1.top + diff;
+
+ rPanel2.right = rPanel1.right;
+ rPanel2.left = rPanel1.left;
+ rPanel2.top = rStatus1.bottom;
+ rPanel2.bottom = rPanel2.top + height/3 - diff;
+
+ rStatus2.right = rPanel1.right;
+ rStatus2.left = rPanel1.left;
+ rStatus2.top = rPanel2.bottom;
+ rStatus2.bottom = rStatus2.top + diff;
+
+
+ SetPosition (dmwp->StatusGroup, &rStatus1);
+ SetPosition (dmwp->UpperInfoPanel, &rStatus1);
+ SetPosition (dmwp->StatusGroupLower, &rStatus2);
+ SetPosition (dmwp->LowerInfoPanel, &rStatus2);
+ SetPosition (dmwp->hUpperPanel, &rPanel1);
+ SetPosition (dmwp->hLowerPanel, &rPanel2);
+ } else {
+ Hide(dmwp->LowerInfoPanel);
+ Hide(dmwp->StatusGroupLower);
+ Hide(dmwp->hLowerPanel);
+
+ /* set focus */
+ dmwp->hWndDDV = dmwp->hUpperPanel;
+ DDV_SetMenuFocus(w);
+ dmwp->InfoPanel = dmwp->UpperInfoPanel;
+ SetTitle(dmwp->InfoPanel,"Ready !");
+ SetTitle(dmwp->LowerInfoPanel,"");
+
+ rPanel1.right = width;
+ rPanel1.left = 0;
+ rPanel1.top = rButton.bottom + gap;
+ rPanel1.bottom = rPanel1.top + height - diff;
+
+ rStatus1.right = rPanel1.right;
+ rStatus1.left = rPanel1.left;
+ rStatus1.top = rPanel1.bottom;
+ rStatus1.bottom = rStatus1.top + diff;
+
+ SetPosition (dmwp->StatusGroup, &rStatus1);
+ SetPosition (dmwp->UpperInfoPanel, &rStatus1);
+ SetPosition (dmwp->hUpperPanel, &rPanel1);
+ }
+ AdjustPrnt (dmwp->hUpperPanel, &rPanel1, FALSE);
+
+/* Update();*/
+}
+
+/*****************************************************************************
+
+ Function : DDV_ResizeDDV
+
+ Purpose : update DDV panel (size and scrolls)
+
+ Parameters : p; DDV panel
+ bInit; TRUE only when DDV panel is created
+
+ Return value : none
+
+*****************************************************************************/
+extern void DDV_Resize_DDV (PaneL p, Boolean bInit)
+{
+DdvMainPtr dmp;
+RecT rcP;
+Int4 vCurPos,hCurPos;
+BaR vsb,hsb;
+WindoW temport;
+
+ if (!p) return;
+ dmp = (DdvMainPtr) GetObjectExtra((Handle)p);
+ if (dmp==NULL) return;
+
+ GetPosition(p, &rcP);
+ /*panels of DDV; */
+
+ UDV_ComputePanelSize(rcP,&(dmp->GrData.udv_panel.cxClient),
+ &(dmp->GrData.udv_panel.cyClient));
+
+ temport=SavePort(ParentWindow(p));
+ Select(p);
+
+ /*current scroll status*/
+ vsb = GetSlateVScrollBar ((SlatE) p);
+ vCurPos=GetBarValue(vsb);
+ hsb = GetSlateHScrollBar ((SlatE) p);
+ hCurPos=GetBarValue(hsb);
+
+ /*update scrolls*/
+ DDV_UpdateVScrollVal(p,bInit,vCurPos);
+ DDV_UpdateHScrollVal(p,bInit,hCurPos);
+
+ InvalRect(&rcP);
+ RestorePort(temport);
+}
+
+/*****************************************************************************
+
+ Function : DDV_WinMainResize()
+
+ Purpose : Main Window Resize function
+
+ Parameters : w; handle of the parent window
+
+ Return value : none
+
+*****************************************************************************/
+extern void DDV_WinMainResize (WindoW w)
+{
+ DdvMainWinPtr mWin_d;
+
+ mWin_d = (DdvMainWinPtr) GetObjectExtra(w);
+ if(mWin_d == NULL) return;
+
+ DDV_SetupWin (w,FALSE);
+ DDV_Resize_DDV (mWin_d->hUpperPanel, FALSE);
+ DDV_Resize_DDV (mWin_d->hLowerPanel, FALSE);
+ Update();
+}
+
+/*****************************************************************************
+
+Function: DDV_CleanupDDVPdata() & DDV_FreeDDVPdata()
+
+Purpose: delete the data attached to the DDV panel
+
+Return value: none
+
+*****************************************************************************/
+static void DDV_FreeDDVPdata(DdvMSADataPtr dmdp,Uint2 userkey,Uint2 procid,
+ Uint2 proctype)
+{
+ParaGPtr pgp;
+BioseqPtr bsp;
+Int4 i;
+Uint2 bsp_eID;
+
+ if (!dmdp) return;
+ /*before deleting the list of ParaG, I need to delete the user object
+ containing the Msg Func*/
+ if (userkey>0 && procid>0 && proctype>0) {
+ for(i=0;i<dmdp->pgp_l.nBsp;i++){
+ pgp=(ParaGPtr)(dmdp->pgp_l.TableHead[i]->data.ptrvalue);
+ bsp=BioseqLockById(pgp->sip);
+ if (bsp != NULL){
+ bsp_eID=ObjMgrGetEntityIDForPointer((Pointer)bsp);
+ BioseqUnlock(bsp);
+ if (bsp_eID>0 && bsp_eID!=dmdp->entityID){
+ ObjMgrFreeUserData(bsp_eID,procid,proctype,userkey);
+ }
+ }
+ }
+ }
+
+ if (dmdp->pgp_l.TableHead) {
+ DDV_DeleteDisplayList(&dmdp->pgp_l);
+ dmdp->pgp_l.TableHead=NULL;
+ }
+ if (dmdp->pgp_l.DisplayVert) {
+ UDV_FreeListParaG(&dmdp->pgp_l.DisplayVert);
+ dmdp->pgp_l.DisplayVert=NULL;
+ }
+ if (dmdp->pgp_l.sabp) {
+ CleanupBlocks(dmdp->pgp_l.sabp);
+ dmdp->pgp_l.sabp=NULL;
+ }
+ if (dmdp->pgp_l.bspp) {
+ dmdp->pgp_l.bspp=DDV_BspInfoDeleteList(dmdp->pgp_l.bspp);
+ dmdp->pgp_l.bspp=NULL;
+ }
+ if (dmdp->pgp_l.RulerDescr) {
+ ValNodeFreeData(dmdp->pgp_l.RulerDescr);
+ dmdp->pgp_l.RulerDescr=NULL;
+ }
+ if (dmdp->pgp_l.entitiesTbl) {
+ MemFree(dmdp->pgp_l.entitiesTbl);
+ dmdp->pgp_l.entitiesTbl=NULL;
+ }
+
+ /* no rows, no cols */
+ dmdp->pgp_l.LengthAli = 0;
+ dmdp->pgp_l.nBsp = 0;
+
+ if(dmdp->entityID != 0)
+ ObjMgrFreeUserData(dmdp->entityID,procid,proctype,userkey);
+ dmdp->entityID=0;
+ dmdp->itemID=0;
+}
+
+extern void DDV_CleanupDDVPdata_g (DdvMainPtr dmp)
+{
+ValNodePtr vnp;
+
+ /*SeqAlign Idx & ParaG List*/
+ DDV_FreeDDVPdata(&(dmp->MSA_d),dmp->userkey,dmp->procid,dmp->proctype);
+ /*graphical data*/
+ DDV_InitDefSAPdispStyles(&(dmp->ddo));
+ ClearUDV_mouse_select(&(dmp->ms));
+ dmp->ms.Action_type=MS_ACTION_FEAT_NOTHING;
+ dmp->procid=0;
+ dmp->proctype=0;
+ dmp->userkey=0;
+
+ switch(dmp->dod.choice){
+ case DDV_OPENTYPE_NOTRESP:
+ break;
+ case DDV_OPENTYPE_FILE:
+ vnp=dmp->dod.vnp;
+ while(vnp){
+ ObjMgrFree(vnp->choice, (Pointer)vnp->data.ptrvalue);
+ vnp=vnp->next;
+ }
+ ValNodeFree(dmp->dod.vnp);
+ break;
+ case DDV_OPENTYPE_SEP:
+ case DDV_OPENTYPE_GI:
+ if (dmp->dod.sep) SeqEntryFree(dmp->dod.sep);
+ break;
+ }
+ memset(&(dmp->dod),0,sizeof(DdvOpenData));
+
+ /*delete list of SeqAligns*/
+ if (dmp->vnp_ali){
+ dmp->vnp_ali=ValNodeFree(dmp->vnp_ali);
+ }
+
+ memset(&dmp->GrData.udv_vscrl,0,sizeof(UDVScrollData));
+ memset(&dmp->GrData.udv_hscrl,0,sizeof(UDVScrollData));
+ dmp->GrData.udv_panel.nTotLines=0;
+ dmp->GrData.udv_panel.nTotCol=0;
+
+ /*colors; deleted only by the autonomous DDV*/
+/* if (bRemoveBioseq && dmp->Globals.colorp){
+ DDV_DeleteColorGlobal(dmp->Globals.colorp);*/
+ dmp->Globals.colorp=NULL;
+/* }*/
+
+}
+
+/*WindoW callback*/
+static void DDV_CleanupDDVPdata (GraphiC g, VoidPtr data)
+{
+DdvMainPtr dmp;
+
+ if (data){
+ dmp=(DdvMainPtr)data;
+ if (dmp->bEditor) {
+ DDE_FreeStack(dmp->dsp);
+ }
+ DDV_CleanupDDVPdata_g (dmp);
+ }
+}
+
+
+static PaneL DDV_PanelInit(GrouP g, WindoW w,DdvMainWinPtr dmwp,
+ SAM_ViewGlobal *vgp, Boolean bEditor,
+ Nlm_PnlClckProc ClickProc, Int4 Width)
+{
+ PaneL p;
+ DdvMainPtr dmp;
+ Int2 Margins;
+
+ Margins=20*stdCharWidth;
+
+ /*init data blocks*/
+ dmp=(DdvMainPtr)MemNew(sizeof(DdvMain));
+ if (!dmp) return(FALSE);
+
+ /*init default SeqAlign display options for standalon DDV and for
+ DDV started from Cn3D*/
+ if (dmwp->AutonomeViewer)
+ dmp->MasterViewer=SAMVIEWDDV;
+ if(vgp == NULL) {
+ DDV_InitDefSAPdispStyles(&(dmp->ddo));
+ }
+ else if(vgp->MasterViewer == SAMVIEWCN3D) {
+ DDV_InitCn3DSAPdispStyles(&(dmp->ddo));
+ dmp->MouseMode=DDV_MOUSEMODE_SELECT;
+ }
+
+ dmp->ms.Action_type=MS_ACTION_FEAT_NOTHING;
+
+ if(vgp == NULL)
+ p = AutonomousPanel4 (g,
+ (Int2)2*((screenRect.right-screenRect.left)-Margins)/3,
+ (Int2)2*((screenRect.bottom-screenRect.top)-Margins)/Width,
+ DDV_DrawViewer,DDV_VScrlProc,DDV_HScrlProc,
+ sizeof(DdvMainPtr),NULL,NULL);
+ else
+ p = AutonomousPanel4 (g,
+ (Int2)vgp->Rect.right - vgp->Rect.left,
+ (Int2)vgp->Rect.bottom - vgp->Rect.top,
+ DDV_DrawViewer,DDV_VScrlProc,DDV_HScrlProc,
+ sizeof(DdvMainPtr),NULL,NULL);
+
+ if(!p) return NULL;
+
+ Nlm_SetSlateBorder ((SlatE) p, FALSE);
+ SetPanelClick(p,ClickProc,
+ DDV_DragProc,DDV_HoldProc,DDV_ReleaseProc);
+ SetSlateChar ((SlatE) p, DDV_KeyboardProc);
+
+ SetObjectExtra (p, (Pointer) dmp, (FreeProc)DDV_CleanupDDVPdata);
+
+ dmp->hWndDDV=p;
+ dmp->hParent=w;
+ dmp->bEditor=bEditor;
+ if (!dmp->bEditor){
+ dmp->deri.curEditRow=(Int4)-1;
+ dmp->deri.curMasterRow=(Int4)0;
+ }
+ UDV_InitFont(&(dmp->GrData.udv_font));
+ SelectFont(dmp->GrData.udv_font.hFnt);
+ UDV_FontDim(&(dmp->GrData.udv_font.cxChar),&(dmp->GrData.udv_font.cyChar));
+
+ /*init the graphical elements of DDV*/
+ DDV_InitGraphGlobal(dmp);
+ return p;
+}
+
+/*****************************************************************************
+
+Function: DDV_CreateViewerPanel()
+
+Purpose: create the Viewer main panel
+
+Return value: none
+
+*****************************************************************************/
+extern Boolean DDV_CreateViewerPanel(WindoW w,DdvMainWinPtr dmwp,
+ SAM_ViewGlobal *vgp, Boolean bEditor)
+{
+PaneL p, p2;
+GrouP g,g2,StatusGroup,StatusGroupLower;
+ButtoN gotoBtn;
+TexT gotoRowTxt,gotoColTxt;
+PrompT info, infoLower;
+FonT hFnt;
+Int2 cxChar,cyChar;
+
+
+#ifdef WIN_MAC
+ hFnt = ParseFont ("Monaco, 9");
+#endif
+
+#ifdef WIN_MSWIN
+ hFnt = ParseFont ("Courier, 7");
+#endif
+
+#ifdef WIN_MOTIF
+ hFnt = ParseFont ("fixed, 12");
+#endif
+
+ SelectFont (hFnt);
+ cxChar=MaxCharWidth();
+ cyChar=LineHeight();
+ g = HiddenGroup (w, 5, 0, NULL);
+ gotoBtn = PushButton (g, "Go to:",UDV_GotoBtnProc);
+ StaticPrompt (g, "row:", 0, 3*cyChar/2, hFnt, 'l');
+ gotoRowTxt = DialogText (g, "0", (Int2)4, NULL);
+ StaticPrompt (g, "col:", 0, 3*cyChar/2, hFnt, 'l');
+ gotoColTxt = DialogText (g, "0", (Int2)4, NULL);
+
+ g = HiddenGroup (w, 1, 2, NULL);
+ g2 = HiddenGroup(g,1,1,NULL);
+ DDV_SetupMenus(w,dmwp->UseNetwork,bEditor, vgp);
+ p=DDV_PanelInit(g2, w, dmwp, vgp, bEditor, DDV_ClickProcUpper, 4);
+ if(!p) return FALSE;
+ dmwp->hUpperPanel = p; /*handle of the upper DDV panel (the multiple)*/
+ dmwp->hWndDDV=p; /* default focus */
+
+ StatusGroup = HiddenGroup (g, 1, 1, NULL);
+ info = StaticPrompt (StatusGroup, "Ready !", 0, 3*cyChar/2, hFnt, 'l');
+
+ g2 = HiddenGroup (g, 1, 1, NULL);
+ p2=DDV_PanelInit(g2, w, dmwp, vgp, bEditor, DDV_ClickProcLower, 6);
+ if(!p) return FALSE;
+ dmwp->hLowerPanel = p2; /*handle of the DDV panel (the pairwise) */
+
+ StatusGroupLower = HiddenGroup (g, 1, 0, NULL);
+ infoLower = StaticPrompt (StatusGroupLower, "", 0, 3*cyChar/2, hFnt, 'l');
+
+ AlignObjects(ALIGN_RIGHT, (HANDLE) p,(HANDLE) StatusGroup,(HANDLE) p2,
+ (HANDLE) StatusGroupLower, NULL);
+
+ if (gotoBtn==NULL || gotoRowTxt==NULL ||
+ gotoColTxt==NULL || info==NULL || infoLower == NULL)
+ return(FALSE);
+
+ SetWindowTimer (w, DDV_TimerProc);
+
+ dmwp->gotoBtn=gotoBtn;
+ dmwp->gotoValRow=gotoRowTxt;
+ dmwp->gotoValCol=gotoColTxt;
+ dmwp->StatusGroup=StatusGroup;
+ dmwp->StatusGroupLower=StatusGroupLower;
+ dmwp->InfoPanel=info;
+ dmwp->UpperInfoPanel = info;
+ dmwp->LowerInfoPanel = infoLower;
+
+ DDV_SetMenuFocus(w);
+ Disable(dmwp->gotoBtn);
+ Disable(dmwp->gotoValRow);
+ Disable(dmwp->gotoValCol);
+ /*init graph objects: call UDV functions ...*/
+
+
+ return(TRUE);
+}
+
+/*******************************************************************************
+
+ Function : DDV_WinMainProgQuit()
+
+ Purpose : end of prog
+
+ Parameters : w; main window handle
+
+ Return value : none
+
+*******************************************************************************/
+extern void DDV_WinMainProgQuit(WindoW w)
+{
+ QuitProgram();
+}
+
+/*******************************************************************************
+
+ Function : QuitProc()
+
+ Purpose : bye-bye procedure !
+
+ Parameters : i; menu item which has called this function
+
+ Return value : none
+
+*******************************************************************************/
+static void QuitProc(IteM i)
+{
+WindoW hWinMain;
+
+ hWinMain=(WindoW)ParentWindow(i);
+ if (!hWinMain) return;
+ DDV_SlaveQuit(hWinMain);
+}
+
+NLM_EXTERN void DDV_Save(ButtoN g) {
+/*----------------------------------------------------------------------------
+* save edits, quit pop-up, quit DDE
+*---------------------------------------------------------------------------*/
+ WindoW hDialog;
+ WindoW hWinMain;
+ DdvMainWinPtr mWin_d;
+ DdvMainPtr dmp;
+
+ /* quit pop-up */
+ hDialog = (WindoW)ParentWindow(g);
+ if (!hDialog) return;
+ Remove(hDialog);
+
+ /* save the edits */
+ hWinMain = (WindoW) GetObjectExtra(hDialog);
+ mWin_d = (DdvMainWinPtr) GetObjectExtra(hWinMain);
+ dmp = (DdvMainPtr) GetObjectExtra(mWin_d->hWndDDV);
+ DDV_SaveEdits(dmp, TRUE);
+
+ /* quit DDE */
+ if (mWin_d->AutonomeViewer)
+ QuitProgram(); /*standalone DDV*/
+ else
+ Remove(hWinMain);/*slave viewer : just kill the main window*/
+}
+
+
+NLM_EXTERN void DDV_NoSave(ButtoN g) {
+/*----------------------------------------------------------------------------
+* quit pop-up, quit DDE
+*---------------------------------------------------------------------------*/
+ WindoW hDialog;
+ WindoW hWinMain;
+ DdvMainWinPtr mWin_d;
+
+ /* quit the pop-up */
+ hDialog = (WindoW)ParentWindow(g);
+ if (!hDialog) return;
+ Remove(hDialog);
+
+ /* quit DDE */
+ hWinMain = (WindoW) GetObjectExtra(hDialog);
+ mWin_d = (DdvMainWinPtr) GetObjectExtra(hWinMain);
+ if (mWin_d->AutonomeViewer)
+ QuitProgram(); /*standalone DDV*/
+ else
+ Remove(hWinMain);/*slave viewer : just kill the main window*/
+}
+
+
+NLM_EXTERN void DDV_Cancel(ButtoN g) {
+/*----------------------------------------------------------------------------
+* quit pop-up
+*---------------------------------------------------------------------------*/
+ WindoW hDialog;
+
+ /* quit the pop-up */
+ hDialog = (WindoW)ParentWindow(g);
+ if (!hDialog) return;
+ Remove(hDialog);
+}
+
+
+/*******************************************************************************
+
+ Function : DDV_CloseData()
+
+ Purpose : bye-bye data, i.e. use that function to delete all the data
+ loaded within DDV.
+
+ Parameters : mWin_d; main data block
+
+ Return value : none
+
+*******************************************************************************/
+extern void DDV_CloseData(DdvMainWinPtr mWin_d,Boolean bFinalExit)
+{
+
+ WatchCursor();
+ /*dmp=(DdvMainPtr)GetObjectExtra(mWin_d->hWndDDV);*/
+
+ /*DDV_CleanupDDVPdata_g(dmp);*/
+ if (!bFinalExit)
+ DDV_SetupWin (mWin_d->hWndMain,TRUE);
+ ArrowCursor();
+}
+
+
+NLM_EXTERN void DDV_FileCloseIt(WindoW hWinMain) {
+/*----------------------------------------------------------------------------
+* part of DDV_FileClose
+*---------------------------------------------------------------------------*/
+ DdvMainPtr dmp;
+ DdvMainWinPtr mWin_d;
+ RecT rc;
+
+ mWin_d = (DdvMainWinPtr) GetObjectExtra((Handle)hWinMain);
+ if (mWin_d==NULL) return;
+
+ /* delete data */
+ dmp=(DdvMainPtr)GetObjectExtra(mWin_d->hWndDDV);
+ DDV_CleanupDDVPdata_g(dmp);
+ DDV_CloseData(mWin_d,FALSE);
+ DDV_EnableGotoTBItems(hWinMain,FALSE);
+
+ /* blank the panel that's closed */
+ mWin_d->Show_logo=FALSE;
+ ObjectRect(mWin_d->hUpperPanel, &rc);
+ InvalRect(&rc);
+ ObjectRect(mWin_d->hLowerPanel, &rc);
+ InvalRect(&rc);
+
+ Update();
+}
+
+
+/*******************************************************************************
+
+ Function : DDV_FileClose()
+
+ Purpose : close a SeqAlign
+
+ Parameters : i; menu item which has called this function
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_FileClose(IteM i)
+{
+ WindoW hWinMain;
+
+ hWinMain=(WindoW)ParentWindow(i);
+ if (!hWinMain) return;
+
+ DDV_FileCloseIt(hWinMain);
+ return;
+}
+
+
+#ifdef DEBUG_DDV
+static Uint1 DDV_GetCurrentUAGAPStyle(MsaParaGPopListPtr mpplp)
+{
+Int4 j;
+ValNodePtr vnp,vnp2;
+ParaGPtr pgp;
+MsaTxtDispPtr mtdp;
+
+ if (mpplp->TableHead){
+ for(j=0;j<mpplp->nBsp;j++){
+ vnp=mpplp->TableHead[j];
+ while(vnp){
+ pgp=(ParaGPtr)vnp->data.ptrvalue;
+ if (pgp){
+ vnp2=pgp->ptxtList;
+ while(vnp2){
+ mtdp=(MsaTxtDispPtr)vnp2->data.ptrvalue;
+ if (mtdp->IsUnAligned && mtdp->IsGap){
+ return(mtdp->TextStyle);
+ }
+ vnp2=vnp2->next;
+ }
+ }
+ vnp=vnp->next;
+ }
+ }
+ }
+ return(0);
+}
+
+static void DDV_SetCurrentUAGAPStyle(MsaParaGPopListPtr mpplp,Uint1 UATextStyle)
+{
+Int4 j;
+ValNodePtr vnp,vnp2;
+ParaGPtr pgp;
+MsaTxtDispPtr mtdp;
+
+ if (mpplp->TableHead){
+ for(j=0;j<mpplp->nBsp;j++){
+ vnp=mpplp->TableHead[j];
+ while(vnp){
+ pgp=(ParaGPtr)vnp->data.ptrvalue;
+ if (pgp){
+ vnp2=pgp->ptxtList;
+ while(vnp2){
+ mtdp=(MsaTxtDispPtr)vnp2->data.ptrvalue;
+ if (mtdp->IsUnAligned && mtdp->IsGap){
+ mtdp->TextStyle=UATextStyle;
+ }
+ vnp2=vnp2->next;
+ }
+ }
+ vnp=vnp->next;
+ }
+ }
+ }
+}
+
+
+/*******************************************************************************
+
+ Function : DDV_ShowHideUnAlignGap()
+
+ Purpose : use or not the ~ char to display an unalign gap
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_ShowHideUnAlignGap(IteM i)
+{
+static Boolean bFirst=TRUE;
+static Uint1 UA_TextStyle;
+DdvMainWinPtr mWin_d;
+DdvMainPtr dmp;
+WindoW hWinMain,hDispDlg;
+
+ /*get some data*/
+ hWinMain=(WindoW)ParentWindow(i);
+ if (hWinMain==NULL) return;
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (hWinMain);
+ if (mWin_d==NULL) return;
+ if (mWin_d->hWndDDV==NULL) return;
+ dmp = (DdvMainPtr) GetObjectExtra(mWin_d->hWndDDV);
+ if (dmp==NULL) return;
+
+ if (bFirst){
+ UA_TextStyle=DDV_GetCurrentUAGAPStyle(&(dmp->MSA_d.pgp_l));
+ bFirst=FALSE;
+ }
+
+ if (UA_TextStyle==MSA_TXT_STYLE_UAGAP)
+ UA_TextStyle=MSA_TXT_STYLE_GAP;
+ else
+ UA_TextStyle=MSA_TXT_STYLE_UAGAP;
+
+ DDV_SetCurrentUAGAPStyle(&(dmp->MSA_d.pgp_l),UA_TextStyle);
+}
+#endif
+
+/*******************************************************************************
+
+ Function : DDV_DispStyles_OkProc()
+
+ Purpose : manage ok button of the Display Styles dialog box
+
+ Parameters : g; button
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_DispStyles_OkProc(ButtoN g)
+{
+WindoW hDispDlg;
+DdvMainWinPtr mWin_d;
+DdvDispStylesMSGPtr dsmp;
+DdvMainPtr dmp;
+DDVUpdateLayoutDataPtr dumdp;
+DDVUpdateMSGPtr dump;
+Char szBuf[15]={""};
+Int2 value;
+Char title[10]={""};
+Int4 j;
+
+ hDispDlg=(WindoW)ParentWindow(g);
+ Hide(hDispDlg);
+ if (!hDispDlg) return;
+
+ dsmp = (DdvDispStylesMSGPtr) GetObjectExtra (hDispDlg);
+
+ if (dsmp==NULL) return;
+
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (dsmp->hWinMain);
+ dmp = (DdvMainPtr) GetObjectExtra(mWin_d->hWndDDV);
+
+ dumdp=(DDVUpdateLayoutDataPtr)MemNew(sizeof(DDVUpdateLayoutData));
+ if (!dumdp){
+ MemFree(dsmp);
+ Remove(hDispDlg);
+ /*todo : add user message to inform for error*/
+ return;
+ }
+
+ dump=(DDVUpdateMSGPtr)MemNew(sizeof(DDVUpdateMSG));
+ if (!dump){
+ MemFree(dsmp);
+ MemFree(dumdp);
+ Remove(hDispDlg);
+ /*todo : add user message to inform for error*/
+ return;
+ }
+
+ /*check box for color display*/
+ dumdp->bUseColors=GetStatus((Handle)dsmp->chk2);
+ /*show left tail check box*/
+ dumdp->ShowLeftTail=GetStatus((Handle)dsmp->chk3);
+ /*show right tail check box*/
+ dumdp->ShowRightTail=GetStatus((Handle)dsmp->chk4);
+
+ if (Enabled((Handle)dsmp->g1)){
+ /*size of the spacer*/
+ GetTitle(dsmp->edit1, title, 9);
+ value=(Int2)atoi(title);
+ if (value<1)
+ dumdp->SpacerSize=1;
+ else if (value>20){
+ dumdp->SpacerSize=20;
+ }
+ else dumdp->SpacerSize=(Uint1)value;
+ /*get the values back from the user*/
+ value=GetValue((Handle)dsmp->g2);
+ if (value==1){/*use spacer ?*/
+ dumdp->DispDiscStyle=MSA_TXT_STYLE_1;
+ }
+ else{/*use justification*/
+ dumdp->DispDiscStyle=MSA_TXT_STYLE_2;
+ value=GetValue((Handle)dsmp->g5);
+ switch(value){
+ case 1:
+ dumdp->DiscJustification=DISP_JUST_LEFT;
+ break;
+ case 2:
+ dumdp->DiscJustification=DISP_JUST_RIGHT;
+ break;
+ case 3:
+ dumdp->DiscJustification=DISP_JUST_CENTER;
+ break;
+ case 4:
+ dumdp->DiscJustification=DISP_JUST_SPLIT;
+ break;
+ }
+ }
+ }
+
+ /*sequence list... something selected?*/
+ /*set the ruler styles*/
+ for(j=0;j<dmp->MSA_d.pgp_l.nBsp;j++){
+ if (GetItemStatus (dsmp->BspNames, (Int2)(j+1))){/*selected ?*/
+ if(!dumdp->SeqList){
+ dumdp->SeqList=(Int4Ptr)MemNew(sizeof(Int4));
+ if (!dumdp->SeqList) break;
+ dumdp->SeqList[0]=j+1;
+ dumdp->nSeq++;
+ }
+ else{
+ dumdp->SeqList=(Int4Ptr)MemExtend(dumdp->SeqList,
+ (dumdp->nSeq+1)*sizeof(Int4),dumdp->nSeq*sizeof(Int4));
+ if (dumdp->SeqList==NULL){
+ dumdp->nSeq=0;
+ break;
+ }
+ dumdp->SeqList[dumdp->nSeq]=j+1;
+ dumdp->nSeq++;
+ }
+ }
+ }
+ if (dumdp->nSeq>0){
+ value=GetValue((Handle)dsmp->g12);
+ switch(value){
+ case 1:
+ dumdp->RulerStyle=SCALE_POS_TOP;
+ break;
+ case 2:
+ dumdp->RulerStyle=SCALE_POS_NONE;
+ break;
+ }
+ }
+
+ dumdp->ddv_panel=mWin_d->hWndDDV;
+
+ /*send a OM_MSG_UPDATE message*/
+ dump->type=UPDATE_TYPE_LAYOUT;
+ dump->data=(Pointer)dumdp;
+ ObjMgrSendProcMsg(OM_MSG_UPDATE, dmp->MSA_d.entityID,dmp->MSA_d.itemID,
+ OBJ_SEQALIGN,0,0,(Pointer)dump);
+
+ /*close the dlg box*/
+ Remove(hDispDlg);
+}
+
+/*******************************************************************************
+
+ Function : DDV_DispStyles_cancelProc()
+
+ Purpose : manage cancel button of the Display Styles dialog box
+
+ Parameters : g; button
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_DispStyles_cancelProc(ButtoN g)
+{
+WindoW hDispDlg;
+DdvDispStylesMSGPtr dsmp;
+
+ hDispDlg=(WindoW)ParentWindow(g);
+
+ if (!hDispDlg) return;
+
+ dsmp = (DdvDispStylesMSGPtr) GetObjectExtra (hDispDlg);
+
+ if (dsmp==NULL) return;
+
+ Remove(hDispDlg);
+}
+
+
+/*******************************************************************************
+
+ Function : DDV_DispStyles_SelAllProc()
+
+ Purpose : manage SelAll BSP button of the Display Styles dialog box
+
+ Parameters : g; button
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_DispStyles_SelAllProc(ButtoN g)
+{
+WindoW hDispDlg;
+DdvMainWinPtr mWin_d;
+DdvDispStylesMSGPtr dsmp;
+DdvMainPtr dmp;
+Int4 j;
+
+ hDispDlg=(WindoW)ParentWindow(g);
+ if (!hDispDlg) return;
+ dsmp = (DdvDispStylesMSGPtr) GetObjectExtra (hDispDlg);
+ if (dsmp==NULL) return;
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (dsmp->hWinMain);
+ dmp = (DdvMainPtr) GetObjectExtra(mWin_d->hWndDDV);
+
+ for(j=0;j<dmp->MSA_d.pgp_l.nBsp;j++){
+ SetItemStatus (dsmp->BspNames, (Int2)(j+1), TRUE);
+ }
+}
+
+/*******************************************************************************
+
+ Function : DDV_DispStyles_SelNoneProc()
+
+ Purpose : manage Sel None BSP button of the Display Styles dialog box
+
+ Parameters : g; button
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_DispStyles_SelNoneProc(ButtoN g)
+{
+WindoW hDispDlg;
+DdvMainWinPtr mWin_d;
+DdvDispStylesMSGPtr dsmp;
+DdvMainPtr dmp;
+Int4 j;
+
+ hDispDlg=(WindoW)ParentWindow(g);
+ if (!hDispDlg) return;
+ dsmp = (DdvDispStylesMSGPtr) GetObjectExtra (hDispDlg);
+ if (dsmp==NULL) return;
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (dsmp->hWinMain);
+ dmp = (DdvMainPtr) GetObjectExtra(mWin_d->hWndDDV);
+
+ for(j=0;j<dmp->MSA_d.pgp_l.nBsp;j++){
+ SetItemStatus (dsmp->BspNames, (Int2)(j+1), FALSE);
+ }
+}
+
+
+/*******************************************************************************
+
+ Function : DDV_DispStyles_DiscSetCtrlVal()
+
+ Purpose : set the values for the ctrl in the group "disc. align options"
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_DispStyles_DiscSetCtrlVal(DdvDispStylesMSGPtr dsmp,
+ DDV_Disp_OptPtr ddop)
+{
+Char szBuf[15]={""};
+
+
+ Enable(dsmp->g1);
+
+ if (ddop->DispDiscStyle==MSA_TXT_STYLE_1)
+ SetValue(dsmp->g2,1);
+ else
+ SetValue(dsmp->g2,2);
+
+ sprintf(szBuf,"%i",ddop->SpacerSize);
+ SetTitle(dsmp->edit1,szBuf);/*spacer size*/
+
+ if (ddop->DiscJustification>0)
+ SetValue(dsmp->g5,(Int2)(ddop->DiscJustification-DISP_JUST_LEFT+1));
+ else
+ SetValue(dsmp->g5,1);
+}
+
+/*******************************************************************************
+
+ Function : DDV_DeselectItem()
+
+ Purpose : Deselects everything
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_DeselectItem(IteM i)
+{
+ DdvMainWinPtr mWin_d;
+ DdvMainPtr dmp;
+ WindoW hWinMain;
+
+ hWinMain=(WindoW)ParentWindow(i);
+ if (hWinMain==NULL) return;
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (hWinMain);
+ if (mWin_d==NULL) return;
+ if (mWin_d->hWndDDV==NULL) return;
+ dmp = (DdvMainPtr) GetObjectExtra(mWin_d->hWndDDV);
+ if (dmp==NULL) return;
+
+ ObjMgrDeSelectAll();
+ ObjMgrSendProcMsg(OM_MSG_UPDATE, dmp->MSA_d.entityID,dmp->MSA_d.itemID,
+ OBJ_SEQALIGN,0,0,NULL);
+ ObjMgrSendMsg(OM_MSG_MOUSEUP, dmp->MSA_d.entityID, dmp->MSA_d.itemID,
+ OBJ_SEQALIGN);
+}
+
+/*******************************************************************************
+
+ Function : DDV_DisplayStyles()
+
+ Purpose : create the Display Styles dialog box
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_DisplayStyles(IteM i)
+{
+DdvMainWinPtr mWin_d;
+DdvMainPtr dmp;
+WindoW hWinMain,hDispDlg;
+GrouP g0,g1,g2,g3,g4,g5,g6,g7,g8,g9,g10,g11,g12,g13;
+LisT BspNames;
+ButtoN chk2,chk3,chk4;
+TexT edit1;
+DdvDispStylesMSGPtr dsmp;
+SeqIdPtr sip;
+Char szAccess[21];
+Char szBuf[10];
+Int4 j;
+ValNodePtr vnp;
+ParaGPtr pgp;
+
+ /*get some data*/
+ hWinMain=(WindoW)ParentWindow(i);
+ if (hWinMain==NULL) return;
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (hWinMain);
+ if (mWin_d==NULL) return;
+ if (mWin_d->hWndDDV==NULL) return;
+ dmp = (DdvMainPtr) GetObjectExtra(mWin_d->hWndDDV);
+ if (dmp==NULL) return;
+
+ /*init MsgStruct; to be used when user clicks on [OK]*/
+ dsmp=(DdvDispStylesMSGPtr)MemNew(sizeof(DdvDispStylesMSG));
+ if (!dsmp) return;
+
+ /*DlgBox window*/
+ hDispDlg=MovableModalWindow(-30, -20, -10, -10,
+ "DDV - display options", NULL);
+ if (!hDispDlg){
+ MemFree(dsmp);
+ return;
+ }
+
+ SetObjectExtra (hDispDlg, (Pointer) dsmp, StdCleanupExtraProc);
+/*
+ the dlg controls
+
+ g6 main group for all the dlg; put all the controls there
+ |->chk2 check for color display
+ |
+ |->g0 main group for "Disc. SeqAlign display options"
+ | |->g1
+ | | |->g2 radio group 1 (spacer/seq.)
+ | | |->g3
+ | | |->g4 TexT ctrl, spacer size
+ | | |->g5 radio group 2 (justification)
+ | |->g13 check btns for tails
+ |
+ |->g8 main group for "Bioseq ruler"
+ | |->g9
+ | |->BspNames BSP names listbox
+ | |->g10 the controls (radio & buttons)
+ | |->g11
+ | |->g12
+ |->g7 (ok/cancel buttons)
+*/
+ /*top-level group*/
+ g6=HiddenGroup(hDispDlg, -1, 0,NULL);
+
+ chk2=CheckBox(g6,"Use a color display",NULL);
+
+ /*Disc. SeqAlign display options group - start*/
+ g0=NormalGroup(g6, -1, 0, "Disc. SeqAlign display options",NULL, NULL);
+ g1=HiddenGroup(g0, 2, 0,NULL);
+ g2=HiddenGroup(g1,0,2,NULL);
+ RadioButton(g2,"spacer");
+ RadioButton(g2,"sequence");
+ g3=HiddenGroup(g1,0,2,NULL);
+ g4=HiddenGroup(g3,2,0,NULL);
+ edit1=DialogText(g4,NULL,6,NULL);
+ g5=HiddenGroup(g3,0,4,NULL);
+ RadioButton(g5,"Left");
+ RadioButton(g5,"Right");
+ RadioButton(g5,"Center");
+ RadioButton(g5,"Split");
+ g13=HiddenGroup(g0,0,2,NULL);
+ chk3=CheckBox(g13,"Show left tail",NULL);
+ chk4=CheckBox(g13,"Show right tail",NULL);
+ /*Disc. SeqAlign display options group - end*/
+
+ /*Bioseq list - start*/
+ g8=NormalGroup(g6, -1, 0, "Bioseq ruler",NULL, NULL);
+ g9=HiddenGroup(g8,0,2,NULL);
+ BspNames=MultiList(g9,6,6,NULL);
+ if (dmp->MSA_d.pgp_l.TableHead){
+ for(j=0;j<dmp->MSA_d.pgp_l.nBsp;j++){
+ vnp=dmp->MSA_d.pgp_l.TableHead[j];
+ pgp=(ParaGPtr)vnp->data.ptrvalue;
+ if (pgp->sip){
+ sip = SeqIdFindBest(pgp->sip, SEQID_GENBANK);
+ if (!sip)
+ sip = SeqIdFindBest(pgp->sip, 0);
+ SeqIdWrite(sip, szAccess,PRINTID_TEXTID_ACCESSION, 20);
+ ListItem(BspNames,szAccess);
+ }
+ }
+ }
+ g10=HiddenGroup(g9,2,0,NULL);
+ g11=NormalGroup(g10, 2, 0, "Auto select",NULL, NULL);
+ PushButton (g11, "All", DDV_DispStyles_SelAllProc);
+ PushButton (g11, "None", DDV_DispStyles_SelNoneProc);
+ g12=NormalGroup(g10, 3, 0, "Ruler Style",NULL, NULL);
+ RadioButton(g12,"Top");
+ RadioButton(g12,"None");
+ SetValue(g12,2);
+ /*Bioseq list - end*/
+
+ /*ok - cancel group - start*/
+ g7=HiddenGroup(g6, 2, 0,NULL);
+ PushButton (g7, "Ok", DDV_DispStyles_OkProc);
+ PushButton (g7, "Cancel", DDV_DispStyles_cancelProc);
+ /*ok - cancel group - end*/
+
+ /*copy data*/
+ dsmp->hWinMain=hWinMain;
+ dsmp->chk2=chk2;
+ dsmp->chk3=chk3;
+ dsmp->chk4=chk4;
+ dsmp->g1=g1;
+ dsmp->g2=g2;
+ dsmp->g5=g5;
+ dsmp->g12=g12;
+ dsmp->edit1=edit1;
+ dsmp->BspNames=BspNames;
+
+ /*build the dlgbox*/
+ RealizeWindow(hDispDlg);
+ Show(hDispDlg);
+
+ /*color display check box*/
+ SetStatus(chk2,dmp->ddo.bUseColors);
+ /*show left tail check box*/
+ SetStatus(chk3,dmp->ddo.ShowLeftTail);
+ /*show right tail check box*/
+ SetStatus(chk4,dmp->ddo.ShowRightTail);
+ /*spacer size*/
+ sprintf(szBuf,"%i",dmp->ddo.SpacerSize);
+ SetTitle(dsmp->edit1, szBuf);
+
+ /*depending on the SAP type, init some controls*/
+ DDV_DispStyles_DiscSetCtrlVal(dsmp,&(dmp->ddo));
+/*
+ if (AlnMgrIsSAPDiscAli(dmp->MSA_d.pgp_l.sap)){
+ DDV_DispStyles_DiscSetCtrlVal(dsmp,&(dmp->ddo));
+ }
+ else{
+ Disable(g1);
+ }
+*/
+}
+
+
+static void SelectJustify(ChoicE i) {
+/*----------------------------------------------------------------------------
+* handle the Justify left/right/center selection
+*---------------------------------------------------------------------------*/
+ DdvMainWinPtr mWin_d;
+ DdvMainPtr dmp;
+ WindoW hWinMain;
+ Int2 Value;
+
+ hWinMain=(WindoW)ParentWindow(i);
+ if (!hWinMain) return;
+ mWin_d = (DdvMainWinPtr) GetObjectExtra(hWinMain);
+ if (mWin_d==NULL) return;
+ dmp=(DdvMainPtr)GetObjectExtra(mWin_d->hWndDDV);
+ if (dmp==NULL) return;
+ if (!dmp->MSA_d.pgp_l.TableHead) return;
+
+ Value = GetValue(i);
+ switch(Value) {
+ case 1:
+ DDE_LeftJustify(dmp->dsp, TRUE);
+ break;
+ case 2:
+ DDE_RightJustify(dmp->dsp, TRUE);
+ break;
+ case 3:
+ DDE_CenterJustify(dmp->dsp, TRUE);
+ break;
+ default:
+ break;
+ }
+
+ /* shut off the selection */
+ SetValue(mWin_d->MainMenu.Justify, 0);
+
+ DDV_ReDraw(dmp);
+ return;
+}
+
+
+/*******************************************************************************
+
+ Function : SelectMouseMode()
+
+ Purpose : modification of the mouse mode
+
+ Parameters : i; menu item
+
+ Return value : none
+
+*******************************************************************************/
+static void SelectMouseMode(ChoicE i)
+{
+Int2 value;
+DdvMainWinPtr mWin_d;/*program data*/
+DdvMainPtr dmp;
+WindoW hWinMain;
+Int4 from_col,to_col,from_row,to_row,bsp_pos;
+Char szAccess[21];
+
+
+ hWinMain=(WindoW)ParentWindow(i);
+ if (!hWinMain) return;
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (hWinMain);
+ if (mWin_d==NULL) return;
+ dmp=(DdvMainPtr)GetObjectExtra(mWin_d->hWndDDV);
+ if (dmp==NULL) return;
+ if (!dmp->MSA_d.pgp_l.TableHead) return;
+
+ /*get the disp coord range*/
+ DDV_GetCurrentDispRange(dmp->hWndDDV,&(dmp->GrData),
+ dmp->MSA_d.pgp_l.LengthAli,&from_col,&to_col,
+ &from_row,&to_row);
+ /*switch to one-bsed value because dmp->dci values
+ are one-based values*/
+ from_row++;
+ to_row++;
+
+ value=GetValue(i);
+ switch(value){
+ case 1:/*query mode*/
+ dmp->MouseMode=DDV_MOUSEMODE_QUERY;
+ goto Continue;
+ case 2:/*select mode*/
+ dmp->MouseMode=DDV_MOUSEMODE_SELECT;
+ goto Continue;
+ case 3:
+ dmp->MouseMode=DDV_MOUSEMODE_SELECT_ONE_ROW;
+
+Continue:
+ dmp->dci.old_row=dmp->dci.new_row;
+ dmp->dci.old_col=dmp->dci.new_col;
+ dmp->dci.new_row=(Int4)-1;
+ dmp->dci.new_col=(Int4)-1;
+ /*hide the caret from old coordinates*/
+ if (dmp->dci.old_col>=from_col && dmp->dci.old_col<=to_col &&
+ dmp->dci.old_row>=from_row && dmp->dci.old_row<=to_row){
+ DDV_InvalRegion(dmp->hWndDDV,&(dmp->GrData),
+ _max_(0,dmp->dci.old_col-1),dmp->dci.old_col+1,
+ dmp->dci.old_row,FALSE);
+ }
+ SetTitle(mWin_d->InfoPanel,"Ready !");
+ break;
+ case 4:/*edit mode*/
+ dmp->MouseMode=DDV_MOUSEMODE_EDIT;
+ dmp->dci.new_row=dmp->dci.old_row;
+ dmp->dci.new_col=dmp->dci.old_col;
+ /*show the caret from new coordinates*/
+ if (dmp->dci.new_col>=from_col && dmp->dci.new_col<=to_col &&
+ dmp->dci.new_row>=from_row && dmp->dci.new_row<=to_row){
+ DDV_InvalRegion(dmp->hWndDDV,&(dmp->GrData),
+ _max_(0,dmp->dci.new_col-1),dmp->dci.new_col+1,
+ dmp->dci.new_row,FALSE);
+ }
+ DDV_GetSeqNameGivenRow(dmp->MSA_d.pgp_l.TableHead,
+ dmp->dci.new_row,szAccess);
+ bsp_pos=DDV_GetBspCoordGivenPgpList(
+ dmp->MSA_d.pgp_l.TableHead[dmp->dci.new_row-1],
+ dmp->dci.new_col);
+ if (bsp_pos!=(Int4)-1){
+ DDV_DispPositionInStatus(mWin_d->InfoPanel,
+ bsp_pos+1,dmp->dci.new_row,szAccess);
+ /*+1 : switch to one-based value*/
+ }
+ break;
+ }
+}
+
+static void DDV_ShowLowerPanel(IteM i)
+{
+ DdvMainWinPtr mWin_d;/*program data*/
+
+ mWin_d = (DdvMainWinPtr) GetObjectExtra((Handle)i);
+ if(!mWin_d) return;
+ DDV_SetupWin (mWin_d->hWndMain,FALSE);
+}
+
+/*******************************************************************************
+
+ Function : DDV_SetMenuFocus()
+
+ Purpose : Set menu item values depending on which panel has focus
+
+ Parameters : w; handle of the dialog box
+
+ Return value : none
+
+*******************************************************************************/
+
+NLM_EXTERN void DDV_SetMenuFocus(WindoW w)
+{
+DdvMainWinPtr mWin_d;/*program data*/
+DdvMainPtr dmp;
+
+ mWin_d = (DdvMainWinPtr) GetObjectExtra((Handle)w);
+
+ if (!mWin_d) return;
+ dmp = (DdvMainPtr) GetObjectExtra(mWin_d->hWndDDV);
+
+ switch(dmp->MouseMode){
+ case DDV_MOUSEMODE_QUERY:
+ SetValue(mWin_d->MainMenu.MouseMode,1);
+ break;
+ case DDV_MOUSEMODE_SELECT:
+ SetValue(mWin_d->MainMenu.MouseMode,2);
+ break;
+ case DDV_MOUSEMODE_SELECT_ONE_ROW:
+ SetValue(mWin_d->MainMenu.MouseMode,3);
+ break;
+ case DDV_MOUSEMODE_EDIT:
+ SetValue(mWin_d->MainMenu.MouseMode,4);
+ break;
+ }
+
+}
+
+/*******************************************************************************
+
+ Function : DDV_SetupMenus()
+
+ Purpose : create the menu of DD-Viewer
+
+ Parameters : w; handle of the dialog box
+ isID1Ok;TRUE if ID1 is enabled
+ bEditor; true = show editor's commands
+
+ Return value : none
+
+*******************************************************************************/
+extern void DDV_SetupMenus(WindoW w,Boolean isID1Ok,Boolean bEditor,
+ SAM_ViewGlobal *vgp)
+{
+MenU m,s,s2;/*temp variable*/
+DdvMainWinPtr mWin_d;/*program data*/
+Boolean* pNoGaps;
+Boolean NoGaps;
+
+ mWin_d = (DdvMainWinPtr) GetObjectExtra((Handle)w);
+
+ if (!mWin_d) return;
+
+ /*File menu*/
+ m=PulldownMenu(w,"File");
+ mWin_d->MainMenu.File=m;
+
+ if (mWin_d->AutonomeViewer){/*available only for the Auntonomous viewer*/
+ s=SubMenu(m,"Open from ");
+ mWin_d->MainMenu.FileOpen=CommandItem(s,"a local file...",
+ DDV_OpenFile);
+ mWin_d->MainMenu.EntrezOpen=CommandItem(s,"the network...",
+ DDV_OpenNetwork);
+ if (isID1Ok==FALSE) Disable(mWin_d->MainMenu.EntrezOpen);
+
+ mWin_d->MainMenu.FileClose=CommandItem(m,"Close",DDV_FileClose);
+ SeparatorItem(m);
+ mWin_d->MainMenu.FileExport=CommandItem(m,"Export...",DDV_ExportTexte);
+ s=SubMenu(m,"Import ");
+ mWin_d->MainMenu.ImportSeq=CommandItem(s,"a single sequence",DDV_ImportBioseq);
+ mWin_d->MainMenu.ImportNucSeqAlign=CommandItem(s,"a nuc. sequence alignment",DDV_ImportNucSeqAlign);
+ mWin_d->MainMenu.ImportProtSeqAlign=CommandItem(s,"a prot. sequence alignment",DDV_ImportProtSeqAlign);
+ SeparatorItem(m);
+ VSMAddToMenu(m, VSM_DESKTOP);
+ SeparatorItem(m);
+ }
+ else{
+ mWin_d->MainMenu.FileExport=CommandItem(m,"Export...",DDV_ExportTexte);
+ /* for editor allow save of edits */
+ if (bEditor) {
+ mWin_d->MainMenu.SaveEdits=CommandItem(m,"Save",DDV_CallSaveEdits);
+ }
+ SeparatorItem(m);
+ }
+ mWin_d->MainMenu.QuitViewer=CommandItem(m,"Quit/Q",QuitProc);
+
+ /*Edit Menu*/
+ if (bEditor){
+ m=PulldownMenu(w,"Edit");
+ mWin_d->MainMenu.Edit=m;
+/*
+ mWin_d->MainMenu.DeleteRow=CommandItem(m,"Delete row", DDV_DeleteRow);
+ mWin_d->MainMenu.MoveRowLeft=CommandItem(m,"Move row to the left", DDV_MoveRowLeft);
+ mWin_d->MainMenu.MoveRowRight=CommandItem(m,"Move row to the right", DDV_MoveRowRight);
+ mWin_d->MainMenu.LeftBoundaryLeft=CommandItem(m,"Move left boundary left", DDV_MoveLeftBoundaryLeft);
+ mWin_d->MainMenu.LeftBoundaryRight=CommandItem(m,"Move left boundary right", DDV_MoveLeftBoundaryRight);
+ mWin_d->MainMenu.RightBoundaryLeft=CommandItem(m,"Move right boundary left", DDV_MoveRightBoundaryLeft);
+ mWin_d->MainMenu.RightBoundaryRight=CommandItem(m,"Move right boundary right", DDV_MoveRightBoundaryRight);
+*/
+ mWin_d->MainMenu.CreateBlock=CommandItem(m,"Create block...", DDV_CreateBlock);
+ mWin_d->MainMenu.DeleteBlock=CommandItem(m,"Delete block", DDV_DeleteBlock);
+ mWin_d->MainMenu.Prev=CommandItem(m,"Undo (Ctrl + z)", DDV_Prev);
+ mWin_d->MainMenu.Next=CommandItem(m,"Redo (Ctrl + y)", DDV_Next);
+ mWin_d->MainMenu.Orig=CommandItem(m,"Restore original", DDV_Orig);
+ /* to start, can't undo or redo anything */
+ Disable(mWin_d->MainMenu.Prev);
+ Disable(mWin_d->MainMenu.Next);
+ }
+
+ if (mWin_d->AutonomeViewer){
+ mWin_d->MainMenu.Align = PulldownMenu(w, "Alignment/A");
+ mWin_d->MainMenu.Hide=CommandItem(mWin_d->MainMenu.Align,
+ "Hide or Show Rows...",DDV_HideDlgItem);
+ }
+
+ /* Align menu */
+ if(vgp != NULL) {
+ if(vgp->MasterViewer == SAMVIEWCN3D) {
+ mWin_d->MainMenu.Align = PulldownMenu(w, "Alignment/A");
+ mWin_d->MainMenu.Hide=CommandItem(mWin_d->MainMenu.Align,
+ "Hide or Show Rows...",DDV_HideDlgItem);
+ mWin_d->MainMenu.Deselect=CommandItem(mWin_d->MainMenu.Align,
+ "Deselect All",DDV_DeselectItem);
+ SeparatorItem(mWin_d->MainMenu.Align);
+ mWin_d->MainMenu.AddRow = SubMenu(mWin_d->MainMenu.Align, "Add New Row");
+ mWin_d->MainMenu.FromFile = SubMenu(mWin_d->MainMenu.AddRow, "From FASTA file");
+ CommandItem(mWin_d->MainMenu.FromFile,
+ "By gapped BLAST...", (Nlm_ItmActnProc)vgp->BlastFileGap);
+ CommandItem(mWin_d->MainMenu.FromFile,
+ "By ungapped BLAST...", (Nlm_ItmActnProc)vgp->BlastFile);
+ if (vgp->NetStartProc) {
+ mWin_d->MainMenu.FromNet = SubMenu(mWin_d->MainMenu.AddRow, "Download from Entrez");
+ CommandItem(mWin_d->MainMenu.FromNet,
+ "By gapped BLAST...", (Nlm_ItmActnProc)vgp->BlastNetGap);
+ CommandItem(mWin_d->MainMenu.FromNet,
+ "By ungapped BLAST...", (Nlm_ItmActnProc)vgp->BlastNet);
+ }
+ }
+ }
+
+ /*Options menu*/
+ m=PulldownMenu(w,"Options");
+ mWin_d->MainMenu.Options=m;
+ if (!bEditor) {
+ mWin_d->MainMenu.DispStyles=CommandItem(m,"Styles",DDV_DisplayStyles);
+ }
+
+#ifdef DEBUG_DDV
+ CommandItem(m,"Switch UA Gap",DDV_ShowHideUnAlignGap);
+#endif
+ s=SubMenu(m,"Mouse modes");
+ mWin_d->MainMenu.MouseMode=ChoiceGroup(s,SelectMouseMode);
+ ChoiceItem(mWin_d->MainMenu.MouseMode,"Query");
+ ChoiceItem(mWin_d->MainMenu.MouseMode,"Select rectangle");
+ ChoiceItem(mWin_d->MainMenu.MouseMode,"Select one row");
+ /* only allow "Edit" option for DDE, when not running in NoGaps mode */
+ pNoGaps = (Boolean*) GetAppProperty("dde_nogaps");
+ if (pNoGaps == NULL) NoGaps = TRUE;
+ else NoGaps = *pNoGaps;
+ if (!NoGaps) {
+ if (bEditor)
+ ChoiceItem(mWin_d->MainMenu.MouseMode,"Edit");
+ }
+
+ if (bEditor) {
+ s2=SubMenu(m,"Justify");
+ mWin_d->MainMenu.Justify=ChoiceGroup(s2,SelectJustify);
+ ChoiceItem(mWin_d->MainMenu.Justify,"Left");
+ ChoiceItem(mWin_d->MainMenu.Justify,"Right");
+ ChoiceItem(mWin_d->MainMenu.Justify,"Center");
+ }
+
+ /* only launch the editor from the viewer */
+ if (!bEditor && mWin_d->EditAllowed) {
+ mWin_d->MainMenu.ShowLowerPanel = StatusItem(m,
+ "Show Lower Panel/L", DDV_ShowLowerPanel);
+ SetObjectExtra (mWin_d->MainMenu.ShowLowerPanel, (Pointer)mWin_d, NULL);
+ mWin_d->MainMenu.LaunchEditor=CommandItem(m,"Launch editor...",DDV_LaunchEditor);
+ mWin_d->MainMenu.MergeBlocks=CommandItem(m,"Merge 2 blocks...",DDV_MergeBlocks);
+ mWin_d->MainMenu.SplitBlock=CommandItem(m,"Split block in 2...",DDV_SplitBlock);
+ mWin_d->MainMenu.DeleteDDVBlock=CommandItem(m, "Delete block...",DDV_DeleteBlock2);
+ }
+
+ if (mWin_d->AutonomeViewer && mWin_d->NetCfgMenuProc){
+ mWin_d->MainMenu.ConfigNet=CommandItem(m,"Network...",
+ mWin_d->NetCfgMenuProc);
+ }
+ /*Help menu*/
+ m=PulldownMenu(w,"Help");
+ CommandItem(m,"About...",DDV_AboutProc);
+}
+
+/*******************************************************************************
+
+ Function : DDV_WinMainCleanup()
+
+ Purpose : free memory before leaving viewer
+
+ Parameters : mWin_d ; main window data
+
+ Return value : none
+
+*******************************************************************************/
+extern void DDV_WinMainCleanup(GraphiC g, VoidPtr data)
+{
+DdvMainWinPtr mWin_d;
+
+ if (!data) return;
+ mWin_d=(DdvMainWinPtr)data;
+
+ /*main window data - Logo*/
+/* if (mWin_d->f1) DeleteFont(mWin_d->f1);
+ if (mWin_d->f2) DeleteFont(mWin_d->f2);
+ if (mWin_d->f3) DeleteFont(mWin_d->f3);
+*/
+ /*delete Align data*/
+ DDV_CloseData(mWin_d,TRUE);
+
+ MemFree(mWin_d);
+}
+
+/*******************************************************************************
+
+ Purpose : init the graphical data structure of DDV. Use only when you start DDV.
+
+ Function : DDV_InitGraphGlobal()
+
+ Parameters : dmp; main DDV data block
+
+ Return value : -
+
+*******************************************************************************/
+extern void DDV_InitGraphGlobal(DdvMainPtr dmp)
+{
+Int2 decal=0;
+
+ dmp->GrData.udv_font.LineHeight=
+ UDV_ComputeLineHeight(dmp->GrData.udv_font.cyChar);
+ dmp->GrData.udv_font.ColWidth=
+ DDV_ComputeColWidth(dmp->GrData.udv_font.cxChar);
+ UDV_Init_ScaleData(&(dmp->GrData));
+ UDV_Build_Other_Colors(&(dmp->GrData));
+ /*... then adjust values for DDV*/
+ dmp->GrData.udv_scale.ScalePosition=(Int2)SCALE_POS_TOP;
+ dmp->GrData.udv_panel.ShowFeatures=FALSE;
+ dmp->GrData.udv_panel.ShowByBlock=FALSE;
+ dmp->GrData.udv_scale.cxLeftScale=dmp->GrData.udv_font.cxChar*2;
+ dmp->GrData.udv_panel.cxName=PANEL_NAME_WIDTH*dmp->GrData.udv_font.cxChar;
+ if (dmp->GrData.udv_scale.ShowMajorTick) decal++;
+ if (dmp->GrData.udv_scale.ScalePosition==SCALE_POS_TOP) decal++;
+ dmp->GrData.udv_panel.cyScale=decal*dmp->GrData.udv_font.LineHeight;
+ dmp->MSA_d.pgp_l.DisplayType=DDV_DISP_HORZ;
+}
+
+/*******************************************************************************
+
+ Function : DDV_SetRulerAttribInPGP()
+
+ Purpose : modify the BSP ruler attribute for a row in the MSA
+
+ Return value : -
+
+*******************************************************************************/
+extern void DDV_SetRulerAttribInPGP(ValNodePtr ParaG_Head, Uint1 RulerStyle)
+{
+ValNodePtr vnp;
+ParaGPtr pgp;
+
+ vnp=ParaG_Head;
+ while(vnp){
+ pgp=(ParaGPtr)vnp->data.ptrvalue;
+ if (pgp){
+ pgp->ScaleStyle=RulerStyle;
+ switch (RulerStyle){
+ case SCALE_POS_NONE:
+ pgp->nLines=1;
+ break;
+ case SCALE_POS_TOP:
+ pgp->nLines=2;
+ break;
+ default:
+ pgp->nLines=1;
+ break;
+ }
+ }
+ vnp=vnp->next;
+ }
+}
+
+/*******************************************************************************
+
+ Function : DDV_SetRulerAttribInPGP()
+
+ Purpose : modify the BSP ruler attribute for a row in the MSA
+
+ Return value : -
+
+*******************************************************************************/
+extern void DDV_SortPGPLineNum(ValNodePtr PNTR Head, Int4 nBsp)
+{
+ValNodePtr vnp;
+ParaGPtr pgp;
+Int4 n=0,j;
+
+ for(j=0;j<nBsp;j++){
+ vnp=Head[j];
+ while(vnp){
+ pgp=(ParaGPtr)vnp->data.ptrvalue;
+ pgp->StartLine=n;
+ vnp=vnp->next;
+ }
+ n+=pgp->nLines;
+ }
+}
+
+/*******************************************************************************
+
+ Function : DDV_ExportSeqAlign()
+
+ Purpose : export a SeqAlign
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_ExportSeqAlign(SeqAlignPtr sap,CharPtr szFName)
+{
+SeqAlignPtr sap_to_save=NULL;
+AsnIoPtr aip;
+AsnTypePtr atp;
+AsnModulePtr amp;
+
+ sap_to_save=AlnMgrGetSubAlign(sap, NULL, 0, -1);
+ if (sap_to_save==NULL) goto error;
+
+ amp = AsnAllModPtr ();
+ atp = AsnTypeFind (amp,"Seq-align");
+
+ if ((aip = AsnIoOpen (szFName, "w")) == NULL) goto error;
+ SeqAlignAsnWrite( sap, aip, atp );
+ AsnIoReset(aip);
+ return;
+error:
+ if (sap_to_save) SeqAlignFree(sap_to_save);
+ Message(MSG_OK, "Sorry, ASN.1 SeqAlign cannot be exported.");
+ return;
+}
+
+/*******************************************************************************
+
+ Function : DDV_ExportSeqAlign()
+
+ Purpose : export a SeqAlign
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_ExportSeqAnnot(SeqAlignPtr sap,CharPtr szFName)
+{
+SeqAlignPtr sap_to_save=NULL;
+
+ sap_to_save=AlnMgrGetSubAlign(sap, NULL, 0, -1);
+ if (sap_to_save==NULL){
+ Message(MSG_OK, "Sorry, ASN.1 SeqAlign cannot be exported.");
+ return;
+ }
+ /*Salsa export function*/
+ seqalign_write (sap_to_save, szFName);
+ if (sap_to_save) SeqAlignFree(sap_to_save);
+}
+
+/*******************************************************************************
+
+ Function : DDVExportTexteChooseFormat()
+
+ Purpose : manage popup list of SeqAlign Format (export)
+
+ Return value : none
+
+*******************************************************************************/
+static void DDVExportTexteChooseFormat (PopuP pop)
+{
+DdvExportTexteMSGPtr detmp;
+WindoW hExportDlg;
+Int2 value;
+
+ hExportDlg=(WindoW)ParentWindow(pop);
+
+ if (!hExportDlg) return;
+
+ detmp = (DdvExportTexteMSGPtr) GetObjectExtra (hExportDlg);
+
+ if (detmp==NULL) return;
+
+ value=GetValue(pop);
+
+ if(value>2){
+ Disable(detmp->chk2);
+ Disable(detmp->chk3);
+ Disable(detmp->chk4);
+ Disable(detmp->chk5);
+ Disable(detmp->chk6);
+ }
+ else{
+ Enable(detmp->chk2);
+ Enable(detmp->chk3);
+ Enable(detmp->chk4);
+ Enable(detmp->chk5);
+ Enable(detmp->chk6);
+ }
+ return;
+}
+
+/*******************************************************************************
+
+ Function : DDVExportTexteOkProc()
+
+ Purpose : manage ok button of the Export dialog box
+
+ Return value : none
+
+*******************************************************************************/
+static void DDVExportTexteOkProc(ButtoN g)
+{
+DdvExportTexteMSGPtr detmp;
+DdvMainWinPtr mWin_d;
+DdvMainPtr dmp;
+DDVOptionsBlock dob;
+WindoW hExportDlg;
+Uint4 disp_options=0;
+FILE *hFile;
+Int2 value;
+Boolean bRulerNum,bRulerTick,bShowBlock,bShowStrand,bShowBSPcoord,
+ bPrintGap;
+Char szFName[PATH_MAX]={""};
+
+ hExportDlg=(WindoW)ParentWindow(g);
+
+ if (!hExportDlg) return;
+
+ detmp = (DdvExportTexteMSGPtr) GetObjectExtra (hExportDlg);
+
+ if (detmp==NULL) {
+ Remove(hExportDlg);
+ return;
+ }
+
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (detmp->hWinMain);
+ dmp = (DdvMainPtr) GetObjectExtra(mWin_d->hWndDDV);
+
+ /*get the user's choices*/
+ value=GetValue(detmp->pop);
+
+ bRulerNum=bRulerTick=bShowBlock=bShowStrand=bShowBSPcoord=FALSE;
+ disp_options = VIEW_FULLSEQ;
+
+ if(value<3){/*text and HTML only*/
+ bRulerNum=GetStatus(detmp->chk2);
+ if (bRulerNum){
+ bRulerTick=GetStatus(detmp->chk3);
+ }
+ else{
+ bRulerTick=FALSE;
+ }
+ bShowBlock=GetStatus(detmp->chk4);
+ bShowStrand=GetStatus(detmp->chk5);
+ bShowBSPcoord=GetStatus(detmp->chk6);
+ if (bRulerNum) disp_options |= RULER_TOP;
+ if (bRulerTick) disp_options|=RULER_TICK;
+ if (bShowBlock) disp_options|=DISPE_SHOWBLOCK;
+ if (bShowStrand) disp_options|=DISP_STRAND;
+ if (bShowBSPcoord) disp_options|=DISP_BSP_COORD;
+ }
+
+ GetTitle(detmp->edit1, szFName, PATH_MAX-1);
+
+ switch(value){
+ case 1:/*text*/
+ disp_options|=DISP_FULL_TXT;
+ break;
+ case 2:/*html*/
+ disp_options|=DISP_FULL_HTML;
+ break;
+ case 3:/*philou*/
+ disp_options|=DISP_PHYLIP_TXT;
+ break;
+ case 4:/*fasta + gaps*/
+ bPrintGap=TRUE;
+ break;
+ case 5:/*fasta without gaps*/
+ bPrintGap=FALSE;
+ break;
+ case 6:/*seqalign*/
+ DDV_ExportSeqAlign(dmp->MSA_d.pgp_l.sap,szFName);
+ Remove(hExportDlg);
+ return;
+ case 7:/*seqannot*/
+ DDV_ExportSeqAnnot(dmp->MSA_d.pgp_l.sap,szFName);
+ Remove(hExportDlg);
+ return;
+ }
+
+ MemFill(&dob,0,sizeof(DDVOptionsBlock));
+ dob.LineSize=ParaG_Size;
+ hFile=fopen(szFName,"w");
+ if (!hFile){
+ Message(MSG_OK, "File creation failed !");
+ }
+ else{/*a last... save the SeqAlign*/
+ switch(value){
+ case 1:
+ case 2:
+ case 3:/*text,html,philou only*/
+ DDV_DumpSAPInAFile(&(dmp->MSA_d.pgp_l),&dob, hFile,disp_options,
+ dmp->Globals.colorp);
+ break;
+ case 4:
+ case 5:/*Fasta*/
+ DDV_DumpSAPInFastaFile(&(dmp->MSA_d.pgp_l),&dob, hFile,bPrintGap);
+ break;
+ }
+ fclose(hFile);
+ }
+ Remove(hExportDlg);
+}
+
+/*******************************************************************************
+
+ Function : DDVExportTextecancelProc()
+
+ Purpose : manage cancel button of the Export dialog box
+
+ Return value : none
+
+*******************************************************************************/
+static void DDVExportTextecancelProc(ButtoN g)
+{
+WindoW hExportDlg;
+DdvExportTexteMSGPtr detmp;
+
+ hExportDlg=(WindoW)ParentWindow(g);
+
+ if (!hExportDlg) return;
+
+ detmp = (DdvExportTexteMSGPtr) GetObjectExtra (hExportDlg);
+
+ if (detmp==NULL) {
+ Remove(hExportDlg);
+ return;
+ }
+
+ Remove(hExportDlg);
+}
+
+/*******************************************************************************
+
+ Function : DDVExportTexteShowNumber()
+
+ Purpose : manage ShoWNumber checkbox of the Export dialog box
+
+ Return value : none
+
+*******************************************************************************/
+static void DDVExportTexteShowNumber(ButtoN g)
+{
+WindoW hExportDlg;
+DdvExportTexteMSGPtr detmp;
+
+ hExportDlg=(WindoW)ParentWindow(g);
+
+ if (!hExportDlg) return;
+
+ detmp = (DdvExportTexteMSGPtr) GetObjectExtra (hExportDlg);
+
+ if (detmp==NULL) return;
+
+ if (GetStatus(detmp->chk2)==FALSE){
+ Disable(detmp->chk3);
+ }
+ else{
+ Enable(detmp->chk3);
+ }
+
+ return;
+}
+
+/*******************************************************************************
+
+ Function : DDVExportTexteFNameProc()
+
+ Purpose : manage File name edit control of the Export dialog box
+
+ Parameters : t; edit control
+
+ Return value : none
+
+*******************************************************************************/
+static void DDVExportTexteFNameProc(TexT t)
+{
+Char szFName[PATH_MAX]={""};
+WindoW hExportDlg;
+DdvExportTexteMSGPtr detmp;
+
+ hExportDlg=(WindoW)ParentWindow(t);
+
+ if (!hExportDlg) return;
+
+ detmp = (DdvExportTexteMSGPtr) GetObjectExtra (hExportDlg);
+
+ if (detmp==NULL) return;
+
+ GetTitle(t, szFName, PATH_MAX-1);
+
+ if (StringLen(szFName) == 0)
+ Disable(detmp->ok);
+ else Enable(detmp->ok);
+
+ return;
+}
+
+/*******************************************************************************
+
+ Function : DDVExportTexteBrowseFile()
+
+ Purpose : manage browse button of the Export dialog box
+
+ Parameters : g; button
+
+ Return value : none
+
+*******************************************************************************/
+static void DDVExportTexteBrowseFile(ButtoN g)
+{
+WindoW hExportDlg;
+DdvExportTexteMSGPtr detmp;
+Char path[PATH_MAX]={""};
+
+ hExportDlg=(WindoW)ParentWindow(g);
+
+ if (!hExportDlg) return;
+
+ detmp = (DdvExportTexteMSGPtr) GetObjectExtra (hExportDlg);
+
+ if (detmp==NULL) return;
+ if (!detmp->edit1) return;
+
+ if (GetOutputFileName (path, PATH_MAX-1, NULL)){
+ SetTitle(detmp->edit1, path);
+ DDVExportTexteFNameProc(detmp->edit1);
+ }
+
+ return;
+}
+
+/*******************************************************************************
+
+ Function : DDV_ExportTexte()
+
+ Purpose : create the Export dialog box
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_ExportTexte(IteM i)
+{
+DdvExportTexteMSGPtr detmp;
+DdvMainWinPtr mWin_d;
+DdvMainPtr dmp;
+WindoW hWinMain,hExportDlg;
+GrouP g0,g1,g4,g7,g8,g10;
+ButtoN chk2,chk3,chk4,chk5,chk6,browse,ok;
+TexT edit1;
+PopuP pop;
+PrompT txt;
+
+ /*get some data*/
+ hWinMain=(WindoW)ParentWindow(i);
+ if (hWinMain==NULL) return;
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (hWinMain);
+ if (mWin_d==NULL) return;
+ if (mWin_d->hWndDDV==NULL) return;
+ dmp = (DdvMainPtr) GetObjectExtra(mWin_d->hWndDDV);
+ if (dmp==NULL) return;
+
+ /*init MsgStruct; to be used when user clicks on [OK]*/
+ detmp=(DdvExportTexteMSGPtr)MemNew(sizeof(DdvExportTexteMSG));
+ if (!detmp) return;
+
+ /*DlgBox window*/
+ hExportDlg=MovableModalWindow(-30, -20, -10, -10,
+ "DDV - export a SeqAlign", NULL);
+
+ if (!hExportDlg){
+ MemFree(detmp);
+ return;
+ }
+
+ SetObjectExtra (hExportDlg, (Pointer) detmp, StdCleanupExtraProc);
+
+ /*top-level groups*/
+ g0=HiddenGroup(hExportDlg, -1, 0,NULL);
+
+ g1=NormalGroup(g0,2,0,"SeqAlign Ruler",NULL,NULL);
+/* g2=HiddenGroup(g1,2,0);*/
+ chk2=CheckBox(g1,"Show number",DDVExportTexteShowNumber);
+ chk3=CheckBox(g1,"Show ticks",NULL);
+
+ g4=NormalGroup(g0,0,4,"SeqAlign format",NULL,NULL);
+ chk4=CheckBox(g4,"Use block of 10 letters",NULL);
+ chk5=CheckBox(g4,"Display strand orientation",NULL);
+ chk6=CheckBox(g4,"Display BioSeq coordinates",NULL);
+ g7=HiddenGroup(g4,2,0,NULL);
+ txt=StaticPrompt(g7,"Format :",0,0,systemFont,'l');
+#ifdef WIN_MAC
+ pop=PopupList(g7,TRUE,DDVExportTexteChooseFormat);
+#endif
+
+#ifndef WIN_MAC
+ pop=PopupList(g7,FALSE,DDVExportTexteChooseFormat);
+#endif
+ AlignObjects(ALIGN_MIDDLE,(HANDLE) txt, (HANDLE) pop, NULL);
+ PopupItem(pop,"Text");
+ PopupItem(pop,"HTML");
+ PopupItem(pop,"Phylip");
+ PopupItem(pop,"Fasta with gaps");
+ PopupItem(pop,"Fasta without gaps");
+ PopupItem(pop,"ASN.1 SeqAlign");
+ PopupItem(pop,"ASN.1 SeqAnnot");
+
+ g8=NormalGroup(g0,3,0,"File name",NULL,NULL);
+ edit1=DialogText(g8,"",20,DDVExportTexteFNameProc);
+ browse=PushButton (g8, "Browse...", DDVExportTexteBrowseFile);
+
+ /*ok - cancel group - start*/
+ g10=HiddenGroup(g0, 2, 0,NULL);
+ ok=PushButton (g10, "Ok", DDVExportTexteOkProc);
+ PushButton (g10, "Cancel", DDVExportTextecancelProc);
+ /*build the dlgbox*/
+ RealizeWindow(hExportDlg);
+ Show(hExportDlg);
+ /*copy data*/
+ detmp->hWinMain=hWinMain;
+ detmp->chk2=chk2;
+ detmp->chk3=chk3;
+ detmp->chk4=chk4;
+ detmp->chk5=chk5;
+ detmp->chk6=chk6;
+ detmp->pop=pop;
+ detmp->edit1=edit1;
+ detmp->ok=ok;
+ /*color display check box*/
+ SetStatus(chk2,TRUE);
+ SetStatus(chk3,TRUE);
+ SetStatus(chk4,TRUE);
+ SetStatus(chk5,TRUE);
+ SetStatus(chk6,TRUE);
+ SetValue(pop,1);
+ Disable(detmp->ok);
+}
+
+/*******************************************************************************
+
+ Function : UDV_GotoBtnProc()
+
+ Purpose : create the Export dialog box
+
+ Return value : none
+
+*******************************************************************************/
+static void UDV_GotoBtnProc(ButtoN g)
+{
+DdvMainWinPtr dmwp;
+DdvMainPtr dmp;
+MsaParaGPopList mppl;
+WindoW hParent;
+Char szCol[20],szRow[20],szInfo[255];
+Int4 col,row,from_col,to_col,from_row,to_row,old_pos;
+Boolean bHorzScroll,bVertScroll;
+BaR hsb,vsb;
+
+ /*get main data block*/
+ hParent=(WindoW)ParentWindow(g);
+ if (!hParent) return;
+ dmwp=(DdvMainWinPtr)GetObjectExtra(hParent);
+ if (!dmwp) return;
+ dmp=(DdvMainPtr)GetObjectExtra(dmwp->hWndDDV);
+ if (!dmp) return;
+
+ /*get user values*/
+ GetTitle(dmwp->gotoValCol,szCol,19);
+ GetTitle(dmwp->gotoValRow,szRow,19);
+ col=atoi(szCol);
+ row=atoi(szRow);
+
+ /*check their validity*/
+ mppl=dmp->MSA_d.pgp_l;
+ if (row<1 || row>mppl.nBsp){
+ sprintf(szInfo,"Please enter a 'row' value in\nthe range [1..%i]",
+ mppl.nBsp);
+ Message(MSG_OK,szInfo);
+ Select(dmwp->gotoValRow);
+ return;
+ }
+ if (col<1 || col>mppl.LengthAli){
+ sprintf(szInfo,"Please enter a 'column' value in\nthe range [1..%i]",
+ mppl.LengthAli);
+ Message(MSG_OK,szInfo);
+ Select(dmwp->gotoValCol);
+ return;
+ }
+
+ /*do I need to scroll the panel content*/
+ DDV_GetCurrentDispRange(dmwp->hWndDDV,&dmp->GrData,mppl.LengthAli,
+ &from_col,&to_col,&from_row,&to_row);
+ if (col>=from_col && col<=to_col)
+ bHorzScroll=FALSE;
+ else
+ bHorzScroll=TRUE;
+ if (row>=from_row && row<=to_row)
+ bVertScroll=FALSE;
+ else
+ bVertScroll=TRUE;
+
+ dmp->dtd.col=col;
+ dmp->dtd.row=row;
+ if (bHorzScroll){
+ hsb = GetSlateHScrollBar ((SlatE) dmp->hWndDDV);
+ col--;/*switch to zero-based values*/
+ old_pos=GetBarValue(hsb);
+ SetValue(hsb,old_pos+(col-old_pos)-5);
+ }
+ if (bVertScroll){
+ vsb = GetSlateVScrollBar ((SlatE) dmp->hWndDDV);
+ row--;/*switch to zero-based values*/
+ old_pos=GetBarValue(vsb);
+ SetValue(vsb,old_pos+(row-old_pos));
+ }
+ dmp->dtd.action=DDV_INVAL_REGION;
+ dmp->dtd.status=DDV_SET_TIMER;
+}
+
+/*******************************************************************************
+
+ Function : DDV_TimerProc()
+
+ Purpose : timer callback of DDV
+
+ Return value : none
+
+*******************************************************************************/
+extern void DDV_TimerProc (WindoW w)
+{
+DdvMainWinPtr dmwp;
+DdvMainPtr dmp;
+Int4 col,row;
+
+ /*get main data block*/
+ dmwp=(DdvMainWinPtr)GetObjectExtra(w);
+ if (!dmwp) return;
+ dmp=(DdvMainPtr)GetObjectExtra(dmwp->hWndDDV);
+ if (!dmp) return;
+ if (dmp->dtd.status==DDV_SET_TIMER){
+ dmp->dtd.delay=0;
+ if (dmp->dtd.action==DDV_INVAL_REGION){
+ DDV_InvalRegion(dmp->hWndDDV,&(dmp->GrData),
+ _max_(0,dmp->dtd.col-1),dmp->dtd.col+1,
+ dmp->dtd.row,FALSE);
+ }
+ dmp->dtd.status=DDV_TEST_TIMER;
+ }
+ if (dmp->dtd.status==DDV_TEST_TIMER){
+ if (dmp->dtd.delay>10){
+ if (dmp->dtd.action==DDV_INVAL_REGION){
+ col=dmp->dtd.col;
+ row=dmp->dtd.row;
+ dmp->dtd.col=0;
+ dmp->dtd.row=0;
+ DDV_InvalRegion(dmp->hWndDDV,&(dmp->GrData),
+ _max_(0,col-1),col+1,row,FALSE);
+ dmp->dtd.action=DDV_NOTHING;
+ }
+ }
+ }
+ dmp->dtd.delay++;
+}
+
+/*******************************************************************************
+
+ Function : DDV_DeleteRow()
+
+ Purpose : UI to delete a row
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_DeleteRow(IteM i)
+{
+DdvMainWinPtr mWin_d;
+DdvMainPtr dmp;
+WindoW hWinMain,temport;
+DDE_StackPtr ddesp;
+RecT rcP;
+static Int4 PassCount = 0;
+BaR hsb;
+
+ /*get some data*/
+ hWinMain=(WindoW)ParentWindow(i);
+ if (hWinMain==NULL) return;
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (hWinMain);
+ if (mWin_d==NULL) return;
+ if (mWin_d->hWndDDV==NULL) return;
+ dmp = (DdvMainPtr) GetObjectExtra(mWin_d->hWndDDV);
+ if (dmp==NULL) return;
+
+ ddesp = dmp->dsp;
+
+ if (PassCount == 0) {
+ DDE_ShiftBlock(ddesp, 0, 5, TRUE);
+ }
+
+ if (PassCount == 1) {
+ DDE_ShiftBlock(ddesp, 0, -5, TRUE);
+ PassCount = 4;
+ }
+
+ if (PassCount == 5) {
+ DDE_InsertGap(ddesp, 7, 1649, TRUE);
+ DDE_InsertGap(ddesp, 7, 1649, TRUE);
+ DDE_InsertGap(ddesp, 7, 9, TRUE);
+ DDE_InsertGap(ddesp, 7, 9, TRUE);
+ DDE_InsertGap(ddesp, 7, 9, TRUE);
+ DDE_InsertGap(ddesp, 7, 11, TRUE);
+ DDE_InsertGap(ddesp, 7, 3, TRUE);
+ DDE_InsertGap(ddesp, 7, 1, TRUE);
+ DDE_InsertGap(ddesp, 7, 0, TRUE);
+ DDE_InsertGap(ddesp, 7, 0, TRUE);
+ DDE_InsertGap(ddesp, 7, 27, TRUE);
+ DDE_InsertGap(ddesp, 7, 23, TRUE);
+ DDE_InsertGap(ddesp, 7, 22, TRUE);
+ DDE_InsertGap(ddesp, 7, 1645, TRUE);
+ DDE_InsertGap(ddesp, 7, 1655, TRUE);
+ DDE_InsertGap(ddesp, 7, 1649, TRUE);
+ DDE_InsertGap(ddesp, 7, 1649, TRUE);
+ DDE_InsertGap(ddesp, 7, 1650, TRUE);
+ DDE_InsertGap(ddesp, 7, 1648, TRUE);
+ DDE_InsertGap(ddesp, 7, 1648, TRUE);
+ PassCount = 6;
+ }
+
+ if (PassCount == 7) {
+ DDE_RemoveGap(ddesp, 7, 1649, TRUE);
+ DDE_RemoveGap(ddesp, 7, 1645, TRUE);
+ DDE_RemoveGap(ddesp, 7, 15, TRUE);
+ DDE_RemoveGap(ddesp, 7, 15, TRUE);
+ DDE_RemoveGap(ddesp, 7, 1, TRUE);
+ DDE_RemoveGap(ddesp, 7, 1, TRUE);
+ DDE_RemoveGap(ddesp, 7, 25, TRUE);
+ DDE_RemoveGap(ddesp, 7, 20, TRUE);
+ DDE_RemoveGap(ddesp, 7, 18, TRUE);
+ DDE_RemoveGap(ddesp, 7, 12, TRUE);
+ DDE_RemoveGap(ddesp, 7, 11, TRUE);
+ DDE_RemoveGap(ddesp, 7, 4, TRUE);
+ DDE_RemoveGap(ddesp, 7, 0, TRUE);
+ DDE_RemoveGap(ddesp, 7, 0, TRUE);
+ DDE_InsertGap(ddesp, 7, 0, TRUE);
+ DDE_RemoveGap(ddesp, 7, 1636, TRUE);
+ DDE_InsertGap(ddesp, 7, 1645, TRUE);
+ DDE_InsertGap(ddesp, 7, 1647, TRUE);
+ DDE_RemoveGap(ddesp, 7, 1645, TRUE);
+ DDE_RemoveGap(ddesp, 7, 1646, TRUE);
+ DDE_InsertGap(ddesp, 7, 1645, TRUE);
+ DDE_InsertGap(ddesp, 7, 1647, TRUE);
+ DDE_RemoveGap(ddesp, 7, 1647, TRUE);
+ DDE_RemoveGap(ddesp, 7, 1645, TRUE);
+ DDE_RemoveGap(ddesp, 7, 0, TRUE);
+ DDE_InsertGap(ddesp, 7, 0, TRUE);
+ DDE_InsertGap(ddesp, 7, 0, TRUE);
+ DDE_InsertGap(ddesp, 7, 1, TRUE);
+ DDE_InsertGap(ddesp, 7, 3, TRUE);
+ DDE_InsertGap(ddesp, 7, 5, TRUE);
+ DDE_RemoveGap(ddesp, 7, 1, TRUE);
+ DDE_RemoveGap(ddesp, 7, 2, TRUE);
+ DDE_RemoveGap(ddesp, 7, 0, TRUE);
+ DDE_RemoveGap(ddesp, 7, 0, TRUE);
+ DDE_RemoveGap(ddesp, 7, 1, TRUE);
+ DDE_InsertGap(ddesp, 7, 1649, TRUE);
+ DDE_InsertGap(ddesp, 7, 1648, TRUE);
+ DDE_InsertGap(ddesp, 7, 1647, TRUE);
+ DDE_InsertGap(ddesp, 7, 1647, TRUE);
+ DDE_RemoveGap(ddesp, 7, 1647, TRUE);
+ DDE_InsertGap(ddesp, 7, 0, TRUE);
+ DDE_RemoveGap(ddesp, 7, 1648, TRUE);
+ DDE_InsertGap(ddesp, 7, 1649, TRUE);
+ DDE_RemoveGap(ddesp, 7, 1649, TRUE);
+ PassCount = 14;
+ }
+
+ if (PassCount == 15) {
+ DDE_HideRow(ddesp, 3, TRUE);
+ DDE_HideRow(ddesp, 3, TRUE);
+ DDE_HideRow(ddesp, 4, TRUE);
+ DDE_HideRow(ddesp, 0, TRUE);
+ DDE_HideRow(ddesp, 7, TRUE);
+ }
+
+ if (PassCount == 16) {
+ DDE_ShowRow(ddesp, 2, TRUE);
+ DDE_ShowRow(ddesp, 3, TRUE);
+ DDE_ShowRow(ddesp, 0, TRUE);
+ DDE_ShowRow(ddesp, 4, TRUE);
+ DDE_ShowRow(ddesp, 7, TRUE);
+ }
+
+ if (PassCount == 17) {
+ DDE_MoveRow(ddesp, 5, 2, TRUE);
+ }
+
+ if (PassCount == 18) {
+ DDE_HideRow(ddesp, 3, TRUE);
+ DDE_HideRow(ddesp, 4, TRUE);
+ DDE_HideRow(ddesp, 0, TRUE);
+ DDE_HideRow(ddesp, 7, TRUE);
+ DDE_HideRow(ddesp, 2, TRUE);
+ DDE_HideRow(ddesp, 1, TRUE);
+ DDE_HideRow(ddesp, 6, TRUE);
+ DDE_HideRow(ddesp, 5, TRUE);
+ DDE_HideRow(ddesp, 4, TRUE);
+ PassCount = 19;
+ }
+
+ if (PassCount == 20) {
+ DDE_ShowRow(ddesp, 7, TRUE);
+ DDE_ShowRow(ddesp, 0, TRUE);
+ DDE_ShowRow(ddesp, 4, TRUE);
+ DDE_ShowRow(ddesp, 3, TRUE);
+ DDE_ShowRow(ddesp, 1, TRUE);
+ DDE_ShowRow(ddesp, 5, TRUE);
+ DDE_ShowRow(ddesp, 6, TRUE);
+ DDE_ShowRow(ddesp, 2, TRUE);
+ PassCount = 27;
+ }
+
+ if (PassCount == 28) {
+ DDE_MoveRow(ddesp, 3, 3, TRUE);
+ DDE_MoveRow(ddesp, 2, 5, TRUE);
+ DDE_MoveRow(ddesp, 0, 6, TRUE);
+ DDE_MoveRow(ddesp, 7, 1, TRUE);
+ DDE_MoveRow(ddesp, 7, 0, TRUE);
+ DDE_MoveRow(ddesp, 0, 7, TRUE);
+ PassCount = 33;
+ }
+
+ if (PassCount == 34) {
+ DDE_HideRow(ddesp, 6, TRUE);
+ DDE_HideRow(ddesp, 1, TRUE);
+ DDE_HideRow(ddesp, 0, TRUE);
+ DDE_HideRow(ddesp, 7, TRUE);
+ PassCount = 37;
+ }
+
+ if (PassCount == 38) {
+ DDE_MoveRow(ddesp, 3, 1, TRUE);
+ DDE_MoveRow(ddesp, 0, 2, TRUE);
+ DDE_MoveRow(ddesp, 0, 3, TRUE);
+ DDE_MoveRow(ddesp, 3, 0, TRUE);
+ PassCount = 41;
+ }
+
+ if (PassCount == 42) {
+ DDE_ShowRow(ddesp, 1, TRUE);
+ DDE_ShowRow(ddesp, 7, TRUE);
+ DDE_ShowRow(ddesp, 6, TRUE);
+ DDE_ShowRow(ddesp, 0, TRUE);
+ PassCount = 45;
+ }
+
+ if (PassCount == 46) {
+ DDE_HideNewRow(ddesp, 5, TRUE);
+ DDE_HideNewRow(ddesp, 2, TRUE);
+ DDE_HideNewRow(ddesp, 4, TRUE);
+ DDE_HideNewRow(ddesp, 3, TRUE);
+ PassCount = 49;
+ }
+
+ if (PassCount == 50) {
+ DDE_ShowNewRow(ddesp, 2, TRUE);
+ DDE_ShowNewRow(ddesp, 3, TRUE);
+ DDE_ShowNewRow(ddesp, 5, TRUE);
+ DDE_ShowNewRow(ddesp, 4, TRUE);
+ PassCount = 53;
+ }
+
+ if (PassCount == 54) {
+ DDE_HideRow(ddesp, 4, TRUE);
+ DDE_HideRow(ddesp, 7, TRUE);
+ DDE_HideRow(ddesp, 0, TRUE);
+ DDE_RestoreRowOrder(ddesp, TRUE);
+ DDE_ShowRow(ddesp, 7, TRUE);
+ DDE_ShowRow(ddesp, 0, TRUE);
+ DDE_ShowRow(ddesp, 4, TRUE);
+ }
+
+ if (PassCount == 55) {
+ DDE_ShiftRightBoundary(ddesp, 0, -1640, TRUE);
+ DDE_DeleteBlock(ddesp, 0, TRUE);
+ PassCount = 64;
+ }
+
+ if (PassCount == 65) {
+ DDE_CreateBlock(ddesp, 20, 30, TRUE);
+ DDE_CreateBlock(ddesp, 15, 35, TRUE);
+ DDE_CreateBlock(ddesp, 25, 40, TRUE);
+ DDE_CreateBlock(ddesp, 15, 40, TRUE);
+ }
+
+ MemCopy(&(dmp->MSA_d.pgp_l), ddesp->pEdit->pPopList, sizeof(MsaParaGPopList));
+
+ DDV_InitColour_When_Start(dmp->MSA_d.pgp_l.sap,
+ &(dmp->MSA_d.pgp_l),&(dmp->Globals.colorp), FALSE);
+
+ /* recalculate window size */
+ DDV_WhatSize(dmp);
+ /* adjust horizontal scroll bar */
+ hsb = GetSlateHScrollBar((SlatE) dmp->hWndDDV);
+ DDV_UpdateHScrollVal(dmp->hWndDDV, FALSE, GetBarValue(hsb));
+
+ PassCount++;
+
+ temport=SavePort(mWin_d->hWndDDV);
+ Select(mWin_d->hWndDDV);
+ ObjectRect(mWin_d->hWndDDV, &rcP);
+ InvalRect(&rcP);
+ Update();
+ RestorePort(temport);
+ return;
+}
+
+static void DDV_MoveRowLeft(IteM i)
+{
+ DDV_DoEditFunction(i, MOVE_ROW_LEFT);
+ return;
+}
+
+static void DDV_MoveRowRight(IteM i)
+{
+ DDV_DoEditFunction(i, MOVE_ROW_RIGHT);
+ return;
+}
+
+static void DDV_MoveLeftBoundaryLeft(IteM i)
+{
+ DDV_DoEditFunction(i, MOVE_LEFT_BOUNDARY_LEFT);
+ return;
+}
+
+static void DDV_MoveLeftBoundaryRight(IteM i)
+{
+ DDV_DoEditFunction(i, MOVE_LEFT_BOUNDARY_RIGHT);
+ return;
+}
+
+static void DDV_MoveRightBoundaryLeft(IteM i)
+{
+ DDV_DoEditFunction(i, MOVE_RIGHT_BOUNDARY_LEFT);
+ return;
+}
+
+static void DDV_MoveRightBoundaryRight(IteM i)
+{
+ DDV_DoEditFunction(i, MOVE_RIGHT_BOUNDARY_RIGHT);
+ return;
+}
+
+static void DDV_DeleteBlock(IteM i)
+{
+ DDV_DoEditFunction(i, DDE_DELETE_BLOCK);
+ return;
+}
+
+static void DDV_CreateBlock(IteM i)
+{
+ DDV_DoEditFunction(i, DDE_CREATE_BLOCK);
+ return;
+}
+
+static void DDV_Prev(IteM i)
+{
+ DDV_DoEditFunction(i, DDE_PREV);
+ return;
+}
+
+static void DDV_Next(IteM i)
+{
+ DDV_DoEditFunction(i, DDE_NEXT);
+ return;
+}
+
+static void DDV_Orig(IteM i)
+{
+ DDV_DoEditFunction(i, DDE_ORIG);
+ return;
+}
+
+static void DDV_LaunchEditor(IteM i)
+{
+ DDV_DoEditFunction(i, DDE_LAUNCH_EDITOR);
+ return;
+}
+
+static void DDV_MergeBlocks(IteM i)
+{
+ DDV_DoEditFunction(i, DDE_MERGE_BLOCKS);
+ return;
+}
+
+static void DDV_SplitBlock(IteM i)
+{
+ DDV_DoEditFunction(i, DDE_SPLIT_BLOCK);
+ return;
+}
+
+static void DDV_DeleteBlock2(IteM i)
+{
+ DDV_DoEditFunction(i, DDV_DELETE_BLOCK);
+ return;
+}
+
+
+static void DDV_CallSaveEdits(IteM i) {
+/*----------------------------------------------------------------------------
+* get DDVMainPtr and call DDV_SaveEdits
+*---------------------------------------------------------------------------*/
+ WindoW hWinMain;
+ DdvMainWinPtr mWin_d;
+ DdvMainPtr dmp;
+
+ hWinMain=(WindoW)ParentWindow(i);
+ if (hWinMain==NULL) return;
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (hWinMain);
+ if (mWin_d==NULL) return;
+ if (mWin_d->hWndDDV==NULL) return;
+ dmp = (DdvMainPtr) GetObjectExtra(mWin_d->hWndDDV);
+ if (dmp==NULL) return;
+
+ DDV_SaveEdits(dmp, TRUE);
+}
+
+
+static void write_annot(SeqAlignPtr align)
+{
+ SeqAnnotPtr annot;
+ AsnIoPtr aip;
+
+ annot = SeqAnnotNew();
+ annot->type = 2;
+ annot->data = align;
+
+ aip = AsnIoOpen("temp2.sat", "w");
+ SeqAnnotAsnWrite(annot, aip, NULL);
+ AsnIoClose(aip);
+
+ annot->data = NULL;
+ SeqAnnotFree(annot);
+}
+
+
+NLM_EXTERN void DDV_SaveEdits(DdvMainPtr dmp, Boolean UpdateDDV) {
+/*----------------------------------------------------------------------------
+* create a DenseSeg for the block that has been created or edited.
+* pass this info to the AlnMgr and tell it to add or replace the block.
+*---------------------------------------------------------------------------*/
+ Int4* pStarts;
+ Int4* pLens;
+ Uint1* pStrands;
+ Int4 ii, jj, NumSegs, NumRows, NumBlocksAtLastSave, NumBlocksNow;
+ DenseSegPtr dsp;
+ SeqAlignPtr sap, indexed_sap;
+ SeqId head;
+ SeqIdPtr sip_prev, sip;
+ DDVUpdateMSG dum;
+ MsaParaGPopListPtr mpplp;
+ Boolean ReDraw;
+ BaR hsb;
+ Int4 HPos, Col, i;
+
+ /* note: dsp is DenseSegPtr */
+ /* dmp->dsp is DDE_StackPtr */
+
+ NumRows = dmp->dsp->pEdit->TotalNumRows;
+ NumSegs = DDE_GetNumSegmentsInBlock(dmp->dsp->pEdit, 0);
+ sap = ViewMgr_GetBegin(dmp->MSA_d.pgp_l.viewed_sap);
+ indexed_sap = ViewMgr_GetBeginIndexed(dmp->MSA_d.pgp_l.viewed_sap);
+
+ /* if there's a block that gets added or replaced, create a DenseSeg */
+ if (NumSegs > 0) {
+ /* create the empty dense seg, do NOT free it in this routine */
+ dsp = DenseSegNew();
+ dsp->dim = dmp->dsp->pEdit->TotalNumRows;
+ dsp->numseg = NumSegs;
+ /* create the starts, lens, and strands arrays */
+ pStarts = MemNew(NumRows * NumSegs * sizeof(Int4));
+ pLens = MemNew(NumSegs * sizeof(Int4));
+ pStrands = MemNew(NumRows * NumSegs * sizeof(Uint1));
+ DDE_CreateArraysForDenseSeg(dmp->dsp->pEdit, 0, pStarts, pLens); /* fill starts and lens */
+ for (ii=0; ii<NumSegs; ii++) {
+ for (jj=0; jj<NumRows; jj++) {
+ pStrands[ii*NumRows + jj] = AlnMgrGetNthStrand(sap, jj+1); /* fill strands */
+ }
+ }
+ dsp->starts = pStarts;
+ dsp->lens = pLens;
+ dsp->strands = pStrands;
+ /* create the linked-list of SeqIdPtr's */
+ sip_prev = &head;
+ for (ii=0; ii<NumRows; ii++) {
+ sip = AlnMgrGetNthSeqIdPtr(indexed_sap, ii+1);
+ sip_prev->next = sip;
+ sip_prev = sip_prev->next;
+ }
+ dsp->ids = head.next;
+ }
+
+ if (NumSegs > 0) {NumBlocksNow = 1;}
+ else {NumBlocksNow = 0;}
+
+ NumBlocksAtLastSave = dmp->dsp->NumBlocks;
+
+ ReDraw = FALSE;
+ if ((NumBlocksAtLastSave==1) && (NumBlocksNow==0)) {
+ /* delete block */
+ AlnMgrReplaceBlock(indexed_sap, NULL, dmp->dsp->LaunchBlock+1);
+ }
+ if ((NumBlocksAtLastSave==1) && (NumBlocksNow==1)) {
+ /* replace block */
+ AlnMgrReplaceBlock(indexed_sap, dsp, dmp->dsp->LaunchBlock+1);
+ ReDraw = TRUE;
+ }
+ if ((NumBlocksAtLastSave==0) && (NumBlocksNow==1)) {
+ /* add block */
+ AlnMgrAddBlock(indexed_sap, dsp);
+ dmp->dsp->IsUnAligned = FALSE;
+ ReDraw = TRUE;
+ }
+
+ SeqAlignListFree(sap);
+ sap = AlnMgrGetSubAlign(indexed_sap, NULL, 0, -1);
+
+ ViewMgr_SetBegin(dmp->MSA_d.pgp_l.viewed_sap, sap, FALSE, FALSE);
+ /* indicate there are no edits to save when quitting DDE */
+ dmp->dsp->SomethingToSave = FALSE;
+
+ dmp->dsp->NumBlocks = NumBlocksNow;
+
+ /* redraw the display when 2 aligned blocks are merged */
+ /* if merging with preceeding block, launch block is decremented */
+ /* (there's no need to redraw when the first block is left aligned */
+ /* or when the last block is right aligned. however, since I have */
+ /* no way of knowing how many blocks there are, a right aligned last */
+ /* block always causes a redraw) */
+
+ /* update: we decided not to do auto merge. so, I'm setting */
+ /* ReDraw to FALSE here. no redraw. no modifying block index. */
+ /* if we go back to auto-merge, just get rid of this one line. */
+ ReDraw = FALSE;
+
+ if (ReDraw) {
+ if (DDE_FirstColumnIsAligned(dmp->dsp->pEdit)) {
+ if (dmp->dsp->LaunchBlock == 0) {
+ ReDraw = FALSE;
+ }
+ else {
+ dmp->dsp->LaunchBlock--;
+ }
+ }
+ else if (!DDE_LastColumnIsAligned(dmp->dsp->pEdit)) {
+ ReDraw = FALSE;
+ }
+ }
+
+ if (ReDraw) {
+ mpplp = DDE_CreateDisplay(indexed_sap, dmp->dsp->LaunchBlock,
+ dmp->dsp->IsUnAligned, &dmp->dsp->NumBlocks);
+ mpplp->viewed_sap = dmp->dsp->pEdit->pPopList->viewed_sap;
+ dmp->dsp->pEdit = DDE_New(mpplp, dmp->dsp->pEdit->TotalNumRows);
+ DDE_MergeNodesLists(dmp->dsp->pEdit);
+ /* hide the rows in DDE that are hidden in DDV */
+ NumRows = dmp->dsp->pEdit->TotalNumRows;
+ for (i=0; i<NumRows; i++) {
+ if (ViewMgr_TRow2VRow(dmp->MSA_d.pgp_l.viewed_sap, i+1) == -1) {
+ DDE_HideRow(dmp->dsp, i, FALSE);
+ }
+ }
+ DDE_Add(dmp->dsp);
+ dmp->dsp->SomethingToSave = FALSE;
+ /* position block at 5th col */
+ hsb = GetSlateHScrollBar((SlatE) dmp->hWndDDV);
+ HPos = GetBarValue(hsb);
+ Col = DDE_GetAlignStart(dmp->dsp->pEdit, 0);
+ DDV_ReDrawAtCol(dmp, HPos+Col-5, TRUE);
+ }
+
+ /* tell DDV to rebuild its display */
+ if (UpdateDDV) {
+ dum.type = UPDATE_TYPE_VIEWMGR;
+ dum.data = NULL;
+ ViewMgr_Update(dmp->MSA_d.pgp_l.viewed_sap);
+ ObjMgrSendProcMsg(OM_MSG_UPDATE, dmp->MSA_d.entityID, dmp->MSA_d.itemID,
+ OBJ_SEQALIGN, 0, 0, (Pointer)&dum);
+ }
+
+ return;
+}
+
+/*******************************************************************************
+
+ Function : DDV_DoEditFunction(Item i, Int4 WhichOne)
+
+ Purpose : UI to do one of the edit functions
+
+ Return value : none
+
+*******************************************************************************/
+static void DDV_DoEditFunction(IteM i, Int4 WhichOne)
+{
+DdvMainWinPtr mWin_d;
+DdvMainPtr dmp;
+WindoW hWinMain;
+DDE_StackPtr ddesp;
+
+ /*get some data*/
+ hWinMain=(WindoW)ParentWindow(i);
+ if (hWinMain==NULL) return;
+ mWin_d = (DdvMainWinPtr) GetObjectExtra (hWinMain);
+ if (mWin_d==NULL) return;
+ if (mWin_d->hWndDDV==NULL) return;
+ dmp = (DdvMainPtr) GetObjectExtra(mWin_d->hWndDDV);
+ if (dmp==NULL) return;
+
+ ddesp = dmp->dsp;
+
+ switch (WhichOne) {
+ case MOVE_ROW_LEFT:
+ DDE_ShiftRow(ddesp, 4, -1, TRUE, TRUE);
+ DDV_ReDraw(dmp);
+ break;
+ case MOVE_ROW_RIGHT:
+ DDE_ShiftRow(ddesp, 4, 1, TRUE, TRUE);
+ DDV_ReDraw(dmp);
+ break;
+ case MOVE_LEFT_BOUNDARY_LEFT:
+ DDE_ShiftLeftBoundary(ddesp, 0, -1, TRUE);
+ DDV_ReDraw(dmp);
+ break;
+ case MOVE_LEFT_BOUNDARY_RIGHT:
+ DDE_ShiftLeftBoundary(ddesp, 0, 1, TRUE);
+ DDV_ReDraw(dmp);
+ break;
+ case MOVE_RIGHT_BOUNDARY_LEFT:
+ DDE_ShiftRightBoundary(ddesp, 0, -1, TRUE);
+ DDV_ReDraw(dmp);
+ break;
+ case MOVE_RIGHT_BOUNDARY_RIGHT:
+ DDE_ShiftRightBoundary(ddesp, 0, 1, TRUE);
+ DDV_ReDraw(dmp);
+ break;
+ case DDE_DELETE_BLOCK:
+ if (DDE_DeleteBlock(ddesp, 0, TRUE)) {
+ DDV_ReDraw(dmp);
+ }
+ break;
+ case DDE_CREATE_BLOCK:
+ /* switch to the mode that allows block creation */
+ dmp->SavedMouseMode = dmp->MouseMode;
+ dmp->MouseMode = DDV_MOUSEMODE_CREATEBLOCK;
+ CrossCursor();
+ break;
+ case DDE_PREV:
+ if (DDE_Prev(ddesp)) {
+ DDV_ReDraw(dmp);
+ }
+ break;
+ case DDE_NEXT:
+ if (DDE_Next(ddesp)){
+ DDV_ReDraw(dmp);
+ }
+ break;
+ case DDE_ORIG:
+ DDE_GetOriginal(ddesp, TRUE);
+ DDV_ReDraw(dmp);
+ break;
+ case DDE_LAUNCH_EDITOR:
+ dmp->SavedMouseMode = dmp->MouseMode;
+ dmp->MouseMode = DDV_MOUSEMODE_LAUNCHEDITOR;
+ CrossCursor();
+ break;
+ case DDE_MERGE_BLOCKS:
+ dmp->SavedMouseMode = dmp->MouseMode;
+ dmp->MouseMode = DDV_MOUSEMODE_MERGEBLOCKS1;
+ CrossCursor();
+ break;
+ case DDE_SPLIT_BLOCK:
+ dmp->SavedMouseMode = dmp->MouseMode;
+ dmp->MouseMode = DDV_MOUSEMODE_SPLITBLOCK;
+ CrossCursor();
+ break;
+ case DDV_DELETE_BLOCK:
+ dmp->SavedMouseMode = dmp->MouseMode;
+ dmp->MouseMode = DDV_MOUSEMODE_DELETEBLOCK;
+ CrossCursor();
+ break;
+ }
+ if (dmp->bEditor) {
+ DDV_GreyOut(mWin_d, DDE_AtStartOfStack(dmp->dsp), DDE_AtEndOfStack(dmp->dsp));
+ }
+ return;
+}
+
+
+NLM_EXTERN void DDVResetProc (PaneL p)
+
+{
+}
+
+static void PopulateDDV (BioseqViewPtr bvp)
+
+{
+}
+
+static void ShowDDV (BioseqViewPtr bvp, Boolean show)
+
+{
+}
+
+static void SelectDDV (BioseqViewPtr bvp, Uint2 selentityID, Uint2 selitemID,
+ Uint2 selitemtype, SeqLocPtr region,
+ Boolean select, Boolean scrollto)
+
+{
+}
+
+static void ResizeDDV (BioseqViewPtr bvp)
+
+{
+}
+
+BioseqPageData ddvPageData = {
+ "Multiple", TRUE, TRUE, TRUE, FALSE, -1,
+ PopulateDDV, ShowDDV, SelectDDV,
+ NULL, NULL,
+ NULL, NULL, ResizeDDV, NULL
+};
+
diff --git a/ddv/ddvpanel.h b/ddv/ddvpanel.h
new file mode 100644
index 00000000..cd3edb40
--- /dev/null
+++ b/ddv/ddvpanel.h
@@ -0,0 +1,278 @@
+/* $Id: ddvpanel.h,v 1.30 2000/07/12 22:22:42 hurwitz Exp $
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information (NCBI)
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government do not place any restriction on its use or reproduction.
+* We would, however, appreciate having the NCBI and the author cited in
+* any work or product based on this material
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* ===========================================================================
+*
+* File Name: ddvpanel.h
+*
+* Author: Patrick Durand
+*
+* Version Creation Date: 06/19/99
+*
+* $Revision: 1.30 $
+*
+* File Description:
+*
+* Modifications:
+* --------------------------------------------------------------------------
+* $Log: ddvpanel.h,v $
+* Revision 1.30 2000/07/12 22:22:42 hurwitz
+* added delete block to DDV
+*
+* Revision 1.29 2000/07/08 20:43:58 vakatov
+* Get all "#include" out of the 'extern "C" { }' scope; other cleanup...
+*
+* Revision 1.28 2000/07/05 19:23:14 lewisg
+* add two panes to ddv, update msvc project files
+*
+* Revision 1.27 2000/06/30 22:31:51 hurwitz
+* added merge block function for DDV
+*
+* Revision 1.26 2000/06/02 19:57:04 hurwitz
+* added a query dialog when converting from pairwise multiple to true multiple, bug fix of double freeing of a seqAlignPtr
+*
+* Revision 1.25 2000/05/15 22:00:36 hurwitz
+* put save-edits query into DDV_SlaveQuit where it belongs
+*
+* Revision 1.24 2000/04/29 21:49:24 kans
+* removed bad characters on Mac
+*
+* Revision 1.23 2000/04/27 20:05:55 kans
+* added stub functions for Sequin
+*
+* Revision 1.22 2000/04/27 19:57:59 hurwitz
+* scroll to aligned block on launch of DDE
+*
+* Revision 1.21 2000/04/21 23:00:50 hurwitz
+* can launch DDE from DDV
+*
+* Revision 1.20 2000/04/10 21:41:26 lewisg
+* move alignment menus into ddv, udv from cn3d
+*
+* Revision 1.19 2000/04/10 20:58:42 hurwitz
+* added GUI controls for DeleteBlock in DDE
+*
+* Revision 1.18 2000/04/07 16:21:08 hurwitz
+* made delete block faster, added delete block to edit menu
+*
+* Revision 1.17 2000/03/21 14:21:47 durand
+* fixed a problem with menus setup
+*
+* Revision 1.16 2000/03/14 22:08:21 hurwitz
+* undo and redo working properly, restore-original function added
+*
+* Revision 1.15 2000/03/10 23:01:43 hurwitz
+* added undo and redo functions, first pass
+*
+* Revision 1.14 2000/03/06 22:45:58 hurwitz
+* can shift right boundary of an aligned block left and right, DDVRuler updates added
+*
+* Revision 1.13 2000/02/08 14:10:43 durand
+* made extern the functions DDV_UpdateHScrollVal and
+*
+* Revision 1.12 2000/02/04 16:05:41 durand
+* add click action to select a row
+*
+* Revision 1.11 2000/01/26 13:38:55 durand
+* update the GUI for the editor. Add functions to create the data to be used by the editor
+*
+* Revision 1.10 2000/01/10 15:09:45 durand
+* Use Entrez instead of ID1
+*
+* Revision 1.9 1999/12/07 21:40:14 durand
+* add mouse modes menu and caret facility for the editor
+*
+* Revision 1.8 1999/12/06 16:19:20 durand
+* add GoTo facility to DDV
+*
+* Revision 1.7 1999/12/03 23:17:23 lewisg
+* Patrick's new global update msg, argument passing when launching ddv, experimental editing
+*
+* Revision 1.6 1999/11/30 17:29:00 durand
+* fix a problem of redeclaration of the function DDV_CloseData
+*
+* Revision 1.5 1999/11/29 15:26:26 durand
+* designed a new GUI to fix problems under MacOS, Linux and SGI
+*
+* Revision 1.4 1999/10/22 20:12:47 durand
+* add Export command (text, HTML and Phylip formats)
+*
+* Revision 1.3 1999/10/20 13:17:19 durand
+* add display for disc. SeqAlign tails
+*
+* Revision 1.2 1999/10/15 21:57:37 durand
+* add a UI for display options
+*
+* Revision 1.1 1999/09/30 14:10:29 durand
+* add ddv to toolkit
+*
+* Revision 1.5 1999/09/09 21:55:07 durand
+* instantiate the Fle|Close command of DDV
+*
+* Revision 1.4 1999/07/01 14:08:08 durand
+* the loader functions of DDV or now in ddvopen.c
+*
+* Revision 1.2 1999/06/28 22:07:22 durand
+* add loader functions and clean the code with Lint and Purify
+*
+* Revision 1.1 1999/06/19 17:21:08 durand
+* add Vibrant DDV code
+*
+*
+*
+* ==========================================================================
+*/
+
+#ifndef _DDVPANEL_
+#define _DDVPANEL_
+
+#include <udviewer.h>
+#include <ddvmain.h>
+
+#undef NLM_EXTERN
+#ifdef NLM_IMPORT
+#define NLM_EXTERN NLM_IMPORT
+#else
+#define NLM_EXTERN extern
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/******************************************************************************
+
+ Data structures
+
+******************************************************************************/
+typedef struct ddvdispstylesmsg {/*used by the Display Styles Dlg box*/
+ WindoW hWinMain; /*DDV main window handle*/
+ ButtoN chk2;/*use color display chk box*/
+ ButtoN chk3;/*show left tail chk box*/
+ ButtoN chk4;/*show right tail chk box*/
+ GrouP g1; /*main group for Highlight unaligned regions"*/
+ GrouP g2; /*"Spacer" group for Highlight unaligned regions"*/
+ GrouP g5; /*"seq. justification" group for Highlight unaligned regions"*/
+ GrouP g12; /*BSP ruler style group*/
+ TexT edit1; /*size TexT */
+ LisT BspNames;/*list of BSP names*/
+ } DdvDispStylesMSG, PNTR DdvDispStylesMSGPtr;
+
+typedef struct ddvexporttextemsg {/*used by the Display Styles Dlg box*/
+ WindoW hWinMain; /*DDV main window handle*/
+ ButtoN chk2;/*show number*/
+ ButtoN chk3;/*show ticks*/
+ ButtoN chk4;/*Use block of 10 letters*/
+ ButtoN chk5;/*Display strand orientation*/
+ ButtoN chk6;/*Display BioSeq coordinates*/
+ ButtoN ok;
+ PopuP pop; /*list of available formats*/
+ TexT edit1; /*filename */
+ } DdvExportTexteMSG, PNTR DdvExportTexteMSGPtr;
+
+
+/******************************************************************************
+
+ Defines
+
+******************************************************************************/
+
+#define DDV_DEFAULT_PARAG_SIZE 70
+
+#define MOVE_ROW_LEFT 0
+#define MOVE_ROW_RIGHT 1
+#define MOVE_LEFT_BOUNDARY_LEFT 2
+#define MOVE_LEFT_BOUNDARY_RIGHT 3
+#define MOVE_RIGHT_BOUNDARY_LEFT 4
+#define MOVE_RIGHT_BOUNDARY_RIGHT 5
+#define DDE_PREV 6
+#define DDE_NEXT 7
+#define DDE_ORIG 8
+#define DDE_DELETE_BLOCK 9 /* for DDE */
+#define DDE_CREATE_BLOCK 10
+#define DDE_LAUNCH_EDITOR 11
+#define DDE_MERGE_BLOCKS 12
+#define DDE_SPLIT_BLOCK 13
+#define DDV_DELETE_BLOCK 14 /* for DDV */
+
+
+/******************************************************************************
+
+ Global varaibles
+
+******************************************************************************/
+extern Char szAppName[];
+extern Char szAppName2[];
+
+
+/******************************************************************************
+
+ Exported functions
+
+******************************************************************************/
+extern void DDV_EnableGotoTBItems(WindoW hParent,Boolean bEnable);
+extern void DDV_WhatSize(DdvMainPtr dmp);
+extern void DDV_InitPanelData(UDVPanelDataPtr pdp);
+extern void DDV_SetupWin (WindoW w,Boolean bInit);
+extern void DDV_Resize_DDV (PaneL p, Boolean bInit);
+extern void DDV_WinMainResize (WindoW w);
+extern void DDV_UpdateVScrollVal(PaneL p,Boolean bInit,Int4 CurPos);
+extern void DDV_UpdateHScrollVal(PaneL p,Boolean bInit,Int4 CurPos);
+extern void DDV_VHScrl(PaneL p,UnDViewerGraphDataPtr gdp, Int4 newval, Int4 oldval,
+ Boolean IsVscroll);
+extern void DDV_VScrlProc (BaR sb, SlatE s, Int4 newval, Int4 oldval);
+extern void DDV_HScrlProc (BaR sb, SlatE s, Int4 newval, Int4 oldval);
+extern Boolean DDV_CreateViewerPanel(WindoW w,DdvMainWinPtr dmwp,
+ SAM_ViewGlobal *vgp,Boolean bEditor);
+NLM_EXTERN void DDV_SetMenuFocus(WindoW w);
+extern void DDV_SetupMenus(WindoW w,Boolean isID1Ok,Boolean bEditor,
+ SAM_ViewGlobal *vgp);
+extern void DDV_WinMainResize (WindoW w);
+extern void DDV_WinMainCleanup (GraphiC g, VoidPtr data);
+extern void DDV_WinMainProgQuit(WindoW w);
+extern void DDV_InitGraphGlobal(DdvMainPtr dmp);
+extern void DDV_CloseData(DdvMainWinPtr mWin_d,Boolean bFinalExit);
+extern void DDV_SetRulerAttribInPGP(ValNodePtr ParaG_Head, Uint1 RulerStyle);
+extern void DDV_SortPGPLineNum(ValNodePtr PNTR Head, Int4 nBsp);
+extern void DDV_CleanupDDVPdata_g (DdvMainPtr dmp);
+extern void DDV_TimerProc (WindoW w);
+NLM_EXTERN void DDVResetProc (PaneL p);
+
+NLM_EXTERN void DDV_Save(ButtoN g);
+NLM_EXTERN void DDV_NoSave(ButtoN g);
+NLM_EXTERN void DDV_Cancel(ButtoN g);
+NLM_EXTERN void DDV_FileCloseIt(WindoW hWinMain);
+NLM_EXTERN void DDV_SaveEdits(DdvMainPtr dmp, Boolean UpdateDDV);
+
+#ifdef __cplusplus
+}
+#endif
+
+#undef NLM_EXTERN
+#ifdef NLM_EXPORT
+#define NLM_EXTERN NLM_EXPORT
+#else
+#define NLM_EXTERN
+#endif
+
+#endif /* ndef _DDVPANEL_ */
diff --git a/ddv/udv.dsp b/ddv/udv.dsp
new file mode 100644
index 00000000..708f87d7
--- /dev/null
+++ b/ddv/udv.dsp
@@ -0,0 +1,117 @@
+# Microsoft Developer Studio Project File - Name="udv" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=udv - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "udv.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "udv.mak" CFG="udv - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "udv - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE "udv - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "udv - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "udv___Win32_Debug"
+# PROP BASE Intermediate_Dir "udv___Win32_Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "udv___Win32_Debug"
+# PROP Intermediate_Dir "udv___Win32_Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /I "..\ddv" /I "..\cn3d" /I "..\access" /I "..\asnstat" /I "..\connect\lbapi" /I "..\connect" /I "..\asnlib" /I "..\vibrant" /I "..\biostruc" /I "..\object" /I "..\api" /I "..\cdromlib" /I "..\desktop" /I "..\tools" /I "..\corelib" /I "..\network\taxon1\common" /I "..\network\vibnet" /I "..\network\entrez\client" /I "..\network\nsclilib" /I "..\network\medarch\client" /I "..\network\id1arch" /I "..\network\taxon1\taxon2" /I "..\network\blast3\client" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# SUBTRACT CPP /Fr
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib vibnet.lib ncbidesk.lib ddvlib.lib ncbitool.lib ncbinacc.lib netcli.lib vibrant.lib ncbicdr.lib ncbiobj.lib ncbi.lib opengl32.lib glu32.lib glaux.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"..\cdromlib\debug" /libpath:"..\cdromlib\ncbicdr___Win32_Debug" /libpath:"..\corelib\debug" /libpath:"..\vibrant\debug" /libpath:"..\object\debug" /libpath:"..\biostruc\debug" /libpath:"..\desktop\debug" /libpath:"..\tools\debug" /libpath:"..\network\entrez\client\debug" /libpath:"..\network\vibnet\debug" /libpath:"..\network\nsclilib\debug" /libpath:"..\network\taxon1\taxon2\debug" /libpath:"..\network\id1arch\debug" /libpath:"..\network\medarch\client\debug" /libpath:"..\network\blast3\client\debug" /libpath:"ddvlib___Win32_Debug"
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "udv - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "udv___Win32_Release"
+# PROP BASE Intermediate_Dir "udv___Win32_Release"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "udv___Win32_Release"
+# PROP Intermediate_Dir "udv___Win32_Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /I "..\ddv" /I "..\cn3d" /I "..\access" /I "..\asnstat" /I "..\connect\lbapi" /I "..\connect" /I "..\asnlib" /I "..\vibrant" /I "..\biostruc" /I "..\object" /I "..\api" /I "..\cdromlib" /I "..\desktop" /I "..\tools" /I "..\corelib" /I "..\network\taxon1\common" /I "..\network\vibnet" /I "..\network\entrez\client" /I "..\network\nsclilib" /I "..\network\medarch\client" /I "..\network\id1arch" /I "..\network\taxon1\taxon2" /I "..\network\blast3\client" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# SUBTRACT BASE CPP /Fr
+# ADD CPP /nologo /W3 /Gm /GX /Zi /I ".." /I "..\ddv" /I "..\cn3d" /I "..\access" /I "..\asnstat" /I "..\connect\lbapi" /I "..\connect" /I "..\asnlib" /I "..\vibrant" /I "..\biostruc" /I "..\object" /I "..\api" /I "..\cdromlib" /I "..\desktop" /I "..\tools" /I "..\corelib" /I "..\network\taxon1\common" /I "..\network\vibnet" /I "..\network\entrez\client" /I "..\network\nsclilib" /I "..\network\medarch\client" /I "..\network\id1arch" /I "..\network\taxon1\taxon2" /I "..\network\blast3\client" /D "_WINDOWS" /D "WIN32" /D "_MBCS" /YX /FD /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib vibnet.lib ncbidesk.lib ddvlib.lib ncbitool.lib ncbinacc.lib netcli.lib vibrant.lib ncbicdr.lib ncbiobj.lib ncbi.lib opengl32.lib glu32.lib glaux.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"..\cdromlib\debug" /libpath:"..\cdromlib\ncbicdr___Win32_Debug" /libpath:"..\corelib\debug" /libpath:"..\vibrant\debug" /libpath:"..\object\debug" /libpath:"..\biostruc\debug" /libpath:"..\desktop\debug" /libpath:"..\tools\debug" /libpath:"..\network\entrez\client\debug" /libpath:"..\network\vibnet\debug" /libpath:"..\network\nsclilib\debug" /libpath:"..\network\taxon1\taxon2\debug" /libpath:"..\network\taxon1\common\debug" /libpath:"..\network\id1arch\debug" /libpath:"..\network\medarch\client\debug" /libpath:"..\network\blast3\client\debug" /libpath:"ddvlib___Win32_Debug"
+# SUBTRACT BASE LINK32 /pdb:none
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib vibnet.lib ncbidesk.lib ddvlib.lib ncbitool.lib ncbinacc.lib netcli.lib vibrant.lib ncbicdr.lib ncbiobj.lib ncbi.lib opengl32.lib glu32.lib glaux.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"..\cdromlib\ncbicdr___Win32_Release" /libpath:"..\cdromlib\ncbinacc___Win32_Release" /libpath:"..\corelib\ncbi___Win32_Release" /libpath:"..\vibrant\vibrant___Win32_Release" /libpath:"..\object\object___Win32_Release" /libpath:"..\biostruc\mmdb___Win32_Release" /libpath:"..\desktop\desktop___Win32_Release" /libpath:"..\tools\tools___Win32_Release" /libpath:"..\network\entrez\client\netentr___Win32_Release" /libpath:"..\network\vibnet\vibnet___Win32_Release" /libpath:"..\network\nsclilib\netcli___Win32_Release" /libpath:"..\network\taxon1\taxon2\ncbitxc2___Win32_Release" /libpath:"..\network\id1arch\ncbiid1___Win32_Release" /libpath:"..\network\medarch\client\medarch___Win32_Release" /libpath:"..\network\blast3\client\netblast___Win32_Release" /libpath:"..\cn3d\ncbicn3d___Win32_Release" /libpath:"..\ddv\ddvlib___Win32_Release"
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "udv - Win32 Debug"
+# Name "udv - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\link\mswin\udv.rc
+# End Source File
+# Begin Source File
+
+SOURCE=..\demo\udvmain.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project