1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* filename: xpages.c *
* *
* UTIL C-source: Medical Image Conversion Utility *
* *
* purpose : image pages routines *
* *
* project : (X)MedCon by Erik Nolf *
* *
* Functions : XMdcPagesSelected() - Handle selected page *
* XMdcPagesGoTo() - Go to a specified page *
* XMdcPagesCreateMenu() - Create pages menu *
* XMdcPagesNext() - Go to next page *
* XMdcPagesPrev() - Go to previous page *
* XMdcPagesSelCallbackApply() - Apply new page display *
* XMdcPagesSel() - Select page display *
* XMdcPagesGetNrImages() - Get images per page *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* $Id: xpages.c,v 1.22 2008/01/23 21:28:37 enlf Exp $
*/
/*
Copyright (C) 1997-2008 by Erik Nolf
This program 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, 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 Place - Suite 330, Boston, MA 02111-1307, USA. */
/****************************************************************************
H E A D E R S
****************************************************************************/
#include <stdio.h>
#include "xmedcon.h"
/****************************************************************************
D E F I N E S
****************************************************************************/
static GtkWidget *wpages=NULL;
/****************************************************************************
F U N C T I O N S
****************************************************************************/
void XMdcPagesSelected(GtkWidget *widget, Uint32 *pagenr)
{
if ( (Uint32)(*pagenr) != my.curpage) {
my.curpage = (Uint32)(*pagenr);
MdcDebugPrint("one-based selected page = %u",my.curpage + 1);
XMdcMainWidgetsInsensitive();
XMdcRemovePreviousColorMap();
XMdcRemovePreviousImages();
XMdcBuildColorMap();
XMdcBuildCurrentImages();
my.prevpage = my.curpage;
XMdcMainWidgetsResensitive();
}
}
gboolean XMdcPagesGoTo(GtkWidget *spinner, gpointer data)
{
GtkWidget *menu;
GtkWidget *active;
GtkSpinButton *spin = GTK_SPIN_BUTTON(spinner);
Uint32 page, newpage;
page = (Uint32) gtk_spin_button_get_value_as_int(spin); newpage = page - 1;
if ( page == 0 || page > my.number_of_pages ) {
XMdcDisplayWarn("Need a number between [1 , %u]",my.number_of_pages);
}else{
gtk_option_menu_set_history(GTK_OPTION_MENU(my.pagemenu),newpage);
menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(my.pagemenu));
gtk_menu_set_active(GTK_MENU(menu),newpage);
active = gtk_menu_get_active(GTK_MENU(menu));
gtk_menu_item_activate(GTK_MENU_ITEM(active));
}
return(TRUE);
}
GtkWidget *XMdcPagesCreateMenu(void)
{
GtkWidget *menu;
GtkWidget *menuitem;
GSList *group;
Uint32 i;
menu = gtk_menu_new();
group= NULL;
for(i=0; i<my.number_of_pages; i++) {
sprintf(mdcbufr,"Page: %4u/%u",i+1,my.number_of_pages);
menuitem = gtk_radio_menu_item_new_with_label(group,mdcbufr);
gtk_signal_connect(GTK_OBJECT (menuitem), "activate",
GTK_SIGNAL_FUNC(XMdcPagesSelected),
(Uint32 *)&my.pagenumber[i]);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menuitem));
gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(menuitem),TRUE);
gtk_menu_append(GTK_MENU(menu),menuitem);
gtk_widget_show(menuitem);
}
return(menu);
}
void XMdcPagesNext(void)
{
GtkWidget *menu;
GtkWidget *active;
Uint32 nextpage;
nextpage = my.curpage + 1;
if (nextpage < my.number_of_pages) {
gtk_option_menu_set_history(GTK_OPTION_MENU(my.pagemenu),nextpage);
menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(my.pagemenu));
gtk_menu_set_active(GTK_MENU(menu),nextpage);
active = gtk_menu_get_active(GTK_MENU(menu));
gtk_menu_item_activate(GTK_MENU_ITEM(active));
}
}
void XMdcPagesPrev(void)
{
GtkWidget *menu;
GtkWidget *active;
Uint32 prevpage;
if (my.curpage > 0) {
prevpage = my.curpage - 1;
gtk_option_menu_set_history(GTK_OPTION_MENU(my.pagemenu),prevpage);
menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(my.pagemenu));
gtk_menu_set_active(GTK_MENU(menu),prevpage);
active = gtk_menu_get_active(GTK_MENU(menu));
gtk_menu_item_activate(GTK_MENU_ITEM(active));
}
}
void XMdcPagesSelCallbackApply(GtkWidget *widget, gpointer data)
{
Int8 type=XMDC_PAGES_FRAME_BY_FRAME;
MdcDebugPrint("pages layout: ");
if (GTK_TOGGLE_BUTTON(sPagesSelection.FrameByFrame)->active) {
MdcDebugPrint("\tper frame"); type = XMDC_PAGES_FRAME_BY_FRAME;
}else if (GTK_TOGGLE_BUTTON(sPagesSelection.SliceBySlice)->active) {
MdcDebugPrint("\tper slice"); type = XMDC_PAGES_SLICE_BY_SLICE;
}else if (GTK_TOGGLE_BUTTON(sPagesSelection.ScreenFull)->active) {
MdcDebugPrint("\tscreen full"); type = XMDC_PAGES_SCREEN_FULL;
}
if (type != sPagesSelection.CurType) {
sPagesSelection.CurType = type;
if (XMDC_FILE_OPEN == MDC_YES) {
/* prevent useless reprocessing */
if (my.fi->number == 1) return;
XMdcProgressBar(MDC_PROGRESS_BEGIN,0.,"Redisplay images:");
XMdcViewerHide();
XMdcViewerEnableAutoShrink();
XMdcViewerReset();
XMdcDisplayImages();
XMdcProgressBar(MDC_PROGRESS_END,0.,NULL);
}
}
}
void XMdcPagesSel(void)
{
GtkWidget *box1;
GtkWidget *box2;
GtkWidget *box3;
GtkWidget *box4;
GtkWidget *frame;
GtkWidget *button;
GtkWidget *separator;
GSList *group;
if (wpages == NULL) {
wpages = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_signal_connect(GTK_OBJECT(wpages),"destroy",
GTK_SIGNAL_FUNC(XMdcMedconQuit),NULL);
gtk_signal_connect(GTK_OBJECT(wpages),"delete_event",
GTK_SIGNAL_FUNC(XMdcHandlerToHide),NULL);
gtk_window_set_title(GTK_WINDOW(wpages),"Pages Selection");
gtk_container_set_border_width (GTK_CONTAINER (wpages), 0);
box1 = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (wpages), box1);
gtk_widget_show(box1);
/* create upper box - Initial Resize */
box2 = gtk_vbox_new (FALSE, 5);
gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER(box2), 5);
gtk_widget_show(box2);
box3 = gtk_hbox_new (FALSE, 5);
gtk_box_pack_start(GTK_BOX(box2), box3, TRUE, TRUE, 0);
gtk_widget_show(box3);
frame = gtk_frame_new("Display Pages");
gtk_box_pack_start(GTK_BOX (box3), frame, TRUE, TRUE, 0);
gtk_widget_show(frame);
box4 = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(frame), box4);
gtk_container_set_border_width(GTK_CONTAINER(box4), 5);
gtk_widget_show(box4);
button = gtk_radio_button_new_with_label(NULL, "frame by frame (volume)");
gtk_box_pack_start(GTK_BOX(box4), button, TRUE, TRUE, 0);
if (sPagesSelection.CurType == XMDC_PAGES_FRAME_BY_FRAME);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button), TRUE);
gtk_widget_show(button);
sPagesSelection.FrameByFrame = button;
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
button = gtk_radio_button_new_with_label(group, "slice by slice (image)");
gtk_box_pack_start(GTK_BOX(box4), button, TRUE, TRUE, 0);
if (sPagesSelection.CurType == XMDC_PAGES_SLICE_BY_SLICE)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button), TRUE);
gtk_widget_show(button);
sPagesSelection.SliceBySlice = button;
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
button = gtk_radio_button_new_with_label(group, "whole screen filled");
gtk_box_pack_start (GTK_BOX(box4), button, TRUE, TRUE, 0);
if (sPagesSelection.CurType == XMDC_PAGES_SCREEN_FULL)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button), TRUE);
gtk_widget_show(button);
sPagesSelection.ScreenFull = button;
/* create horizontal separator */
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, FALSE, 0);
gtk_widget_show (separator);
/* create bottom button box */
box2 = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start(GTK_BOX(box1), box2, TRUE, TRUE, 2);
gtk_widget_show(box2);
button = gtk_button_new_with_label("Apply");
gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 2);
gtk_signal_connect_object(GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(gtk_widget_hide), GTK_OBJECT(wpages));
gtk_signal_connect(GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(XMdcPagesSelCallbackApply), NULL);
gtk_widget_show(button);
button = gtk_button_new_with_label ("Cancel");
gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 2);
gtk_signal_connect_object(GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(gtk_widget_hide),GTK_OBJECT(wpages));
gtk_signal_connect(GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(XMdcViewerShow), NULL);
gtk_widget_show(button);
}else{
/* set buttons to appropriate state */
GtkWidget *b1, *b2, *b3;
gtk_widget_hide(wpages);
b1 = sPagesSelection.FrameByFrame;
b2 = sPagesSelection.SliceBySlice;
b3 = sPagesSelection.ScreenFull;
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b1),FALSE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b2),FALSE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b3),FALSE);
switch (sPagesSelection.CurType) {
case XMDC_PAGES_FRAME_BY_FRAME :
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b1),TRUE); break;
case XMDC_PAGES_SLICE_BY_SLICE :
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b2),TRUE); break;
case XMDC_PAGES_SCREEN_FULL :
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b3),TRUE); break;
}
}
XMdcShowWidget(wpages);
}
Uint32 XMdcPagesGetNrImages(void)
{
Uint32 nr=0;
switch (sPagesSelection.CurType) {
case XMDC_PAGES_FRAME_BY_FRAME: nr = my.fi->dim[3];
break;
case XMDC_PAGES_SLICE_BY_SLICE: nr = 1;
break;
case XMDC_PAGES_SCREEN_FULL : nr = my.fi->number;
break;
}
return(nr);
}
|