Esempio n. 1
0
void MiscItemPropertyChange::apply() const {
    if(!town.preset_items[index].exists())
        throw std::logic_error("Undo history corruption: Attempt to modify property of an item in an empty slot");
    switch(prop) {
    case CHARGES:
        applyTo(town.preset_items[index].charges);
        break;
    case PROPERTY_MASK:
        applyTo(town.preset_items[index].properties);
        break;
    }
    setSelection(SelectionType::Item,index,true);
}
Esempio n. 2
0
void SpecialEncounterStateChange::apply() const {
    if(editing_town) {
        if(town.spec_id[index] == kNO_TOWN_SPECIALS)
            throw std::logic_error("Undo history corruption: Attempt to modify a town special encounter in an empty slot");
        applyTo(town.spec_id[index]);
    }
    else { //outdoors
        if(current_terrain.spec_id[index] == kNO_OUT_SPECIALS)
            throw std::logic_error("Undo history corruption: Attempt to modify an outdoor special encounter in an empty slot");
        //This cast is a bit questionable but seems to behave correctly
        applyTo((unsigned char&)current_terrain.spec_id[index]);
    }
    setSelection(SelectionType::SpecialEncounter,index,true);
}
Esempio n. 3
0
void RectChangeStep::applyToRect(Rect& r) const {
    switch(side) {
    case TOP:
        applyTo(r.top);
        break;
    case BOTTOM:
        applyTo(r.bottom);
        break;
    case LEFT:
        applyTo(r.left);
        break;
    case RIGHT:
        applyTo(r.right);
        break;
    }
}
Esempio n. 4
0
void VersionFinal::reapply(const bool alreadyReseting)
{
	if (!alreadyReseting)
	{
		beginResetModel();
	}

	clear();

	auto existingOrders = getExistingOrder();
	QList<int> orders = existingOrders.values();
	std::sort(orders.begin(), orders.end());
	QList<VersionFilePtr> newVersionFiles;
	for (auto order : orders)
	{
		auto file = versionFile(existingOrders.key(order));
		newVersionFiles.append(file);
		file->applyTo(this);
	}
	versionFiles.swap(newVersionFiles);
	finalize();
	if (!alreadyReseting)
	{
		endResetModel();
	}
}
Esempio n. 5
0
 void visit(UnrolledLoopStatement *s)
 {
     for (size_t i = 0; i < s->statements->dim; i++)
         if (doCond((*s->statements)[i]))
             return;
     applyTo(s);
 }
Esempio n. 6
0
 void visit(CompoundStatement *s)
 {
     for (size_t i = 0; i < s->statements->dim; i++)
         if (doCond((*s->statements)[i]))
             return;
     applyTo(s);
 }
Esempio n. 7
0
void TerrainScriptMemoryCellChange::apply() const {
    if(!town.ter_scripts[index].exists)
        throw std::logic_error("Undo history corruption: Attempt to modify memory cell of a terrain script in an empty slot");
    if(cell>=10)
        throw std::logic_error("Undo history corruption: Attempt to modify out of range terrain script memory cell");
    applyTo(town.ter_scripts[index].memory_cells[cell]);
    setSelection(SelectionType::TerrainScript,index,true);
}
Esempio n. 8
0
void CreatureMemoryCellChange::apply() const {
    if(!town.creatures[index].exists())
        throw std::logic_error("Undo history corruption: Attempt to modify memory cell of a creature in an empty slot");
    if(cell>=10)
        throw std::logic_error("Undo history corruption: Attempt to modify out of range creature memory cell");
    applyTo(town.creatures[index].memory_cells[cell]);
    setSelection(SelectionType::Creature,index,true);
}
Esempio n. 9
0
void VersionBuilder::readJsonAndApply(const QJsonObject &obj)
{
	m_version->clear();

	auto file = VersionFile::fromJson(QJsonDocument(obj), QString(), false);

	file->applyTo(m_version);
	m_version->VersionPatches.append(file);
}
Esempio n. 10
0
    void visit(TryCatchStatement *s)
    {
        if (doCond(s->body))
            return;

        for (size_t i = 0; i < s->catches->dim; i++)
            if (doCond((*s->catches)[i]->handler))
                return;
        applyTo(s);
    }
OsmAnd::ColorARGB OsmAnd::MapPresentationEnvironment_P::getDefaultBackgroundColor(const ZoomLevel zoom) const
{
    auto result = _defaultBackgroundColor;

    if (_defaultBackgroundColorAttribute)
    {
        MapStyleEvaluator evaluator(owner->resolvedStyle, owner->displayDensityFactor * owner->mapScaleFactor);
        applyTo(evaluator);
        evaluator.setIntegerValue(owner->styleBuiltinValueDefs->id_INPUT_MINZOOM, zoom);

        MapStyleEvaluationResult evalResult;
        if (evaluator.evaluate(_defaultBackgroundColorAttribute, &evalResult))
            evalResult.getIntegerValue(owner->styleBuiltinValueDefs->id_OUTPUT_ATTR_COLOR_VALUE, result.argb);
    }

    return result;
}
unsigned int OsmAnd::MapPresentationEnvironment_P::getRoadsDensityLimitPerTile(const ZoomLevel zoom) const
{
    auto result = _roadsDensityLimitPerTile;

    if (_roadsDensityLimitPerTileAttribute)
    {
        MapStyleEvaluator evaluator(owner->resolvedStyle, owner->displayDensityFactor * owner->mapScaleFactor);
        applyTo(evaluator);
        evaluator.setIntegerValue(owner->styleBuiltinValueDefs->id_INPUT_MINZOOM, zoom);

        MapStyleEvaluationResult evalResult;
        if (evaluator.evaluate(_roadsDensityLimitPerTileAttribute, &evalResult))
            evalResult.getIntegerValue(owner->styleBuiltinValueDefs->id_OUTPUT_ATTR_INT_VALUE, result);
    }

    return result;
}
Esempio n. 13
0
void OsmAnd::MapPresentationEnvironment_P::obtainShadowRenderingOptions(const ZoomLevel zoom, int& mode, ColorARGB& color) const
{
    mode = _shadowRenderingMode;
    color = _shadowRenderingColor;

    if (_attributeRule_shadowRendering)
    {
        MapStyleEvaluator evaluator(owner->style, owner->displayDensityFactor);
        applyTo(evaluator);
        evaluator.setIntegerValue(owner->styleBuiltinValueDefs->id_INPUT_MINZOOM, zoom);

        MapStyleEvaluationResult evalResult;
        if (evaluator.evaluate(_attributeRule_shadowRendering, &evalResult))
        {
            evalResult.getIntegerValue(owner->styleBuiltinValueDefs->id_OUTPUT_ATTR_INT_VALUE, mode);
            evalResult.getIntegerValue(owner->styleBuiltinValueDefs->id_OUTPUT_SHADOW_COLOR, color.argb);
        }
    }
}
float OsmAnd::MapPresentationEnvironment_P::getGlobalPathPadding() const
{
    auto result = _globalPathPadding;

    if (_globalPathPaddingAttribute)
    {
        MapStyleEvaluator evaluator(owner->resolvedStyle, owner->displayDensityFactor * owner->symbolsScaleFactor);
        applyTo(evaluator);

        MapStyleEvaluationResult evalResult;
        if (evaluator.evaluate(_globalPathPaddingAttribute, &evalResult))
        {
            float value = 0.0f;
            if (evalResult.getFloatValue(owner->styleBuiltinValueDefs->id_OUTPUT_ATTR_FLOAT_VALUE, value))
                result = value;
        }
    }

    return result;
}
void
ShortCircuitedGeometryVisitor::applyTo(const Geometry &geom)
{
	for (unsigned int i=0, n=geom.getNumGeometries(); i<n; ++i)
	{
		const Geometry *element = geom.getGeometryN(i);
		if (dynamic_cast<const GeometryCollection*>(element))
		{
			applyTo(*element);
		}
		else
		{
			// calls the abstract virtual
			visit(*element);
			if (isDone()) done = true;
		}

		if ( done ) return;
	}
}
Esempio n. 16
0
	TypePtr tryDeduceReturnType(const FunctionTypePtr& funType, const TypeList& argumentTypes) {
		NodeManager& manager = funType->getNodeManager();

		// try deducing variable instantiations the argument types
		auto varInstantiation = types::getTypeVariableInstantiation(manager, funType->getParameterTypes()->getTypes(), argumentTypes);

		// check whether derivation was successful
		if(!varInstantiation) {
			std::stringstream msg;
			msg << "Cannot match arguments (" << join(", ", argumentTypes, print<deref<TypePtr>>()) << ") \n"
				   "         to parameters ("
			    << join(", ", funType->getParameterTypes(), print<deref<TypePtr>>()) << ")";
			throw ReturnTypeDeductionException(msg.str());
		}

		// extract return type
		const TypePtr& resType = funType->getReturnType();

		// compute and return the expected return type
		return varInstantiation->applyTo(manager, resType);
	}
double OsmAnd::MapPresentationEnvironment_P::getPolygonAreaMinimalThreshold(const ZoomLevel zoom) const
{
    auto result = _polygonMinSizeToDisplay;

    if (_polygonMinSizeToDisplayAttribute)
    {
        MapStyleEvaluator evaluator(owner->resolvedStyle, owner->displayDensityFactor * owner->mapScaleFactor);
        applyTo(evaluator);
        evaluator.setIntegerValue(owner->styleBuiltinValueDefs->id_INPUT_MINZOOM, zoom);

        MapStyleEvaluationResult evalResult;
        if (evaluator.evaluate(_polygonMinSizeToDisplayAttribute, &evalResult))
        {
            int polygonMinSizeToDisplay;
            if (evalResult.getIntegerValue(owner->styleBuiltinValueDefs->id_OUTPUT_ATTR_INT_VALUE, polygonMinSizeToDisplay))
                result = polygonMinSizeToDisplay;
        }
    }

    return result;
}
Esempio n. 18
0
int
Substitution::applyTo(Term &t) const
{
    // search for the substitution variable in the term
    if (t.type == Term::Variable)
    {
        // check if the variables are the same
        if (t.value == variable)
            t = term;
    }
    else if (t.type == Term::PredicateFunction || t.type == Term::Function)
    {
        ListIterator<Term *> pargsIter(*t.pargs);
        for ( ; !pargsIter.done(); pargsIter++)
        {
            if (pargsIter() == NULL)
                continue;
            if (applyTo(*pargsIter()) != OK)
                return(NOTOK);
        }
    }
    return(OK);
}
void OsmAnd::MapPresentationEnvironment_P::obtainShadowOptions(const ZoomLevel zoom, ShadowMode& mode, ColorARGB& color) const
{
    bool ok;
    mode = _shadowMode;
    color = _shadowColor;

    if (_shadowOptionsAttribute)
    {
        MapStyleEvaluator evaluator(owner->resolvedStyle, owner->displayDensityFactor * owner->mapScaleFactor);
        applyTo(evaluator);
        evaluator.setIntegerValue(owner->styleBuiltinValueDefs->id_INPUT_MINZOOM, zoom);

        MapStyleEvaluationResult evalResult;
        if (evaluator.evaluate(_shadowOptionsAttribute, &evalResult))
        {
            int modeValue = 0;
            ok = evalResult.getIntegerValue(owner->styleBuiltinValueDefs->id_OUTPUT_ATTR_INT_VALUE, modeValue);
            if (ok)
                mode = static_cast<ShadowMode>(modeValue);

            evalResult.getIntegerValue(owner->styleBuiltinValueDefs->id_OUTPUT_SHADOW_COLOR, color.argb);
        }
    }
}
Esempio n. 20
0
void ScenStartLocationTownChange::LocationChange::apply() const {
    applyTo(scenario.what_start_loc_in_town);
}
Esempio n. 21
0
void TownEntranceTownChange::apply() const {
    if(current_terrain.exit_dests[index] == kNO_OUT_TOWN_ENTRANCE)
        throw std::logic_error("Undo history corruption: Attempt to modify a town entrance in an empty slot");
    applyTo(current_terrain.exit_dests[index]);
    setSelection(SelectionType::TownEntrance,index,true);
}
Esempio n. 22
0
void UnitNormFilter::applyInPlace(Mat& image) const {
	if (image.type() == CV_32FC1)
		normalize(image);
	else
		image = applyTo(image);
}
	/**
	 * Applies this filter to an image, writing the filtered data into the image itself.
	 *
	 * @param[in,out] image The image that should be filtered.
	 */
	virtual void applyInPlace(Mat& image) const {
		image = applyTo(image);
	}
	/**
	 * Applies this filter to an image, writing the filtered image data into a newly created image.
	 *
	 * @param[in] image The image that should be filtered.
	 * @return The filtered image.
	 */
	Mat applyTo(const Mat& image) const {
		Mat filtered;
		applyTo(image, filtered);
		return filtered;
	}
Esempio n. 25
0
void FloorChange::apply() const {
    if(editing_town)
        applyTo(t_d.floor[x][y]);
    else
        applyTo(current_terrain.floor[x][y]);
}
Esempio n. 26
0
void ScenStartLocationOutdoorChange::SectionChange::apply() const {
    applyTo(scenario.what_outdoor_section_start_in);
}
Esempio n. 27
0
void ScenStartLocationOutdoorChange::LocationChange::apply() const {
    applyTo(scenario.start_where_in_outdoor_section);
}
Esempio n. 28
0
void ScenStartLocationTownChange::TownChange::apply() const {
    applyTo(scenario.start_in_what_town);
}
Esempio n. 29
0
void WaypointLocationChangeStep::apply() const {
    applyTo(town.waypoints[index]);
    setSelection(SelectionType::Waypoint,index,true);
}
Esempio n. 30
0
void TownEntrancePointLocationChange::apply() const {
    applyTo(town.start_locs[index]);
    setSelection(SelectionType::None,0);
}