示例#1
0
文件: job.cpp 项目: AMDmi3/alacarte
/**
 * @brief Computes a all tiles contained in the MetaIdentifier.
 *
 **/
void Job::process()
{
	shared_ptr<Geodata> geodata = manager->getGeodata();

	FixedRect rect = computeRect(mid);
	STAT_START(Statistic::GeoContainsData);
		empty = !geodata->containsData(rect);
	STAT_STOP(Statistic::GeoContainsData);

	if(empty) {
		STAT_WRITE();
		return;
	}

	cached = initTiles();
	if (cached) {
		STAT_WRITE();
		return;
	}

	STAT_START(Statistic::GeoNodes);
		auto nodeIDs = geodata->getNodeIDs(rect);
	STAT_STOP(Statistic::GeoNodes);

	STAT_START(Statistic::GeoWays);
		auto wayIDs = geodata->getWayIDs(rect);
	STAT_STOP(Statistic::GeoWays);

	STAT_START(Statistic::GeoRelation);
		auto relationIDs = geodata->getRelationIDs(rect);
	STAT_STOP(Statistic::GeoRelation);

	STAT_STATS(nodeIDs->size(), wayIDs->size(), relationIDs->size());

	shared_ptr<Stylesheet> stylesheet = manager->getStylesheetManager()->getStylesheet(mid->getStylesheetPath());
	RenderAttributes renderAttributes;
	STAT_START(Statistic::StylesheetMatch);
		stylesheet->match(nodeIDs, wayIDs, relationIDs, mid, &renderAttributes);
	STAT_STOP(Statistic::StylesheetMatch);

	const shared_ptr<Renderer>& renderer = manager->getRenderer();
	STAT_START(Statistic::Renderer);
		renderer->renderMetaTile(renderAttributes, meta);
	STAT_STOP(Statistic::Renderer);
}
示例#2
0
void DateTimeGrid::drawForeground(QPainter* painter, const QRectF& rect)
{
    painter->save();

    QRectF r = computeRect(QDateTime::currentDateTime(),
                           QDateTime::currentDateTime().addDays(2),
                           rect);

    static QString text("Holiday");
    QFont font = painter->font();
    font.setPixelSize(r.width()/5);

    QFontMetrics fm(font);
    int width = fm.width(text);
    int height = fm.boundingRect(text).height();

    painter->translate(r.center());
    painter->translate(-width/2, height/2);
    painter->setFont(font);
    painter->drawText(0, 0, text);

    painter->restore();
}
示例#3
0
void DateTimeGrid::drawBackground(QPainter* painter, const QRectF& rect)
{
    QLinearGradient grad;
    grad.setCoordinateMode( QGradient::ObjectBoundingMode );
    grad.setStart( 0.5, 0.5 );
    grad.setFinalStop( 0.5, 0.0 );
    grad.setSpread( QGradient::ReflectSpread );
//    grad.setCenter( 0.5, 0.5 );
//    grad.setFocalPoint( 0.5, 0.5 );
//    grad.setRadius( 0.5 );
    QColor currentColor = Qt::blue;
    for ( qreal i = 0; i <= 1.0; i += 0.1 )
    {
        currentColor = currentColor.lighter( 100 + 20 * i );
        grad.setColorAt( i, currentColor );
    }
    QBrush brush( grad);
    //brush.setColor(Qt::lightGray);

    QRectF r = computeRect(QDateTime::currentDateTime(),
                           QDateTime::currentDateTime().addDays(2),
                           rect);
    painter->fillRect(r, brush);
}
示例#4
0
    DisplayConfigPtr DisplayConfigFactory::create(OSVR_ClientContext ctx) {
        DisplayConfigPtr cfg(new DisplayConfig);
        try {
            auto const descriptorString = ctx->getStringParameter("/display");

            auto desc = display_schema_1::DisplayDescriptor(descriptorString);
            cfg->m_viewers.container().emplace_back(Viewer(ctx, HEAD_PATH));
            auto &viewer = cfg->m_viewers.container().front();
            auto eyesDesc = desc.getEyes();

            /// Set up stereo vs mono
            std::vector<uint8_t> eyeIndices;
            Eigen::Vector3d offset;
            if (eyesDesc.size() == 2) {
                // stereo
                offset = desc.getIPDMeters() / 2. * Eigen::Vector3d::UnitX();
                eyeIndices = {0, 1};
            } else {
                // if (eyesDesc.size() == 1)
                // mono
                offset = Eigen::Vector3d::Zero();
                eyeIndices = {0};
            }

            /// Handle radial distortion parameters
            boost::optional<OSVR_RadialDistortionParameters> distort;
            auto k1 = desc.getDistortion();
            if (k1.k1_red != 0 || k1.k1_green != 0 || k1.k1_blue != 0) {
                OSVR_RadialDistortionParameters params;
                params.k1.data[0] = k1.k1_red;
                params.k1.data[1] = k1.k1_green;
                params.k1.data[2] = k1.k1_blue;
                distort = params;
            }

            /// Compute angular offset about Y of the optical (view) axis
            util::Angle axisOffset = 0. * util::radians;
            {
                auto overlapPct = desc.getOverlapPercent();

                if (overlapPct < 1.) {
                    const auto hfov = desc.getHorizontalFOV();
                    const auto angularOverlap = hfov * overlapPct;
                    axisOffset = (hfov - angularOverlap) / 2.;
                }
            }

            /// Infer the number of display inputs and their association with
            /// eyes (actually surfaces) based on the descriptor.
            std::vector<OSVR_DisplayInputCount> displayInputIndices;
            if (eyesDesc.size() == 2 &&
                display_schema_1::DisplayDescriptor::FULL_SCREEN ==
                    desc.getDisplayMode()) {
                // two eyes, full screen - that means two screens.

                displayInputIndices = {0, 1};

                cfg->m_displayInputs.push_back(DisplayInput(
                    desc.getDisplayWidth(), desc.getDisplayHeight()));
                cfg->m_displayInputs.push_back(DisplayInput(
                    desc.getDisplayWidth(), desc.getDisplayHeight()));
            } else {
                // everything else, assume 1 screen.
                // Note that it's OK that displayInputIndices.size() >=
                // eyesDesc.size(), we'll just not end up using the second
                // entry.
                displayInputIndices = {0, 0};

                cfg->m_displayInputs.push_back(DisplayInput(
                    desc.getDisplayWidth(), desc.getDisplayHeight()));
            }
            BOOST_ASSERT_MSG(displayInputIndices.size() >= eyesDesc.size(),
                             "Must have at least as many indices as eyes");

            /// Create the actual eye (with implied surface) objects
            for (auto eye : eyeIndices) {
                // This little computation turns 0 into -1 and 1 into 1, used as
                // a coefficient to make the two eyes do opposite things.
                // Doesn't affect mono, which has a zero offset vector.
                double offsetFactor = (2. * eye) - 1.;

                // Set up per-eye distortion parameters, if needed
                boost::optional<OSVR_RadialDistortionParameters> distortEye(
                    distort);
                if (distortEye) {
                    distortEye->centerOfProjection.data[0] =
                        eyesDesc[eye].m_CenterProjX;
                    distortEye->centerOfProjection.data[1] =
                        eyesDesc[eye].m_CenterProjY;
                }

                // precompute translation offset for this eye
                auto xlateOffset = (offsetFactor * offset).eval();

                // precompute the optical axis rotation for this eye
                // here, the left eye should get a positive offset since it's a
                // positive rotation about y, hence the -1 factor.
                auto eyeAxisOffset = axisOffset * -1. * offsetFactor;

                // Look up the display index for this eye.
                auto displayInputIdx = displayInputIndices[eye];

                /// Create the ViewerEye[Surface] and add it to the container.
                viewer.container().emplace_back(ViewerEye(
                    ctx, xlateOffset, HEAD_PATH, computeViewport(eye, desc),
                    computeRect(desc), eyesDesc[eye].m_rotate180,
                    desc.getPitchTilt().value(), distortEye, displayInputIdx,
                    eyeAxisOffset));
            }

            OSVR_DEV_VERBOSE("Display: " << desc.getHumanReadableDescription());
            return cfg;
        } catch (std::exception const &e) {
            OSVR_DEV_VERBOSE(
                "Couldn't create a display config internally! Exception: "
                << e.what());
            return DisplayConfigPtr{};
        } catch (...) {
            OSVR_DEV_VERBOSE("Couldn't create a display config internally! "
                             "Unknown exception!");
            return DisplayConfigPtr{};
        }
    }