示例#1
0
size_t batch_simplify(
        Structure & structure,
        const std::vector<std::string> & routes,
        const char * source_file,
        const char * destin_file)
{
    POMAGMA_INFO("simplifying expressions");
    POMAGMA_ASSERT(
        std::string(source_file) != std::string(destin_file),
        "source and destin cannot be the same");
    SimplifyParser parser(structure.signature(), routes);

    std::ofstream destin(destin_file);
    POMAGMA_ASSERT(destin, "failed to open " << destin_file);
    destin << "# expressions simplifed by pomagma\n";

    size_t line_count = 0;
    for (LineParser iter(source_file); iter.ok(); iter.next()) {
        const std::string & expression = * iter;
        POMAGMA_DEBUG("simplifying " << expression);

        // simplify relations like EQUAL I APP APP S K K
        parser.begin(expression);
        std::string type = parser.parse_token();
        SimplifyTerm lhs = parser.parse_term();
        SimplifyTerm rhs = parser.parse_term();
        parser.end();
        destin << type << " " << lhs.route << " " << rhs.route << "\n";

        ++line_count;
    }

    return line_count;
}
void qtvplugin_geomarker::cb_paintEvent( QPainter * pImage )
{
	if (!m_pVi || m_bVisible==false)
		return ;
	QRect rect = m_pVi->windowRect();
	// Calc current viewport in world
	double leftcenx, topceny, rightcenx, bottomceny;
	m_pVi->CV_DP2World(0,0,&leftcenx,&topceny);
	m_pVi->CV_DP2World(rect.width()-1,rect.height()-1,&rightcenx,&bottomceny);

	int winsz = 256 * (1<<m_pVi->level());

	QRectF destin(
				0,
				0,
				rect.width(),
				rect.height()
				);
	if (too_many_items()==false)
	{
		//Warpping 180, -180. because longitude +180 and -180 is the same point,
		// but the map is plat, -180 and + 180 is quite different positions, we
		// should draw 3 times, to slove cross 180 drawing problems.
		for (int p = -1; p<=1 ;++p)
		{
			QRectF source(
						leftcenx + p * winsz,
						topceny,
						(rightcenx - leftcenx),
						(bottomceny - topceny)
						);

			m_pScene->render(pImage,destin,source);

		}
	}
	else
	{
		QPen pen(QColor(255,0,0,128));
		pen.setWidth(m_pVi->level()/2+1);
		pImage->setPen(pen);
		QList<QTVP_GEOMARKER::geoItemBase *> items
				= m_pScene->geo_items();
		foreach (QTVP_GEOMARKER::geoItemBase * pitem, items)
		{
			QPointF pt = pitem->center_pos();
			qint32 x,y;
			m_pVi->CV_World2DP(pt.x(),pt.y(),&x,&y);
			pImage->drawPoint(x,y);
		}
	}