Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zmap
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
zmap
Commits
bc58a6c3
Commit
bc58a6c3
authored
20 years ago
by
edgrif
Browse files
Options
Downloads
Patches
Plain Diff
new file to hold window utility routines.
parent
c550a28a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/zmapWindow/zmapWindowUtils.c
+217
-0
217 additions, 0 deletions
src/zmapWindow/zmapWindowUtils.c
with
217 additions
and
0 deletions
src/zmapWindow/zmapWindowUtils.c
0 → 100755
+
217
−
0
View file @
bc58a6c3
/* File: zmapWindowUtils.c
* Author: Ed Griffiths (edgrif@sanger.ac.uk)
* Copyright (c) Sanger Institute, 2005
*-------------------------------------------------------------------
* ZMap is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see the on-line version at http://www.gnu.org/copyleft/gpl.txt
*-------------------------------------------------------------------
* This file is part of the ZMap genome database package
* originated by
* Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk,
* Rob Clack (Sanger Institute, UK) rnc@sanger.ac.uk
*
* Description: Utility functions for the zMapWindow code.
*
* Exported functions: See ZMap/zmapWindow.h
* HISTORY:
* Last edited: Jan 20 17:03 2005 (edgrif)
* Created: Thu Jan 20 14:43:12 2005 (edgrif)
* CVS info: $Id: zmapWindowUtils.c,v 1.1 2005-01-24 13:22:19 edgrif Exp $
*-------------------------------------------------------------------
*/
#include
<ZMap/zmapUtils.h>
#include
<zmapWindow_P.h>
static
void
checkScrollRegion
(
ZMapWindow
window
,
double
start
,
double
end
)
;
void
zMapWindowGetVisible
(
ZMapWindow
window
,
double
*
top_out
,
double
*
bottom_out
)
{
double
scroll_x1
,
scroll_y1
,
scroll_x2
,
scroll_y2
;
foo_canvas_get_scroll_region
(
window
->
canvas
,
&
scroll_x1
,
&
scroll_y1
,
&
scroll_x2
,
&
scroll_y2
)
;
*
top_out
=
scroll_y1
;
*
bottom_out
=
scroll_y2
;
return
;
}
/** \Brief Scroll to the selected item.
*
* If necessary, recalculate the scroll region, then scroll to the item
* and highlight it.
*/
gboolean
zMapWindowScrollToItem
(
ZMapWindow
window
,
gchar
*
type
,
GQuark
feature_id
)
{
int
cx
,
cy
,
height
;
double
x1
,
y1
,
x2
,
y2
;
ZMapFeatureItem
featureItem
=
NULL
;
ZMapFeature
feature
;
ZMapFeatureTypeStyle
thisType
;
gboolean
result
;
G_CONST_RETURN
gchar
*
quarkString
;
GtkWidget
*
topWindow
;
if
(
!
(
quarkString
=
g_quark_to_string
(
feature_id
)))
{
zMapLogWarning
(
"Quark %d, of type %s, not a valid quark
\n
"
,
feature_id
,
type
)
;
result
=
FALSE
;
}
else
{
if
((
featureItem
=
(
ZMapFeatureItem
)
g_datalist_id_get_data
(
&
(
window
->
featureItems
),
feature_id
)))
{
feature
=
(
ZMapFeature
)
g_datalist_id_get_data
(
&
(
featureItem
->
feature_set
->
features
),
featureItem
->
feature_key
)
;
zMapAssert
(
feature
)
;
thisType
=
(
ZMapFeatureTypeStyle
)
g_datalist_get_data
(
&
(
window
->
types
),
type
);
zMapAssert
(
thisType
);
topWindow
=
gtk_widget_get_toplevel
(
GTK_WIDGET
(
window
->
canvas
));
gtk_widget_show_all
(
topWindow
);
/* featureItem holds canvasItem and ptr to the feature_set containing the feature. */
featureItem
=
g_datalist_id_get_data
(
&
(
window
->
featureItems
),
feature_id
);
feature
=
g_datalist_id_get_data
(
&
(
featureItem
->
feature_set
->
features
),
feature_id
);
/* May need to move scroll region if object is outside it. */
checkScrollRegion
(
window
,
feature
->
x1
,
feature
->
x2
)
;
/* scroll up or down to user's selection. */
foo_canvas_item_get_bounds
(
featureItem
->
canvasItem
,
&
x1
,
&
y1
,
&
x2
,
&
y2
);
/* world coords */
if
(
y1
<=
0
.
0
)
/* we might be dealing with a multi-box item, eg transcript */
{
double
px1
,
py1
,
px2
,
py2
;
foo_canvas_item_get_bounds
(
FOO_CANVAS_ITEM
(
featureItem
->
canvasItem
->
parent
),
&
px1
,
&
py1
,
&
px2
,
&
py2
);
if
(
py1
>
0
.
0
)
y1
=
py1
;
}
/* Note that because we zoom asymmetrically, we only convert the y coord
* to canvas coordinates, leaving the x as is. */
foo_canvas_w2c
(
window
->
canvas
,
0
.
0
,
y1
,
&
cx
,
&
cy
);
height
=
GTK_WIDGET
(
window
->
canvas
)
->
allocation
.
height
;
foo_canvas_scroll_to
(
window
->
canvas
,
(
int
)
x1
,
cy
-
height
/
3
);
/* canvas pixels */
foo_canvas_item_raise_to_top
(
featureItem
->
canvasItem
);
/* highlight the item */
zmapWindowHighlightObject
(
featureItem
->
canvasItem
,
window
,
thisType
);
zMapWindowFeatureClickCB
(
window
,
feature
)
;
/* show feature details on info_panel */
window
->
focusFeature
=
featureItem
->
canvasItem
;
window
->
focusType
=
thisType
;
result
=
TRUE
;
}
}
/* else silently ignore the fact we've not found it. */
return
result
;
}
/** \Brief Recalculate the scroll region.
*
* If the selected feature is outside the current scroll region, recalculate
* the region to be the same size but with the selecte feature in the middle.
*/
static
void
checkScrollRegion
(
ZMapWindow
window
,
double
start
,
double
end
)
{
double
x1
,
y1
,
x2
,
y2
;
/* NOTE THAT THIS ROUTINE NEEDS TO CALL THE VISIBILITY CHANGE CALLBACK IF WE MOVE
* THE SCROLL REGION TO MAKE SURE THAT ZMAPCONTROL UPDATES ITS SCROLLBARS.... */
foo_canvas_get_scroll_region
(
window
->
canvas
,
&
x1
,
&
y1
,
&
x2
,
&
y2
);
/* world coords */
if
(
start
<
y1
||
end
>
y2
)
{
ZMapWindowVisibilityChangeStruct
vis_change
;
int
top
,
bot
;
double
height
;
height
=
y2
-
y1
;
y1
=
start
-
(
height
/
2
.
0
)
;
if
(
y1
<
window
->
seq_start
)
y1
=
window
->
seq_start
;
y2
=
y1
+
height
;
/* this shouldn't happen */
if
(
y2
>
window
->
seq_end
)
y2
=
window
->
seq_end
;
foo_canvas_set_scroll_region
(
window
->
canvas
,
x1
,
y1
,
x2
,
y2
);
/* UGH, I'M NOT SURE I LIKE THE LOOK OF ALL THIS INT CONVERSION STUFF.... */
/* redraw the scale bar */
top
=
(
int
)
y1
;
/* zmapDrawScale expects integer coordinates */
bot
=
(
int
)
y2
;
gtk_object_destroy
(
GTK_OBJECT
(
window
->
scaleBarGroup
));
window
->
scaleBarGroup
=
zmapDrawScale
(
window
->
canvas
,
window
->
scaleBarOffset
,
window
->
zoom_factor
,
top
,
bot
,
&
(
window
->
major_scale_units
),
&
(
window
->
minor_scale_units
))
;
/* agh, this seems to be here because we move the scroll region...we need a function
* to do this all....... */
if
(
window
->
longItems
)
g_datalist_foreach
(
&
(
window
->
longItems
),
zmapWindowCropLongFeature
,
window
);
/* Call the visibility change callback to notify our caller that our zoom/position has
* changed. */
vis_change
.
zoom_status
=
window
->
zoom_status
;
vis_change
.
scrollable_top
=
y1
;
vis_change
.
scrollable_bot
=
y2
;
(
*
(
window
->
caller_cbs
->
visibilityChange
))(
window
,
window
->
app_data
,
(
void
*
)
&
vis_change
)
;
}
return
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment