Пример #1
0
void main()
{

	void* buff;
	if (totalTouchCount.readObject(buff,0) <= 0)
	{
	   //no data has been saved previously
	   totalTouchCount.writeObject(0);
       LOG("\ntotalTouchCount has been written to\n");

	} else {
        LOG("\ntotalTouchCount hasn't been written to\n");
    }

    Colormap colourList;
    colourList.setEGA();
    vid.setMode(SOLID_MODE);
    vid.colormap[0].set(colourList[1].get());

    Events::cubeTouch.set(&onTouch);

    while(1)
    {
        System::paint();
        int temp = 0;
        totalTouchCount.readObject(temp,0);
        LOG("%d \n",temp);
    }

}
Пример #2
0
 /************************************************************************
    ColormapBlue
 ************************************************************************/
 void ColormapBlue::visit(Colormap& map)
 {
     int range = map.getRange();
     map.addColor(0, QColor(0, 0, 30));
     map.addColor((int)(range / 3.0), QColor(0, 0, 83));
     map.addColor(range - 1, QColor(255, 255, 255));
 }
Пример #3
0
  /** Upload LUT.
   * @param lut_id LUT ID.
   */
  void
  set_colormap(const char *lut_id)
  {
    ColormapFile cmf;
    cmf.read(__file);
    Colormap *cm = cmf.get_colormap();
    FuseLutContent *lc = new FuseLutContent(lut_id, cm->get_buffer(),
					    cm->width(), cm->height(), cm->depth(),
					    /* bytes per cell */ 1);
    delete cm;

    __client->enqueue(new FuseNetworkMessage(FUSE_MT_SET_LUT, lc));
  }
Пример #4
0
 static ::Window make_window(
     const Display& display,
     const VisualInfo& vi,
     const Colormap& cmap,
     unsigned width,
     unsigned height
 )
 {
     ::XSetWindowAttributes swa;
     swa.colormap = cmap.Handle();
     swa.background_pixmap = None;
     swa.border_pixel = 0;
     swa.event_mask = StructureNotifyMask;
     //
     return ::XCreateWindow(
                display,
                RootWindow(display.Get(), vi->screen),
                0, 0, width, height,
                0,
                vi->depth,
                InputOutput,
                vi->visual,
                CWBorderPixel | CWColormap | CWEventMask,
                &swa
            );
 }
Пример #5
0
void main()
{
    assetConfig.append(MainSlot, BetterflowAssets);
    loader.init();

    for (CubeID cube : CubeSet::connected())
    {
        onConnect(NULL, cube);
    }
    Events::cubeConnect.set(&onConnect);

    gVideo[0].setMode(BG0);

    MainMenu gameMenu(&gVideo[0]);

    int colour;
    Colormap colourList;
    colourList.setEGA();

    

    while(1)
    {
        colour = gameMenu.runMenu();

        gVideo[0].setMode(SOLID_MODE);

        gVideo[0].colormap[0].set(colourList[colour].get());
        System::paint();

        TimeStep ts;
        TimeTicker ticker = TimeTicker(1);
        int tickIncr;
        int tickCount  = 0;
        do
        {
            tickIncr = ticker.tick( ts.delta() );
            ts.next();
            tickCount += tickIncr;
        } while (tickCount < 3);

        gVideo[0].setMode(BG0);
        gVideo[0].bg0.erase(StripeTile);
    }

}
RGB determineColor(Colormap &colormap, float value) {
    if(utils::almostEqual(value, 0.0, 4)) { // No signal
        RGB color(0.3, 0.3, 0.3); // Light Grey
        return color;
    } else {
        RGB color = colormap.getColorFromTable(static_cast<int>(value+0.5));
        return color;
    }
}
Пример #7
0
 /************************************************************************
    ColormapFldigi
 ************************************************************************/
 void ColormapFldigi::visit(Colormap& map)
 {
     int range = map.getRange();
     map.addColor(0, QColor(0, 0, 0));
     map.addColor((int)((43 / 255.0) * range), QColor(0, 0, 255));
     map.addColor((int)((87 / 255.0) * range), QColor(0, 255, 255));
     map.addColor((int)((120 / 255.0) * range), QColor(0, 255, 0));
     map.addColor((int)((154 / 255.0) * range), QColor(255, 255, 0));
     map.addColor((int)((217 / 255.0) * range), QColor(255, 0, 0));
     map.addColor(range - 1, QColor(255, 0, 128));
 }
Пример #8
0
// Renvoie une colormap personnalisable
Colormap* createColorMap(float min, float max) {
    Colormap *colorMap = new Colormap();
    colorMap->addColor(min,qRgb(255,255,0));
    colorMap->addColor(max,qRgb(255,0,0));
    return colorMap;
}
void GridDisplay::paintEvent(QPaintEvent* /* event */) 
{

	QPainter painter;
	painter.begin(this);
	_cellSize = grid_->getCellSize(_winSize);

	//Find density
	int maxDensity = 0;
	int minDensity = 100;
	for (int i=0; i < grid_->getFiles().size(); i++) {
		if(grid_->getFilesAt(i).size() > maxDensity)
		{
			maxDensity = grid_->getFilesAt(i).size();
		}
		else if (grid_->getFilesAt(i).size() < minDensity) 
		{
			minDensity = grid_->getFilesAt(i).size();
		}
	}
	Colormap *map = Colormap::factory(Colormap::GreyScale);
	for (int i=0; i < grid_->getHeight(); i++) {
		for (int j=0; j < grid_->getWidth(); j++) {

			int k = j * grid_->getHeight() + i;

			QRect	 myr(i*_cellSize,j*_cellSize,_cellSize,_cellSize);
			QLine	 myl1(i*_cellSize,j*_cellSize, i*_cellSize, j*_cellSize + _cellSize);
			QLine	 myl2(i*_cellSize,j*_cellSize, i*_cellSize+_cellSize, j*_cellSize );

			if ( grid_->getFilesAt(k).size() == 0 ) 
			{
				QColor color;
				if(colourMapMode_)
				{
					color.setRgb(map->getRed(0), map->getGreen(0), map->getBlue(0));
				}
				else
				{
					color.setRgb(map->getRed(128), map->getGreen(0), map->getBlue(0));
				}
				painter.setBrush(color);
			}
			else 
			{
				if(colourMapMode_)
				{
					/*
					* index - genre - color
					* 0 - blues - Qt::blue
					* 1 - classical - Qt::darkRed
					* 2 - country - Qt::green
					* 3 - disco - PURPLE
					* 4 - hiphop - Qt::yellow
					* 5 - jazz - Qt::darkGreen
					* 6 - metal - BROWN
					* 7 - reggae - PINK
					* 8 - rock - ORANGE
					* 9 - pop - Qt::grey
					*/
					int * genreDensity = grid_->getDensity(k);
					double *squarePaintSize = new double[10];
					int startHeight = j*_cellSize;

					for(int m = 0; m < 10; m++)
					{
						squarePaintSize[m] = genreDensity[m] /  (1.0 * grid_->getFilesAt(k).size() );
					}

					// 10 is the number of genres
					for(int l = 0; l < 10; l++)
					{
						QColor * color;
						switch(l)
						{
						case 0:
							color = new QColor(Qt::blue);
							break;
						case 1:
							color = new QColor(Qt::darkRed);
							break;
						case 2:
							color = new QColor(Qt::green);
							break;
						case 3:
							color = new QColor(PURPLE);
							break;
						case 4:
							color = new QColor(Qt::yellow);
							break;
						case 5:
							color = new QColor(Qt::darkGreen);
							break;
						case 6:
							color = new QColor(BROWN);
							break;
						case 7:
							color = new QColor(PINK);
							break;
						case 8:
							color = new QColor(ORANGE);
							break;
						case 9:
							color = new QColor(Qt::gray);
							break;
						}
						if(grid_->getFilesAt(k).size() > 0)
						{
							painter.setBrush(*color);
							painter.setPen(Qt::NoPen);
							QRect rect(i*_cellSize, startHeight, _cellSize, squarePaintSize[l] * _cellSize);
							painter.drawRect(rect);
							startHeight += squarePaintSize[l] *  _cellSize;
						}
					}

				}
				else
				{
					int c = int(grid_->getFilesAt(k).size() / float(maxDensity) * (map->getDepth()-1));
					QColor color(map->getRed(c), map->getGreen(c), map->getBlue(c));
					painter.setBrush(color);
				}
			}

			if(colourMapMode_)
			{
				painter.setPen(Qt::white);
				if(grid_->getFilesAt(k).size() == 0)
				painter.drawRect(myr);
			}
			else
			{
				painter.setPen(Qt::NoPen);
				painter.drawRect(myr);
				painter.setPen(Qt::black);
			}
			painter.drawLine(myl1);
			painter.drawLine(myl2);

			painter.setBrush(Qt::red);
			QRect newr( grid_->getXPos() * _cellSize + _cellSize / 4,
				grid_->getYPos() * _cellSize + _cellSize / 4,
				_cellSize - _cellSize / 2,
				_cellSize-_cellSize / 2);
			painter.drawRect(newr);

			painter.setBrush(Qt::white);
			QRect newr1( grid_->getX1Pos() * _cellSize + _cellSize / 4,
				grid_->getY1Pos() * _cellSize + _cellSize / 4,
				_cellSize - _cellSize / 2,
				_cellSize-_cellSize / 2);
			painter.drawRect(newr1);
		}
	}

	// Draw an 'i' in all initilized squares
	for(int i = 0; i < squareHasInitialized.size(); i++)
	{
		if(squareHasInitialized[i])
		{
			int y = i / grid_->getHeight();
			int x = i % grid_->getHeight();
			painter.setBrush(Qt::green);
			QFont *font = new QFont();
			font->setPointSize(16);
			font->setStyleHint(QFont::OldEnglish);
			painter.setFont(*font);
			painter.drawText(x * _cellSize, y * _cellSize, _cellSize, _cellSize, Qt::AlignCenter, "i");
		}
	}

	delete map;
	painter.end();
}
Пример #10
0
main(int argc, char *argv[])
{
	int i;
	int parse_parse();

	Debug::db_read();
	// Pass 1: scan files
	Block::enter();		// Linkage unit
	for (i = 1; i < argc; i++) {
		if (argv[i] == "-") {	// Linkage unit separator
			Block::exit();
			Block::enter();
			continue;
		}
		Block::enter();	// Compilation unit
		Fchar::set_input(argv[i]);
		Fchar::push_input("/dds/src/research/ie/refactor/wdefs.h");
		Fchar::push_input("/dds/src/research/ie/refactor/wincs.h");
		Pdtoken::macros_clear();
		if (parse_parse() != 0)
			exit(1);
		Block::exit();	// Compilation unit
	}
	Block::exit();		// Linkage unit

	// Pass 2: go through the files annotating identifiers
	deque_string color_names;
	// Some nice HTML colors
	color_names.push_back("ff0000");
	color_names.push_back("bf0000");
	color_names.push_back("00af00");
	color_names.push_back("00ef00");
	color_names.push_back("0000ff");
	color_names.push_back("bfbf00");
	color_names.push_back("00ffff");
	color_names.push_back("ff00ff");

	ifstream in;
	Fileid fi;
	Colormap cm;
	deque_string::const_iterator c = color_names.begin();
	cout << "<html><title>Identifier groups</title>\n"
		"<body bgcolor=\"#ffffff\">\n";
	for (i = 1; i < argc; i++) {
		if (argv[i] == "-") {	// Linkage unit separator
			cout << "<p><hr><p>\n";
			continue;
		}
		if (in.is_open())
			in.close();
		in.clear();		// Otherwise flags are dirty and open fails
		in.open(argv[i], ios::binary);
		if (in.fail()) {
			perror(argv[i]);
			exit(1);
		}
		cout << "<h2>" << argv[i] << "</h2>\n";
		fi = Fileid(argv[i]);
		// Go through the file character by character
		for (;;) {
			Tokid ti;
			int val, len;

			ti = Tokid(fi, in.tellg());
			if ((val = in.get()) == EOF)
				break;
			Eclass *ec;
			if ((ec = ti.check_ec()) && ec->get_size() > 1) {
				Colormap::const_iterator ci;
				ci = cm.find(ec);
				if (ci == cm.end()) {
					// Allocate new color
					cm[ec] = (*c);
					c++;
					if (c == color_names.end())
						c = color_names.begin();
					ci = cm.find(ec);
				}
				cout << "<font color=\"#" << (*ci).second << "\">";
				int len = ec->get_len();
				cout << (char)val;
				for (int j = 1; j < len; j++)
					cout << html((char)in.get());
				cout << "</font>";
				continue;
			}
			cout << html((char)val);
		}
	}
	cout << "</body></html>\n";
	return (0);
}