iipsrv 0.9.9
|
00001 /* 00002 Image View Parameters 00003 00004 Copyright (C) 2003-2009 Ruven Pillay. 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 */ 00020 00021 00022 #ifndef _VIEW_H 00023 #define _VIEW_H 00024 00025 00026 #include <cstddef> 00027 00028 00030 00031 class View{ 00032 00033 00034 private: 00035 00036 // Resolution independent x,y,w,h region viewport 00037 float view_left, view_top, view_width, view_height; 00038 00039 int resolution; 00040 unsigned int max_resolutions; 00041 unsigned int left, top, width, height; 00042 unsigned int min_size; 00043 unsigned int max_size; 00044 unsigned int requested_width; 00045 unsigned int requested_height; 00046 float contrast; 00047 00048 00051 00054 void calculateResolution( unsigned int m, unsigned int r ); 00055 00056 00057 public: 00058 00059 int xangle; 00060 int yangle; 00061 bool shaded; 00062 int shade[3]; 00063 int max_layers; 00064 int layers; 00065 00066 00068 View() { 00069 resolution = 0; max_resolutions = 0; min_size = 8; max_size = 0; 00070 width = 0; height = 0; 00071 view_left = 0.0; view_top = 0.0; view_width = 1.0; view_height = 1.0; 00072 requested_width = 0; requested_height = 0; 00073 contrast = 1.0; 00074 xangle = 0; yangle = 90; 00075 shaded = false; shade[0] = 0; shade[1] = 0; shade[2] = 0; 00076 max_layers = 0; layers = 0; 00077 }; 00078 00079 00081 00082 void setContrast( float c ){ contrast = c; }; 00083 00084 00086 00087 void setMaxSize( unsigned int m ){ max_size = m; }; 00088 00089 00091 00092 void setMaxResolutions( unsigned int r ){ max_resolutions = r; }; 00093 00094 00096 unsigned int getRequestWidth(){ 00097 if( requested_width == 0 && requested_height > 0 ){ 00098 requested_width = static_cast<unsigned int>( width * requested_height / height ); 00099 } 00100 if( requested_width > width ) requested_width = width; 00101 if( requested_width > max_size ) requested_width = max_size; 00102 // If no width has been set, use our full size 00103 if( requested_width <= 0 ) requested_width = width; 00104 return requested_width; 00105 }; 00106 00107 00109 00110 void setRequestWidth( unsigned int w ){ 00111 if( w < max_size ) requested_width = w; 00112 else requested_width = max_size; 00113 }; 00114 00115 00117 unsigned int getRequestHeight(){ 00118 if( requested_height == 0 && requested_width > 0 ){ 00119 requested_height = static_cast<unsigned int>( height * requested_width / width ); 00120 } 00121 if( requested_height > height ) requested_height = height; 00122 if( requested_height > max_size ) requested_height = max_size; 00123 // If no height has been set, use our full size 00124 if( requested_height <= 0 ) requested_height = height; 00125 return requested_height; 00126 }; 00127 00129 00130 void setRequestHeight( unsigned int h ){ 00131 if( h < max_size ) requested_height = h; 00132 else requested_height = max_size; 00133 }; 00134 00135 00137 unsigned int getResolution(); 00138 00139 00141 float getScale(); 00142 00143 00145 00146 void setViewLeft( float x ); 00147 00148 00150 00151 void setViewTop( float y ); 00152 00153 00155 00156 void setViewWidth( float w ); 00157 00158 00160 00161 void setViewHeight( float h ); 00162 00163 00165 00168 void setImageSize( unsigned int w, unsigned int h ){ width = w; height = h; }; 00169 00170 00172 00173 void setMaxLayers( int l ){ max_layers = l; }; 00174 00176 00177 void setLayers( int l ){ layers = l; }; 00178 00180 float getContrast(){ return contrast; }; 00181 00183 unsigned int getImageWidth(){ return width; }; 00184 00186 unsigned int getImageHeight(){ return height; }; 00187 00189 unsigned int getViewLeft() ; 00190 00192 unsigned int getViewTop(); 00193 00195 unsigned int getViewWidth(); 00196 00198 unsigned int getViewHeight(); 00199 00201 unsigned int getLayers(){ 00202 if( layers > max_layers ) layers = max_layers; 00203 return layers; 00204 }; 00205 00207 bool viewPortSet(); 00208 00209 00210 }; 00211 00212 00213 #endif