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
71678619
Commit
71678619
authored
18 years ago
by
rds
Browse files
Options
Downloads
Patches
Plain Diff
cleaned out complex, unused code
parent
1c32e1b3
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/zmapWindowColOrder.c
+34
-293
34 additions, 293 deletions
src/zmapWindow/zmapWindowColOrder.c
with
34 additions
and
293 deletions
src/zmapWindow/zmapWindowColOrder.c
+
34
−
293
View file @
71678619
...
...
@@ -27,9 +27,9 @@
*
* Exported functions: See XXXXXXXXXXXXX.h
* HISTORY:
* Last edited: Dec 1
3
1
6:09
2006 (rds)
* Last edited: Dec 1
5
1
5:33
2006 (rds)
* Created: Tue Dec 5 14:48:45 2006 (rds)
* CVS info: $Id: zmapWindowColOrder.c,v 1.
5
2006-12-1
3
1
6
:3
5:12
rds Exp $
* CVS info: $Id: zmapWindowColOrder.c,v 1.
6
2006-12-1
5
1
5
:3
3:39
rds Exp $
*-------------------------------------------------------------------
*/
...
...
@@ -41,33 +41,23 @@
typedef
struct
{
ZMapWindow
window
;
/* The window */
GList
*
item_list2order
;
/* Which list we'll order */
int
current_list_number
;
/* zero based. */
int
group_length
;
/* item_list2order length */
ZMapStrand
strand
;
/* which strand group we're sorting...
* direction of window->feature_set_names */
GQuark
feature_set_name
;
/* columnWithNameAndFrame depends on this. */
ZMapFrame
frame
;
/* columnWithNameAndFrame depends on this. */
GList
*
names_list
;
gboolean
quick_sort
;
int
three_frame_position
;
}
OrderColumnsDataStruct
,
*
OrderColumnsData
;
static
gint
columnWithName
(
gconstpointer
list_data
,
gconstpointer
user_data
);
static
gint
columnWithFrame
(
gconstpointer
list_data
,
gconstpointer
user_data
);
static
gint
columnWithNameAndFrame
(
gconstpointer
list_data
,
gconstpointer
user_data
);
static
gint
matchFrameSensitiveColCB
(
gconstpointer
list_data
,
gconstpointer
user_data
);
static
void
sortByFSNList
(
gpointer
list_data
,
gpointer
user_data
);
static
void
orderColumnsForFrame
(
OrderColumnsData
order_data
,
GList
*
list
,
ZMapFrame
frame
);
static
void
orderPositionColumns
(
ZMapWindow
window
,
gboolean
redraw_too
);
static
void
orderColumnsCB
(
FooCanvasGroup
*
data
,
FooCanvasPoints
*
points
,
ZMapContainerLevelType
level
,
gpointer
user_data
);
static
gint
qsortColumnsCB
(
gconstpointer
colA
,
gconstpointer
colB
,
gpointer
user_data
);
static
gboolean
isFrameSensitive
(
gconstpointer
col_data
);
static
int
columnFSNListPosition
(
gconstpointer
col_data
,
GList
*
feature_set_names
);
static
ZMapFrame
columnFrame
(
gconstpointer
col_data
);
static
gboolean
order_debug_G
=
FALSE
;
static
gboolean
frame_debug_G
=
FALSE
;
/* void zmapWindowColOrderColumns(ZMapWindow window)
...
...
@@ -76,6 +66,18 @@ static gboolean frame_debug_G = FALSE;
* window->feature_set_names. The foocanvas
*/
void
zmapWindowColOrderColumns
(
ZMapWindow
window
)
{
return
orderPositionColumns
(
window
,
FALSE
);
}
void
zmapWindowColOrderPositionColumns
(
ZMapWindow
window
)
{
return
orderPositionColumns
(
window
,
TRUE
);
}
/* INTERNALS */
static
void
orderPositionColumns
(
ZMapWindow
window
,
gboolean
redraw_too
)
{
FooCanvasGroup
*
super_root
;
OrderColumnsDataStruct
order_data
=
{
NULL
}
;
...
...
@@ -89,14 +91,13 @@ void zmapWindowColOrderColumns(ZMapWindow window)
order_data
.
window
=
window
;
order_data
.
strand
=
ZMAPSTRAND_FORWARD
;
/* makes things simpler */
order_data
.
quick_sort
=
TRUE
;
if
(
order_debug_G
)
printf
(
"%s: starting column ordering
\n
"
,
__PRETTY_FUNCTION__
);
zmapWindowContainerExecute
(
FOO_CANVAS_GROUP
(
super_root
),
ZMAPCONTAINER_LEVEL_STRAND
,
orderColumnsCB
,
&
order_data
);
zmapWindowContainerExecuteFull
(
FOO_CANVAS_GROUP
(
super_root
),
ZMAPCONTAINER_LEVEL_STRAND
,
orderColumnsCB
,
&
order_data
,
NULL
,
NULL
,
redraw_too
);
/* If we've reversed the feature_set_names list, and left it like that, re-reverse. */
if
(
order_data
.
strand
==
ZMAPSTRAND_REVERSE
)
...
...
@@ -106,151 +107,7 @@ void zmapWindowColOrderColumns(ZMapWindow window)
printf
(
"%s: columns should now be in order
\n
"
,
__PRETTY_FUNCTION__
);
return
;
}
static
gint
columnWithName
(
gconstpointer
list_data
,
gconstpointer
user_data
)
{
FooCanvasGroup
*
parent
=
FOO_CANVAS_GROUP
(
list_data
);
ZMapFeatureAny
feature_any
;
GQuark
name_data
=
GPOINTER_TO_UINT
(
user_data
);
gint
match
=
-
1
;
if
((
feature_any
=
(
ZMapFeatureAny
)(
g_object_get_data
(
G_OBJECT
(
parent
),
ITEM_FEATURE_DATA
))))
{
if
(
name_data
==
feature_any
->
unique_id
)
match
=
0
;
}
return
match
;
}
static
gint
columnWithFrame
(
gconstpointer
list_data
,
gconstpointer
user_data
)
{
FooCanvasGroup
*
parent
=
FOO_CANVAS_GROUP
(
list_data
);
ZMapFrame
frame_data
=
GPOINTER_TO_UINT
(
user_data
);
ZMapWindowItemFeatureSetData
set_data
;
gint
match
=
-
1
;
if
((
set_data
=
g_object_get_data
(
G_OBJECT
(
parent
),
ITEM_FEATURE_SET_DATA
)))
{
if
(
set_data
->
frame
==
frame_data
)
match
=
0
;
}
return
match
;
}
static
gint
columnWithNameAndFrame
(
gconstpointer
list_data
,
gconstpointer
user_data
)
{
OrderColumnsData
order_data
=
(
OrderColumnsData
)
user_data
;
gint
match
=
-
1
;
if
(
!
columnWithName
(
list_data
,
GUINT_TO_POINTER
(
order_data
->
feature_set_name
)))
{
if
(
order_data
->
frame
==
ZMAPFRAME_NONE
)
match
=
0
;
else
if
(
!
columnWithFrame
(
list_data
,
GUINT_TO_POINTER
(
order_data
->
frame
)))
match
=
0
;
}
return
match
;
}
static
gint
matchFrameSensitiveColCB
(
gconstpointer
list_data
,
gconstpointer
user_data
)
{
FooCanvasGroup
*
col_group
=
FOO_CANVAS_GROUP
(
list_data
);
ZMapWindowItemFeatureSetData
set_data
;
ZMapFeatureAny
feature_any
;
ZMapFeatureTypeStyle
style
;
gint
match
=
-
1
;
if
((
set_data
=
g_object_get_data
(
G_OBJECT
(
col_group
),
ITEM_FEATURE_SET_DATA
))
&&
(
feature_any
=
(
ZMapFeatureAny
)(
g_object_get_data
(
G_OBJECT
(
col_group
),
ITEM_FEATURE_DATA
))))
{
style
=
set_data
->
style
;
/* style = zmapWindowStyleTableFind(set_data->style_table, feature_any->unique_id); */
/* Using the set_data->style seems to work well here. There are
* frame specific columns ONLY when 3 Frame display is on. This
* avoids looking at window->display_3_frame which is actaully
* UNSET when drawing the 3 frame columns... */
if
(
style
->
opts
.
frame_specific
)
{
match
=
0
;
if
(
frame_debug_G
)
printf
(
"%s: %s is frame sensitive
\n
"
,
__PRETTY_FUNCTION__
,
g_quark_to_string
(
feature_any
->
unique_id
));
}
}
return
match
;
}
static
void
sortByFSNList
(
gpointer
list_data
,
gpointer
user_data
)
{
OrderColumnsData
order_data
=
(
OrderColumnsData
)
user_data
;
GList
*
column
;
int
position
,
target
,
positions_to_move
;
order_data
->
feature_set_name
=
GPOINTER_TO_UINT
(
list_data
);
if
((
column
=
g_list_find_custom
(
order_data
->
item_list2order
,
order_data
,
columnWithNameAndFrame
)))
{
/* find position based on the difference between the 2
* list lengths. Although there is a g_list_position
* function, it means passing in the original list and
* possibly longer list traversal... Not that is really
* an issue. */
position
=
g_list_length
(
column
);
target
=
order_data
->
current_list_number
;
if
(
order_debug_G
)
printf
(
"%s: %s
\n\t
list_length = %d
\n\t
group_length = %d
\n\t
position = %d
\n\t
target = %d
\n
"
,
__PRETTY_FUNCTION__
,
g_quark_to_string
(
order_data
->
feature_set_name
),
position
,
order_data
->
group_length
,
order_data
->
group_length
-
position
,
target
);
position
=
order_data
->
group_length
-
position
;
if
(
position
!=
target
)
{
positions_to_move
=
target
-
position
;
if
(
order_debug_G
)
printf
(
"%s: moving %d
\n
"
,
__PRETTY_FUNCTION__
,
positions_to_move
);
if
(
positions_to_move
>
0
)
zMap_g_list_raise
(
column
,
positions_to_move
);
else
if
(
positions_to_move
<
0
)
zMap_g_list_lower
(
column
,
positions_to_move
*
-
1
);
}
order_data
->
current_list_number
++
;
}
return
;
}
static
void
orderColumnsForFrame
(
OrderColumnsData
order_data
,
GList
*
list
,
ZMapFrame
frame
)
{
/* simple function so that all this get remembered... */
order_data
->
current_list_number
=
order_data
->
feature_set_name
=
0
;
order_data
->
item_list2order
=
list
;
order_data
->
group_length
=
g_list_length
(
list
);
order_data
->
frame
=
ZMAPFRAME_NONE
;
g_list_foreach
(
order_data
->
window
->
feature_set_names
,
sortByFSNList
,
order_data
);
return
;
}
static
void
orderColumnsCB
(
FooCanvasGroup
*
data
,
FooCanvasPoints
*
points
,
...
...
@@ -258,12 +115,9 @@ static void orderColumnsCB(FooCanvasGroup *data, FooCanvasPoints *points,
{
OrderColumnsData
order_data
=
(
OrderColumnsData
)
user_data
;
FooCanvasGroup
*
strand_group
;
int
interface_check
;
ZMapStrand
strand
;
ZMapWindow
window
=
order_data
->
window
;
GList
*
frame_list
=
NULL
,
*
sensitive_list
=
NULL
,
*
sensitive_tmp
=
NULL
;
GList
*
frame_list
=
NULL
;
if
(
level
==
ZMAPCONTAINER_LEVEL_STRAND
)
{
...
...
@@ -271,10 +125,6 @@ static void orderColumnsCB(FooCanvasGroup *data, FooCanvasPoints *points,
strand_group
=
zmapWindowContainerGetFeatures
(
data
);
zMapAssert
(
strand_group
);
/* check that g_list_length doesn't do g_list_first! */
interface_check
=
g_list_length
(
strand_group
->
item_list_end
);
zMapAssert
(
interface_check
==
1
);
strand
=
zmapWindowContainerGetStrand
(
data
);
if
(
strand
==
ZMAPSTRAND_REVERSE
)
...
...
@@ -294,118 +144,18 @@ static void orderColumnsCB(FooCanvasGroup *data, FooCanvasPoints *points,
else
zMapAssertNotReached
();
/* What! */
if
(
order_data
->
quick_sort
)
{
order_data
->
names_list
=
window
->
feature_set_names
;
if
((
frame_list
=
g_list_find
(
window
->
feature_set_names
,
GUINT_TO_POINTER
(
zMapStyleCreateID
(
ZMAP_FIXED_STYLE_3FRAME
)))))
{
order_data
->
three_frame_position
=
g_list_position
(
order_data
->
names_list
,
frame_list
);
strand_group
->
item_list
=
g_list_sort_with_data
(
strand_group
->
item_list
,
qsortColumnsCB
,
order_data
);
}
}
else
order_data
->
names_list
=
window
->
feature_set_names
;
if
((
frame_list
=
g_list_find
(
window
->
feature_set_names
,
GUINT_TO_POINTER
(
zMapStyleCreateID
(
ZMAP_FIXED_STYLE_3FRAME
)))))
{
if
((
frame_list
=
g_list_find
(
window
->
feature_set_names
,
GUINT_TO_POINTER
(
zMapStyleCreateID
(
ZMAP_FIXED_STYLE_3FRAME
)))))
{
/* grep out the group->item_list frame sensitive columns */
/* This only produces a list when 3 frame is on
* (see comment in matchFrameSensitiveColCB). */
sensitive_list
=
zMap_g_list_grep
(
&
(
strand_group
->
item_list
),
order_data
,
matchFrameSensitiveColCB
);
sensitive_tmp
=
sensitive_list
;
/* hold on to a copy of ptr for later */
}
if
(
order_debug_G
)
printf
(
"%s:
\n
"
,
__PRETTY_FUNCTION__
);
/* order the non frame sensitive ones */
orderColumnsForFrame
(
order_data
,
strand_group
->
item_list
,
ZMAPFRAME_NONE
);
/* reset this. */
strand_group
->
item_list
=
g_list_first
(
strand_group
->
item_list
);
/* Are we displaying any 3 frame columns */
if
(
sensitive_list
)
{
GList
*
tmp_list
;
int
position
=
0
;
/* If so, order the frame sensitive ones */
/* This all works based on the g_list_find_custom function
* returning the first and only the first column with a name
* it finds. The orderColumnsForFrame then moves the column
* only as far as the first column in the list.
*/
/* start with Frame 0. */
orderColumnsForFrame
(
order_data
,
sensitive_list
,
ZMAPFRAME_0
);
/* list will have changed, find first... this is a pain ... */
sensitive_list
=
tmp_list
=
g_list_first
(
sensitive_list
);
/* alter the start of the list to be the first column with frame 1 */
if
((
sensitive_list
=
g_list_find_custom
(
sensitive_list
,
GUINT_TO_POINTER
(
ZMAPFRAME_1
),
columnWithFrame
)))
{
/* order this list of columns */
orderColumnsForFrame
(
order_data
,
sensitive_list
,
ZMAPFRAME_1
);
}
else
sensitive_list
=
tmp_list
;
/* reset list to not be NULL in case of no frame 1 cols */
/* list will have changed, find first... this is a pain ... (still) */
sensitive_list
=
tmp_list
=
g_list_first
(
sensitive_list
);
/* alter the start of the list to be the first column with frame 2 */
if
((
sensitive_list
=
g_list_find_custom
(
sensitive_list
,
GUINT_TO_POINTER
(
ZMAPFRAME_2
),
columnWithFrame
)))
{
/* order this list of columns */
orderColumnsForFrame
(
order_data
,
sensitive_list
,
ZMAPFRAME_2
);
}
else
sensitive_list
=
tmp_list
;
/* reset list, although kinda redundant. */
/* again reset the list everything has changed... */
sensitive_list
=
g_list_first
(
sensitive_tmp
);
/* find where to insert the sensitive list. */
/* This is a little tedious and possibly the weakest point of this.
* frame_list is a GList member from the window->feature_set_names
* We step backwards through this until we get to the beginning
* trying to find a column in the strand_group (not frame sensitive)
* which where we can insert the sensitive list.
*/
while
(
frame_list
)
{
if
((
tmp_list
=
g_list_find_custom
(
strand_group
->
item_list
,
frame_list
->
data
,
columnWithName
)))
{
position
=
g_list_position
(
strand_group
->
item_list
,
tmp_list
);
if
(
frame_debug_G
)
printf
(
"%s: inserting sensitive list after %s @ position %d
\n
"
,
__PRETTY_FUNCTION__
,
g_quark_to_string
(
GPOINTER_TO_UINT
(
frame_list
->
data
)),
position
);
break
;
}
frame_list
=
frame_list
->
prev
;
}
/* insert the frame sensitive ones into the non frame sensitive list */
strand_group
->
item_list
=
zMap_g_list_insert_list_after
(
strand_group
->
item_list
,
sensitive_list
,
position
);
}
order_data
->
three_frame_position
=
g_list_position
(
order_data
->
names_list
,
frame_list
);
strand_group
->
item_list
=
g_list_sort_with_data
(
strand_group
->
item_list
,
qsortColumnsCB
,
order_data
);
}
/* update foo_canvas list cache. joy. */
strand_group
->
item_list_end
=
g_list_last
(
strand_group
->
item_list
);
}
...
...
@@ -414,12 +164,6 @@ static void orderColumnsCB(FooCanvasGroup *data, FooCanvasPoints *points,
}
/*
* Could all be done with quick sort in g_list_sort_with_data
* Not sure which is faster...
*
*/
static
gboolean
isFrameSensitive
(
gconstpointer
col_data
)
{
FooCanvasGroup
*
col_group
=
FOO_CANVAS_GROUP
(
col_data
);
...
...
@@ -574,6 +318,3 @@ static gint qsortColumnsCB(gconstpointer colA, gconstpointer colB, gpointer user
return
order
;
}
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