Ejemplo n.º 1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
CmdFeature* CmdFeatureManager::getCommandFeature(const std::string& commandId)
{
    std::pair<CmdFeature*, size_t> featurePair = createFeature(commandId);

    return featurePair.first;

}
Ejemplo n.º 2
0
	bool createFeature()
	{
		for (int i = 0; i < 1000; ++i)
		{
			if (_exits.empty())
				break;

			// choose a random side of a random room or corridor
			int r = randomInt(_exits.size());
			int x = randomInt(_exits[r].x, _exits[r].x + _exits[r].width - 1);
			int y = randomInt(_exits[r].y, _exits[r].y + _exits[r].height - 1);

			// north, south, west, east
			for (int j = 0; j < DirectionCount; ++j)
			{
				if (createFeature(x, y, static_cast<Direction>(j)))
				{
					_exits.erase(_exits.begin() + r);
					return true;
				}
			}
		}

		return false;
	}
Ejemplo n.º 3
0
//--------------------------------------------------------------------------------------------------
/// Get action for the specified command.
/// The action is owned by the PdmCommandItemManager
//--------------------------------------------------------------------------------------------------
QAction* CmdFeatureManager::action(const QString& commandId)
{
    std::pair<CmdFeature*, size_t> featurePair = createFeature(commandId.toStdString());

    QAction* act = featurePair.first->action();
    m_actionToFeatureIdxMap[act] = featurePair.second;

    return act;
}
Ejemplo n.º 4
0
void HarfBuzzShaper::CapsFeatureSettingsScopedOverlay::overlayCapsFeatures(
    FontDescription::FontVariantCaps variantCaps)
{
    static hb_feature_t smcp = createFeature('s', 'm', 'c', 'p', 1);
    static hb_feature_t pcap = createFeature('p', 'c', 'a', 'p', 1);
    static hb_feature_t c2sc = createFeature('c', '2', 's', 'c', 1);
    static hb_feature_t c2pc = createFeature('c', '2', 'p', 'c', 1);
    static hb_feature_t unic = createFeature('u', 'n', 'i', 'c', 1);
    static hb_feature_t titl = createFeature('t', 'i', 't', 'l', 1);
    if (variantCaps == FontDescription::SmallCaps
        || variantCaps == FontDescription::AllSmallCaps) {
        prependCounting(smcp);
        if (variantCaps == FontDescription::AllSmallCaps) {
            prependCounting(c2sc);
        }
    }
    if (variantCaps == FontDescription::PetiteCaps
        || variantCaps == FontDescription::AllPetiteCaps) {
        prependCounting(pcap);
        if (variantCaps == FontDescription::AllPetiteCaps) {
            prependCounting(c2pc);
        }
    }
    if (variantCaps == FontDescription::Unicase) {
        prependCounting(unic);
    }
    if (variantCaps == FontDescription::TitlingCaps) {
        prependCounting(titl);
    }
}
Ejemplo n.º 5
0
void ScalarEntityDialog::on_pushButton_ok_clicked()
{
    if(ui->spinBox_count->value()>0){
        QString name = ui->lineEdit_name->text();
        QString group = this->ui->comboBox_group->currentText();
        int count = ui->spinBox_count->value();
        Configuration::FeatureTypes featureType = static_cast<Configuration::FeatureTypes>(ui->comboBox_scalarEntityType->itemData(ui->comboBox_scalarEntityType->currentIndex()).toInt());
        bool actual = ui->checkBox_actual->isChecked();
        bool nominal = ui->checkBox_nominal->isChecked();
        bool comPoint = ui->checkBox_commonPoint->isChecked();
        CoordinateSystem *nominalSystem = NULL;
        QString function = this->ui->comboBox_function->currentText();

        if(nominal){
            for(int k=0; k<OiFeatureState::getFeatureCount();k++){
                if(OiFeatureState::getFeatures().at(k)->getCoordinateSystem() != NULL &&
                        ui->comboBox_nominalSystem->currentText() == OiFeatureState::getFeatures().at(k)->getCoordinateSystem()->getFeatureName()){
                    nominalSystem = OiFeatureState::getFeatures().at(k)->getCoordinateSystem();
                }
                if(OiFeatureState::getFeatures().at(k)->getStation() != NULL &&
                        ui->comboBox_nominalSystem->currentText() == OiFeatureState::getFeatures().at(k)->getStation()->getFeatureName()){
                    nominalSystem = OiFeatureState::getFeatures().at(k)->getStation()->coordSys;
                }
            }
        }

        FeatureAttributesExchange featureAttributes;
        featureAttributes.count = count;
        featureAttributes.featureType = featureType;
        featureAttributes.name = name;
        featureAttributes.group = group;
        featureAttributes.function = function;
        featureAttributes.actual = actual;
        featureAttributes.nominal = nominal;
        featureAttributes.common = comPoint;
        featureAttributes.nominalSystem = nominalSystem;

        emit createFeature(featureAttributes);

        this->close();
    }
}
Ejemplo n.º 6
0
	void generate(int maxFeatures)
	{
		// place the first room in the center
		if (!makeRoom(_width / 2, _height / 2, static_cast<Direction>(randomInt(4), true)))
		{
			std::cout << "Unable to place the first room.\n";
			return;
		}

		// we already placed 1 feature (the first room)
		for (int i = 1; i < maxFeatures; ++i)
		{
			if (!createFeature())
			{
				std::cout << "Unable to place more features (placed " << i << ").\n";
				break;
			}
		}

		if (!placeObject(UpStairs))
		{
			std::cout << "Unable to place up stairs.\n";
			return;
		}

		if (!placeObject(DownStairs))
		{
			std::cout << "Unable to place down stairs.\n";
			return;
		}

		for (char& tile : _tiles)
		{
			if (tile == Unused)
				tile = ' ';
			else if (tile == Floor || tile == Corridor)
				tile = ' ';
		}
	}
Ejemplo n.º 7
0
void HarfBuzzShaper::setFontFeatures()
{
    const FontDescription& description = m_font->getFontDescription();

    static hb_feature_t noKern = createFeature('k', 'e', 'r', 'n');
    static hb_feature_t noVkrn = createFeature('v', 'k', 'r', 'n');
    switch (description.getKerning()) {
    case FontDescription::NormalKerning:
        // kern/vkrn are enabled by default
        break;
    case FontDescription::NoneKerning:
        m_features.append(description.isVerticalAnyUpright() ? noVkrn : noKern);
        break;
    case FontDescription::AutoKerning:
        break;
    }

    static hb_feature_t noClig = createFeature('c', 'l', 'i', 'g');
    static hb_feature_t noLiga = createFeature('l', 'i', 'g', 'a');
    switch (description.commonLigaturesState()) {
    case FontDescription::DisabledLigaturesState:
        m_features.append(noLiga);
        m_features.append(noClig);
        break;
    case FontDescription::EnabledLigaturesState:
        // liga and clig are on by default
        break;
    case FontDescription::NormalLigaturesState:
        break;
    }
    static hb_feature_t dlig = createFeature('d', 'l', 'i', 'g', 1);
    switch (description.discretionaryLigaturesState()) {
    case FontDescription::DisabledLigaturesState:
        // dlig is off by default
        break;
    case FontDescription::EnabledLigaturesState:
        m_features.append(dlig);
        break;
    case FontDescription::NormalLigaturesState:
        break;
    }
    static hb_feature_t hlig = createFeature('h', 'l', 'i', 'g', 1);
    switch (description.historicalLigaturesState()) {
    case FontDescription::DisabledLigaturesState:
        // hlig is off by default
        break;
    case FontDescription::EnabledLigaturesState:
        m_features.append(hlig);
        break;
    case FontDescription::NormalLigaturesState:
        break;
    }
    static hb_feature_t noCalt = createFeature('c', 'a', 'l', 't');
    switch (description.contextualLigaturesState()) {
    case FontDescription::DisabledLigaturesState:
        m_features.append(noCalt);
        break;
    case FontDescription::EnabledLigaturesState:
        // calt is on by default
        break;
    case FontDescription::NormalLigaturesState:
        break;
    }

    static hb_feature_t hwid = createFeature('h', 'w', 'i', 'd', 1);
    static hb_feature_t twid = createFeature('t', 'w', 'i', 'd', 1);
    static hb_feature_t qwid = createFeature('q', 'w', 'i', 'd', 1);
    switch (description.widthVariant()) {
    case HalfWidth:
        m_features.append(hwid);
        break;
    case ThirdWidth:
        m_features.append(twid);
        break;
    case QuarterWidth:
        m_features.append(qwid);
        break;
    case RegularWidth:
        break;
    }

    // font-variant-numeric:
    static hb_feature_t lnum = createFeature('l', 'n', 'u', 'm', 1);
    if (description.variantNumeric().numericFigureValue() == FontVariantNumeric::LiningNums)
        m_features.append(lnum);

    static hb_feature_t onum = createFeature('o', 'n', 'u', 'm', 1);
    if (description.variantNumeric().numericFigureValue() == FontVariantNumeric::OldstyleNums)
        m_features.append(onum);

    static hb_feature_t pnum = createFeature('p', 'n', 'u', 'm', 1);
    if (description.variantNumeric().numericSpacingValue() == FontVariantNumeric::ProportionalNums)
        m_features.append(pnum);
    static hb_feature_t tnum = createFeature('t', 'n', 'u', 'm', 1);
    if (description.variantNumeric().numericSpacingValue() == FontVariantNumeric::TabularNums)
        m_features.append(tnum);

    static hb_feature_t afrc = createFeature('a', 'f', 'r', 'c', 1);
    if (description.variantNumeric().numericFractionValue() == FontVariantNumeric::StackedFractions)
        m_features.append(afrc);
    static hb_feature_t frac = createFeature('f', 'r', 'a', 'c', 1);
    if (description.variantNumeric().numericFractionValue() == FontVariantNumeric::DiagonalFractions)
        m_features.append(frac);

    static hb_feature_t ordn = createFeature('o', 'r', 'd', 'n', 1);
    if (description.variantNumeric().ordinalValue() == FontVariantNumeric::OrdinalOn)
        m_features.append(ordn);

    static hb_feature_t zero = createFeature('z', 'e', 'r', 'o', 1);
    if (description.variantNumeric().slashedZeroValue() == FontVariantNumeric::SlashedZeroOn)
        m_features.append(zero);


    FontFeatureSettings* settings = description.featureSettings();
    if (!settings)
        return;

    // TODO(drott): crbug.com/450619 Implement feature resolution instead of
    // just appending the font-feature-settings.
    unsigned numFeatures = settings->size();
    for (unsigned i = 0; i < numFeatures; ++i) {
        hb_feature_t feature;
        const AtomicString& tag = settings->at(i).tag();
        feature.tag = HB_TAG(tag[0], tag[1], tag[2], tag[3]);
        feature.value = settings->at(i).value();
        feature.start = 0;
        feature.end = static_cast<unsigned>(-1);
        m_features.append(feature);
    }
}
Ejemplo n.º 8
0
/* Create a feature on the map */
FEATURE * buildFeature(FEATURE_STATS *psStats, UDWORD x, UDWORD y,BOOL FromSave)
{
	UDWORD		mapX, mapY;
	UDWORD		width,breadth, foundationMin,foundationMax, height;
	UDWORD		startX,startY,max,min;
	SDWORD		i;
	UBYTE		vis;
	//try and create the Feature
	FEATURE* psFeature = createFeature();

	if (psFeature == NULL)
	{
		debug(LOG_WARNING, "Feature couldn't be built.");
		return NULL;
	}
	psFeature->psStats = psStats;
	// features are not in the cluster system
	// this will cause an assert when they still end up there
	psFeature->cluster = ~0;
	//add the feature to the list - this enables it to be drawn whilst being built
	addFeature(psFeature);

	// get the terrain average height
	startX = map_coord(x);
	startY = map_coord(y);
	foundationMin = TILE_MAX_HEIGHT;
	foundationMax = TILE_MIN_HEIGHT;
	for (breadth = 0; breadth < psStats->baseBreadth; breadth++)
	{
		for (width = 0; width < psStats->baseWidth; width++)
		{
			getTileMaxMin(startX + width, startY + breadth, &max, &min);
			if (foundationMin > min)
			{
				foundationMin = min;
			}
			if (foundationMax < max)
			{
				foundationMax = max;
			}
		}
	}
	//return the average of max/min height
	height = (foundationMin + foundationMax) / 2;

	// snap the coords to a tile
	if (!FromSave)
	{
		x = (x & ~TILE_MASK) + psStats->baseWidth  %2 * TILE_UNITS/2;
		y = (y & ~TILE_MASK) + psStats->baseBreadth%2 * TILE_UNITS/2;
	}
	else
	{
		if ((x & TILE_MASK) != psStats->baseWidth  %2 * TILE_UNITS/2 ||
		    (y & TILE_MASK) != psStats->baseBreadth%2 * TILE_UNITS/2)
		{
			debug(LOG_WARNING, "Feature not aligned. position (%d,%d), size (%d,%d)", x, y, psStats->baseWidth, psStats->baseBreadth);
		}
	}

	psFeature->pos.x = x;
	psFeature->pos.y = y;

	/* Dump down the building wrecks at random angles - still looks shit though */
	if(psStats->subType == FEAT_BUILD_WRECK || psStats->subType == FEAT_TREE)
	{
		psFeature->rot.direction = gameRand(DEG_360);
	}
	else
	{
		psFeature->rot.direction = 0;
	}
	psFeature->selected = false;
	psFeature->body = psStats->body;
	psFeature->player = MAX_PLAYERS+1;	//set the player out of range to avoid targeting confusions
	objSensorCache((BASE_OBJECT *)psFeature, NULL);
	objEcmCache((BASE_OBJECT *)psFeature, NULL);
	psFeature->bTargetted = false;
	psFeature->timeLastHit = 0;
	psFeature->lastHitWeapon = WSC_NUM_WEAPON_SUBCLASSES;  // no such weapon

	// it has never been drawn
	psFeature->sDisplay.frameNumber = 0;

	if(getRevealStatus())
	{
		vis = 0;
	}
	else
	{
		if(psStats->visibleAtStart)
		{
  			vis = UBYTE_MAX;
		}
		else
		{
			vis = 0;
		}
	}

	// note that the advanced armour system current unused for features
	for (i = 0; i < NUM_HIT_SIDES; i++)
	{
		int j;

		for (j = 0; j < WC_NUM_WEAPON_CLASSES; j++)
		{
			psFeature->armour[i][j] = psFeature->psStats->armourValue;
		}
	}

	memset(psFeature->seenThisTick, 0, sizeof(psFeature->seenThisTick));
	memset(psFeature->visible, 0, sizeof(psFeature->visible));

	//load into the map data
	mapX = map_coord(x) - psStats->baseWidth/2;
	mapY = map_coord(y) - psStats->baseBreadth/2;

	// set up the imd for the feature
	if(psFeature->psStats->subType==FEAT_BUILD_WRECK)
	{
		psFeature->sDisplay.imd = getRandomWreckageImd();
	}
	else
	{
		psFeature->sDisplay.imd = psStats->psImd;
  	}

	ASSERT_OR_RETURN(NULL, psFeature->sDisplay.imd, "No IMD for feature");		// make sure we have an imd.

	for (width = 0; width < psStats->baseWidth; width++)
	{
		for (breadth = 0; breadth < psStats->baseBreadth; breadth++)
		{
			MAPTILE *psTile = mapTile(mapX + width, mapY + breadth);

			//check not outside of map - for load save game
			ASSERT_OR_RETURN(NULL, mapX + width < mapWidth, "x coord bigger than map width - %s, id = %d", getName(psFeature->psStats->pName), psFeature->id);
			ASSERT_OR_RETURN(NULL, mapY + breadth < mapHeight, "y coord bigger than map height - %s, id = %d", getName(psFeature->psStats->pName), psFeature->id);

			if (width != psStats->baseWidth && breadth != psStats->baseBreadth)
			{
				if (TileHasFeature(psTile))
				{
					FEATURE *psBlock = (FEATURE *)psTile->psObject;

					debug(LOG_ERROR, "%s(%d) already placed at (%d+%d, %d+%d) when trying to place %s(%d) at (%d+%d, %d+%d) - removing it",
					      getName(psBlock->psStats->pName), psBlock->id, map_coord(psBlock->pos.x), psBlock->psStats->baseWidth, map_coord(psBlock->pos.y),
					      psBlock->psStats->baseBreadth, getName(psFeature->psStats->pName), psFeature->id, mapX, psStats->baseWidth, mapY, psStats->baseBreadth);

					removeFeature(psBlock);
				}

				psTile->psObject = (BASE_OBJECT*)psFeature;

				// if it's a tall feature then flag it in the map.
				if (psFeature->sDisplay.imd->max.y > TALLOBJECT_YMAX)
				{
					auxSetBlocking(mapX + width, mapY + breadth, AIR_BLOCKED);
				}

				if (psStats->subType != FEAT_GEN_ARTE && psStats->subType != FEAT_OIL_DRUM && psStats->subType != FEAT_BUILD_WRECK)
				{
					auxSetBlocking(mapX + width, mapY + breadth, FEATURE_BLOCKED);
				}
			}

			if( (!psStats->tileDraw) && (FromSave == false) )
			{
				psTile->height = height;
			}
		}
	}
	psFeature->pos.z = map_TileHeight(mapX,mapY);//jps 18july97

//	// set up the imd for the feature
//	if(psFeature->psStats->subType==FEAT_BUILD_WRECK)
//	{
//		psFeature->sDisplay.imd = wreckageImds[rand()%MAX_WRECKAGE];
//	}
//	else
//	{
//		psFeature->sDisplay.imd = psStats->psImd;
// 	}

	return psFeature;
}
Ejemplo n.º 9
0
/*!
 * \brief create feature.
 * Saves the values set up in the GUI and emits them to the create feature function in the controller, that crates the feature,
 * adds it to the features list and displays it in the table model.
 */
void CreateFeature::on_toolButton_create_clicked()
{
    if(ui->spinBox_count->value()>0){

        int count = ui->spinBox_count->value();
        int featureType = this->typeOfFeature;
        QString name = ui->lineEdit_name->text();
        bool isActual = ui->checkBox_actualNominal->isChecked();
        bool isCommon = ui->checkBox_common->isChecked();
        CoordinateSystem *nominalSystem = NULL;

        if(name == ""){
            return;
        }

        if (typeOfFeature != Configuration::eTrafoParamFeature){

            if(isActual){

                for(int k=0; k<this->featureList.size();k++){
                    if(this->featureList.at(k)->getCoordinateSystem() != NULL &&
                            ui->comboBox_nominalSystem->currentText() == this->featureList.at(k)->getCoordinateSystem()->name){
                        nominalSystem = this->featureList.at(k)->getCoordinateSystem();
                    }
                }
            }
        emit createFeature(count,featureType,name,isActual,isCommon,nominalSystem);



        }else{
            CoordinateSystem *from;
            CoordinateSystem *to;
            if(ui->comboBox_destinationSystem->currentText() != ui->comboBox_startSystem->currentText()){

                for(int i=0;i<this->featureList.size();i++){
                    if(featureList.at(i)->getCoordinateSystem() != NULL &&
                            ui->comboBox_destinationSystem->currentText() == featureList.at(i)->getCoordinateSystem()->name){
                        to = featureList.at(i)->getCoordinateSystem();
                    }
                    if(featureList.at(i)->getStation() != NULL &&
                            ui->comboBox_destinationSystem->currentText() == featureList.at(i)->getStation()->name){
                        to = featureList.at(i)->getStation()->coordSys;
                    }
                    if(featureList.at(i)->getCoordinateSystem() != NULL &&
                            ui->comboBox_startSystem->currentText() == featureList.at(i)->getCoordinateSystem()->name){
                        from = featureList.at(i)->getCoordinateSystem();
                    }
                    if(featureList.at(i)->getStation() != NULL &&
                            ui->comboBox_startSystem->currentText() == featureList.at(i)->getStation()->name){
                        from = featureList.at(i)->getStation()->coordSys;
                    }
                }

                emit createTrafoParam(count,featureType,name,from,to);
            }else{
                return;
            }
        }

        this->close();
    }

}
void HarfBuzzShaper::setFontFeatures()
{
    const FontDescription& description = m_font->getFontDescription();

    static hb_feature_t noKern = createFeature('k', 'e', 'r', 'n');
    static hb_feature_t noVkrn = createFeature('v', 'k', 'r', 'n');
    switch (description.getKerning()) {
    case FontDescription::NormalKerning:
        // kern/vkrn are enabled by default
        break;
    case FontDescription::NoneKerning:
        m_features.append(description.isVerticalAnyUpright() ? noVkrn : noKern);
        break;
    case FontDescription::AutoKerning:
        break;
    }

    static hb_feature_t noClig = createFeature('c', 'l', 'i', 'g');
    static hb_feature_t noLiga = createFeature('l', 'i', 'g', 'a');
    switch (description.commonLigaturesState()) {
    case FontDescription::DisabledLigaturesState:
        m_features.append(noLiga);
        m_features.append(noClig);
        break;
    case FontDescription::EnabledLigaturesState:
        // liga and clig are on by default
        break;
    case FontDescription::NormalLigaturesState:
        break;
    }
    static hb_feature_t dlig = createFeature('d', 'l', 'i', 'g', 1);
    switch (description.discretionaryLigaturesState()) {
    case FontDescription::DisabledLigaturesState:
        // dlig is off by default
        break;
    case FontDescription::EnabledLigaturesState:
        m_features.append(dlig);
        break;
    case FontDescription::NormalLigaturesState:
        break;
    }
    static hb_feature_t hlig = createFeature('h', 'l', 'i', 'g', 1);
    switch (description.historicalLigaturesState()) {
    case FontDescription::DisabledLigaturesState:
        // hlig is off by default
        break;
    case FontDescription::EnabledLigaturesState:
        m_features.append(hlig);
        break;
    case FontDescription::NormalLigaturesState:
        break;
    }
    static hb_feature_t noCalt = createFeature('c', 'a', 'l', 't');
    switch (description.contextualLigaturesState()) {
    case FontDescription::DisabledLigaturesState:
        m_features.append(noCalt);
        break;
    case FontDescription::EnabledLigaturesState:
        // calt is on by default
        break;
    case FontDescription::NormalLigaturesState:
        break;
    }

    static hb_feature_t hwid = createFeature('h', 'w', 'i', 'd', 1);
    static hb_feature_t twid = createFeature('t', 'w', 'i', 'd', 1);
    static hb_feature_t qwid = createFeature('q', 'w', 'i', 'd', 1);
    switch (description.widthVariant()) {
    case HalfWidth:
        m_features.append(hwid);
        break;
    case ThirdWidth:
        m_features.append(twid);
        break;
    case QuarterWidth:
        m_features.append(qwid);
        break;
    case RegularWidth:
        break;
    }

    FontFeatureSettings* settings = description.featureSettings();
    if (!settings)
        return;

    unsigned numFeatures = settings->size();
    for (unsigned i = 0; i < numFeatures; ++i) {
        hb_feature_t feature;
        const AtomicString& tag = settings->at(i).tag();
        feature.tag = HB_TAG(tag[0], tag[1], tag[2], tag[3]);
        feature.value = settings->at(i).value();
        feature.start = 0;
        feature.end = static_cast<unsigned>(-1);
        m_features.append(feature);
    }
}