Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

drawTv_activity.c

Go to the documentation of this file.
00001 /*********
00002  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
00003  * University of Manchester, UK.  All rights reserved.
00004  * 
00005  * Redistribution and use in source and binary forms, with or without modification, 
00006  * are permitted provided that the following conditions are met:
00007  * 
00008  *   . Redistributions of source code must retain the above copyright notice, 
00009  *     this list of conditions and the following disclaimer.
00010  *    
00011  *   . Redistributions in binary form must reproduce the above copyright notice,
00012  *     this list of conditions and the following disclaimer in the documentation 
00013  *     and/or other materials provided with the distribution.
00014  * 
00015  *   . Neither the name of the University of Manchester nor the names of its
00016  *     contributors may be used to endorse or promote products derived from this 
00017  *     software without specific prior written permission.
00018  * 
00019  * 
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
00021  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
00022  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
00023  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
00024  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
00025  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
00026  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00027  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
00028  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
00029  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
00030  * POSSIBILITY OF SUCH DAMAGE.
00031  *
00032  **********
00033  *
00034  * Program :    TINA
00035  * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/draw/drawTv_activity.c,v $
00036  * Date    :  $Date: 2003/10/01 16:02:47 $
00037  * Version :  $Revision: 1.3 $
00038  * CVS Id  :  $Id: drawTv_activity.c,v 1.3 2003/10/01 16:02:47 tony Exp $
00039  *
00040  * Author  : Legacy TINA
00041  *
00042  * Notes :
00043  *
00044  *********
00045 */
00046 
00047 #include "drawTv_activity.h"
00048 
00049 #if HAVE_CONFIG_H
00050   #include <config.h>
00051 #endif
00052 
00053 #include <tina/sys/sysDef.h>
00054 #include <tina/sys/sysPro.h>
00055 #include <tina/math/mathDef.h>
00056 #include <tinatool/draw/draw_TvDef.h>
00057 #include <tinatool/draw/draw_TvPro.h>
00058 
00059 int tv_set_activity(Tv * tv, int activity)
00060 {
00061   extern void tv_screen_set_activity_cursor();
00062   int oldactivity = 0;
00063 
00064   if (tv)
00065   {
00066     oldactivity = tv->activity;
00067     tv->activity = activity;
00068     (void) tv_set_activity_message(tv);
00069     if (tv->tv_screen)
00070     {
00071       tv_screen_set_activity_cursor(tv->tv_screen, activity);
00072     }
00073   }
00074   return (oldactivity);
00075 }
00076 
00077 void tv_set_activity_message(Tv * tv)
00078 {
00079   if (tv == NULL)
00080     return;
00081 
00082   switch (tv->activity)
00083   {
00084   case ZOOM:
00085     switch (tv->zoomlevel)
00086     {
00087     case IMZOOM:
00088       tv_set_message(tv, "imzoom : shift / scale / roi");
00089       break;
00090     case ZOOM2:
00091       tv_set_message(tv, "zoom2D : shift / scale-rot2D / null");
00092       break;
00093     }
00094     break;
00095   case ROI:
00096     tv_set_message(tv, "rect : define / show / null");
00097     break;
00098   case POLYROI:
00099     tv_set_message(tv, "poly : next / end (show) / restart");
00100     break;
00101   case POINT:
00102     tv_set_message(tv, "point : move / delete / add");
00103     break;
00104   case GLOBAL:
00105     tv_set_message(tv, "global : trans / scale / rotate");
00106     break;
00107   case PICK:
00108     {
00109       char *name = tv->pick.name;
00110       char string[512];
00111 
00112       (void) string_append(string,
00113                            "pick : choose / ", name, " / cancel",
00114                            NULL);
00115       tv_set_message(tv, string);
00116     }
00117     break;
00118   case MOUSE:
00119     {
00120       Tv_mouse *mouse = &tv->mouse;
00121       char string[512];
00122 
00123       (void) string_append(string,
00124                            mouse->name, " : ",
00125                            mouse->left_name, " / ",
00126                            mouse->middle_name, " / ",
00127                            mouse->right_name, NULL);
00128       tv_set_message(tv, string);
00129     }
00130     break;
00131   case 0:
00132   default:
00133     tv_set_message(tv, "null");
00134   }
00135 }
00136 
00137 /*
00138  * Handle mouse events (not keyboard) in screen.  Meaning of an event
00139  * * (eg mouse SELECT) depends on the tv->activity (zoom, roi, pick
00140  * * mouse). 
00141  */
00142 void tv_activity_proc(Tv * tv, int state, Ipos pos)
00143 {
00144   switch (tv->activity)
00145   {
00146   case 0:
00147     return;
00148   case ZOOM:
00149     tv_zoom_proc(tv, state, pos);
00150     break;
00151   case ROI:
00152     tv_roi_proc(tv, state, pos);
00153     break;
00154   case POLYROI:
00155     tv_polyroi_proc(tv, state, pos);
00156     break;
00157   case POINT:
00158     tv_roipnt_proc(tv, state, pos);
00159     break;
00160   case GLOBAL:
00161     tv_roigbl_proc(tv, state, pos);
00162     break;
00163   case PICK:
00164     tv_pick_proc(tv, state, pos);
00165     break;
00166   case MOUSE:
00167     tv_mouse_proc(tv, state, pos);
00168     break;
00169   }
00170 }

Generated on Thu Nov 12 02:20:44 2009 for Tools by doxygen 1.3.6