Exemplo n.º 1
0
bool Costume::restoreState(SaveGame *state) {
	if (state->readBool()) {
		Common::String str = state->readString();
		setColormap(str);
	}

	for (int i = 0; i < _numChores; ++i) {
		_chores[i]->restoreState(state);
	}

	for (int i = 0; i < _numComponents; ++i) {
		Component *c = _components[i];

		if (c) {
			c->_visible = state->readBool();
			c->_matrix.setPosition(state->readVector3d());
			c->restoreState(state);
		}
	}

	int numPlayingChores = state->readLEUint32();
	for (int i = 0; i < numPlayingChores; ++i) {
		int id = state->readLESint32();
		_playingChores.push_back(_chores[id]);
	}

	_lookAtRate = state->readFloat();
	_head->restoreState(state);
	_head->loadJoints(getModelNodes());

	return true;
}
Exemplo n.º 2
0
PaintData::PaintData()
	: _type(TYPE::SIGNAL),
	_mins(0),
	_maxs(0),
	_dim(0),
	_colormap(0),
	_pen(0),
	_brush(0),
	_back_brush(0),
	_font(0),
	_font_pen(0),
	_font_brush(0),
	_precision(2),
	_fix_limits(false),
	_fix_min (0),
	_fix_max (0),
	_indx (0),
	_indy (1),
	_reset_limits (true),
	_stream_has_changed (true) {

	_label[0] = '\0';

	_painter = new Painter();
	setColormap(IColormap::COLORMAP::COLOR64);
	setPen(IPainter::ITool::COLORS::GREEN, 1, IPainter::ITool::LINE_STYLES::SOLID);
	setBrush(IPainter::ITool::COLORS::BLACK);
	setBackground(true, IPainter::ITool::COLORS::BLACK);
	setFont("Courier New", IPainter::ITool::COLORS::WHITE, IPainter::ITool::COLORS::BLACK, 15, IPainter::ITool::FONT_STYLES::NORMAL);
	setPointSize(5);

	ssi_stream_init(_stream, 0, 0, sizeof(ssi_real_t), SSI_REAL, 0);
	ssi_stream_init(_resample, 0, 0, sizeof(ssi_real_t), SSI_REAL, 0);
}
Exemplo n.º 3
0
caScan2D::caScan2D(QWidget *parent) : QWidget(parent)
{
    m_init = true;

    m_widthDefined = false;
    m_heightDefined = false;

    m_xcptDefined = false;
    m_ycptDefined = false;
    m_xnewdataDefined = false;
    m_ynewdataDefined = false;
    m_savedata_pathDefined = false;
    m_savedata_subdirDefined = false;
    m_savedata_filenameDefined = false;

    thisSimpleView = false;
    savedSize = 0;
    savedWidth = 0;
    savedHeight = 0;
    selectionInProgress = false;

    savedData = (float*) 0;

    initWidgets();

    Xpos = Ypos = 0;

    scrollArea = (QScrollArea *) 0;

    mainLayout = new QGridLayout(this);
    mainLayout->setMargin(0);
    mainLayout->setSpacing(0);
    setLayout(mainLayout);
    setup();

    setColormap(spectrum_wavelength);
    setCustomMap("");
    setDiscreteCustomMap(false);
    
    setROIChannelsRead("");
    setROIChannelsWrite("");

    setROIreadType(none);
    setROIwriteType(none);

    setROIwritemarkerType(box);
    setROIreadmarkerType(box);
    
    setAccessW(true);
    installEventFilter(this);

    scaleFactor = 1.0;

    UpdatesPerSecond = 0;
    startTimer(1000);
    
    writeTimer = new QTimer(this);
    connect(writeTimer, SIGNAL(timeout()), this, SLOT(updateChannels()));   
}
Exemplo n.º 4
0
int caCamera::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    
#ifndef QT_NO_PROPERTIES
     if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = getPV_Data(); break;
        case 1: *reinterpret_cast< QString*>(_v) = getPV_Width(); break;
        case 2: *reinterpret_cast< QString*>(_v) = getPV_Height(); break;
        case 3: *reinterpret_cast< QString*>(_v) = getPV_Code(); break;
        case 4: *reinterpret_cast< QString*>(_v) = getPV_BPP(); break;
        case 5: *reinterpret_cast< zoom*>(_v) = getZoom(); break;
        case 6: *reinterpret_cast< colormap*>(_v) = getColormap(); break;
        case 7: *reinterpret_cast< bool*>(_v) = getInitialAutomatic(); break;
        case 8: *reinterpret_cast< QString*>(_v) = getMinLevel(); break;
        case 9: *reinterpret_cast< QString*>(_v) = getMaxLevel(); break;
        case 10: *reinterpret_cast< QString*>(_v) = getDataProcChannels(); break;
        }
        _id -= 11;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setPV_Data(*reinterpret_cast< QString*>(_v)); break;
        case 1: setPV_Width(*reinterpret_cast< QString*>(_v)); break;
        case 2: setPV_Height(*reinterpret_cast< QString*>(_v)); break;
        case 3: setPV_Code(*reinterpret_cast< QString*>(_v)); break;
        case 4: setPV_BPP(*reinterpret_cast< QString*>(_v)); break;
        case 5: setZoom(*reinterpret_cast< zoom*>(_v)); break;
        case 6: setColormap(*reinterpret_cast< colormap*>(_v)); break;
        case 7: setInitialAutomatic(*reinterpret_cast< bool*>(_v)); break;
        case 8: setMinLevel(*reinterpret_cast< QString*>(_v)); break;
        case 9: setMaxLevel(*reinterpret_cast< QString*>(_v)); break;
        case 10: setDataProcChannels(*reinterpret_cast< QString*>(_v)); break;
        }
        _id -= 11;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 11;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Exemplo n.º 5
0
void ScintillaEditor::setHighlightScheme(const QString &name)
{
	for (const auto &colorSchemeEntry : enumerateColorSchemes()) {
		const auto colorScheme = colorSchemeEntry.second.get();
		if (colorScheme->name() == name) {
			setColormap(colorScheme);
			return;
		}
	}

	noColor();
}
Exemplo n.º 6
0
void ScintillaEditor::setHighlightScheme(const QString &name)
{
	const colorscheme_set_t colorscheme_set = enumerateColorSchemes();

	for (colorscheme_set_t::const_iterator it = colorscheme_set.begin(); it != colorscheme_set.end(); it++) {
		const EditorColorScheme *colorScheme = (*it).second.get();
		if (colorScheme->name() == name) {
			setColormap(colorScheme);
			return;
		}
	}

	noColor();
}
Exemplo n.º 7
0
static Bool
initLogo(ModeInfo * mi)
{
	Display *display = MI_DISPLAY(mi);
	Window window = MI_WINDOW(mi);
	imagestruct *ip = &ims[MI_SCREEN(mi)];

	if (ip->logo == None) {
		getImage(mi, &ip->logo, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_BITS,
#ifdef HAVE_XPM
			DEFAULT_XPM, IMAGE_NAME,
#endif
			&ip->graphics_format, &ip->cmap, &ip->black);
		if (ip->logo == None) {
			free_image(display, ip);
			return False;
		}
		ip->pixw = ip->logo->width;
		ip->pixh = ip->logo->height;
	}
#ifndef STANDALONE
	if (ip->cmap != None) {
		setColormap(display, window, ip->cmap, MI_IS_INWINDOW(mi));
		if (ip->bgGC == None) {
			XGCValues xgcv;

			xgcv.background = ip->black;
			if ((ip->bgGC = XCreateGC(display, window, GCBackground,
					&xgcv)) == None) {
				free_image(display, ip);
				return False;
			}
		}
	} else
#endif /* STANDALONE */
	{
		ip->black = MI_BLACK_PIXEL(mi);
		ip->bgGC = MI_GC(mi);
	}
	return True;
}
Exemplo n.º 8
0
static Bool
init_stuff(ModeInfo * mi)
{
	Display    *display = MI_DISPLAY(mi);
	Window      window = MI_WINDOW(mi);
	puzzlestruct *pp = &puzzles[MI_SCREEN(mi)];

	if (pp->logo == None)
		getImage(mi, &pp->logo, PUZZLE_WIDTH, PUZZLE_HEIGHT, PUZZLE_BITS,
#ifdef HAVE_XPM
			 DEFAULT_XPM, PUZZLE_NAME,
#endif
			 &pp->graphics_format, &pp->cmap, &pp->black);
	if (pp->logo == None) {
		free_puzzle(display, pp);
		return False;
	}
#ifndef STANDALONE
	if (pp->cmap != None) {
		setColormap(display, window, pp->cmap, MI_IS_INWINDOW(mi));
		if (pp->backGC == None) {
			XGCValues   xgcv;

			xgcv.background = pp->black;
			if ((pp->backGC = XCreateGC(display, window, GCBackground,
					 &xgcv)) == None) {
				free_puzzle(display, pp);
				return False;
			}
		}
	} else
#endif /* STANDALONE */
	{
		pp->black = MI_BLACK_PIXEL(mi);
		pp->backGC = MI_GC(mi);
	}
	return True;
}
Exemplo n.º 9
0
static Bool
init_stuff(ModeInfo * mi)
{
	Display    *display = MI_DISPLAY(mi);
	Window      window = MI_WINDOW(mi);
	life1dstruct *lp = &life1ds[MI_SCREEN(mi)];

	if (lp->logo == None) {
		getImage(mi, &lp->logo, CELL_WIDTH, CELL_HEIGHT, CELL_BITS,
#ifdef HAVE_XPM
			 DEFAULT_XPM, CELL_NAME,
#endif
			 &lp->graphics_format, &lp->cmap, &lp->black);
		if (lp->logo == None) {
			return False;
		}
	}
#ifndef STANDALONE
	if (lp->cmap != None) {
		setColormap(display, window, lp->cmap, MI_IS_INWINDOW(mi));
		if (lp->backGC == None) {
			XGCValues   xgcv;

			xgcv.background = lp->black;
			if ((lp->backGC = XCreateGC(display, window, GCBackground,
					&xgcv)) == None) {
				return False;
			}
		}
	} else
#endif /* STANDALONE */
	{
		lp->black = MI_BLACK_PIXEL(mi);
		lp->backGC = MI_GC(mi);
	}
	return True;
}
Exemplo n.º 10
0
DensityViewerWindow::DensityViewerWindow(QWidget *parent) :
    QMainWindow(parent)
{
    //ui->setupUi(this);

    QHBoxLayout *mainLayout = new QHBoxLayout;
    densityViewer = new DensityViewer;
    mainLayout->addWidget(densityViewer);

    auto controllerBar = new QVBoxLayout;

    auto plusButton = new QPushButton("zoom in");
    connect(plusButton,&QPushButton::clicked,[=](bool){densityViewer->changeZoom(1.2);});
    auto minusButton = new QPushButton("zoom out");
    connect(minusButton,&QPushButton::clicked,[=](bool){densityViewer->changeZoom(1./1.2);});
    auto plusMinus = new QHBoxLayout;

    plusMinus->addWidget(minusButton);
    plusMinus->addWidget(plusButton);

    controllerBar->addLayout(plusMinus);

    colorSaturation = new QDoubleSpinBox;
    colorSaturation->setMaximum(INFINITY);
    colorSaturation->setSingleStep(1);
    colorSaturation->setValue(100);
    colorSaturation->setEnabled(false);

    controllerBar->addWidget(new QLabel("Color saturation"));
    connect(colorSaturation,
            SIGNAL(valueChanged(double)),
            densityViewer,
            SLOT(setColorSaturation(double)));
    controllerBar->addWidget(colorSaturation);

    //http://forum.qt.io/topic/17409/solved-qt-4-7-qcombobox-custom-item-delegate-doesn-t-affect-the-current-item-displayed/3

    colormapComboBox = new QComboBox;
    colormapComboBox->setEnabled(false);
    for (const auto& cmap : Colormap::AvailableColormaps )
        colormapComboBox->addItem(QString::fromStdString(cmap.first));

    connect(colormapComboBox,SIGNAL(activated(QString)),densityViewer,SLOT(setColormap(QString)));

    controllerBar->addWidget(colormapComboBox);

    controllerBar->addWidget(new QLabel("Select section:"));
    sectionComboBox = new QComboBox;

    sectionComboBox->setEnabled(false);

    connect(sectionComboBox,
            static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::activated),
            [=](QString sec){densityViewer->setSectionDirection( sec );});

    controllerBar->addWidget(sectionComboBox);

    auto xStretch = new QHBoxLayout;
    xStretch->addWidget(new QLabel("x="));
    sectionIndex = new QDoubleSpinBox;
    sectionIndex->setValue(0);
    sectionIndex->setEnabled(false);

    connect(sectionIndex, SIGNAL(valueChanged(double)),densityViewer, SLOT(setSectionIndex(double)));
    connect(densityViewer, SIGNAL(changedSectionDirection()),this,SLOT(setXLimits()));

    xStretch->addWidget(sectionIndex);
    controllerBar->addLayout(xStretch);

    auto gridOn = new QCheckBox("grid");

    gridOn->setChecked(false);
    connect(gridOn,SIGNAL(clicked(bool)),densityViewer,SLOT(setGrid(bool)));

    controllerBar->addWidget(gridOn);

    auto infoButton = new QPushButton("info");
    connect(infoButton,
            &QPushButton::clicked,
            [=](){densityViewer->setInteractionMode(DensityViewerInteractionMode::info);});
    controllerBar->addWidget(infoButton);

    auto panButton = new QPushButton("pan");
    connect(panButton,
            &QPushButton::clicked,
            [=](){densityViewer->setInteractionMode(DensityViewerInteractionMode::pan);});
    controllerBar->addWidget(panButton);

    auto zoomButton = new QPushButton("zoom");
    connect(zoomButton,
            &QPushButton::clicked,
            [=](){densityViewer->setInteractionMode(DensityViewerInteractionMode::zoom);});
    controllerBar->addWidget(zoomButton);

    auto homeButton = new QPushButton("home");
    connect(homeButton,
            SIGNAL(pressed()),
            densityViewer,
            SLOT(goHome()));
    controllerBar->addWidget(homeButton);

    auto updateButton = new QPushButton("update");
    connect(updateButton,
            SIGNAL(pressed()),
            this,
            SLOT(updateDataset()));
    controllerBar->addWidget(updateButton);

    controllerBar->addStretch();

    coordinateCursor = new QLabel;
    coordinateCursor->setMinimumWidth(150);
    connect(densityViewer,
            &DensityViewer::dataCursorMoved,
            [=](int, int, vector<double>,string text){coordinateCursor->setText(QString::fromStdString(text));});
    controllerBar->addWidget(coordinateCursor);

    mainLayout->addLayout(controllerBar);

    connect(densityViewer,
            SIGNAL(loadedDensityData(DensityData&)),
            this,
            SLOT(updateControls()));

    //Context menu
    auto openDataset = new QAction("&Open dataset", this);
    openDataset->setShortcuts(QKeySequence::Open);
    connect(openDataset, SIGNAL(triggered()), this, SLOT(openFile()));

    QMenu* fileMenu = menuBar()->addMenu("&File");
    fileMenu->addAction(openDataset);

    // Set layout in QWidget
    QWidget *inners = new QWidget();
    inners->setLayout(mainLayout);

    // Set QWidget as the central layout of the main window
    setCentralWidget(inners);
    //mainLayout->setContentsMargins(0, 0, 0, 0);
    mainLayout->setSpacing(0);

    //For debug purposes
    //densityViewer->loadDensityData("/Users/arkadiy/ag/yell/yell playground/delta-pdf.h5");

}
Exemplo n.º 11
0
/* **********************************************************************
  HBITMAP DSCreateBitmapInfo(l_int32 width, l_int32 height, l_int32 depth,
                             PIXCMAP *cmap)

  PARAMETERS:
    l_int32 width - Desired width of the DIBSection
    l_int32 height - Desired height of the DIBSection
    l_int32 depth - Desired bit-depth of the DIBSection
    PIXCMAP cmap - leptonica colormap for depths < 16

  RETURNS:
    LPBITMAPINFO - a ptr to BITMAPINFO of the desired size and bit-depth
                   NULL on failure

  REMARKS:
    Creates a BITMAPINFO based on the criteria passed in as parameters.

********************************************************************** */
static LPBITMAPINFO
DSCreateBitmapInfo(l_int32 width,
                   l_int32 height,
                   l_int32 depth,
                   PIXCMAP *cmap)
{
l_int32       nInfoSize;
LPBITMAPINFO  pbmi;
LPDWORD       pMasks;

    nInfoSize = sizeof(BITMAPINFOHEADER);
    if( depth <= 8 )
        nInfoSize += sizeof(RGBQUAD) * (1 << depth);
    if((depth == 16) || (depth == 32))
        nInfoSize += (3 * sizeof(DWORD));

        /* Create the header big enough to contain color table and
         * bitmasks if needed. */
    pbmi = (LPBITMAPINFO)malloc(nInfoSize);
    if (!pbmi)
        return NULL;

    ZeroMemory(pbmi, nInfoSize);
    pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    pbmi->bmiHeader.biWidth = width;
    pbmi->bmiHeader.biHeight = height;
    pbmi->bmiHeader.biPlanes = 1;
    pbmi->bmiHeader.biBitCount = depth;

        /* override below for 16 and 32 bpp */
    pbmi->bmiHeader.biCompression = BI_RGB;

        /*  ?? not sure if this is right?  */
    pbmi->bmiHeader.biSizeImage = DSImageBitsSize(pbmi);

    pbmi->bmiHeader.biXPelsPerMeter = 0;
    pbmi->bmiHeader.biYPelsPerMeter = 0;
    pbmi->bmiHeader.biClrUsed = 0;	/* override below */
    pbmi->bmiHeader.biClrImportant = 0;

    switch(depth)
    {
        case 24:
                /* 24bpp requires no special handling */
            break;
        case 16:
                /* if it's 16bpp, fill in the masks and override the
                 * compression.  These are the default masks -- you
                 * could change them if needed. */
            pMasks = (LPDWORD)(pbmi->bmiColors);
            pMasks[0] = 0x00007c00;
            pMasks[1] = 0x000003e0;
            pMasks[2] = 0x0000001f;
            pbmi->bmiHeader.biCompression = BI_BITFIELDS;
            break;
        case 32:
                /* if it's 32 bpp, fill in the masks and override
                 * the compression */
            pMasks = (LPDWORD)(pbmi->bmiColors);
            /*pMasks[0] = 0x00ff0000; */
            /*pMasks[1] = 0x0000ff00; */
            /*pMasks[2] = 0x000000ff; */
            pMasks[0] = 0xff000000;
            pMasks[1] = 0x00ff0000;
            pMasks[2] = 0x0000ff00;

            pbmi->bmiHeader.biCompression = BI_BITFIELDS;
            break;
        case 8:
        case 4:
        case 1:
            setColormap(pbmi, cmap);
            break;
    }
    return pbmi;
}
Exemplo n.º 12
0
void
fixColormap(ModeInfo * mi, int ncolors, float saturation,
	    Bool mono, Bool install, Bool inroot, Bool inwindow, Bool verbose)
{
	Display    *display = MI_DISPLAY(mi);
	Window     window = MI_WINDOW(mi);
	Screen     *scr = MI_SCREENPTR(mi);
	Colormap    cmap = MI_COLORMAP(mi);
	Colormap    dcmap = DefaultColormapOfScreen(scr);
	XColor      xcolor;
	unsigned char *red = (unsigned char *) NULL,
		*green = (unsigned char *) NULL,
		*blue = (unsigned char *) NULL;
	int         colorcount, i, fixed, visualclass;

#ifndef COMPLIANT_COLORMAP
	Bool        retry = False;

#endif

	if (mono || CellsOfScreen(scr) <= 2) {
		if (MI_PIXELS(mi))
			return;
		if ((MI_PIXELS(mi) = (unsigned long *) calloc(2,
				sizeof (unsigned long))) == NULL) {
			(void) fprintf(stderr, "could not get the 2 colors for mono\n");
		}

		monoColormap(scr, MI_SCREENINFO(mi), foreground, background);
		return;
	}
	colorcount = ncolors;
	if (((  red = (unsigned char *) calloc(ncolors,
			sizeof (unsigned char))) == NULL) ||
	    ((green = (unsigned char *) calloc(ncolors,
			sizeof (unsigned char))) == NULL) ||
	    (( blue = (unsigned char *) calloc(ncolors,
			sizeof (unsigned char))) == NULL)) {
		(void) fprintf(stderr, "could not get the %d colors\n", ncolors);
		if (red != NULL)
			free(red);
		if (green != NULL)
			free(green);
		return;
	}

	visualclass = MI_VISUALCLASS(mi);
	fixed = (visualclass == StaticGray) || (visualclass == StaticColor) ||
		(visualclass == TrueColor);
	if (
#ifdef USE_DTSAVER
		   dtsaver ||	/* needs to be in focus without mouse */

#endif
		   inroot || (!install && !fixed) || cmap == None) {
		cmap = dcmap;
	}
	if (cmap != dcmap && MI_PIXELS(mi)) {
		XFreeColors(display, cmap, MI_PIXELS(mi), MI_NPIXELS(mi), 0);
#ifndef COMPLIANT_COLORMAP
		XFreeColors(display, cmap, &(MI_BLACK_PIXEL(mi)), 1, 0);
		XFreeColors(display, cmap, &(MI_WHITE_PIXEL(mi)), 1, 0);
#endif
		XFreeColors(display, cmap, &(MI_BG_PIXEL(mi)), 1, 0);
		XFreeColors(display, cmap, &(MI_FG_PIXEL(mi)), 1, 0);
	}
	/* else if (cmap) { (void) printf("cmap: this case is possible?\n");  } */
	if (MI_PIXELS(mi))
		free(MI_PIXELS(mi));
	if ((MI_PIXELS(mi) = (unsigned long *) calloc(ncolors,
			sizeof (unsigned long))) == NULL) {
		(void) fprintf(stderr, "could not get the %d colors\n", ncolors);
	}
	/* "allocate" the black and white pixels, so that they
	   will be included by XCopyColormapAndFree() if it gets called */
#ifdef COMPLIANT_COLORMAP
	MI_BLACK_PIXEL(mi) = BlackPixelOfScreen(scr);
	MI_WHITE_PIXEL(mi) = WhitePixelOfScreen(scr);
#else
	MI_BLACK_PIXEL(mi) = allocPixel(display, cmap, "Black", "Black");
	MI_WHITE_PIXEL(mi) = allocPixel(display, cmap, "White", "White");
#endif
	MI_BG_PIXEL(mi) = allocPixel(display, cmap, background, "White");
	MI_FG_PIXEL(mi) = allocPixel(display, cmap, foreground, "Black");
	hsbramp(0.0, saturation, 1.0, 1.0, saturation, 1.0, colorcount,
		red, green, blue);

	MI_NPIXELS(mi) = 0;
	for (i = 0; i < colorcount; i++) {
		xcolor.red = red[i] << 8;
		xcolor.green = green[i] << 8;
		xcolor.blue = blue[i] << 8;
		xcolor.flags = DoRed | DoGreen | DoBlue;

		if (!XAllocColor(display, cmap, &xcolor)) {
#ifdef COMPLIANT_COLORMAP
			if (!install || cmap != dcmap)
				break;
			if ((cmap = XCopyColormapAndFree(display, cmap)) == dcmap)
				break;
			if (verbose)
				(void) fprintf(stderr, "using private colormap\n");
			if (!XAllocColor(display, cmap, &xcolor))
				break;
#else
			if (verbose)
				(void) fprintf(stderr, "ran out of colors on colormap\n");
			if ((saturation != 1.0 || ncolors != 64) && MI_NPIXELS(mi) < 2) {
				if (verbose)
					(void) fprintf(stderr,
						       "retrying with saturation = 1.0 and ncolors = 64\n");
				retry = True;
			}
			break;
#endif
		}
		MI_PIXELS(mi)[i] = xcolor.pixel;
		MI_NPIXELS(mi)++;
	}
	free(red);
	free(green);
	free(blue);
	if (verbose)
		(void) fprintf(stderr, "%d pixel%s allocated\n", MI_NPIXELS(mi),
			       (MI_NPIXELS(mi) == 1) ? "" : "s");
	if (MI_NPIXELS(mi) <= 4) {
		XFreeColors(display, cmap, MI_PIXELS(mi), MI_NPIXELS(mi), 0);
#ifndef COMPLIANT_COLORMAP
		XFreeColors(display, cmap, &(MI_BLACK_PIXEL(mi)), 1, 0);
		XFreeColors(display, cmap, &(MI_WHITE_PIXEL(mi) ), 1, 0);
#endif
		XFreeColors(display, cmap, &(MI_BG_PIXEL(mi)), 1, 0);
		XFreeColors(display, cmap, &(MI_FG_PIXEL(mi)), 1, 0);
#ifndef COMPLIANT_COLORMAP
		if (retry) {
			fixColormap(mi, 64, 1.0,
				    mono, install, inroot, inwindow, verbose);
			return;
		}
#endif
		monoColormap(scr, MI_SCREENINFO(mi), foreground, background);
		MI_COLORMAP(mi) = cmap = DefaultColormapOfScreen(scr);
		return;
	}
	MI_COLORMAP(mi) = cmap;
	if ((install || fixed) && !inroot && MI_NPIXELS(mi) > 2) {
#if 0
		(void) XGetWindowAttributes(display, window, &xgwa);
		if (cmap != xgwa.colormap)
#endif
#if 1				/* Turn off to simulate fvwm and tvwm */
			setColormap(display, window, cmap, inwindow);
#endif
	}
#if 0
	else {
		/* white and black colors may not be right for GL modes so lets set them */
		MI_BLACK_PIXEL(mi) = BlackPixelOfScreen(scr);
		MI_WHITE_PIXEL(mi) = WhitePixelOfScreen(scr);
		/* foreground and background colors may not be right.... */
		BlackPixelOfScreen(scr) = MI_BLACK_PIXEL(mi);
		WhitePixelOfScreen(scr) = MI_WHITE_PIXEL(mi);
	}
#endif
}
Exemplo n.º 13
0
caWaterfallPlot::caWaterfallPlot(QWidget *parent): QWidget(parent)
{

    QHBoxLayout *hboxLayout = new QHBoxLayout(this);

    thisCountNumber = 0;

    datamutex = new QMutex;

    // define a new plot
    plot = new QwtPlot(this);
    QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    plot->setSizePolicy(sizePolicy);

    // add it to layout
    hboxLayout->addWidget(plot);

    // define spectrogram
    d_spectrogram = new QwtPlotSpectrogram();
    d_spectrogram->setRenderThreadCount(0); // use system specific thread count

    d_spectrogram->setColorMap(new ColorMap_Wavelength());

    // define data
    m_data = new SpectrogramData();

    // set 200 rows ( NumberofColumns columns for demo
    setRows(nbRows);
    setCols(nbCols);
    ActualNumberOfColumns = NumberOfColumns = nbCols;
    reducedArray = (double*) malloc(ActualNumberOfColumns * sizeof(double));
    memset(reducedArray, 0, ActualNumberOfColumns *sizeof(double));

    // initialize data
    m_data->initData(NumberOfColumns, getRows());
    thisIntensityMin = 0;
    thisIntensityMax = 1000;
    setIntensityScalingMax(Channel);
    setIntensityScalingMin(Channel);

    // set data to spectrogram
    countRows = 0;
    d_spectrogram->setData(m_data);
    d_spectrogram->attach(plot);

    // define a grid
    plotGrid = new QwtPlotGrid();
    plotGrid->attach(plot);

    // no titles yet
    setTitlePlot("");
    setTitleX("");
    setTitleY("");

    // enable axis
    setXaxisEnabled(true);
    setYaxisEnabled(true);

    setCustomMap("");
    setDiscreteCustomMap(false);
    setColormap(spectrum_wavelength);

    updatePlot();


    firstMonitorPlot = firstDemoPlot = firstTimerPlot = true;

    // set a timer for nice demo

    thisUnits = Millisecond;
    thisPeriod = 200;

    Timer = new QTimer(this);
    Timer->setInterval((int) thisPeriod);
    Timer->start();
    position = 0.0;
    drift = 1.0;
    disableDemo = false;
    connect(Timer, SIGNAL(timeout()), this, SLOT(TimeOut()));
}