当前位置: 首页>>代码示例>>C++>>正文


C++ Selection::getPosition方法代码示例

本文整理汇总了C++中Selection::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Selection::getPosition方法的具体用法?C++ Selection::getPosition怎么用?C++ Selection::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Selection的用法示例。


在下文中一共展示了Selection::getPosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: deform

	void TerrainImpl::deform(const Selection& selection, float intensity)
	{
		for(Selection::const_iterator iter = selection.begin() ; iter != selection.end() ; iter ++)
		{
			if(size_t(iter->first.getX() + selection.getPosition().getX()) >= mInfo->getWidth()
				|| size_t(iter->first.getY() + selection.getPosition().getY()) >= mInfo->getHeight())
				continue;
			float& height = mInfo->at(size_t(iter->first.getX() + selection.getPosition().getX())
				, size_t(iter->first.getY() + selection.getPosition().getY()));
			height += intensity * iter->second;
		}
		updateTiles(selection.getMin().getX(), selection.getMin().getY(), selection.getMax().getX(), selection.getMax().getY());
	}
开发者ID:duzhi5368,项目名称:FKOgreWorldEdit,代码行数:13,代码来源:ETTerrainImpl.cpp

示例2: avgFlatten

	void TerrainImpl::avgFlatten(const Selection& selection, float intensity)
	{
		// add by 王宏张 2007-7-25
		// 计算平均高度
		float avgHeiht = 0.0f;
		for(Selection::const_iterator iter = selection.begin() ; iter != selection.end() ; ++iter)
		{
			if(size_t(iter->first.getX() + selection.getPosition().getX()) >= mInfo->getWidth()
				|| size_t(iter->first.getY() + selection.getPosition().getY()) >= mInfo->getHeight())
				continue;
			float height = mInfo->at(size_t(iter->first.getX() + selection.getPosition().getX())
				, size_t(iter->first.getY() + selection.getPosition().getY()));
			avgHeiht += height;
		}
		avgHeiht /= selection.size();

		for(Selection::const_iterator iter = selection.begin() ; iter != selection.end() ; ++iter)
		{
			if(size_t(iter->first.getX() + selection.getPosition().getX()) >= mInfo->getWidth()
				|| size_t(iter->first.getY() + selection.getPosition().getY()) >= mInfo->getHeight())
				continue;
			float& height = mInfo->at(size_t(iter->first.getX() + selection.getPosition().getX())
				, size_t(iter->first.getY() + selection.getPosition().getY()));
			height = avgHeiht; // avgFlatten算法
		}
		updateTiles(selection.getMin().getX(), selection.getMin().getY(), selection.getMax().getX(), selection.getMax().getY());
	}
开发者ID:duzhi5368,项目名称:FKOgreWorldEdit,代码行数:27,代码来源:ETTerrainImpl.cpp

示例3: if

SelectionPopup::SelectionPopup(const Selection& sel,
                               CelestiaCore* _appCore,
                               QWidget* parent) :
    QMenu(parent),
    selection(sel),
    appCore(_appCore),
    centerAction(NULL),
    gotoAction(NULL)
{
    Simulation* sim = appCore->getSimulation();
    Vec3d v = sel.getPosition(sim->getTime()) - sim->getObserver().getPosition();

    if (sel.body() != NULL)
    {
        addAction(boldTextItem(QString::fromUtf8(sel.body()->getName(true).c_str())));

        // Start and end dates
        double startTime = 0.0;
        double endTime = 0.0;
        sel.body()->getLifespan(startTime, endTime);
        
        if (startTime > -1.0e9 || endTime < 1.0e9)
        {
            addSeparator();

            if (startTime > -1.0e9)
            {
                ostringstream startDateStr;
                startDateStr << "Start: " << astro::TDBtoUTC(startTime);
                QAction* startDateAct = new QAction(startDateStr.str().c_str(), this);
                connect(startDateAct, SIGNAL(triggered()),
                        this, SLOT(slotGotoStartDate()));
                addAction(startDateAct);
            }

            if (endTime < 1.0e9)
            {
                ostringstream endDateStr;
                endDateStr << "End: " << astro::TDBtoUTC(endTime);
                QAction* endDateAct = new QAction(endDateStr.str().c_str(), this);
                connect(endDateAct, SIGNAL(triggered()),
                        this, SLOT(slotGotoEndDate()));
                addAction(endDateAct);
            }
        }

    }
    else if (sel.star() != NULL)
    {
        std::string name = sim->getUniverse()->getStarCatalog()->getStarName(*sel.star());
        addAction(boldTextItem(QString::fromUtf8(ReplaceGreekLetterAbbr(name).c_str())));
        
        // Add some text items giving additional information about
        // the star.
        double distance = v.length() * 1e-6;
        char buff[50];

        setlocale(LC_NUMERIC, "");

        if (abs(distance) >= astro::AUtoLightYears(1000.0f))
            sprintf(buff, "%.3f %s", distance, ("ly"));
        else if (abs(distance) >= astro::kilometersToLightYears(10000000.0))
            sprintf(buff, "%.3f %s", astro::lightYearsToAU(distance), ("au"));
        else if (abs(distance) > astro::kilometersToLightYears(1.0f))
            sprintf(buff, "%.3f km", astro::lightYearsToKilometers(distance));
        else
            sprintf(buff, "%.3f m", astro::lightYearsToKilometers(distance) * 1000.0f);

        addAction(italicTextItem(tr("Distance: ") + QString::fromUtf8(buff)));

        sprintf(buff, "%.2f (%.2f)",
                sel.star()->getAbsoluteMagnitude(),
                astro::absToAppMag(sel.star()->getAbsoluteMagnitude(),
                                   (float) distance));
        addAction(italicTextItem(tr("Abs (app) mag: ") + QString::fromUtf8(buff)));

        sprintf(buff, "%s", sel.star()->getSpectralType());
        addAction(italicTextItem(tr("Class: ") + QString::fromUtf8(buff)));

        setlocale(LC_NUMERIC, "C");
    }
    else if (sel.deepsky() != NULL)
    {
        addAction(boldTextItem(QString::fromUtf8(sim->getUniverse()->getDSOCatalog()->getDSOName(sel.deepsky()).c_str())));
    }

    addSeparator();

    QAction* selectAction = new QAction(tr("&Select"), this);
    connect(selectAction, SIGNAL(triggered()), this, SLOT(slotSelect()));
    addAction(selectAction);

    centerAction = new QAction(tr("&Center"), this);
    connect(centerAction, SIGNAL(triggered()), this, SLOT(slotCenterSelection()));
    addAction(centerAction);

    gotoAction = new QAction(tr("&Goto"), this);
    connect(gotoAction, SIGNAL(triggered()), this, SLOT(slotGotoSelection()));
    addAction(gotoAction);

//.........这里部分代码省略.........
开发者ID:sanyaade-embedded-systems,项目名称:STA,代码行数:101,代码来源:qtselectionpopup.cpp


注:本文中的Selection::getPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。