示例#1
0
void FrequencyPowerPlot::StartNewLine(const std::string &lineTitle)
{
	if(_plot == 0)
	{
		_plot = new Plot("frequency-vs-power.pdf");
		_plot->SetXAxisText("Frequency (MHz)");
		_plot->SetYAxisText("Vis. power");
		_plot->SetFontSize(12);
		_plot->SetLogScale(false, _logYAxis);
		_plot->StartLine(lineTitle);
	} else {
		AddCurrentLine(*_plot);
		_values.clear();
		_plot->StartLine(lineTitle);
	}
}
示例#2
0
void FrequencyPowerPlot::MakePlot()
{
	if(_plot == 0)
	{
		Plot plot("frequency-vs-power.pdf");
		plot.SetXAxisText("Frequency (MHz)");
		plot.SetYAxisText("Vis. power");
		plot.SetLogScale(false, _logYAxis);
		plot.StartScatter();
		AddCurrentLine(plot);
		plot.Close();
		plot.Show();
	} else {
		_plot->Close();
		_plot->Show();
	}
}
示例#3
0
void Font::SplitTextToStrings(const WideString & text, const Vector2 & targetRectSize, Vector<WideString> & resultVector)
{
	int32 targetWidth = (int32)(targetRectSize.dx * Core::GetVirtualToPhysicalFactor());

	enum
	{
		SKIP = 0,
		GOODCHAR,	// all characters we like (symbols, special chars, except \n and space
		FINISH,	// process last line
		EXIT,
	};

    // Yuri Coder, 2013/12/10. Replace "\n" occurrences (two chars) to '\n' (one char) is done by Yaml parser,
    // so appropriate code (state NEXTLINE)is removed from here. See please MOBWOT-6499.

    
    SeparatorPositions separator;
    
	resultVector.clear();
	int state = SKIP;
	int totalSize = (int)text.length();
	
	Vector<float32> sizes;
	GetStringSize(text, &sizes);
    if(sizes.size() == 0)
    {
        return;
    }

    bool wasSeparator = false;
	
	for(int pos = 0; state != EXIT; pos++)
	{
		char16 t = 0;
		if(pos < totalSize)
		{
			t = text[pos];
		}
        bool isSeparator = IsWordSeparator(t);

		switch (state) 
		{
			case SKIP:
				if (t == 0){ state = FINISH; break; } // if end of string process FINISH state and exit
				else if (IsSpace(t))break; // if space continue with the same state
                else if(IsLineEnd(t))
				{
					// this block is copied from case NEXTLINE: if(t == 'n')
					// unlike in NEXTLINE where we ignore 2 symbols, here we ignore only one
					// so last position is pos instead of (pos-1)
					if (separator.IsLineInitialized()) // if we already have something in current line we add to result
					{
                        AddCurrentLine(text, pos, separator, resultVector);
					}else
					{
						resultVector.push_back(L""); // here we add empty line if there was no characters in current line
					}
					state = SKIP; //always switch to SKIP because we do not know here what will be next
					break;
				}
				else // everything else is good characters
				{
					state = GOODCHAR;
					separator.lastWordStart = pos;
					separator.lastWordEnd = pos;
					if (!separator.IsLineInitialized()) separator.currentLineStart = pos;
				}
				break;
			case GOODCHAR:
                {
                    
                    if(IsSpace(t) || IsLineEnd(t) || t == 0 || (wasSeparator && !isSeparator)) // if we've found any possible separator process current line
				    {
                    
                        //calculate current line width
					    float32 currentLineWidth = 0;

					    int32 startPos = (separator.IsLineInitialized()) ? separator.currentLineStart : 0;
					    for (int i = startPos; i < pos ; i++)
					    {
						    currentLineWidth += sizes[i];
					    }
                    
                        if((currentLineWidth < targetWidth) || ((IsSpace(t) || isSeparator) && 0 == targetWidth))
                        {   // pos could be the end of line. We need to save it
                            if(IsLineEnd(t) || t == 0)
                            {
                                AddCurrentLine(text, pos, separator, resultVector);
                            }
                            else
                            {
                                separator.currentLineEnd = pos;
                                separator.lastWordEnd = pos;
                            }
                        }
                        else if(currentLineWidth == targetWidth)
                        {   // line fit all available space
                            DVASSERT(pos > separator.currentLineStart);
                        
                            AddCurrentLine(text, pos, separator, resultVector);
                        }
                        else
                        {   //currentLineWidth > targetWidth
                            int32 currentLineLength = separator.currentLineEnd - separator.currentLineStart;
                            if((currentLineLength > 0))
                            {   // use previous position of separator to split text
                            
                                pos = separator.currentLineEnd;
                                AddCurrentLine(text, pos, separator, resultVector);
                                t = 0;
                                if(pos + 1 < totalSize)
		                        {
			                        t = text[pos + 1];
		                        }
                                if(IsSpace(t) || IsLineEnd(t) || t == 0)
                                {
							        state = SKIP;
                                }
                                else
                                {
                                    state = GOODCHAR;
					                separator.lastWordStart = pos;
					                separator.lastWordEnd = pos;
					                if (!separator.IsLineInitialized()) separator.currentLineStart = pos;
                                }
							    break;
                            }
                            else if(pos)
                            {   // truncate text by symbol for very long word
                                if(0 == targetWidth)
                                {
                                    AddCurrentLine(text, pos, separator, resultVector);
                                }
                                else
                                {
								    int32 endPos = (separator.IsLineInitialized()) ? separator.currentLineStart : 0;
                                    for (int i = pos-1; i >= endPos; --i)
                                    {
                                        currentLineWidth -= sizes[i];
                                        if(currentLineWidth <= targetWidth)
                                        {
                                            separator.currentLineEnd = i;
                                            int32 currentLineLength = separator.currentLineEnd - separator.currentLineStart;
                                            if((currentLineLength > 0)) // use previous position of separator to split text
                                            {
                                                pos = separator.currentLineEnd-1;
                                            
                                                AddCurrentLine(text, separator.currentLineEnd, separator, resultVector);
                                            }
                                        
                                            break;
                                        }
                                    
                                        DVASSERT(i);
                                    }
                                }

							    state = SKIP;
							    break;
                            }
                            else
                            {
                                DVASSERT(0);
                            }
                        }
                    }

					if (IsSpace(t) || IsLineEnd(t)) state = SKIP; // if cur char is space go to skip
					else if (t == 0) state = FINISH;
                    else if(wasSeparator && !isSeparator)
                    {
                        // good char after separator
					    separator.lastWordStart = pos;
					    separator.lastWordEnd = pos;
					    if (!separator.IsLineInitialized()) separator.currentLineStart = pos;
                    }
                }
				break;
			case FINISH:
				if (separator.IsLineInitialized()) // we check if we have something left in currentline and add this line to results
				{
                    DVASSERT(separator.currentLineEnd > separator.currentLineStart);
                    AddCurrentLine(text, separator.currentLineEnd, separator, resultVector);
				}
				state = EXIT; // always exit from here
				break;
		};
        wasSeparator = isSeparator;
	};
}