From be2442c185237aac7ddc6b9cb8037b1749e9de67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Fri, 24 Jul 2009 13:20:32 +0000 Subject: [PATCH] Dennis: Use flags to implement source/target selections ( and possibly other tags ) Implement-source-target-object-flags-in-a-generic-style git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6632 383ad7c9-94d9-4d36-a494-682f7c89f535 --- common/BaseObject.cc | 44 +++++++++++++++++++++++++++++++++----------- common/BaseObject.hh | 36 +++++++++++++++++++++++------------- 2 files changed, 56 insertions(+), 24 deletions(-) diff --git a/common/BaseObject.cc b/common/BaseObject.cc index d325cf9d..9296e002 100644 --- a/common/BaseObject.cc +++ b/common/BaseObject.cc @@ -59,8 +59,7 @@ BaseObject::BaseObject(const BaseObject& _object) { ++idGenerator; persistentId_ = _object.persistentId_; objectType_ = _object.objectType_; - target_ = _object.target_; - source_ = _object.source_; + flags_ = _object.flags_; visible_ = _object.visible_; parentItem_ = 0; childItems_.clear(); @@ -74,8 +73,7 @@ BaseObject::BaseObject(BaseObject* _parent) : id_(-1), persistentId_(-1), objectType_(DATA_NONE), - target_(false), - source_(false), + flags_(), visible_(true), parentItem_(_parent), name_("NONAME") @@ -116,8 +114,8 @@ void BaseObject::cleanup() { persistentId_ = -1; objectType_ = DATA_NONE; - target_ = false; - source_ = false; + flags_.clear(); + visible_ = true; name_ = "NONAME"; } @@ -175,23 +173,47 @@ void BaseObject::printObjectInfo() { // =============================================================================== -// source/target Handling +// flag Handling // =============================================================================== bool BaseObject::target() { - return target_; + return flag("target"); } void BaseObject::target(bool _target) { - target_= _target; + setFlag("target", _target); } bool BaseObject::source() { - return source_; + return flag("source"); } void BaseObject::source(bool _source) { - source_ = _source; + setFlag("source", _source); +} + +bool BaseObject::flag(QString _flag) +{ + return flags_.contains(_flag); +} + +void BaseObject::setFlag(QString _flag, bool _set) +{ + if (flags_.contains(_flag)) + { + if (!_set) + flags_.removeAll(_flag); + } + else + { + if (_set) + flags_ << _flag; + } +} + +QStringList BaseObject::flags() +{ + return flags_; } // =============================================================================== diff --git a/common/BaseObject.hh b/common/BaseObject.hh index 1054bd04..a0b68d61 100644 --- a/common/BaseObject.hh +++ b/common/BaseObject.hh @@ -170,13 +170,16 @@ class DLLEXPORTONLY BaseObject { /** @} */ //=========================================================================== - /** @name Source/target handling + /** @name Flag handling (source, target, ...) * @{ */ //=========================================================================== public: /** Is this item selected as a target item? - */ + * Most algorithms operate on target meshes. These meshes are also considered as active. + * Blending for inactive meshes is handled by DataControlPlugin so emit objectSelectionChanged + * if you changed this value.\n + */ bool target(); /** Set this item as a target @@ -184,26 +187,33 @@ class DLLEXPORTONLY BaseObject { void target(bool _target); /** Is this item selected as a source item? - */ + * Some algorithms use source meshes to define their input. + */ bool source(); /** Set this item as a source */ void source(bool _source); - private: + /** Get a custom flag of this item + */ + bool flag(QString _flag); - /** Is this item selected as a target item? - * Most algorithms operate on target meshes. These meshes are also considered as active. - * Blending for inactive meshes is handled by DataControlPlugin so emit updated_objects - * if you changed this value.\n - */ - bool target_; + /** Set a custom flag on this item + */ + void setFlag(QString _flag, bool _set); - /** Is this item selected as a source item? - * Some algorithms use source meshes to define their input. + /** Get all flags of this item */ - bool source_; + QStringList flags(); + + private: + + /** Stores all item flags as strings. Source and target flags are represented + * as "source" and "target" strings. + */ + QStringList flags_; + /** @} */ -- GitLab