String8 ProgramCache::generateFragmentShader(const Key& needs) {
    Formatter fs;
    if (needs.getTextureTarget() == Key::TEXTURE_EXT) {
        fs << "#extension GL_OES_EGL_image_external : require";
    }

    // default precision is required-ish in fragment shaders
    fs << "precision mediump float;";

    if (needs.getTextureTarget() == Key::TEXTURE_EXT) {
        fs << "uniform samplerExternalOES sampler;"
           << "varying vec2 outTexCoords;";
    } else if (needs.getTextureTarget() == Key::TEXTURE_2D) {
        fs << "uniform sampler2D sampler;"
           << "varying vec2 outTexCoords;";
    } else if (needs.getTextureTarget() == Key::TEXTURE_OFF) {
        fs << "uniform vec4 color;";
    }
    if (needs.hasPlaneAlpha()) {
        fs << "uniform float alphaPlane;";
    }
    if (needs.hasColorMatrix()) {
        fs << "uniform mat4 colorMatrix;";
    }
    fs << "void main(void) {" << indent;
    if (needs.isTexturing()) {
        fs << "gl_FragColor = texture2D(sampler, outTexCoords);";
    } else {
        fs << "gl_FragColor = color;";
    }
    if (needs.isOpaque()) {
        fs << "gl_FragColor.a = 1.0;";
    }
    if (needs.hasPlaneAlpha()) {
        // modulate the alpha value with planeAlpha
        if (needs.isPremultiplied()) {
            // ... and the color too if we're premultiplied
            fs << "gl_FragColor *= alphaPlane;";
        } else {
            fs << "gl_FragColor.a *= alphaPlane;";
        }
    }

    if (needs.hasColorMatrix()) {
        if (!needs.isOpaque() && needs.isPremultiplied()) {
            // un-premultiply if needed before linearization
            fs << "gl_FragColor.rgb = gl_FragColor.rgb/gl_FragColor.a;";
        }
        fs << "gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(2.2));";
        fs << "gl_FragColor     = colorMatrix*gl_FragColor;";
        fs << "gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(1.0 / 2.2));";
        if (!needs.isOpaque() && needs.isPremultiplied()) {
            // and re-premultiply if needed after gamma correction
            fs << "gl_FragColor.rgb = gl_FragColor.rgb*gl_FragColor.a;";
        }
    }

    fs << dedent << "}";
    return fs.getString();
}
/*****************************************************
**
**   PrintoutHelper   ---   writeHouse
**
******************************************************/
void PrintoutHelper::writeHouse( Table *table, const int &row, const int &line, const int& house, const bool &vedic )
{
	double len;
	wxString s;
	Lang lang;
	Formatter *formatter = Formatter::get();

	if ( config->useVedicPlanetNames ) s = lang.getBhavaName( house - 1 );
	else s.Printf( wxT( "%02d" ), house );
	table->setEntry( row, line, s );

	len = h->getHouse( house - 1, vedic );
	if ( config->useVedicPositions )
		table->setEntry( row + 2, line, writer->getPosFormatted( len, false, DEG_PRECISION_SECOND ), false );
	else
	{
		table->setEntry( row + 2, line, formatter->getLenFormatted( getRasiLen( len ), DEG_PRECISION_MINUTE ));
		table->setEntry( row + 3, line, writer->getSignName( getRasi( len )), config->useSignSymbols );
	}
	if ( vedic )
	{
		KpData kp = h->getHouseKPLords( house - 1 );
		table->setEntry( row + 5, line, writer->getObjectName( kp.lord, TSHORT, true ), config->usePlanetSymbols );
		table->setEntry( row + 6, line, writer->getObjectName( kp.sublord, TSHORT, true ), config->usePlanetSymbols );
		table->setEntry( row + 7, line, writer->getObjectName( kp.subsublord, TSHORT, true ), config->usePlanetSymbols );
	}
}
Example #3
0
/*****************************************************
**
**   TextHelper   ---   writeAstronomicalData
**
******************************************************/
int TextHelper::writeAstronomicalData()
{
	wxString pname;
	int p, ret = 0;

	Calculator *calculator = CalculatorFactory().getCalculator();
	Formatter *f = Formatter::get();
	Lang lang;

	vector<int> obs1 = chartprops->getPlanetList();
	vector<int> obs;
	for ( unsigned int i = 0; i < obs1.size(); i++ )
	{
		if ( obs1[i] < MAX_EPHEM_OBJECTS ) obs.push_back( obs1[i] );
	}

	if ( show_header ) writer->writeHeader1( _( "Astronomical Positions" ));
	Table table( 4, obs.size() + 1 );
	table.setHeader( 0,  _( "Planet" ));
	table.setHeader( 1,  _( "Longitude" ));
	table.setHeader( 2,  _( "Latitute" ));
	table.setHeader( 3,  _( "Speed (deg/day)" ));
	table.col_line[0] = true;
	table.col_alignment[0] = Align::Right;
	table.col_alignment[1] = Align::Right;

	int line = 1;
	for ( unsigned int i = 0; i < obs.size(); i++ )
	{
		p = obs[i];
		if ( horoscope->getTropicalLength( p ) == 0 ) ret++;
		pname = writer->getObjectName( p, TLARGE);
		table.setEntry( 0, line, pname );
		table.setEntry( 1, line, writer->getPosFormatted( horoscope->getTropicalLength( p ), horoscope->isRetrograde( p ), DEG_PRECISION_MORE ));

		if ( p != OASCENDANT && p != OMERIDIAN )
		{
			table.setEntry( 2, line, f->getLatitudeFormatted( horoscope->getLatitude( p ), DEG_PRECISION_MORE ));
			table.setEntry( 3, line, f->getLenFormatted( horoscope->getSpeed( p ), DEG_PRECISION_MORE ));
		}
		line++;
	}
	writer->writeTable( table );

	Table t2( 2, 5 );
	t2.setHeader( 0,  _( "Name" ));
	t2.setHeader( 1,  _( "Value" ));
	writer->writeHeader2( _( "Ayanamsa" ));
	line = 1;
	for ( int i = 0; i < NB_AYANAMSAS; i++ )
	{
		t2.setEntry( 0, line, lang.getAyanamsaName( i+1 ));
		t2.setEntry( 1, line, f->getDegreesFormatted( calculator->calcAyanamsa( horoscope->getJD(), i+1 ), DEG_PRECISION_MORE ));
		line++;
	}
	t2.setEntry( 0, 4, _( "Custom" ) );
	t2.setEntry( 1, 4, f->getDegreesFormatted( calculator->calcAyanamsa( horoscope->getJD(), 4 ), DEG_PRECISION_MORE ));
	writer->writeTable( t2 );
	return ret;
}
Example #4
0
  bool EmployeeMenu::search(void)
  {
    ui::HelperForm hfForm;
    std::string employeeCode = hfForm.getSimpleInput("Employee Id");

    if( employeeCode.empty())
      return false;

    EmployeeInfo info;

    try {
      info = bc::HRManager::getInstance()->searchEmployee(employeeCode);
    }catch(GeneralException* ge)
      {
	mvprintw(15, 1, ge->getMessage().c_str());
	mvprintw(20, 3, "Press any key to continue..." );
	getch();
	return false;
      }

    Formatter fm;
    fm.getFormattedOutput(info);


    return false;                //do not quit from the menu
  }
Example #5
0
int
main() {
    const RegisterDictionary *regdict = RegisterDictionary::dictionary_i386();
    SymbolicSemantics::RiscOperatorsPtr ops = SymbolicSemantics::RiscOperators::instance(regdict);
    RegisterStateGenericPtr rstate = RegisterStateGeneric::promote(ops->get_state()->get_register_state());
    SValuePtr x;
    Formatter fmt;
    fmt.set_line_prefix("    ");

    // Write all 32 bits of a register
    std::cout <<"write reg@0+32\n";
    RegisterDescriptor r_0_32(x86_regclass_gpr, 0, 0, 32);
    rstate->writeRegister(r_0_32, ops->undefined_(32), ops.get());
    rstate->print(std::cout, fmt);

    // Write low-order 16 bits of a register
    std::cout <<"\nwrite reg@0+16\n";
    RegisterDescriptor r_0_16(x86_regclass_gpr, 0, 0, 16);
    rstate->writeRegister(r_0_16, ops->undefined_(16), ops.get());
    rstate->print(std::cout, fmt);

    // Read bits 8-31. Bits [8-15] are from one register and [16-31] are from another
    std::cout <<"\nread reg@8+24\n";
    RegisterDescriptor r_8_24(x86_regclass_gpr, 0, 8, 24);
    x = rstate->readRegister(r_8_24, ops.get());
    std::cout <<"  got " <<*x <<"\n";
    rstate->print(std::cout, fmt);
}
QString AttributeHelper::numericMetadataDetails( const DefinitionInfo& info ) const
{
    QStringList details;

    int decimal = info.metadata( "decimal" ).toInt();
    if ( decimal > 0 )
        details.append( tr( "Decimal places: %1" ).arg( decimal ) );

    bool strip = info.metadata( "strip" ).toBool();

    Formatter formatter;

    QVariant minValue = info.metadata( "min-value" );
    if ( minValue.isValid() )
        details.append( tr( "Min. value: %1" ).arg( formatter.convertNumber( minValue.toString(), decimal, strip ) ) );

    QVariant maxValue = info.metadata( "max-value" );
    if ( maxValue.isValid() )
        details.append( tr( "Max. value: %1" ).arg( formatter.convertNumber( maxValue.toString(), decimal, strip ) ) );

    if ( strip )
        details.append( tr( "Strip zeros" ) );

    return details.join( "; " );
}
/*****************************************************
**
**   PrintoutHelper   ---   writeWesternAspectarium
**
******************************************************/
void PrintoutHelper::writeWesternAspectarium( ChartProperties *props, const int &type )
{
	Formatter *formatter = Formatter::get();
	wxString s;

  AspectExpert expert( h );
	list<AspectEvent> al = expert.update( h, props );

	int numrows = (int)al.size() / 3;
	if ( al.size() % 3 ) numrows++;

	Table table( 12, numrows + 1 );
	table.show_grid = false;

	table.setHeader( 0, _( "Aspect" ), false, 2 );
	table.setHeader( 3, _( "Orbis" ) );
	table.col_line[2] = true;
	table.col_line[3] = true;

	table.setHeader( 4, _( "Aspect" ), false, 2 );
	table.setHeader( 7, _( "Orbis" ) );
	table.col_line[6] = true;
	table.col_line[7] = true;

	table.setHeader( 8, _( "Aspect" ), false, 2 );
	table.setHeader( 11, _( "Orbis" ) );
	table.col_line[10] = true;

	int col = 0;
	int row = 0;
	for ( list<AspectEvent>::iterator iter = al.begin(); iter != al.end(); iter++ )
	{
		table.setEntry( 4 * col, row + 1, writer->getObjectName( (*iter).planet1, TMEDIUM ), config->usePlanetSymbols );

		s = AspectExpert::getAspectSymbol( (*iter).aspectType );
    if ( s.IsEmpty())
    {
      s = AspectExpert::getAspectShortDescription( (*iter).aspectType );
			table.setEntry( 4 * col + 1, row + 1, s, false );
    }
		else
		{
			table.setEntry( 4 * col + 1, row + 1, s, true );
		}
		table.setEntry( 4 * col + 2, row + 1, writer->getObjectName( (*iter).planet2, TMEDIUM ), config->usePlanetSymbols );
		table.setEntry( 4 * col + 3, row + 1,  formatter->getLenFormatted( (*iter).orbis, DEG_PRECISION_MINUTE ), false );

		row++;
		if ( row >= numrows )
		{
			col++;
			row = 0;
		}
	}
	writer->writeTable( table, true );
}
Example #8
0
/*****************************************************
**
**   EphemExpert   ---   writeDetails
**
******************************************************/
void EphemExpert::writeDetails( Writer *writer )
{
	int i;
	wxString s, tz_str, thetime;
	Lang lang;
	Formatter *formatter = Formatter::get();
	TzUtil tzu;

	if ( ! cdetails ) calcDetails();

	s.Printf( wxT ( "%s %d" ), (const wxChar*)lang.getMonthName( month-1 ), year );
	writer->writeHeader1( s );

	int line = 1;
	int nb_leaps = 0;
	for ( i = 0; i < nb_days; i++ )
	{
		if ( i > 0 && weekday[i] == 0 ) nb_leaps++;
	}
	Table table( 5, nb_days+1+nb_leaps );
	table.setHeader( 0, _( "Day" ));
	table.setHeader( 1, _( "Sidereal Time" ));
	table.setHeader( 2, _( "Sunrise" ));
	table.setHeader( 3, _( "Sunset" ));
	table.setHeader( 4, _( "Tithi (Sunrise)" ));

	line = 1;
	for ( i = 0; i < nb_days; i++ )
	{
		// blank line on weekend
		if ( i > 0 && weekday[i] == 0 )
		{
			for ( int j = 0; j < 5; j++ ) table.setHeaderEntry( j, line, wxEmptyString );
			line++;
		}

		s.Printf( wxT( "%02d %s" ), i+1, (const wxChar*)lang.getWeekdayName( weekday[i] ).Left(2) );
		if ( testDayIndexForCurrent( i+1 )) table.setHeaderEntry( 0, line, s );
		else	table.setEntry( 0, line, s );

		table.setEntry( 1, line, formatter->getTimeFormatted( st[i] ) );

		TzFormattedDate fd = tzu.getDateFormatted( sunrise[i], isLocaltime );
		thetime = fd.timeFormatted;
		//if ( dstchange ) thetime << wxT( " " ) << fd.timezoneFormatted;
		table.setEntry( 2, line, thetime );

		fd = tzu.getDateFormatted( sunset[i], isLocaltime );
		table.setEntry( 3, line, fd.timeFormatted );

		table.setEntry( 4, line, lang.getTithiName( tithi[i] ));
		line++;
	}
	writer->writeTable( table );
}
Example #9
0
void printDocument(const Formatter& file)
{
	file.printHeader();
	file.printTitle();
	while (!file.Eof())
	{
		file.printParagraph();
	}
	file.printFooter();
	std::cout << std::endl;
}
/*****************************************************
**
**   GenericTableWriter   ---   writeObjectLatitude
**
******************************************************/
void GenericTableWriter::writeObjectLatitude( const uint &i0, const TcColumnSet &set )
{
  table->setHeader( i0,  _( "Declination" ));
	Formatter *f = Formatter::get();
	ObjectPosition pos;
	for ( uint p = 0; p < obs.size(); p++ )
	{
		pos = getObjectPosition( obs[p], set );
		table->setEntry( i0, p + 1, f->getLatitudeFormatted( pos.latitude, DEG_PRECISION_SECOND ));
	}
}
    virtual void operator()(Formatter& output)
    {
        for (sexpr::Node* name_expr = namespace_node->s_expr->first_child; name_expr != 0; name_expr = name_expr->next_sibling)
        {
            output.put_id(name_expr->token);

            if (!is_last(name_expr))
            {
                output.put_str("::");
            }
        }
    }
Example #12
0
/*****************************************************
**
**   DasaImpl   ---   dump
**
******************************************************/
void DasaImpl::dump(wxString &o)
{
    Formatter *f = Formatter::get();
    Writer *writer = WriterFactory().getWriter( WRITER_TEXT );

    if ( expert->isRasiDasaExpert() )
        o << writer->getSignName( lord );
    else
        o <<  writer->getObjectName( lord,TMEDIUM, true );

    o	<< wxT( " " ) << f->getDateStringFromJD( getStartJD() ) << wxT( " - " ) << f->getDateStringFromJD( getEndJD() ) << Endl;
}
Example #13
0
/*****************************************************
**
**   UranianConjunctionEvent   ---   write
**
******************************************************/
wxString UranianConjunctionEvent::write( Writer *writer, const bool show_date ) const
{
	Formatter *formatter = Formatter::get();
	wxString s;

	s << writer->getObjectName( p1 ) 
		<< writer->getUranianAspectSymbol( type )
		<< writer->getObjectName( p2 )
		<< wxT( " " ) << ( ! show_date &&orbis > 0 ? wxT( "-" ) : wxT( " " ));
	if ( show_date ) s << formatter->getDateStringFromJD( jd );
	else s << formatter->getDegreesFormatted( fabs( orbis ));
	return s;
}
/*****************************************************
**
**   DateInputField   ---   formatValue
**
******************************************************/
void DateInputField::formatValue()
{
	Formatter *formatter = Formatter::get();
	if ( Validate())
	{
		value = getDoubleValue();
		SetValue( formatter->getDateStringFromJD( value ));
	}
	else
	{
		SetValue( formatter->getDateStringFromJD( value ));
	}
}
/*****************************************************
**
**   DegMinSecInputField   ---   formatValue
**
******************************************************/
void DegMinSecInputField::formatValue()
{
	Formatter *formatter = Formatter::get();
	if ( Validate())
	{
		value = getDoubleValue();
		SetValue( formatter->getDegreesFormatted( value, format ));
	}
	else
	{
		SetValue( formatter->getDegreesFormatted( value, format ));
	}
}
Example #16
0
QString AttributeHelper::formatExpression( const DefinitionInfo& info, const QString& value ) const
{
    AttributeType type = toAttributeType( info );

    if ( ( type == TextAttribute || type == EnumAttribute || type == UserAttribute ) && value.startsWith( QLatin1String( "[Me]" ) ) )
        return QString( "[%1]" ).arg( tr( "Me" ) );

    if ( type == DateTimeAttribute && value.startsWith( QLatin1String( "[Today]" ) ) )
        return QString( "[%1]%2" ).arg( tr( "Today" ), value.mid( 7 ) );

    Formatter formatter;
    return formatter.convertAttributeValue( info, value, false );
}
Example #17
0
void Serialiser::read( Formatter &formatter )
{
    Array refs = formatter.referencedObjects( refCounter );
    for( Array::iterator ri = refs.begin(); ri != refs.end(); ++ri )
	referencedValues_.insert( std::make_pair(ri->get().index, ri->get()) ); 

    Primitive root;
    refCounter = formatter.decode( string(""), root, refCounter );
    Map &m = boost::get<Map>( root.value );

    for( Map::iterator i = m.begin(); i != m.end(); i++ )
	values_[i->first] = i->second;
}
/*****************************************************
**
**   GenericTableWriter   ---   write45DegreeLongitude
**
******************************************************/
void GenericTableWriter::write45DegreeLongitude( const uint &colid, const TcColumnSet &set )
{
	assert( table->getNbCols() >= colid + 1 );
	assert( table->getNbRows() > obs.size());
	Formatter *formatter = Formatter::get();

	table->setHeader( colid,  _( "45 Degree" ));
	for ( uint p = 0; p < obs.size(); p++ )
	{
		table->setEntry( colid, p + 1, formatter->getLenFormatted( a_red( getObjectPosition( obs[p], set ).longitude, 45.0 )));
		if ( IS_EPHEM_OBJECT( obs[p] ) && h->getTropicalLongitude( obs[p] ) == 0 ) table->errorcount++;
	}
}
Example #19
0
        Document<Formatter>::Document(Formatter& formatter)
    {
        _elements.reserve(32);
        _attributes.reserve(64);
        _firstRootAttribute = ~0u;

            // Parse the input formatter, building a tree
            // of elements and a list of attributes.
            // We can start with several top-level elements
        unsigned lastEle = ~0u;
        unsigned lastAttrib = ~0u;
        for (;;) {
            switch (formatter.PeekNext()) {
            case Formatter::Blob::AttributeName:
                {
                    Formatter::InteriorSection name, value;
                    if (formatter.TryAttribute(name, value)) {
                        _attributes.push_back(AttributeDesc{name, value, ~0u});
                        if (lastAttrib != ~0u) {
                            _attributes[lastAttrib]._nextSibling = unsigned(_attributes.size()-1);
                        } else {
                            _firstRootAttribute = unsigned(_attributes.size()-1);
                        }
                        lastAttrib = unsigned(_attributes.size()-1);
                    }
                }
                continue;

            case Formatter::Blob::BeginElement:
                {
                    auto newEle = ParseElement(formatter);
                    if (newEle == ~0u) break;
                    if (lastEle != ~0u) _elements[lastEle]._nextSibling = newEle;
                    lastEle = newEle;
                }
                continue;

            default:
                break;
            }

            break;
        }
        
        //      Sometimes we serialize in some elements as a "Document"
        //      In these cases, there may be more data in the file...
        // if (formatter.PeekNext() != Formatter::Blob::None)
        //     Throw(FormatException(
        //         "Unexpected trailing characters in StreamDOM", formatter.GetLocation()));
    }
HtmlText IssueDetailsGenerator::changeLinks( const ChangeEntity& change, HtmlText::Flags flags )
{
    HtmlText result( flags );

    if ( change.stampId() != change.id() ) {
        Formatter formatter;
        result.appendText( tr( "Last Edited:" ) );
        result.appendText( QString::fromUtf8( " %1 — %2" ).arg( formatter.formatDateTime( change.modifiedDate(), true ), change.modifiedUser() ) );
        result.appendText( " | " );
    }

    result.createAnchor( QString( "item%1" ).arg( change.id() ) );
    if ( flags.testFlag( HtmlText::NoInternalLinks ) ) {
        if ( change.type() == CommentAdded )
            result.appendText( tr( "Comment #%1" ).arg( change.id() ) );
        else
            result.appendText( tr( "Attachment #%1" ).arg( change.id() ) );
    } else {
        if ( change.type() == CommentAdded )
            result.appendImageAndText( "comment", tr( "Comment #%1" ).arg( change.id() ) );
        else
            result.appendImageAndText( "file-attach", tr( "Attachment #%1" ).arg( change.id() ) );
    }
    result.endAnchor();

    if ( !flags.testFlag( HtmlText::NoInternalLinks ) ) {
        if ( change.type() == CommentAdded ) {
            result.appendText( " | " );
            result.appendImageAndTextLink( "comment-reply", tr( "Reply" ), QString( "command://reply-comment/%1" ).arg( change.id() ) );
        }

        if ( m_isAdmin || change.createdUserId() == dataManager->currentUserId() ) {
            result.appendText( " | " );
            if ( change.type() == CommentAdded )
                result.appendImageAndTextLink( "edit-modify", tr( "Edit" ), QString( "command://edit-comment/%1" ).arg( change.id() ) );
            else
                result.appendImageAndTextLink( "edit-modify", tr( "Edit" ), QString( "command://edit-file/%1" ).arg( change.id() ) );

            result.appendText( " | " );
            if ( change.type() == CommentAdded )
                result.appendImageAndTextLink( "edit-delete", tr( "Delete" ), QString( "command://delete-comment/%1" ).arg( change.id() ) );
            else
                result.appendImageAndTextLink( "edit-delete", tr( "Delete" ), QString( "command://delete-file/%1" ).arg( change.id() ) );
        }
    }

    return result;
}
void IssueDetailsGenerator::writeAttributes( HtmlWriter* writer, const QList<ValueEntity>& values, HtmlText::Flags flags )
{
    QStringList headers;
    QList<HtmlText> items;

    Formatter formatter;

    for ( int i = 0; i < values.count(); i++ ) {
        const ValueEntity& value = values.at( i );
        headers.append( value.name() + tr( ":" ) );
        QString formattedValue = formatter.convertAttributeValue( value.definition(), value.value(), true );
        items.append( HtmlText::parse( HtmlText::convertTabsToSpaces( formattedValue ), flags ) );
    }

    writer->writeInfoList( headers, items, true );
}
Example #22
0
void
SymbolicMemory::print(std::ostream &out, Formatter &formatter_) const {
    SymbolicSemantics::Formatter *formatter = dynamic_cast<SymbolicSemantics::Formatter*>(&formatter_);
    InsnSemanticsExpr::Formatter dflt_expr_formatter;
    InsnSemanticsExpr::Formatter &expr_formatter = formatter ? formatter->expr_formatter : dflt_expr_formatter;
    out <<formatter_.get_line_prefix() <<(*mem_ + expr_formatter) <<"\n";
}
/*****************************************************
**
**   DateInputField   ---   getDoubleValue
**
******************************************************/
double DateInputField::getDoubleValue()
{
	Formatter *formatter = Formatter::get();
	int day, month, year;

	if ( Validate())
	{
		if ( formatter->getDateIntsFromString( (const wxChar*)GetValue(), day, month, year ))
		{
			JDate date;
			date.setDate( day, month, year, 0 );
			return date.getJD();
		}
	}
	return value;
}
/*****************************************************
**
**   DegMinSecInputField   ---   getDoubleValue
**
******************************************************/
double DegMinSecInputField::getDoubleValue()
{
	Formatter *formatter = Formatter::get();
	int deg, min, sec;

	if ( GetValue().IsEmpty()) return 0.0;

	const bool b = formatter->getDegreeIntsFromString( (const wxChar*)GetValue(), deg, min, sec );
	if ( ! b )
	{
		printf( "DegMinSecInputField::getDoubleValue WARN: invalid string %s\n", str2char( GetValue()));
		return value;
	}
	double v = sec + min * 60 + deg * 3600;
	return v / 3600.0;
}
Example #25
0
void ConfigurationChecker::set_banner(Directory & container, Formatter object, const char * type, int id)
{
    Directory * node;
    char buffer[32];

    banner = string("    ") + object.str() + " : ";

    sprintf(buffer, "id = %d", id);

    node = container.findChild(OBJECTTREE, type, NULL)->getFirstChild();
    while(node != 0 && node->toInteger() != id)
        node = node->getNext();

    if( node != 0 ) {
        banner += node->getKey() + " (" + buffer + ") ";

        node = node->findChild("position");
        if(node != 0)
            banner += string("at ") + node->toString();
    }
    else
        banner += buffer;

    if(VerboseMessage::getVerbose())
    {
        cout << banner << endl;
        banner.erase();
    }
}
String8 ProgramCache::generateVertexShader(const Key& needs) {
    Formatter vs;
    if (needs.isTexturing()) {
        vs  << "attribute vec4 texCoords;"
            << "varying vec2 outTexCoords;";
    }
    vs << "attribute vec4 position;"
       << "uniform mat4 projection;"
       << "uniform mat4 texture;"
       << "void main(void) {" << indent
       << "gl_Position = projection * position;";
    if (needs.isTexturing()) {
        vs << "outTexCoords = (texture * texCoords).st;";
    }
    vs << dedent << "}";
    return vs.getString();
}
Example #27
0
	/**************************************************************
	***
	**    MaitreyaTextclient   ---   setLocation
	***
	***************************************************************/
	void setLocation( wxString s )
	{
		const char MINUS = '-';
		Formatter *formatter =  Formatter::get();
		double lon = 0.0, lat = 0.0, tz = 0.0;
		wxString name;
		wxStringTokenizer t( s, wxT( " " ));

		if ( t.HasMoreTokens()) name = t.GetNextToken();
		if ( t.HasMoreTokens())
		{
			wxString slong = t.GetNextToken();
			bool negative = false;
			if ( slong.GetChar( 0 ) == '-' )
			{
				negative = true;
				slong = slong.AfterFirst( MINUS );
			}
			if ( ! formatter->parseDegreeString( slong, lon, 180.0 ))
			{
				fatalError( "cannot parse longitude string " + slong );
			}
			if ( negative ) lon *= -1;
			printf( "long token %s value %f\n", str2char( slong ), lon );
		}
		if ( t.HasMoreTokens())
		{
			wxString slat = t.GetNextToken();
			bool negative = false;
			if ( slat.GetChar( 0 ) == '-' )
			{
				negative = true;
				slat = slat.AfterFirst( MINUS );
			}
			if ( ! formatter->parseDegreeString( slat, lat, 90.0 ))
			{
				fatalError( "cannot parse latitude string " + slat );
			}
			if ( negative ) lat *= -1;
			printf( "lat token %s value %f\n", str2char( slat ), lat );
		}
		if ( t.HasMoreTokens()) tz = myatof( t.GetNextToken());
		dataset.setLocation( name, lon, lat, tz, 0.0 );
		printf( "set Location name %s longitude %f latitude %f tz %f\n", str2char( name ), lon, lat, tz );
	}
HtmlText IssueDetailsGenerator::formatFile( const FileEntity& file, HtmlText::Flags flags )
{
    HtmlText result( flags );

    result.appendLink( file.name(), QString( "attachment://%1" ).arg( file.id() ) );
    result.appendText( " (" );

    Formatter formatter;
    result.appendText( formatter.formatSize( file.size() ) );

    result.appendText( ")" );

    if ( !file.description().isEmpty() ) {
        result.appendText( QString::fromUtf8( " — " ) );
        result.appendParsed( file.description() );
    }

    return result;
}
Example #29
0
    void format_entity(const Formatter& f, const Entity& e,
        const bool empty_out_content = false) {
        const auto fn(f.ownership_hierarchy().formatter_name());
        BOOST_LOG_SEV(lg, debug) << "Formatting: '" << e.name()
                                 << "' with '" << fn << "'";

        const auto ctx(factory_.make(e.id()));
        const auto fp(ctx.formatter_properties());
        const auto i(fp.find(fn));
        if (i == fp.end()) {
            BOOST_LOG_SEV(lg, error) << formatter_properties_not_found << fn;
            BOOST_THROW_EXCEPTION(
                workflow_error(formatter_properties_not_found + fn));
        }

        const auto is_formatter_enabled(i->second.enabled());
        if (!is_formatter_enabled) {
            BOOST_LOG_SEV(lg, debug) << "Formatter not enabled for type.";
            return;
        }

        auto file(f.format(ctx, e));

        if (empty_out_content) {
            BOOST_LOG_SEV(lg, debug) << "Emptying out content.";
            file.content().clear();
        }

        files_.push_front(file);
        if (!file.overwrite()) {
            BOOST_LOG_SEV(lg, debug) << "Filename: "
                                     << file.path().generic_string();
            BOOST_LOG_SEV(lg, debug) << "Content: "
                                     << (file.content().empty() ? "<empty>" :
                                         file.content());
            BOOST_LOG_SEV(lg, debug) << "Finished formatting: '" << e.name()
                                     << "'";
        } else {
            BOOST_LOG_SEV(lg, debug) << "Not dumping file contents to log "
                                     << "(overwrite is false).";
        }
    }
HtmlText IssueDetailsGenerator::descriptionLinks( const DescriptionEntity& description, HtmlText::Flags flags )
{
    HtmlText result( flags );

    Formatter formatter;
    result.appendText( tr( "Last Edited:" ) );
    result.appendText( QString::fromUtf8( " %1 — %2" ).arg( formatter.formatDateTime( description.modifiedDate(), true ), description.modifiedUser() ) );

    if ( !flags.testFlag( HtmlText::NoInternalLinks ) ) {
        result.appendText( " | " );
        result.appendImageAndTextLink( "comment-reply", tr( "Reply" ), "command://reply-description/" );
        if ( m_isOwner || m_isAdmin ) {
            result.appendText( " | " );
            result.appendImageAndTextLink( "edit-modify", tr( "Edit" ), "command://edit-description/" );
            result.appendText( " | " );
            result.appendImageAndTextLink( "edit-delete", tr( "Delete" ), "command://delete-description/" );
        }
    }

    return result;
}