http:^^www.cs.washington.edu^education^courses^457^projects^libui^
来自「This data set contains WWW-pages collect」· EDU^EDUCATION^COURSES^457^PROJECTS^LIBUI^ 代码 · 共 1,346 行 · 第 1/4 页
EDU^EDUCATION^COURSES^457^PROJECTS^LIBUI^
1,346 行
to a slider being changed. Additionally, the callback only occurs when the user has <em>released</em> the mouse, not while the user is <em>dragging</em> the slider.</dd> </dl> Sliders, like all other controls, are added one below another, starting at the top of the control area.</dd><p> <dt><samp><a NAME="uiGetSliderValueDef">double <strong>uiGetSliderValue </strong>( uiSlider <VAR>slider</VAR> );</a></samp></dt> <dd>Returns the current value of <VAR>slider</VAR>.</dd><p> <dt><samp><a NAME="uiSetSliderValueDef">void <strong>uiSetSliderValue </strong>( uiSlider <var>slider</var>, double <VAR>t</VAR>);</a> </samp></dt> <dd>Sets the value of the <VAR>slider</VAR>.</dd><p> <dt><samp><a NAME="uiSetSliderParamsDef">void <strong>uiSetSliderParams </strong>( uiSlider <var>slider</var>, double <var>min</var>, double <var>max</var>, double <var>current</var>, int <var> decimal_points</var>)</a></samp> <dd>Sets the various paramaters of the <var>slider</var>.<p> <dl> <dt><var>slider</var> <dd>The <a href="#uiSliderDef">uiSlider</a> that is being modified. <dt><var>min</var> <dd>The new minimum value for the slider. The minimum value must be less than both the <var>current</var> and the <var>max</var> values. <dt><var>max</var> <dd>The maximum value for the slider. The maximum value must be greater than both the <var>current</var> and the <var>min </var> values. <dt><var>current</var> <dd>The new "current" value that the slider will show. The current value must be between <var>min</var> and <var> max</var>, inclusive. <dt><var>decimal_points</var> <dd>The number of digits to the right of the decimal that will be displayed and reported. Valid ranges are any non-negative integer. </dl><p> See also <strong> <a href="#uiGetSliderParamsDef">uiGetSliderParams()</a></strong> for obtaining the current parameter set for a slider.<p> <dt><samp><a NAME="uiGetSliderParamsDef">void <strong>uiGetSliderParams </strong>(uiSlider <var>slider</var>, double *<var>min</var>, double *<var>max</var>, double *<var>current</var>, int *<var> decimal_points</var>)</a></samp> <dd>Get the various parameters for <var>slider</var>.<p> <dl> <dt><var>slider</var> <dd>The <a href="#uiSliderDef">uiSlider</a> that is being read. <dt><var>min</var> <dd>A pointer to where the minimum value of the slider should be written. <dt><var>max</var> <dd>A pointer to where the maximum value of the slider should be written. <dt><var>current</var> <dd>A pointer to where the current value of the slider should be written. <dt><var>decimal_points</var> <dd>A pointer to where the current number of significant digits right of the decimal should be stored. </dl> See also <strong><a href="uiSetSliderParamsDef">uiSetSliderParams()</a> </strong>.<p> <dt><samp><a NAME="uiMakeMenuDef">uiMenu <strong>uiMakeMenu</strong> (char <VAR>*menuTitle</VAR>);</a></samp></dt> <dd>This function creates the "menu button". When the user clicks on this button, a pop-up menu will appear. To add items to this popup menu, call <a href="#uiAddMenuItemDef"><strong>uiAddMenuItem()</strong></a>, passing in the <samp>uiMenu</samp> type returned by this function. </dd><p> <dt><samp><a NAME="uiAddMenuItemDef">void <strong>uiAddMenuItem</strong> (uiMenu <VAR>menu</VAR>, char <VAR>*menuText</VAR>, <a href="#uiMenuCallbackDef">uiMenuCallback</a> <VAR>callback</VAR>, int <VAR>userData</VAR>);</a></samp> <dd>Add a menu item to the menu <var>menu</var>, which was created with <strong><a href="#uiMakeMenuDef">uiMakeMenu()</a></strong>.<p> <dl> <dt><var>menu</var> <dd>The menu to which this menu item is to be appended. <var>menu </var> is the value returned by <strong> <a href="#uiMakeMenuDef">uiMakeMenu</a></strong>. <dt><var>menuText</var></dt> <dd>This is the label to be associated with this menu item. When the user clicks on the menu button to reveal the popup menu, it is this text that the user will see. <dt><var>callback</var></dt> <dd>The callback routine to be invoked when the user selects this menu item. If no such callback routine is to be used, pass NULL for this argument. <dt><var>userData</var></dt> <dd>This is the optional user data associated with this menu item. When the callback is invoked in response to user activity, this data is passed to the callback routine. </dl><p> Although the <var>userData</var> is only an <samp>int</samp>, it can still be useful. Typically, the id of the menu item being created is used for <var>userData</var>, so that one callback routine can be used for the entire menu. All that the callback routine would have to do, then, is process its argument <var>userData</var> in a <samp> switch ... case ... break</samp> block.<p> <dt><samp><a NAME="uiSetTextDef">void <strong>uiSetText</strong> ( char *<VAR>text</VAR> );</a></samp> <dd>Sets the contents of the text field at the bottom of the window.<p> <dl> <dt><VAR>text</VAR> <dd>The text to be displayed. Pass NULL if no text is to be displayed. </dl> This function only has effect if <a href="#uiInitWindowsDef">uiInitWindows()</a> was called with the <strong>uiHasText</strong> option.<p> <dt><samp><a NAME="uiGetTextDef">char *<strong>uiGetText</strong> ( void );</a></samp> <dd>Returns a pointer to the string in the text field at the bottom of the window. <em>This pointer points to memory allocated just for your program. If you don't call <a href="#uiFreeTextDef">uiFreeText()</a>, that memory won't be freed, and you'll have a memory leak!</em><p> <dt><samp><a NAME="uiFreeTextDef">void <strong>uiFreeText</strong>(char * <var>s</var>);</samp> <dd>Frees the memory allocated by libui when <a href="#uiGetTextDef">uiGetText()</a> is called. <em>Without this freeing call, you will have a memory leak!</em><p></dl><br><hr><br><h3><a name="Routines-Images">Image routines</a></h3><dl> <dt><samp><a NAME="uiNewImageDef">Image *<strong>uiNewImage</strong> (int <VAR>width</VAR>, int <VAR>height</VAR>, argType <VAR>type</VAR> );</a> </samp> <dd>Returns a newly allocated image.<p> <dl> <dt><VAR>width</VAR> <dd>The width of new image. <dt><VAR>height</VAR> <dd>The height of new image. <dt><VAR>type</VAR> <dd>The type of image - either <samp>SCALAR</samp>, for a grayscale image, or <samp>VECTOR</samp>, for a color image. </dl><p> Note that this routine allocates the memory for the image, so you need to call <a HREF="#uiDeleteImageDef">uiDeleteImage()</a> to free up this memory when you're done with the image.<p> <dt><samp><a NAME="uiDeleteImageDef">void <strong>uiDeleteImage</strong> ( Image *<VAR>im</VAR> );</a></samp> <dd>Frees the memory that has been allocated for an image.<p> <dt><samp><a NAME="uiOpenImageDef">Image *<strong>uiOpenImage</strong> (char * <var>filename</var>, int <var>width</var>, int <var>height</var>);</a> </samp> <dd>Opens an RGB file, and reads it into memory. Returns a pointer to the new image.<p> <dl> <dt><var>filename</var> <dd>Name of RGB file to be opened. <dt><var>width</var> <dd>Desired width of new image. If the RGB image on disk has a different width, the image will be scaled. <dt><var>height</var> <dd>Desired height of new image. If the RGB image on disk has a different height, the image will be scaled. </dl><p> If the file cannot be opened, or some other error occurs, <strong> uiOpenImage()</strong> returns <em>NULL</em>. All images that are opened are created as <em>VECTOR</em> images. When you are done with this image, be sure to call <a href="#uiCloseImageDef">uiCloseImage()</a> to properly free the memory associated with the image.<p> <dt><samp><a NAME="uiSaveImageDef">void <strong>uiSaveImage</strong>(Image *<var>image</var>, char *<var>filename</var>);</a></samp> <dd>Save an image to disk as an RGB file.<p> <dl> <dt><var>image</var> <dd>Pointer to image to be saved. This image can either be <em>VECTOR </em> or <em>scalar</em>. <dt><var>filename</var> <dd>Name of file to save image to. This name should end with ".rgb" (no quotes). If it does not, a .rgb extention will be added for you. </dl><p> Pixel scaling is <em>disabled</em> in <strong>uiSaveImage</strong>, so you must call <a href="#uiScalePixelValuesDef">uiScalePixelValues()</a> to reenable scaling, if desired.<p> <dt><samp><a NAME="uiCloseImageDef">void <strong>uiCloseImage</strong> (Image *<var>im</var>);</a></samp> <dd>Close the image <var>im</var> that was opened with <a href="#uiOpenImageDef">uiOpenImage()</a>.<p> <dt><samp><a NAME="uiImageWidthDef">int <strong>uiImageWidth</strong> ( Image *<VAR>im</VAR> );</a></samp><br> <samp><a NAME="uiImageHeightDef">int <strong>uiImageHeight</strong> ( Image *<VAR>im</VAR> );</a></samp> <dd>Returns the width or height of an image.<p> <dt><samp><a NAME="uiImageTypeDef">argType <strong>uiImageType</strong> ( Image *<VAR>im</VAR> );</a></samp> <dd>Returns the type of an image, either <samp><em>SCALAR</em></samp>, for a grayscale image, or <samp><em>VECTOR</em></samp> for a color image.<p> <dt><samp><a NAME="uiSetScalarValueDef">void <strong>uiSetScalarValue </strong> ( Image *<VAR>im</VAR>, int <VAR>ix</VAR>, int <VAR>iy</VAR>, Real <VAR>val</VAR> );</a></samp> <dd>Sets the grayscale intensity of a pixel in an image.<p> <dl> <dt><VAR>im</VAR> <dd>The image to modify. <dt><VAR>ix</VAR>, <VAR>iy</VAR> <dd>The coordinates of the pixel whose color is to be set. <dt><VAR>val</VAR> <dd>The grayscale value of the pixel. This should be normalized to be between 0.0 and 1.0. </dl><p> <dt><samp><a NAME="uiSetVectorValueDef">void <strong>uiSetVectorValue</strong> ( Image *<VAR>im</VAR>, int <VAR>ix</VAR>, int <VAR>iy</VAR>, Vector <VAR>val</VAR> );</a></samp> <dd>Sets the color of a pixel in an image.<p> <dl> <dt><VAR>im</VAR> <dd>The image to modify. <dt><VAR>ix</VAR>, <VAR>iy</VAR> <dd>The coordinates of the pixel whose color is to be set. <dt><VAR>val</VAR> <dd>The color of the pixel. This is a vector where the first (x) component is taken to be the red value, the second (y) component is taken to be the green value, and the the third (z) component is taken to be the blue value. All values should be normalized to be between 0.0 and 1.0. </dl><p> <dt><samp><a NAME="uiGetScalarValueDef">Real <strong>uiGetScalarValue</strong> ( Image *<VAR>im</VAR>, int <VAR>ix</VAR>, int <VAR>iy</VAR> );</a> </samp> <dd>Returns the gray value of a pixel.<p> <dl> <dt><VAR>im</VAR> <dd>The image. <dt><VAR>ix</VAR>, <VAR>iy</VAR> <dd>The coordinates of the pixel. </dl><p> <dt><samp><a NAME="uiGetVectorValueDef">Vector <strong>uiGetVectorValue </strong> ( Image *<VAR>im</VAR>, int <VAR>ix</VAR>, int <VAR>iy</VAR> );</a></samp> <dd>Returns the color value of a pixel.<p> <dl> <dt><VAR>im</VAR> <dd>The image. <dt><VAR>ix</VAR>, <VAR>iy</VAR> <dd>The coordinates of the pixel. </dl><p> <dt><samp><a NAME="uiGetPixelValueDef">unsigned long <strong>uiGetPixelValue </strong> ( Image *<VAR>im</VAR>, int <VAR>ix</VAR>, int <VAR>iy</VAR> );</a></samp> <dd>Returns the color value of a pixel in a packed representation that OpenGL is familiar with.<p> <dl> <dt><VAR>im</VAR> <dd>The image. <dt><VAR>ix</VAR>, <VAR>iy</VAR> <dd>The coordinates of the pixel. </dl><p> The return value of this function is a packed representation of the pixel color. That is, the 32-bit unsigned long that is returned "looks like" RRGGBBAA, where the red component is the upper 8 bits, the green is the next 8, blue next, and alpha is the lowest 8 bits. This value can be used as the argument to a <strong>glColor4ub</strong> call.<p> <dt><samp><a NAME="uiGetPixelDataDef">unsigned long *<strong>uiGetPixelData </strong> ( Image *<VAR>im</VAR> );</a></samp> <dd>Returns an array of pixel values that the call <strong>glDrawPixels </strong> can understand.<p> <dl> <dt><VAR>im</VAR> <dd>The image to get the pixel data from. </dl><p> This is just like calling <a href="#uiGetPixelValueDef">uiGetPixelValue() </a> for each pixel in the image.<p> <dt><samp><a NAME="uiScalePixelValuesDef">void <strong>uiScalePixelValues </strong> ( Image *<VAR>im</VAR>, uiBool <VAR>val</VAR> );</a></samp> <dd>Specifies whether or not to scale the intensity values of an image when retreiving pixel data from it (using <a href="#uiGetPixelValue">uiGetPixelValue()</a> or <a href="#uiGetPixelData">uiGetPixelData()</a>.<p> <dl> <dt><VAR>im</VAR> <dd>The image. <dt><VAR>val</VAR> <dd><samp><em>uiTrue</em></samp> if you want to enable pixel value scaling, and <samp><em>uiFalse</em></samp> if you want to disable it. </dl><p> <dt><samp><a NAME="uiSetScaleFactorDef">void <strong>uiSetScaleFactor</strong> ( Image *<VAR>im</VAR>, Real <VAR>val</VAR> );</a></samp> <dd>Sets the pixel scaling factor for an image.<p> <dl> <dt><VAR>im</VAR> <dd>The image to set the scaling factor of. <dt><VAR>val</VAR> <dd>The scale factor to use when generating pixel values for this image. </dl><p> This procedure sets a constant scaling factor to multiply the value of each pixel with when querying pixel values.<p></dl>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?