Exemple #1
0
	void ConsoleWidget::addDesignErrorLine(const QString &message, Type type)
	{
		auto item = new QStandardItem();

		addLine(message, item, DesignError, type);
	}
Exemple #2
0
void ChatOutput::addErrorMessage(const QString &message)
{
  addLine(tr("[ERROR] "), message);
}
Scene::Scene( QUndoStack* undoStack ) : QGraphicsScene()
{
  // create timer
  for (double k=0; k<=359; k=k+1)
  {
       // These two lines throw a casting error.
      //
      //
      //
      //sine[k]=qSin(k*PI/180);
      //cosine[k]=qCos(k*PI/180);
      //
      //
      //
      //
      //

  }


  QTimer *timer = new QTimer(this);
  connect(timer, SIGNAL(timeout()), this, SLOT(manageObjects()));
  //connect(timer, SIGNAL(timeout()), this, SLOT(collisionDetection()));
  timer->start(1000/25); // fire the timer 25 times per second

  // initialise variables
  m_undoStack     = undoStack;
  this->setSceneRect(0,0,WINDOW_WIDTH-20, WINDOW_HEIGHT-40);


  // create invisible item to provide default top-left anchor to scene
  addLine( 0, 0, 0, 1, QPen(Qt::transparent, 1) );

  // connect selectionChanged signal to selectStations slot
  connect( this, SIGNAL(selectionChanged()), this, SLOT(selectStations()) );

  // set local variables and check if existing station clicked
  qreal           stationX = .5*WINDOW_WIDTH;
  qreal           stationY = .45*WINDOW_HEIGHT;
  qreal           asteroidX[4] = {0.75*WINDOW_WIDTH,0.65*WINDOW_WIDTH , 0.55*WINDOW_WIDTH, 0.45*WINDOW_WIDTH};
  qreal           asteroidY[4] = {0.75*WINDOW_WIDTH,0.65*WINDOW_WIDTH , 0.55*WINDOW_WIDTH, 0.45*WINDOW_WIDTH};
  qreal           bulletX = 0.25*WINDOW_WIDTH;
  qreal           bulletY = 0.25*WINDOW_HEIGHT;
  qreal           asteroidMoveX = -1;
  qreal           asteroidMoveY = -1;
  qreal           xDest, yDest;






  Station*  station = dynamic_cast<Station*>( itemAt( stationX, stationY ) );
  m_undoStack->push( new CommandStationAdd( this, stationX, stationY ) );
  emit message( QString("Ship add at %1,%2").arg(stationX).arg(stationY) );

  for(int i=0; i<=4; i++){
      Asteroid*  asteroid = dynamic_cast<Asteroid*>( itemAt( asteroidX[i], asteroidY[i]) );
      listOfAsteroids->append(asteroid);
      m_undoStack->push( new CommandAsteroidAdd( this, asteroidX[i], asteroidY[i] ) );
      emit message( QString("Asteroid add at %1,%2").arg(asteroidX[i]).arg(asteroidY[i]) );
  }

  Bullet*  bullet = dynamic_cast<Bullet*>( itemAt( bulletX, bulletY ) );
  m_undoStack->push( new CommandBulletAdd( this, bulletX, bulletY ) );
  emit message( QString("Bullet add at %1,%2").arg(bulletX).arg(bulletY) );







  /*
  asteroid = dynamic_cast<Asteroid*>( itemAt( asteroidX, asteroidY ));
  m_undoStack->push( new CommandAsteroidDelete( this, asteroid ) );

  dynamic_cast<Asteroid*>(itemAt(50,300));
  m_undoStack->push( new CommandAsteroidAdd( this, 50, 300 ) );
  */
}
Exemple #4
0
void
ObjectDumper::visitBool(const vespalib::string &name, bool value)
{
    addLine(make_string("%s: %s", name.c_str(), value? "true" : "false"));
}
	/*
	 * Code39 vectorization, implements Barcode1dBase::vectorize()
	 */
	void BarcodeCode39::vectorize( const std::string& codedData,
	                               const std::string& displayText,
	                               const std::string& cookedData,
	                               double&            w,
	                               double&            h )
	{

		/* determine width and establish horizontal scale, based on original cooked data */
		double dataSize = cookedData.size();
		double minL;
		if ( !checksum() )
		{
			minL = (dataSize + 2)*(3*N + 6)*MIN_X + (dataSize + 1)*MIN_I;
		}
		else
		{
			minL = (dataSize + 3)*(3*N + 6)*MIN_X + (dataSize + 2)*MIN_I;
		}
        
		double scale;
		if ( w == 0 )
		{
			scale = 1.0;
		}
		else
		{
			scale = w / (minL + 2*MIN_QUIET);

			if ( scale < 1.0 )
			{
				scale = 1.0;
			}
		}
		double width = minL * scale;

		/* determine text parameters */
		double hTextArea = scale * MIN_TEXT_AREA_HEIGHT;
		double textSize   = scale * MIN_TEXT_SIZE;

		/* determine height of barcode */
		double height = showText() ? h - hTextArea : h;
		height = std::max( height, std::max( 0.15*width, MIN_HEIGHT ) );

		/* determine horizontal quiet zone */
		double xQuiet = std::max( (10 * scale * MIN_X), MIN_QUIET );

		/* Now traverse the code string and draw each bar */
		double x1 = xQuiet;
		for ( unsigned int i=0; i < codedData.size(); i++ )
		{
			double lwidth;
				
			switch ( codedData[i] )
			{

			case 'i':
				/* Inter-character gap */
				x1 += scale * MIN_I;
				break;

			case 'N':
				/* Narrow bar */
				lwidth = scale*MIN_X;
				addLine( x1, 0.0, lwidth, height );
				x1 += scale * MIN_X;
				break;

			case 'W':
				/* Wide bar */
				lwidth = scale*N*MIN_X;
				addLine( x1, 0.0, lwidth, height );
				x1 += scale * N * MIN_X;
				break;

			case 'n':
				/* Narrow space */
				x1 += scale * MIN_X;
				break;

			case 'w':
				/* Wide space */
				x1 += scale * N * MIN_X;
				break;

			default:
				// NOT REACHED
				break;
			}
		}

		if ( showText() )
		{
			std::string starredText = "*" + displayText + "*";
			addText( xQuiet + width/2, height + (hTextArea+0.7*textSize)/2, textSize, starredText );
		}

		/* Overwrite requested size with actual size. */
		w = width + 2*xQuiet;
		h = showText() ? height + hTextArea : height;

	}
/* MapPreviewCanvas::openMap
 * Opens a map from a mapdesc_t
 *******************************************************************/
bool MapPreviewCanvas::openMap(Archive::mapdesc_t map)
{
	// All errors = invalid map
	Global::error = "Invalid map";

	// Check if this map is a pk3 map
	bool map_archive = false;
	if (map.archive)
	{
		map_archive = true;

		// Attempt to open entry as wad archive
		temp_archive = new WadArchive();
		if (!temp_archive->open(map.head))
		{
			delete temp_archive;
			return false;
		}

		// Detect maps
		vector<Archive::mapdesc_t> maps = temp_archive->detectMaps();

		// Set map if there are any in the archive
		if (maps.size() > 0)
			map = maps[0];
		else
			return false;
	}

	// Parse UDMF map
	if (map.format == MAP_UDMF)
	{
		ArchiveEntry* udmfdata = NULL;
		for (ArchiveEntry* mapentry = map.head; mapentry != map.end; mapentry = mapentry->nextEntry())
		{
			// Check entry type
			if (mapentry->getType() == EntryType::getType("udmf_textmap"))
			{
				udmfdata = mapentry;
				break;
			}
		}
		if (udmfdata == NULL)
			return false;

		// Start parsing
		Tokenizer tz;
		tz.openMem(udmfdata->getData(), udmfdata->getSize(), map.head->getName());

		// Get first token
		string token = tz.getToken();
		size_t vertcounter = 0, linecounter = 0;
		while (!token.IsEmpty())
		{
			if (!token.CmpNoCase("namespace"))
			{
				//  skip till we reach the ';'
				do { token = tz.getToken(); }
				while (token.Cmp(";"));
			}
			else if (!token.CmpNoCase("vertex"))
			{
				// Get X and Y properties
				bool gotx = false;
				bool goty = false;
				double x = 0.;
				double y = 0.;
				do
				{
					token = tz.getToken();
					if (!token.CmpNoCase("x") || !token.CmpNoCase("y"))
					{
						bool isx = !token.CmpNoCase("x");
						token = tz.getToken();
						if (token.Cmp("="))
						{
							wxLogMessage("Bad syntax for vertex %i in UDMF map data", vertcounter);
							return false;
						}
						if (isx) x = tz.getDouble(), gotx = true;
						else y = tz.getDouble(), goty = true;
						// skip to end of declaration after each key
						do { token = tz.getToken(); }
						while (token.Cmp(";"));
					}
				}
				while (token.Cmp("}"));
				if (gotx && goty)
					addVertex(x, y);
				else
				{
					wxLogMessage("Wrong vertex %i in UDMF map data", vertcounter);
					return false;
				}
				vertcounter++;
			}
			else if (!token.CmpNoCase("linedef"))
			{
				bool special = false;
				bool twosided = false;
				bool gotv1 = false, gotv2 = false;
				size_t v1 = 0, v2 = 0;
				do
				{
					token = tz.getToken();
					if (!token.CmpNoCase("v1") || !token.CmpNoCase("v2"))
					{
						bool isv1 = !token.CmpNoCase("v1");
						token = tz.getToken();
						if (token.Cmp("="))
						{
							wxLogMessage("Bad syntax for linedef %i in UDMF map data", linecounter);
							return false;
						}
						if (isv1) v1 = tz.getInteger(), gotv1 = true;
						else v2 = tz.getInteger(), gotv2 = true;
						// skip to end of declaration after each key
						do { token = tz.getToken(); }
						while (token.Cmp(";"));
					}
					else if (!token.CmpNoCase("special"))
					{
						special = true;
						// skip to end of declaration after each key
						do { token = tz.getToken(); }
						while (token.Cmp(";"));
					}
					else if (!token.CmpNoCase("sideback"))
					{
						twosided = true;
						// skip to end of declaration after each key
						do { token = tz.getToken(); }
						while (token.Cmp(";"));
					}
				}
				while (token.Cmp("}"));
				if (gotv1 && gotv2)
					addLine(v1, v2, twosided, special);
				else
				{
					wxLogMessage("Wrong line %i in UDMF map data", linecounter);
					return false;
				}
				linecounter++;
			}
			else
			{
				// map preview ignores things, sidedefs, sectors, comments,
				// unknown fields, etc. so skip to end of block
				do { token = tz.getToken(); }
				while (token.Cmp("}"));
			}
			// Iterate to next token
			token = tz.getToken();
		}
	}

	// Read vertices
	if (map.format == MAP_DOOM || map.format == MAP_HEXEN || map.format == MAP_DOOM64)
	{
		// Find VERTEXES entry
		ArchiveEntry* mapentry = map.head;
		ArchiveEntry* vertexes = NULL;
		while (mapentry)
		{
			// Check entry type
			if (mapentry->getType() == EntryType::getType("map_vertexes"))
			{
				vertexes = mapentry;
				break;
			}

			// Exit loop if we've reached the end of the map entries
			if (mapentry == map.end)
				break;
			else
				mapentry = mapentry->nextEntry();
		}

		// Can't open a map without vertices
		if (!vertexes)
			return false;

		// Read vertex data
		MemChunk& mc = vertexes->getMCData();
		mc.seek(0, SEEK_SET);

		if (map.format == MAP_DOOM64)
		{
			doom64vertex_t v;
			while (1)
			{
				// Read vertex
				if (!mc.read(&v, 8))
					break;

				// Add vertex
				addVertex((double)v.x/65536, (double)v.y/65536);
			}
		}
		else
		{
			doomvertex_t v;
			while (1)
			{
				// Read vertex
				if (!mc.read(&v, 4))
					break;

				// Add vertex
				addVertex((double)v.x, (double)v.y);
			}
		}
	}


	// Read linedefs
	if (map.format == MAP_DOOM || map.format == MAP_HEXEN || map.format == MAP_DOOM64)
	{
		// Find LINEDEFS entry
		ArchiveEntry* mapentry = map.head;
		ArchiveEntry* linedefs = NULL;
		while (mapentry)
		{
			// Check entry type
			if (mapentry->getType() == EntryType::getType("map_linedefs"))
			{
				linedefs = mapentry;
				break;
			}

			// Exit loop if we've reached the end of the map entries
			if (mapentry == map.end)
				break;
			else
				mapentry = mapentry->nextEntry();
		}

		// Can't open a map without linedefs
		if (!linedefs)
			return false;

		// Read line data
		MemChunk& mc = linedefs->getMCData();
		mc.seek(0, SEEK_SET);
		if (map.format == MAP_DOOM)
		{
			while (1)
			{
				// Read line
				doomline_t l;
				if (!mc.read(&l, sizeof(doomline_t)))
					break;

				// Check properties
				bool special = false;
				bool twosided = false;
				if (l.side2 != 0xFFFF)
					twosided = true;
				if (l.type > 0)
					special = true;

				// Add line
				addLine(l.vertex1, l.vertex2, twosided, special);
			}
		}
		else if (map.format == MAP_DOOM64)
		{
			while (1)
			{
				// Read line
				doom64line_t l;
				if (!mc.read(&l, sizeof(doom64line_t)))
					break;

				// Check properties
				bool macro = false;
				bool special = false;
				bool twosided = false;
				if (l.side2  != 0xFFFF)
					twosided = true;
				if (l.type > 0)
				{
					if (l.type & 0x100)
						macro = true;
					else special = true;
				}

				// Add line
				addLine(l.vertex1, l.vertex2, twosided, special, macro);
			}
		}
		else if (map.format == MAP_HEXEN)
		{
			while (1)
			{
				// Read line
				hexenline_t l;
				if (!mc.read(&l, sizeof(hexenline_t)))
					break;

				// Check properties
				bool special = false;
				bool twosided = false;
				if (l.side2 != 0xFFFF)
					twosided = true;
				if (l.type > 0)
					special = true;

				// Add line
				addLine(l.vertex1, l.vertex2, twosided, special);
			}
		}
	}

	// Clean up
	if (map_archive)
	{
		temp_archive->close();
		delete temp_archive;
		temp_archive = NULL;
	}

	// Refresh map
	Refresh();

	return true;
}
Exemple #7
0
void
addWonkyCube(Occluder * pOcc, float x, float y, float z, float w, float h, float d, float s, int full)
{
    if (full == 0) {
        addLine(pOcc, x, y + h, z, x, y, z, x, y, z + .1f);
        addLine(pOcc, x, y, z, x, y + h, z, x + .1f, y, z);

        addLine(pOcc, x, y, z, x, y, z + d, x + .1f, y, z);
        addLine(pOcc, x, y + h, z, x, y + h, z + d, x + .1f, y + h, z);
        addLine(pOcc, x, y, z + d, x, y, z, x, y + .1f, z);
        addLine(pOcc, x, y + h, z + d, x, y + h, z, x, y + h - .1f, z);

        addLine(pOcc, x, y + h, z + d, x, y, z + d, x, y, z + d - .1f);
        addLine(pOcc, x, y, z + d, x, y + h, z + d, x + .1f, y, z + d);
    }
    /* Bottom */
    addLine(pOcc, x + w, y + h, z + s, x, y + h, z, x, y + h, z + .1f);
    addLine(pOcc, x, y, z, x + w, y, z + s, x + w, y, z + s + .1f);

    addLine(pOcc, x, y + h, z, x + w, y + h, z + s, x, y + h - .1f, z);
    addLine(pOcc, x + w, y, z + s, x, y, z, x + w, y + .1f, z + s);

    if (full == 2) {
        /* Sides */
        addLine(pOcc, x + w, y + h, z + s, x + w, y + h, z + s + d, x + w - .1f, y + h, z + s);
        addLine(pOcc, x + w, y, z + s, x + w, y, z + s + d, x + w - .1f, y, z + s);
        addLine(pOcc, x + w, y + h, z + s + d, x + w, y + h, z + s, x + w, y + h - .1f, z + s);
        addLine(pOcc, x + w, y, z + s + d, x + w, y, z + s, x + w, y + .1f, z + s);

        addLine(pOcc, x + w, y, z + s, x + w, y + h, z + s, x + w, y + h, z + s + .1f);
        addLine(pOcc, x + w, y + h, z + s, x + w, y, z + s, x + w - .1f, y + h, z + s);

        addLine(pOcc, x + w, y, z + s + d, x + w, y + h, z + s + d, x + w, y + h, z + s + d - .1f);
        addLine(pOcc, x + w, y + h, z + s + d, x + w, y, z + s + d, x + w - .1f, y + h, z + s + d);
    }
    /* Top */
    addLine(pOcc, x + w, y + h, z + s + d, x, y + h, z + d, x, y + h, z + d - .1f);
    addLine(pOcc, x, y, z + d, x + w, y, z + s + d, x + w, y, z + s + d - .1f);

    addLine(pOcc, x, y + h, z + d, x + w, y + h, z + s + d, x, y + h - .1f, z + d);
    addLine(pOcc, x + w, y, z + s + d, x, y, z + d, x + w, y + .1f, z + s + d);
}
DDisplayscene::DDisplayscene()
{
    setSceneRect(-150,-300,300,600);
    addLine(-100,-400,-100,400);
    //侧边栏显示界面
    button_home2 = new DButton;
    button_home2->setPos(-130,-330 + 0*45);
    button_home2->setHoverEnableFlag(true);
    button_home2->boundImageToPress(pressIcon[13]);
    button_home2->boundImageToRelease(releaseIcon[13]);
    button_home2->boundImageToHover(hoverIcon[13]);
    button_home2->setBounds(-20,-20,40,40);
    //button_home2->connect(button_home2,SIGNAL(fireAction()),this,SLOT(home()));
    addItem(button_home2);


    button_account2 = new DButton;
    button_account2->setPos(-130,-330 + 1*45);
    button_account2->setHoverEnableFlag(true);
    button_account2->boundImageToPress(pressIcon[0]);
    button_account2->boundImageToRelease(releaseIcon[0]);
    button_account2->boundImageToHover(hoverIcon[0]);
    button_account2->setBounds(-20,-20,40,40);
    //button_account2->connect(button_account2,SIGNAL(fireAction()),this,SLOT(account()));
    addItem(button_account2);

    button_display2 = new DButton;
    button_display2->setPos(-130,-330 + 2*45);
    button_display2->setHoverEnableFlag(true);
    button_display2->boundImageToPress(pressIcon[1]);
    button_display2->boundImageToRelease(releaseIcon[1]);
    button_display2->boundImageToHover(hoverIcon[1]);
    button_display2->setBounds(-20,-20,40,40);
    //button_display2->connect(button_display2,SIGNAL(fireAction()),this,SLOT(display()));
    addItem(button_display2);

    button_default2 = new DButton;
    button_default2->setPos(-130,-330 + 3*45);
    button_default2->setHoverEnableFlag(true);
    button_default2->boundImageToPress(pressIcon[2]);
    button_default2->boundImageToRelease(releaseIcon[2]);
    button_default2->boundImageToHover(hoverIcon[2]);
    button_default2->setBounds(-20,-20,40,40);
    //button_default2->connect(button_default2,SIGNAL(fireAction()),this,SLOT(default1()));
    addItem(button_default2);

    button_personalization2 = new DButton;
    button_personalization2->setPos(-130,-330 + 4*45);
    button_personalization2->setHoverEnableFlag(true);
    button_personalization2->boundImageToPress(pressIcon[3]);
    button_personalization2->boundImageToRelease(releaseIcon[3]);
    button_personalization2->boundImageToHover(hoverIcon[3]);
    button_personalization2->setBounds(-20,-20,40,40);
    //button_personalization2->connect(button_personalization2,SIGNAL(fireAction()),this,SLOT(personalization()));
    addItem(button_personalization2);

    button_network2 = new DButton;
    button_network2->setPos(-130,-330 + 5*45);
    button_network2->setHoverEnableFlag(true);
    button_network2->boundImageToPress(pressIcon[4]);
    button_network2->boundImageToRelease(releaseIcon[4]);
    button_network2->boundImageToHover(hoverIcon[4]);
    button_network2->setBounds(-20,-20,40,40);
    //button_network2->connect(button_network2,SIGNAL(fireAction()),this,SLOT(network()));
    addItem(button_network2);

    button_sound2 = new DButton;
    button_sound2->setPos(-130,-330 + 6*45);
    button_sound2->setHoverEnableFlag(true);
    button_sound2->boundImageToPress(pressIcon[5]);
    button_sound2->boundImageToRelease(releaseIcon[5]);
    button_sound2->boundImageToHover(hoverIcon[5]);
    button_sound2->setBounds(-20,-20,40,40);
    //button_sound2->connect(button_sound2,SIGNAL(fireAction()),this,SLOT(sound()));
    addItem(button_sound2);

    button_date2 = new DButton;
    button_date2->setPos(-130,-330 + 7*45);
    button_date2->setHoverEnableFlag(true);
    button_date2->boundImageToPress(pressIcon[6]);
    button_date2->boundImageToRelease(releaseIcon[6]);
    button_date2->boundImageToHover(hoverIcon[6]);
    button_date2->setBounds(-20,-20,40,40);
    //button_date2->connect(button_date2,SIGNAL(fireAction()),this,SLOT(date()));
    addItem(button_date2);

    button_power2 = new DButton;
    button_power2->setPos(-130,-330 + 8*45);
    button_power2->setHoverEnableFlag(true);
    button_power2->boundImageToPress(pressIcon[7]);
    button_power2->boundImageToRelease(releaseIcon[7]);
    button_power2->boundImageToHover(hoverIcon[7]);
    button_power2->setBounds(-20,-20,40,40);
    //button_power2->connect(button_power2,SIGNAL(fireAction()),this,SLOT(power()));
    addItem(button_power2);

    button_mouse2 = new DButton;
    button_mouse2->setPos(-130,-330 + 9*45);
    button_mouse2->setHoverEnableFlag(true);
    button_mouse2->boundImageToPress(pressIcon[8]);
    button_mouse2->boundImageToRelease(releaseIcon[8]);
    button_mouse2->boundImageToHover(hoverIcon[8]);
    button_mouse2->setBounds(-20,-20,40,40);
    //button_mouse2->connect(button_mouse2,SIGNAL(fireAction()),this,SLOT(mouse()));
    addItem(button_mouse2);

    button_keyboard2 = new DButton;
    button_keyboard2->setPos(-130,-330 + 10*45);
    button_keyboard2->setHoverEnableFlag(true);
    button_keyboard2->boundImageToPress(pressIcon[9]);
    button_keyboard2->boundImageToRelease(releaseIcon[9]);
    button_keyboard2->boundImageToHover(hoverIcon[9]);
    button_keyboard2->setBounds(-20,-20,40,40);
    //button_keyboard2->connect(button_keyboard2,SIGNAL(fireAction()),this,SLOT(keyboard()));
    addItem(button_keyboard2);

    button_shortcuts2 = new DButton;
    button_shortcuts2->setPos(-130,-330 + 11*45);
    button_shortcuts2->setHoverEnableFlag(true);
    button_shortcuts2->boundImageToPress(pressIcon[10]);
    button_shortcuts2->boundImageToRelease(releaseIcon[10]);
    button_shortcuts2->boundImageToHover(hoverIcon[10]);
    button_shortcuts2->setBounds(-20,-20,40,40);
    //button_shortcuts2->connect(button_shortcuts2,SIGNAL(fireAction()),this,SLOT(shortcuts()));
    addItem(button_shortcuts2);

    button_menu2 = new DButton;
    button_menu2->setPos(-130,-330 + 12*45);
    button_menu2->setHoverEnableFlag(true);
    button_menu2->boundImageToPress(pressIcon[11]);
    button_menu2->boundImageToRelease(releaseIcon[11]);
    button_menu2->boundImageToHover(hoverIcon[11]);
    button_menu2->setBounds(-20,-20,40,40);
    //button_menu2->connect(button_menu2,SIGNAL(fireAction()),this,SLOT(menu()));
    addItem(button_menu2);

    button_system2 = new DButton;
    button_system2->setPos(-130,-330 + 13*45);
    button_system2->setHoverEnableFlag(true);
    button_system2->boundImageToPress(pressIcon[12]);
    button_system2->boundImageToRelease(releaseIcon[12]);
    button_system2->boundImageToHover(hoverIcon[12]);
    button_system2->setBounds(-20,-20,40,40);
    //button_system2->connect(button_system2,SIGNAL(fireAction()),this,SLOT(system()));
    addItem(button_system2);

    button_pow2 = new DButton;
    button_pow2->setPos(-130,-330 + 14*45);
    button_pow2->setHoverEnableFlag(true);
    button_pow2->boundImageToPress(pressIcon[14]);
    button_pow2->boundImageToRelease(releaseIcon[14]);
    button_pow2->boundImageToHover(hoverIcon[14]);
    button_pow2->setBounds(-20,-20,40,40);
    //button_pow2->connect(button_pow2,SIGNAL(fireAction()),this,SLOT(pow()));
    addItem(button_pow2);

    addLine(-100,-290,200,-290);

    QGraphicsTextItem* display = new QGraphicsTextItem("显示");
    display->setPos(-90,-335);
    display->setDefaultTextColor(QColor(255,255,255));
    QFont font_dis;
    font_dis.setPixelSize(14);
    display->setFont(font_dis);
    addItem(display);

    DRset * displayreset = new DRset;
    displayreset->setPos(100,-320);
    displayreset->setHoverEnableFlag(true);
   // displayreset->boundImageToPress(pressIcon[15]);
    displayreset->boundImageToRelease(pressIcon[15]);
    displayreset->boundImageToHover(pressIcon[15]);
    displayreset->setBounds(-30,-10,55,55);
   // displayreset->connect(displayreset,SIGNAL(fireAction()),this,SLOT(displayreset()));
    addItem(displayreset);

}
bool kpFloodFill::prepare ()
{
#if DEBUG_KP_FLOOD_FILL && 1
    kdDebug () << "kpFloodFill::prepare()" << endl;
#endif
    m_boundingRect = QRect ();

    if (m_initState < 1 && !prepareColorToChange ())
    {
        kdError () << "kpFloodFill:prepare() could not prepareColorToChange()!" << endl;
        return false;
    }

#if DEBUG_KP_FLOOD_FILL && 1
    kdDebug () << "\tperforming NOP check" << endl;
#endif

    // get the color we need to replace
    if (m_processedColorSimilarity == 0 && m_color == m_colorToChange)
    {
        // need to do absolutely nothing (this is a significant optimisation
        // for people who randomly click a lot over already-filled areas)
        m_initState = 2;  // sync with all "return true"'s
        return true;
    }

#if DEBUG_KP_FLOOD_FILL && 1
    kdDebug () << "\tconverting to image" << endl;
#endif

    // is this the only way to read pixels?
    m_image = kpPixmapFX::convertToImage (*m_pixmapPtr);
    if (m_image.isNull ())
    {
        kdError () << "kpFloodFill::prepare() could not convert to QImage" << endl;
        return false;
    }

#if DEBUG_KP_FLOOD_FILL && 1
    kdDebug () << "\tcreating fillLinesCache" << endl;
#endif

    // ready cache
    m_fillLinesCache.resize (m_pixmapPtr->height ());

#if DEBUG_KP_FLOOD_FILL && 1
    kdDebug () << "\tcreating fill lines" << endl;
#endif

    // draw initial line
    addLine (m_y, findMinX (m_y, m_x), findMaxX (m_y, m_x));

    for (QValueList <FillLine>::ConstIterator it = m_fillLines.begin ();
         it != m_fillLines.end ();
         it++)
    {
    #if DEBUG_KP_FLOOD_FILL && 0
        kdDebug () << "Expanding from y=" << (*it).m_y
                   << " x1=" << (*it).m_x1
                   << " x2=" << (*it).m_x2
                   << endl;
    #endif

        // make more lines above and below current line
        findAndAddLines (*it, -1);
        findAndAddLines (*it, +1);
    }

#if DEBUG_KP_FLOOD_FILL && 1
    kdDebug () << "\tfinalising memory usage" << endl;
#endif

    // finalize memory usage
    m_image.reset ();
    m_fillLinesCache.clear ();

    m_initState = 2;  // sync with all "return true"'s
    return true;
}
Exemple #10
0
static void
addLineV(Occluder * pOcc, const float v1[3], const float v2[3], const float v3[3])
{
    addLine(pOcc, v1[0], v1[1], v1[2], v2[0], v2[1], v2[2], v3[0], v3[1], v3[2]);
}
Exemple #11
0
const std::vector<unsigned char> KLUPD::HttpProtocol::HTTPRequestBuilder::generateRequest(const Path &fileName, const Path &relativeUrlPath,
    const bool useProxy, const Address &serverAddress,
    const std::string &userAgent,
    const std::string &proxyAuthorizationHeader,
    const size_t regettingPosition,
    const std::vector<unsigned char> &postData)
{
    m_requestBuffer.clear();

    // 1. "GET ftp://user:[email protected]/path/file.xml HTTP/1.1"
    {
        std::ostringstream stream;
        stream.imbue(std::locale::classic());

        // request type
        stream << (m_method == get ? "GET " : "POST ");

        // request_protocol_prefix, request_host
        if(useProxy)
        {
            stream << toProtocolPrefix(serverAddress.m_protocol).toAscii();
            if((serverAddress.m_protocol == ftpTransport)
                && !serverAddress.m_credentials.empty())
            {
                // user:password@
                stream << serverAddress.m_credentials.userName().toAscii()
                    << ":" << serverAddress.m_credentials.password().toAscii() << "@";
            }
            stream << serverAddress.m_hostname.toAscii();
            if(serverAddress.m_protocol == ftpTransport)
            {
                if(serverAddress.m_service != L"21")
                    stream << ":" << serverAddress.m_service.toAscii();
            }
            else
            {
                if(serverAddress.m_service != L"80")
                    stream << ":" << serverAddress.m_service.toAscii();
            }
        }

        Path remotePath = serverAddress.m_path + relativeUrlPath;
        remotePath.correctPathDelimiters();
        stream << remotePath.toAscii() << fileName.toAscii();

        // HTTP version
        stream << " HTTP/1.0";

        addLine(stream.str());
    }


    // 2. "Host: downloads1.kaspersky-labs.com"
    {
        std::ostringstream stream;
        stream.imbue(std::locale::classic());
        stream << "Host: " << serverAddress.m_hostname.toAscii();
        addLine(stream.str());
    }

    if(m_method == get)
    {
        // 3. "Pragma: no-cache" & "Cache-Control: no-cache"
        addLine("Pragma: no-cache");
        addLine("Cache-Control: no-cache");
    }

    // 4. Keep connection
    if(useProxy)
    {
        addLine("Proxy-Connection: keep-alive");
        addLine("Connection: keep-alive");
    }
    else
        addLine("Connection: keep-alive");

    // 5. User-agent
    if(!userAgent.empty())
    {
        std::ostringstream stream;
        stream.imbue(std::locale::classic());
        stream << "User-Agent: " << userAgent;
        addLine(stream.str());
    }

    // 6. Proxy authorization
    if(useProxy && !proxyAuthorizationHeader.empty())
    {
        std::ostringstream stream;
        stream.imbue(std::locale::classic());
        stream << "Proxy-Authorization: " << proxyAuthorizationHeader;
        addLine(stream.str());
    }

    // 7. Regetting range
    if(regettingPosition)
    {
        std::ostringstream stream;
        stream.imbue(std::locale::classic());
        stream << "Range: bytes=" << regettingPosition << "-";
        addLine(stream.str());
    }

    if(m_method == post)
    {
        // 8. Content Length
        std::ostringstream stream;
        stream.imbue(std::locale::classic());
        stream << "Content-Length: " << postData.size();
        addLine(stream.str());

        // 9. post data
        m_requestBuffer.insert(m_requestBuffer.end(), postData.begin(), postData.end());
    }
    return m_requestBuffer;
}
void RayDisplayScene::lightenSender(int senderId, const int &angle)
{
	clearRayNumbers();
	QVector<QLineF> &senderCollidedRays = clearCollidedRays(senderId);
	clearTriangles();
	QVector<Ray> senderRays;
	senderRays.reserve(10);
	for (int i = 1; i < mSidedReceivers.size(); i++) {
		const int sideIdx = (mSenders.at(senderId).side + i) % mSidedReceivers.size();
		for (int j = 0; j < mSidedReceivers.at(sideIdx).size(); j++) {
			QLineF line(mSenders.at(senderId).r->pos(), mSidedReceivers.at(sideIdx).at(j)->pos());
			int lineAngle = int(line.angle()) - mSenders.at(senderId).rotation;
			if ((lineAngle > -angle / 2 && lineAngle < angle / 2) || (lineAngle - 360 > -angle / 2 && lineAngle - 360 < angle / 2)) {
				QGraphicsTextItem *rayNumber;
				rayNumber = addText(QString::number(senderRays.size()));
				rayNumber->setPos(line.p2());
				rayNumber->setZValue(3);
				mRayNumbers << rayNumber;
				senderRays << Ray{line, true, (j == 0) || (j == mSidedReceivers.at(sideIdx).size() - 1) /* corner ray */};
			}
		}
	}
	for (int i = 0; i < senderRays.size(); i++) {
		QGraphicsLineItem *r = nullptr;
		if (!mCollisionEnabled || mCircles.size() <= 1) {
			r = addLine(senderRays.at(i).line, QPen(QBrush(Qt::blue), 1));
		} else {
			/*const int size = mObstacle.size();
			for (int j = 0; j < size; j++) {
				QLineF obsLine(mObstacle.at(j), mObstacle.at((j + 1) % size));
				if (senderRays.at(i).line.intersect(obsLine, nullptr) == QLineF::BoundedIntersection) {
					senderRays[i].visible = false;
					break;
				}
			}*/
			const int size = mCircles.size();
			for (int j = 0; j < size; j++) {
				if (pointToLineDistSquared(mCircles.at(j).center, senderRays.at(i).line) <= mCircles.at(j).radius * mCircles.at(j).radius) {
					senderRays[i].visible = false;
					break;
				}
			}
			if (senderRays.at(i).visible) {
				r = addLine(senderRays.at(i).line, QPen(QBrush(Qt::blue), 1));
			}
		}
		if (r != nullptr) {
			mRays.append(r);
		}
	}
	// add border rays of another colour
	if (senderRays.size() > 0) {
		QGraphicsLineItem *r = nullptr;
		// first
		{
			r = addLine(senderRays.at(0).line, QPen(QBrush(Qt::yellow), 1));
			mRays.append(r);
		}
		// last
		if (senderRays.size() > 1/* && !senderRays.at(senderRays.size() - 1).visible*/) {
			//senderCollidedRays << senderRays.at(senderRays.size() - 1).line;
			r = addLine(senderRays.at(senderRays.size() - 1).line, QPen(QBrush(Qt::yellow), 1));
			mRays.append(r);
		}
		// on every state change
		for (int i = 1; i < senderRays.size() - 1; i++) {
			if (!senderRays.at(i).visible && (senderRays.at(i - 1).visible || senderRays.at(i + 1).visible)) {
				senderCollidedRays << senderRays.at(i).line;
				r = addLine(senderRays.at(i).line, QPen(QBrush(Qt::red), 1));
				mCollidedRaysGraphics[senderId] << r;
			}
		}
	}

	// ******************************
	// -----8<------8<-------8<------

	//cv::Mat cvImage = cvtrack1(senderId, senderRays);

	//cv::imshow(QString(QString("plepleple ")/* + QString::number(senderId)*/).toStdString(), cvImage);
	/*for (int i = 0; i < mCvPolygons.size(); i++) {
		for (int j = 0; j < mCvPolygons.at(i).size(); j++) {
			cv::fillConvexPoly(cvImage, cvPoints.constData(), cvPoints.size(), cv::Scalar(127));
		}
	}*/

	//cvTrack2(cvImage);

	updateCollisions();
}
Exemple #13
0
void scene::prepareItem(QPoint startpoint)
{
	selecting=true;
	start=startpoint;
	tool=currenttool;

	if(rect!=NULL)
	{
		removeItem(rect);
		rect=NULL;
	}
	if(ellipse!=NULL)
	{
		removeItem(ellipse);
		ellipse=NULL;
	}
	if(line!=NULL)
	{
		removeItem(line);
		line=NULL;
	}
	handles.clear();


	QPen pen;
	pen.setWidth(0);
	pen.setColor(Qt::red);
	QBrush brush;
	switch (tool) {
	case 0:
	{
		rect=addRect(start.x(),start.y(),0,0,pen,brush);
		for(int i=0;i<4;i++)
		{
			QGraphicsRectItem* handle=new QGraphicsRectItem(start.x()-handlew/2,start.y()-handleh/2,handlew,handleh,rect);
			handle->setPen(pen);
			handles<<handle;
		}
		ellipse=addEllipse(rect->rect(),pen,brush);
		break;
	}
	case 1:
	{
		line=addLine(start.x(),start.y(),start.x(),start.y(),pen);
		for(int i=0;i<3;i++)
		{
			QGraphicsRectItem* handle=new QGraphicsRectItem(start.x()-handlew/2,start.y()-handleh/2,handlew,handleh,line);
			handle->setPen(pen);
			handles<<handle;
		}
		break;
	}
	case 2:
	{
		rect=addRect(start.x(),start.y(),0,0,pen,brush);
		for(int i=0;i<4;i++)
		{
			QGraphicsRectItem* handle=new QGraphicsRectItem(start.x()-handlew/2,start.y()-handleh/2,handlew,handleh,rect);
			handle->setPen(pen);
			handles<<handle;
		}
		break;
	}
	case 3:
	{
		rect=addRect(start.x()-handlew/2,start.y()-handleh/2,handlew,handleh,pen,brush);
		QGraphicsRectItem* handle=new QGraphicsRectItem(start.x()-handlew/2,start.y()-handleh/2,handlew,handleh,rect);
		handle->setPen(pen);
		QGraphicsLineItem* line=new QGraphicsLineItem(start.x()-10,start.y(),start.x()+10,start.y(),rect);
		line->setPen(pen);
		line=new QGraphicsLineItem(start.x(),start.y()-10,start.x(),start.y()+10,rect);
		line->setPen(pen);
		handles<<handle;
	}
		break;
	default:
		break;
	}
}
Exemple #14
0
static int
addLine_HelpScreen (const wchar_t *characters) {
  HelpPageEntry *page = getPage();
  if (!page) return 0;
  return addLine(page, characters);
}
Exemple #15
0
void
addCube(Occluder * pOcc, float x, float y, float z, float w, float h, float d)
{
    /* Bottom */
    addLine(pOcc, x, y + h, z, x, y, z, x, y, z + .1f);
    addLine(pOcc, x + w, y + h, z, x, y + h, z, x, y + h, z + .1f);
    addLine(pOcc, x + w, y, z, x + w, y + h, z, x + w, y + h, z + .1f);
    addLine(pOcc, x, y, z, x + w, y, z, x + w, y, z + .1f);

    addLine(pOcc, x, y, z, x, y + h, z, x + .1f, y, z);
    addLine(pOcc, x, y + h, z, x + w, y + h, z, x, y + h - .1f, z);
    addLine(pOcc, x + w, y + h, z, x + w, y, z, x + w - .1f, y + h, z);
    addLine(pOcc, x + w, y, z, x, y, z, x + w, y + .1f, z);

    /* Sides */
    addLine(pOcc, x, y, z, x, y, z + d, x + .1f, y, z);
    addLine(pOcc, x, y + h, z, x, y + h, z + d, x + .1f, y + h, z);
    addLine(pOcc, x + w, y + h, z, x + w, y + h, z + d, x + w - .1f, y + h, z);
    addLine(pOcc, x + w, y, z, x + w, y, z + d, x + w - .1f, y, z);

    addLine(pOcc, x, y, z + d, x, y, z, x, y + .1f, z);
    addLine(pOcc, x, y + h, z + d, x, y + h, z, x, y + h - .1f, z);
    addLine(pOcc, x + w, y + h, z + d, x + w, y + h, z, x + w, y + h - .1f, z);
    addLine(pOcc, x + w, y, z + d, x + w, y, z, x + w, y + .1f, z);

    /* Top */
    addLine(pOcc, x, y + h, z + d, x, y, z + d, x, y, z + d - .1f);
    addLine(pOcc, x + w, y + h, z + d, x, y + h, z + d, x, y + h, z + d - .1f);
    addLine(pOcc, x + w, y, z + d, x + w, y + h, z + d, x + w, y + h, z + d - .1f);
    addLine(pOcc, x, y, z + d, x + w, y, z + d, x + w, y, z + d - .1f);

    addLine(pOcc, x, y, z + d, x, y + h, z + d, x + .1f, y, z + d);
    addLine(pOcc, x, y + h, z + d, x + w, y + h, z + d, x, y + h - .1f, z + d);
    addLine(pOcc, x + w, y + h, z + d, x + w, y, z + d, x + w - .1f, y + h, z + d);
    addLine(pOcc, x + w, y, z + d, x, y, z + d, x + w, y + .1f, z + d);
}
Exemple #16
0
void MainWindow::newLine()
{
    QtCanvasItem *item = addLine();
    canvas->update();
    itemClicked(item);
}
void MyScene::update()
{
  this->clear();

  QPen linePen;
  linePen.setWidth(2);


  QPen linePenOven;
  linePenOven.setColor(Qt::green);
  linePenOven.setWidth(3);

  // Draw oven temperature history
  if (dotListOven.count() > 2) {
    for (int i=1; i<dotListOven.count(); i++) {
      addLine(((QWidget *)this->parent())->width() * dotListOven.at(i).x() / maxTime,
              ((QWidget *)this->parent())->height() * dotListOven.at(i).y(),
              ((QWidget *)this->parent())->width() * dotListOven.at(i-1).x() / maxTime,
              ((QWidget *)this->parent())->height() * dotListOven.at(i-1).y(),
              linePenOven);
    }
  }

  if (dotList.count() >= 1) {
    // Reorder Dots from left to right

    qDebug() << "Printing unordered list";

    for (int i=0; i<dotList.count(); i++) {
      qDebug() << "[" << dotList.at(i).x() << "," << dotList.at(i).y() << "]";
    }

    for (int i=0; i<dotList.count(); i++) {
      for (int j=0; j<dotList.count()-1; j++) {
        if (dotList.at(j).x() > dotList.at(j+1).x()) {
          dotList.insert(j, dotList.takeAt(j+1));
        }
      }
    }

    qDebug() << "Printing ordered list";

    for (int i=0; i<dotList.count(); i++) {
      qDebug() << "[" << dotList.at(i).x() << "," << dotList.at(i).y() << "]";
    }

    // Normalize dots "x" with the maximum one
    double maxX = dotList.last().x();
    double scale = 1 / maxX;

    for (int i=0; i<dotList.count(); i++) {
      Dot d = dotList.takeFirst();
      d.x(d.x() * scale);
      dotList.append(d);
    }

    qDebug() << "Printing normalized list";

    for (int i=0; i<dotList.count(); i++) {
      qDebug() << "[" << dotList.at(i).x() << "," << dotList.at(i).y() << "]";
    }


    QPen dotPen;
    dotPen.setWidth(2);

    // Draw dots
    for (int i=0; i<dotList.count(); i++) {

      if (dotList.at(i).selected())
        dotPen.setColor(Qt::red);
      else
        dotPen.setColor(Qt::darkGreen);

      int posX = ((QWidget *)this->parent())->width() * dotList.at(i).x();
      int posY = ((QWidget *)this->parent())->height() * dotList.at(i).y();
      addEllipse(posX,
                 posY,
                 10,
                 10,
                 dotPen)->setPos(-5,-5);
      QString txt1, txt2;
      txt1.append(QString::number((int)(dotList.at(i).x() * (double)maxTime)));
      txt1.append(" s, ");
      txt2.append(QString::number((int)((1.0 - dotList.at(i).y()) * (double)maxTemp)));
      txt2.append(" 'C");
      addSimpleText(txt1)->setPos(posX - 30,
                                  posY - 32);
      addSimpleText(txt2)->setPos(posX - 30,
                                  posY - 20);
    }

    // Draw lines
    addLine(((QWidget *)this->parent())->width() * 0,
            ((QWidget *)this->parent())->height() * 1,
            ((QWidget *)this->parent())->width() * dotList.at(0).x(),
            ((QWidget *)this->parent())->height() * dotList.at(0).y(),
            linePen);

    for (int i=1; i<dotList.count(); i++) {
      addLine(((QWidget *)this->parent())->width() * dotList.at(i).x(),
              ((QWidget *)this->parent())->height() * dotList.at(i).y(),
              ((QWidget *)this->parent())->width() * dotList.at(i-1).x(),
              ((QWidget *)this->parent())->height() * dotList.at(i-1).y(),
              linePen);
    }
  } else {

    double val1 = 1.0 - (double)currentTemperature / maxTemp;
    int y = ((QWidget *)this->parent())->height() * val1;

    addLine(0,
            y,
            ((QWidget *)this->parent())->width(),
            y,
            linePen);
  }
}
Exemple #18
0
static void  addVertex(int i,int  n)
{int  j; 
   vertmrk[i-1] = n; 
   for (j = 1; j <= vcs_stat.valence[i-1]; j++)  
    if (sklt[i-1][j-1] == 1) addLine(i,j,n);
}
Exemple #19
0
void Text::ensureGeometryUpdate() const
{
    // Do nothing, if geometry has not changed
    if (!m_geometryNeedUpdate)
        return;

    // Mark geometry as updated
    m_geometryNeedUpdate = false;

    // Clear the previous geometry
    m_vertices.clear();
    m_outlineVertices.clear();
    m_bounds = FloatRect();

    // No font or text: nothing to draw
    if (!m_font || m_string.isEmpty())
        return;

    // Compute values related to the text style
    bool  bold               = (m_style & Bold) != 0;
    bool  underlined         = (m_style & Underlined) != 0;
    bool  strikeThrough      = (m_style & StrikeThrough) != 0;
    float italic             = (m_style & Italic) ? 0.208f : 0.f; // 12 degrees
    float underlineOffset    = m_font->getUnderlinePosition(m_characterSize);
    float underlineThickness = m_font->getUnderlineThickness(m_characterSize);

    // Compute the location of the strike through dynamically
    // We use the center point of the lowercase 'x' glyph as the reference
    // We reuse the underline thickness as the thickness of the strike through as well
    FloatRect xBounds = m_font->getGlyph(L'x', m_characterSize, bold).bounds;
    float strikeThroughOffset = xBounds.top + xBounds.height / 2.f;

    // Precompute the variables needed by the algorithm
    float hspace = static_cast<float>(m_font->getGlyph(L' ', m_characterSize, bold).advance);
    float vspace = static_cast<float>(m_font->getLineSpacing(m_characterSize));
    float x      = 0.f;
    float y      = static_cast<float>(m_characterSize);

    // Create one quad for each character
    float minX = static_cast<float>(m_characterSize);
    float minY = static_cast<float>(m_characterSize);
    float maxX = 0.f;
    float maxY = 0.f;
    Uint32 prevChar = 0;
    for (std::size_t i = 0; i < m_string.getSize(); ++i)
    {
        Uint32 curChar = m_string[i];

        // Apply the kerning offset
        x += m_font->getKerning(prevChar, curChar, m_characterSize);
        prevChar = curChar;

        // If we're using the underlined style and there's a new line, draw a line
        if (underlined && (curChar == L'\n'))
        {
            addLine(m_vertices, x, y, m_fillColor, underlineOffset, underlineThickness);

            if (m_outlineThickness != 0)
                addLine(m_outlineVertices, x, y, m_outlineColor, underlineOffset, underlineThickness, m_outlineThickness);
        }

        // If we're using the strike through style and there's a new line, draw a line across all characters
        if (strikeThrough && (curChar == L'\n'))
        {
            addLine(m_vertices, x, y, m_fillColor, strikeThroughOffset, underlineThickness);

            if (m_outlineThickness != 0)
                addLine(m_outlineVertices, x, y, m_outlineColor, strikeThroughOffset, underlineThickness, m_outlineThickness);
        }

        // Handle special characters
        if ((curChar == ' ') || (curChar == '\t') || (curChar == '\n'))
        {
            // Update the current bounds (min coordinates)
            minX = std::min(minX, x);
            minY = std::min(minY, y);

            switch (curChar)
            {
            case ' ':
                x += hspace;
                break;
            case '\t':
                x += hspace * 4;
                break;
            case '\n':
                y += vspace;
                x = 0;
                break;
            }

            // Update the current bounds (max coordinates)
            maxX = std::max(maxX, x);
            maxY = std::max(maxY, y);

            // Next glyph, no need to create a quad for whitespace
            continue;
        }


        // Apply the outline
        if (m_outlineThickness != 0)
        {
            const Glyph& glyph = m_font->getGlyph(curChar, m_characterSize, bold, m_outlineThickness);

            float left   = glyph.bounds.left;
            float top    = glyph.bounds.top;
            float right  = glyph.bounds.left + glyph.bounds.width;
            float bottom = glyph.bounds.top  + glyph.bounds.height;

            // Add the outline glyph to the vertices
            addGlyphQuad(m_outlineVertices, Vector2f(x, y), m_outlineColor, glyph, italic, m_outlineThickness);

            // Update the current bounds with the outlined glyph bounds
            minX = std::min(minX, x + left   - italic * bottom - m_outlineThickness);
            maxX = std::max(maxX, x + right  - italic * top    - m_outlineThickness);
            minY = std::min(minY, y + top    - m_outlineThickness);
            maxY = std::max(maxY, y + bottom - m_outlineThickness);
        }

        // Extract the current glyph's description
        const Glyph& glyph = m_font->getGlyph(curChar, m_characterSize, bold);

        // Add the glyph to the vertices
        addGlyphQuad(m_vertices, Vector2f(x, y), m_fillColor, glyph, italic);

        // Update the current bounds with the non outlined glyph bounds
        if (m_outlineThickness == 0)
        {
            float left   = glyph.bounds.left;
            float top    = glyph.bounds.top;
            float right  = glyph.bounds.left + glyph.bounds.width;
            float bottom = glyph.bounds.top  + glyph.bounds.height;

            minX = std::min(minX, x + left  - italic * bottom);
            maxX = std::max(maxX, x + right - italic * top);
            minY = std::min(minY, y + top);
            maxY = std::max(maxY, y + bottom);
        }

        // Advance to the next character
        x += glyph.advance;
    }

    // If we're using the underlined style, add the last line
    if (underlined && (x > 0))
    {
        addLine(m_vertices, x, y, m_fillColor, underlineOffset, underlineThickness);

        if (m_outlineThickness != 0)
            addLine(m_outlineVertices, x, y, m_outlineColor, underlineOffset, underlineThickness, m_outlineThickness);
    }

    // If we're using the strike through style, add the last line across all characters
    if (strikeThrough && (x > 0))
    {
        addLine(m_vertices, x, y, m_fillColor, strikeThroughOffset, underlineThickness);

        if (m_outlineThickness != 0)
            addLine(m_outlineVertices, x, y, m_outlineColor, strikeThroughOffset, underlineThickness, m_outlineThickness);
    }

    // Update the bounding rectangle
    m_bounds.left = minX;
    m_bounds.top = minY;
    m_bounds.width = maxX - minX;
    m_bounds.height = maxY - minY;
}
// ------------------------------------------------------------------------
void DataContainer::addLine(Line *line)
{
	addLine(line, currentIndex, currentTimeStep, currentSlice);
}
Exemple #21
0
void ChatOutput::addMessage(const QString &src, const QString &message)
{
  addLine(tr("<%1> ").arg(src), message);
}
static void U_CALLCONV
lineFn(void *context,
       char *fields[][2], int32_t fieldCount,
       UErrorCode *pErrorCode) {
    char *names[3];
    int16_t lengths[3];
    static uint32_t prevCode=0;
    uint32_t code=0;

    if(U_FAILURE(*pErrorCode)) {
        return;
    }
    /* get the character code */
    code=uprv_strtoul(fields[0][0], NULL, 16);

    /* get the character name */
    names[0]=fields[1][0];
    lengths[0]=getName(names+0, fields[1][1]);
    if(names[0][0]=='<') {
        /* do not store pseudo-names in <> brackets */
        lengths[0]=0;
    }

    /* store 1.0 names */
    /* get the second character name, the one from Unicode 1.0 */
    /* do not store pseudo-names in <> brackets */
    names[1]=fields[10][0];
    lengths[1]=getName(names+1, fields[10][1]);
    if(*(UBool *)context && names[1][0]!='<') {
        /* keep the name */
    } else {
        lengths[1]=0;
    }

    /* get the ISO 10646 comment */
    names[2]=fields[11][0];
    lengths[2]=getName(names+2, fields[11][1]);

    if(lengths[0]+lengths[1]+lengths[2]==0) {
        return;
    }

    /* check for non-character code points */
    if(!UTF_IS_UNICODE_CHAR(code)) {
        fprintf(stderr, "gennames: error - properties for non-character code point U+%04lx\n",
                (unsigned long)code);
        *pErrorCode=U_PARSE_ERROR;
        exit(U_PARSE_ERROR);
    }

    /* check that the code points (code) are in ascending order */
    if(code<=prevCode && code>0) {
        fprintf(stderr, "gennames: error - UnicodeData entries out of order, U+%04lx after U+%04lx\n",
                (unsigned long)code, (unsigned long)prevCode);
        *pErrorCode=U_PARSE_ERROR;
        exit(U_PARSE_ERROR);
    }
    prevCode=code;

    parseName(names[0], lengths[0]);
    parseName(names[1], lengths[1]);
    parseName(names[2], lengths[2]);

    /*
     * set the count argument to
     * 1: only store regular names
     * 2: store regular and 1.0 names
     * 3: store names and ISO 10646 comment
     */
    addLine(code, names, lengths, 3);
}
Exemple #23
0
void ChatOutput::addPrivateMessage(const QString &src, const QString &message)
{
  addLine(tr("* %1 ").arg(src), message);
}
Exemple #24
0
void
ObjectDumper::closeStruct()
{
    closeScope();
    addLine("}");
}
Exemple #25
0
void ChatOutput::addInfoMessage(const QString &message)
{
  addLine(tr("[INFO] "), message);
}
Exemple #26
0
void
ObjectDumper::visitInt(const vespalib::string &name, int64_t value)
{
    addLine(make_string("%s: %" PRId64 "", name.c_str(), value));
}
void OutputWidget::onDocumentError( QString fileName, QString errorType, int line )
{
    addLine( QColor( Qt::red ), QString( "%1: %2" ).arg( fileName ).arg( errorType ) );
}