Skip to content
4 changes: 4 additions & 0 deletions src/core/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,10 @@ void Map::ensureVisibilityOfSelectedObjects(SelectionVisibility visibility)
widget->ensureVisibilityOfRect(rect, MapWidget::DiscreteZoom);
break;

case CenterFullVisibility:
widget->ensureVisibilityOfRect(rect, MapWidget::DiscreteZoom, true);
break;

case IgnoreVisibilty:
break; // Do nothing

Expand Down
1 change: 1 addition & 0 deletions src/core/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ friend class XMLFileExporter;
{
FullVisibility,
PartialVisibility,
CenterFullVisibility,
IgnoreVisibilty
};

Expand Down
73 changes: 72 additions & 1 deletion src/core/objects/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class QRectF;

namespace literal
{
// map file
static const QLatin1String object("object");
static const QLatin1String symbol("symbol");
static const QLatin1String type("type");
Expand All @@ -76,12 +77,45 @@ namespace literal
static const QLatin1String rotation("rotation");
static const QLatin1String size("size");
static const QLatin1String tags("tags");

// object properties
// boolean operations
static const QLatin1String UndefinedSymbol(".UndefinedSymbol");
static const QLatin1String AreaTooSmall(".AreaTooSmall");
static const QLatin1String LineTooShort(".LineTooShort");
// comparisons
static const QLatin1String PaperArea(".PaperArea");
static const QLatin1String RealArea(".RealArea");
static const QLatin1String PaperLength(".PaperLength");
static const QLatin1String RealLength(".RealLength");
}



namespace OpenOrienteering {

static const std::vector<QLatin1String> object_properties = {literal::UndefinedSymbol, literal::AreaTooSmall, literal::LineTooShort,
literal::PaperArea, literal::RealArea, literal::PaperLength, literal::RealLength};

bool Object::isObjectProperty(const QString& property)
{
return std::find(object_properties.begin(), object_properties.end(), property) != object_properties.end();
}

bool Object::isBooleanObjectProperty(const QString& property)
{
return std::find(object_properties.begin(), object_properties.begin() + 3, property) != object_properties.begin() + 3;
}

bool Object::isComparisonObjectProperty(const QString& property)
{
return std::find(object_properties.begin() + 3, object_properties.end(), property) != object_properties.end();
}

const std::vector<QLatin1String>& Object::getObjectProperties()
{
return object_properties;
}

// ### Object implementation ###

Object::Object(Object::Type type, const Symbol* symbol)
Expand Down Expand Up @@ -755,6 +789,17 @@ void Object::includeControlPointsRect(QRectF& rect) const
}


QVariant Object::getObjectProperty(const QString& property) const
{
if (property == literal::UndefinedSymbol)
{
if (map && symbol)
return QVariant(map->findSymbolIndex(symbol) < 0);
}

return QVariant();
}


// ### PathPart ###

Expand Down Expand Up @@ -3220,6 +3265,32 @@ bool PathObject::isLineTooShort() const
}


// override
QVariant PathObject::getObjectProperty(const QString& property) const
{
if (property == literal::AreaTooSmall)
return QVariant(isAreaTooSmall());

if (property == literal::LineTooShort)
return QVariant(isLineTooShort());

if (property == literal::PaperArea)
return QVariant(calculatePaperArea());

if (property == literal::RealArea)
return QVariant(calculateRealArea());

if (property == literal::PaperLength)
return QVariant(getPaperLength());

if (property == literal::RealLength)
return QVariant(getRealLength());

return Object::getObjectProperty(property); // pass to base class function
}



// ### PointObject ###

PointObject::PointObject(const Symbol* symbol)
Expand Down
30 changes: 29 additions & 1 deletion src/core/objects/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ friend class XMLImportExport;
/** Creates an empty object with the given type, symbol, coords and (optional) map. */
explicit Object(Type type, const Symbol* symbol, MapCoordVector coords, Map* map = nullptr);


protected:
/**
* Constructs an Object, initialized from the given prototype.
Expand Down Expand Up @@ -317,6 +318,26 @@ friend class XMLImportExport;
*/
void includeControlPointsRect(QRectF& rect) const;


/**
* Returns dynamic object properties that are common for all objects.
* Derived object classes (i.e., PathObject) override this function to return class specific object properties.
* If derived object classes don't provide a requested property, they invoke the base class function.
*/
virtual QVariant getObjectProperty(const QString& property) const;

/** Returns true if property is a dynamic object property. */
static bool isObjectProperty(const QString& property);

/** Returns true if property is a dynamic object property that returns a boolean value. */
static bool isBooleanObjectProperty(const QString& property);

/** Returns true if property is a dynamic object property that returns a value for comparison. */
static bool isComparisonObjectProperty(const QString& property);

/** Returns keywords of the available dynamic object properties. */
static const std::vector<QLatin1String>& getObjectProperties();

protected:
virtual void updateEvent() const;

Expand Down Expand Up @@ -925,6 +946,14 @@ class PathObject : public Object // clazy:exclude=copyable-polymorphic
bool isLineTooShort() const;


/**
* Returns dynamic object properties that are specific for the PathObject class.
* Note: Overrides the base class function that returns dynamic object properties that are common for all objects.
* If a requested property is not provided by PathObject, the base class function is invoked.
*/
QVariant getObjectProperty(const QString& property) const override;


protected:
/**
* Adjusts the end index of the given part and the start/end indexes of the following parts.
Expand Down Expand Up @@ -1135,7 +1164,6 @@ struct ObjectPathCoord : public PathCoord
};



//### Object inline code ###

inline
Expand Down
Loading