# SoVRMLImageTexture.h

    00001 /**************************************************************************\
    00002  *
    00003  *  This file is part of the Coin 3D visualization library.
    00004  *  Copyright (C) 1998-2003 by Systems in Motion.  All rights reserved.
    00005  *
    00006  *  This library is free software; you can redistribute it and/or
    00007  *  modify it under the terms of the GNU General Public License
    00008  *  ("GPL") version 2 as published by the Free Software Foundation.
    00009  *  See the file LICENSE.GPL at the root directory of this source
    00010  *  distribution for additional information about the GNU GPL.
    00011  *
    00012  *  For using Coin with software that can not be combined with the GNU
    00013  *  GPL, and for taking advantage of the additional benefits of our
    00014  *  support services, please contact Systems in Motion about acquiring
    00015  *  a Coin Professional Edition License.
    00016  *
    00017  *  See <URL:http://www.coin3d.org> for  more information.
    00018  *
    00019  *  Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
    00020  *  <URL:http://www.sim.no>.
    00021  *
    00022 \**************************************************************************/
    00023
    00024 #ifndef COIN_SOVRMLIMAGETEXTURE_H
    00025 #define COIN_SOVRMLIMAGETEXTURE_H
    00026
    00027 #include <Inventor/nodes/SoSubNode.h>
    00028 #include <Inventor/VRMLnodes/SoVRMLTexture.h>
    00029 #include <Inventor/fields/SoMFString.h>
    00030 #include <Inventor/SbImage.h>
    00031
    00032 class SoVRMLImageTexture;
    00033 class SoSensor;
    00034 class SbImage;
    00035
    00036 typedef SbBool VRMLPrequalifyFileCallback(const SbString &, void *,
    00037                                           SoVRMLImageTexture *);
    00038
    00039 class COIN_DLL_API SoVRMLImageTexture : public SoVRMLTexture
    00040 {
    00041   typedef SoVRMLTexture inherited;
    00042   SO_NODE_HEADER(SoVRMLImageTexture);
    00043
    00044 public:
    00045   static void initClass(void);
    00046   SoVRMLImageTexture(void);
    00047
    00048   SoMFString url;
    00049
    00050   static void setDelayFetchURL(const SbBool onoff);
    00051   static void setPrequalifyFileCallBack(VRMLPrequalifyFileCallback * cb,
    00052                                         void * closure);
    00053   void allowPrequalifyFile(SbBool enable);
    00054
    00055   virtual void doAction(SoAction * action);
    00056   virtual void GLRender(SoGLRenderAction * action);
    00057   virtual void callback(SoCallbackAction * action);
    00058   virtual void rayPick(SoRayPickAction * action);
    00059
    00060   void setImage(const SbImage & image);
    00061   const SbImage * getImage(void) const;
    00062
    00063   static void setImageDataMaxAge(const uint32_t maxage);
    00064
    00065 protected:
    00066   virtual ~SoVRMLImageTexture();
    00067
    00068   virtual SbBool readInstance(SoInput * in, unsigned short flags);
    00069   int getReadStatus(void) const;
    00070   void setReadStatus(int status);
    00071
    00072 private:
    00073
    00074   SbBool readImage(const SbString & filename);
    00075   SbBool loadUrl(void);
    00076   class SoVRMLImageTextureP * pimpl;
    00077   static void urlSensorCB(void *, SoSensor *);
    00078   static void glimage_callback(void * closure);
    00079   static SbBool image_read_cb(const SbString &, SbImage *, void *);
    00080   static void read_thread(void * closure);
    00081   static SbBool default_prequalify_cb(const SbString & url,  void * closure,
    00082                                       SoVRMLImageTexture * node);
    00083   static void oneshot_readimage_cb(void *, SoSensor *);
    00084
    00085 }; // class SoVRMLImageTexture
    00086
    00087 #endif // ! COIN_SOVRMLIMAGETEXTURE_H