Beispiel #1
0
/*\internal
  Store color values in the given colormap.
*/
static void qStoreColors(HPALETTE cmap, const QGLColormap & cols)
{
    QRgb color;
    PALETTEENTRY pe;

    for (int i = 0; i < cols.size(); i++) {
        color = cols.entryRgb(i);
        pe.peRed   = qRed(color);
        pe.peGreen = qGreen(color);
        pe.peBlue  = qBlue(color);
        pe.peFlags = 0;

        SetPaletteEntries(cmap, i, 1, &pe);
    }
}
Beispiel #2
0
void QGLWidget::setColormap(const QGLColormap & c)
{
    Q_D(QGLWidget);
    d->cmap = c;

    if (d->cmap.handle()) { // already have an allocated cmap
        d->updateColormap();
    } else {
        LOGPALETTE *lpal = (LOGPALETTE *) malloc(sizeof(LOGPALETTE)
                                                 +c.size()*sizeof(PALETTEENTRY));
        lpal->palVersion    = 0x300;
        lpal->palNumEntries = c.size();
        d->cmap.setHandle(CreatePalette(lpal));
        free(lpal);
        d->updateColormap();
    }
}
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    MySuperGLWidget widget;     // a QGLWidget in color-index mode
    QGLColormap colormap;

    // This will fill the colormap with colors ranging from
    // black to white.
    const int size = 256;
    for (int i = 0; i < size; ++i)
        colormap.setEntry(i, qRgb(i, i, i));

    widget.setColormap(colormap);
    widget.show();
    return app.exec();
}
Beispiel #4
0
AM3dDataSourceView::AM3dDataSourceView(const AMScan* scan, int dataSourceIndex, QWidget *parent) :
	QWidget(parent)
{
	QVBoxLayout* vl = new QVBoxLayout();

	surfacePlot_ = new Qwt3D::SurfacePlot();
	surfacePlot_->setPlotStyle(Qwt3D::FILLEDMESH);
	surfacePlot_->setShading(Qwt3D::GOURAUD);

	surfacePlot_->enableLighting();
	surfacePlot_->illuminate(0);
	surfacePlot_->setLightShift(23,23,23);
	surfacePlot_->setLightRotation(90,0,0);

	surfacePlot_->setRotation(30,0,15);
	surfacePlot_->setZoom(0.90);


	QGLColormap colors;
	colors.setEntry(0, qRgb(0, 0, 131));
	colors.setEntry(1, qRgb(0, 0, 255));
	colors.setEntry(2, qRgb(0, 255, 255));
	colors.setEntry(3, qRgb(255, 255, 0));
	colors.setEntry(4, qRgb(255, 0, 0));
	colors.setEntry(5, qRgb(128, 0, 0));

	surfacePlot_->setColormap(colors);
	surfacePlot_->setResolution(4);
	vl->addWidget(surfacePlot_);

	setLayout(vl);

	if(scan && scan->dataSourceCount() > dataSourceIndex && scan->dataSourceAt(dataSourceIndex)->rank() == 2) {
		scan_ = scan;
		dataSourceIndex_ = dataSourceIndex;
		updatePlotScheduler_.schedule();
	}
	else {
		scan_ = 0;
		dataSourceIndex_ = 0;
	}

	connect(&updatePlotScheduler_, SIGNAL(executed()), this, SLOT(updatePlotFromDataSource()));
}