File: imageInfo.cxx

package info (click to toggle)
imview 1.1.9c-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,068 kB
  • ctags: 3,686
  • sloc: cpp: 28,834; sh: 2,624; ansic: 1,818; makefile: 767; exp: 112; python: 88
file content (160 lines) | stat: -rw-r--r-- 5,354 bytes parent folder | download | duplicates (7)
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
/*
 * $Id: imageInfo.cxx,v 4.2 2003/09/11 12:09:12 hut66au Exp $
 *
 * Imview, the portable image analysis application
 * http://www.cmis.csiro.au/Hugues.Talbot/imview
 * ----------------------------------------------------------
 *
 *  Imview is an attempt to provide an image display application
 *  suitable for professional image analysis. It was started in
 *  1997 and is mostly the result of the efforts of Hugues Talbot,
 *  Image Analysis Project, CSIRO Mathematical and Information
 *  Sciences, with help from others (see the CREDITS files for
 *  more information)
 *
 *  Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was
 *  supported in parts by the Australian Commonwealth Science and 
 *  Industry Research Organisation. Please see the COPYRIGHT file 
 *  for full details. Imview also includes the contributions of 
 *  many others. Please see the CREDITS file for full details.
 *
 *  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 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, USA.
 * */

/*------------------------------------------------------------------------
 *
 * An image info panel using fluid
 *
 * Hugues Talbot	 2 May 1998
 *      
 *-----------------------------------------------------------------------*/

#include <stdio.h>
#include <string.h>
#include "imview.hxx"
#include "imageIO.hxx"
#include "imageViewer.hxx"
#include "menubar.hxx"
#include "imageInfo.hxx"

extern char        *imgDesc;
extern imageIO     *IOBlackBox;
extern imageViewer *mainViewer;



imageinfo::imageinfo()
{
    dbgprintf("Image info panel constructed\n");
    // make sure this is done, fluid depends on it...
    outputWindow = 0;
    return;
}


void imageinfo::setDefaults()
{
    dbgprintf("Setting defaults for info panel\n");
    textOutput->value("We have no information at this stage...\n");

    return;
}

void imageinfo::update(bool forced)
{
    static char buffer[2048];
    static char tmpbuf[100];

    if (outputWindow && (outputWindow->visible() || forced)) {
	if (IOBlackBox->imageData() == 0) {
	    sprintf(buffer, "No image present\n");
	} else {
	    int x, y, w, h;
	    sprintf(buffer, "Path to image: %s\n", IOBlackBox->getImName());
	    int spp = IOBlackBox->getCurrImgNbSamples();
	    sprintf(tmpbuf, "Size: %dx%dx%d, %d sample%c\n",
		    IOBlackBox->imageWidth(),
		    IOBlackBox->imageHeight(),
		    IOBlackBox->imageThickness(),
		    spp, (spp > 1) ? 's':' '
		);
	    strcat(buffer, tmpbuf);
	    sprintf(tmpbuf, "Format: %s\n", IOBlackBox->getImgDesc());
	    strcat(buffer, tmpbuf);
	    sprintf(tmpbuf, "Pixel type: %s\n", IOBlackBox->typeName(IOBlackBox->getCurrImgPixType()));
	    strcat(buffer, tmpbuf);
	    sprintf(tmpbuf, "Image type: %s\n", IOBlackBox->imgTypeName(IOBlackBox->getCurrImgImgType()));
	    strcat(buffer, tmpbuf);
	    int xO, yO, zO;
	    xO = IOBlackBox->getXOffset();
	    yO = IOBlackBox->getYOffset();
	    zO = IOBlackBox->getZOffset();
	    sprintf(tmpbuf, "Offsets: xO=%d, yO=%d, zO=%d\n",
		    xO, yO, zO);
	    strcat(buffer, tmpbuf);
	    
            if (mainViewer->getdisplaymode() == IMV_DISPLAY_IMG_FIT_WINDOW) {
                sprintf(tmpbuf, "Current X zoom factor: %f\n", mainViewer->xZoomFactor());
                strcat(buffer, tmpbuf);
                sprintf(tmpbuf, "Current Y zoom factor: %f\n", mainViewer->yZoomFactor());
                strcat(buffer, tmpbuf);
                sprintf(tmpbuf, "Aspect ratio: %f\n", mainViewer->xZoomFactor()/mainViewer->yZoomFactor());
                strcat(buffer, tmpbuf);
            } else {
                sprintf(tmpbuf, "Current zoom factor: %f ", mainViewer->zoomFactor());
                strcat(buffer, tmpbuf);
                sprintf(tmpbuf, "Default zoom factor: %f \n", mainViewer->getDefaultZoomFactor());
                strcat(buffer, tmpbuf);
                sprintf(tmpbuf, "Minimum zoom factor: %f \n", mainViewer->getMinZoomFactor());
                strcat(buffer, tmpbuf);
            }
	    mainViewer->getCurrentBox(x,y,w,h);
	    sprintf(tmpbuf, "Current subset: x=%d y=%d z=%d w=%d h=%d\n",
		    x, y, IOBlackBox->getCurrZpos(),
		    w, h);
	    strcat(buffer, tmpbuf);
	    sprintf(tmpbuf, "Frame: %d/%d\n",
		    IOBlackBox->getCurrImgFrame()+1,
		    IOBlackBox->getCurrImgNbFrames());
	    strcat(buffer, tmpbuf);
	}
	if (textOutput)
	    textOutput->value((const char *)buffer);
    }
	
    return;
}

void imageinfo::show()
{
    update(true);
    outputWindow->show();
}

void imageinfo::hide()
{
    outputWindow->hide();
}


// callbacks associated with the dialog

void okbutton_cb(Fl_Return_Button *, imageinfo *panel)
{
    dbgprintf("Dismiss Button pressed on image info panel\n");
    // hide the window
    panel->hide();
    return;
}