Back to index

salome-gui  6.5.0
Classes | Defines | Functions | Variables
OCCViewer_ViewPort.cxx File Reference
#include "OCCViewer_ViewPort.h"
#include "SUIT_Session.h"
#include <QColor>
#include <QRect>
#include <QPixmap>
#include <QPainter>
#include <QMultiHash>
#include <QMenu>
#include <QColorDialog>
#include <QColormap>
#include <QCoreApplication>
#include <stdlib.h>
#include <QX11Info>
#include <GL/glx.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/Xmu/StdCmap.h>
#include <Xw_Window.hxx>
#include <Graphic3d_GraphicDevice.hxx>

Go to the source code of this file.

Classes

struct  CMapEntry
 Map of indexed colors For internal purposes. More...

Defines

#define QT_CLEAN_NAMESPACE   /* avoid definition of INT32 and INT8 */

Functions

static void cleanup_cmaps ()
static Colormap choose_cmap (Display *dpy, XVisualInfo *vi)

Variables

static QMultiHash< int,
CMapEntry > * 
cmap_dict = 0
static bool mesa_gl = false

Define Documentation

#define QT_CLEAN_NAMESPACE   /* avoid definition of INT32 and INT8 */

Definition at line 24 of file OCCViewer_ViewPort.cxx.


Function Documentation

static Colormap choose_cmap ( Display *  dpy,
XVisualInfo *  vi 
) [static]

Definition at line 96 of file OCCViewer_ViewPort.cxx.

{
  if ( !cmap_dict )
  {
    cmap_dict = new QMultiHash<int,CMapEntry>;
    const char *v = glXQueryServerString( dpy, vi->screen, GLX_VERSION );
    mesa_gl = strstr( v,"Mesa" ) != 0;
    qAddPostRoutine( cleanup_cmaps );
  }

  QHash<int,CMapEntry>::iterator itH = cmap_dict->find( (long)vi->visualid );
  if ( itH != cmap_dict->end() )  // found colormap for visual
    return itH.value().cmap;
  
  CMapEntry x;
  
  XStandardColormap *c;
  int n, i;

  //#ifdef DEBUG
  //cout << "Choosing cmap for vID = " << vi->visualid << endl;
  //#endif

  if ( vi->visualid == XVisualIDFromVisual( (Visual*)QX11Info::appVisual() ) )
  {
#ifdef DEBUG
//    cout << "Using x11AppColormap" << endl;
#endif
    return QX11Info::appColormap();
  }

  if ( mesa_gl )
  {
    Atom hp_cmaps = XInternAtom( dpy, "_HP_RGB_SMOOTH_MAP_LIST", true );
    if ( hp_cmaps && vi->visual->c_class == TrueColor && vi->depth == 8 )
    {
      if ( XGetRGBColormaps( dpy, RootWindow( dpy, vi->screen ), &c, &n, hp_cmaps ) )
      {
        i = 0;
        while ( i < n && x.cmap == 0 )
        {
          if ( c[i].visualid == vi->visual->visualid )
          {
            x.cmap = c[i].colormap;
            x.scmap = c[i];
          }
          i++;
        }
        XFree( (char*)c );
      }
    }
  }
#if !defined( _OS_SOLARIS_ )
  if ( !x.cmap )
  {
    if ( XmuLookupStandardColormap( dpy, vi->screen, vi->visualid, vi->depth, XA_RGB_DEFAULT_MAP, false, true ) )
    {
      if ( XGetRGBColormaps( dpy, RootWindow( dpy, vi->screen ), &c, &n, XA_RGB_DEFAULT_MAP ) )
      {
        i = 0;
        while ( i < n && x.cmap == 0 )
        {
          if ( c[i].visualid == vi->visualid )
          {
            x.cmap = c[i].colormap;
            x.scmap = c[i];
          }
          i++;
        }
        XFree( (char *)c );
      }
    }
  }
#endif
  if ( !x.cmap )
  {
    // no shared cmap found
    x.cmap = XCreateColormap( dpy, RootWindow( dpy, vi->screen ), vi->visual, AllocNone );
    x.alloc = true;
  }

  cmap_dict->insert( (long)vi->visualid, x ); // associate cmap with visualid
  return x.cmap;
}

Here is the call graph for this function:

static void cleanup_cmaps ( ) [static]

Definition at line 85 of file OCCViewer_ViewPort.cxx.

{
  if ( !cmap_dict )
    return;
  //while (!cmap_dict->isEmpty())
  //  cmap_dict->erase(cmap_dict->begin());
  cmap_dict->clear();
  delete cmap_dict;
  cmap_dict = 0;
}

Here is the caller graph for this function:


Variable Documentation

QMultiHash<int,CMapEntry>* cmap_dict = 0 [static]

Definition at line 82 of file OCCViewer_ViewPort.cxx.

bool mesa_gl = false [static]

Definition at line 83 of file OCCViewer_ViewPort.cxx.