Base/App: add new signal interface to Parameter
Added new signal interface using boost::signals2 signalParamChanged. Exposed to Python as ParameterGrpPy.AttachManager() to monitor changes to all parameters, sub groups under the referring group. Added new attribute for ParameterGrp(Py) to query the Parent and Manager of the referring group.
This commit is contained in:
@@ -154,8 +154,8 @@ namespace sp = std::placeholders;
|
||||
// Application
|
||||
//==========================================================================
|
||||
|
||||
ParameterManager *App::Application::_pcSysParamMngr;
|
||||
ParameterManager *App::Application::_pcUserParamMngr;
|
||||
Base::Reference<ParameterManager> App::Application::_pcSysParamMngr;
|
||||
Base::Reference<ParameterManager> App::Application::_pcUserParamMngr;
|
||||
Base::ConsoleObserverStd *Application::_pConsoleObserverStd = nullptr;
|
||||
Base::ConsoleObserverFile *Application::_pConsoleObserverFile = nullptr;
|
||||
|
||||
@@ -1215,21 +1215,22 @@ ParameterManager & Application::GetUserParameter()
|
||||
|
||||
ParameterManager * Application::GetParameterSet(const char* sName) const
|
||||
{
|
||||
std::map<std::string,ParameterManager *>::const_iterator it = mpcPramManager.find(sName);
|
||||
auto it = mpcPramManager.find(sName);
|
||||
if ( it != mpcPramManager.end() )
|
||||
return it->second;
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const std::map<std::string,ParameterManager *> & Application::GetParameterSetList() const
|
||||
const std::map<std::string,Base::Reference<ParameterManager>> &
|
||||
Application::GetParameterSetList(void) const
|
||||
{
|
||||
return mpcPramManager;
|
||||
}
|
||||
|
||||
void Application::AddParameterSet(const char* sName)
|
||||
{
|
||||
std::map<std::string,ParameterManager *>::const_iterator it = mpcPramManager.find(sName);
|
||||
auto it = mpcPramManager.find(sName);
|
||||
if ( it != mpcPramManager.end() )
|
||||
return;
|
||||
mpcPramManager[sName] = new ParameterManager();
|
||||
@@ -1237,11 +1238,10 @@ void Application::AddParameterSet(const char* sName)
|
||||
|
||||
void Application::RemoveParameterSet(const char* sName)
|
||||
{
|
||||
std::map<std::string,ParameterManager *>::iterator it = mpcPramManager.find(sName);
|
||||
auto it = mpcPramManager.find(sName);
|
||||
// Must not delete user or system parameter
|
||||
if ( it == mpcPramManager.end() || it->second == _pcUserParamMngr || it->second == _pcSysParamMngr )
|
||||
return;
|
||||
delete it->second;
|
||||
mpcPramManager.erase(it);
|
||||
}
|
||||
|
||||
@@ -1260,7 +1260,7 @@ Base::Reference<ParameterGrp> Application::GetParameterGroupByPath(const char*
|
||||
cName.erase(0,pos+1);
|
||||
|
||||
// test if name is valid
|
||||
std::map<std::string,ParameterManager *>::iterator It = mpcPramManager.find(cTemp.c_str());
|
||||
auto It = mpcPramManager.find(cTemp.c_str());
|
||||
if (It == mpcPramManager.end())
|
||||
throw Base::ValueError("Application::GetParameterGroupByPath() unknown parameter set name specified");
|
||||
|
||||
@@ -1651,8 +1651,8 @@ void Application::destruct()
|
||||
Base::Console().Log("Saving user parameter...done\n");
|
||||
|
||||
// now save all other parameter files
|
||||
std::map<std::string,ParameterManager *>& paramMgr = _pcSingleton->mpcPramManager;
|
||||
for (std::map<std::string,ParameterManager *>::iterator it = paramMgr.begin(); it != paramMgr.end(); ++it) {
|
||||
auto& paramMgr = _pcSingleton->mpcPramManager;
|
||||
for (auto it = paramMgr.begin(); it != paramMgr.end(); ++it) {
|
||||
if ((it->second != _pcSysParamMngr) && (it->second != _pcUserParamMngr)) {
|
||||
if (it->second->HasSerializer()) {
|
||||
Base::Console().Log("Saving %s...\n", it->first.c_str());
|
||||
@@ -1660,9 +1660,6 @@ void Application::destruct()
|
||||
Base::Console().Log("Saving %s...done\n", it->first.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// clean up
|
||||
delete it->second;
|
||||
}
|
||||
|
||||
paramMgr.clear();
|
||||
|
||||
@@ -332,7 +332,7 @@ public:
|
||||
Base::Reference<ParameterGrp> GetParameterGroupByPath(const char* sName);
|
||||
|
||||
ParameterManager * GetParameterSet(const char* sName) const;
|
||||
const std::map<std::string, ParameterManager *> & GetParameterSetList() const;
|
||||
const std::map<std::string,Base::Reference<ParameterManager>> & GetParameterSetList(void) const;
|
||||
void AddParameterSet(const char* sName);
|
||||
void RemoveParameterSet(const char* sName);
|
||||
//@}
|
||||
@@ -503,8 +503,8 @@ private:
|
||||
|
||||
/** @name member for parameter */
|
||||
//@{
|
||||
static ParameterManager *_pcSysParamMngr;
|
||||
static ParameterManager *_pcUserParamMngr;
|
||||
static Base::Reference<ParameterManager> _pcSysParamMngr;
|
||||
static Base::Reference<ParameterManager> _pcUserParamMngr;
|
||||
//@}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
@@ -605,7 +605,7 @@ private:
|
||||
std::vector<FileTypeItem> _mExportTypes;
|
||||
std::map<std::string,Document*> DocMap;
|
||||
mutable std::map<std::string,Document*> DocFileMap;
|
||||
std::map<std::string,ParameterManager *> mpcPramManager;
|
||||
std::map<std::string,Base::Reference<ParameterManager>> mpcPramManager;
|
||||
std::map<std::string,std::string> &_mConfig;
|
||||
App::Document* _pActiveDoc;
|
||||
|
||||
|
||||
@@ -64,6 +64,13 @@ void Handled::unref() const
|
||||
}
|
||||
}
|
||||
|
||||
int Handled::unrefNoDelete() const
|
||||
{
|
||||
int res = _lRefCount->deref();
|
||||
assert(res>=0);
|
||||
return res;
|
||||
}
|
||||
|
||||
int Handled::getRefCount() const
|
||||
{
|
||||
return static_cast<int>(*_lRefCount);
|
||||
|
||||
@@ -115,21 +115,6 @@ public:
|
||||
return _toHandle;
|
||||
}
|
||||
|
||||
/** Lower operator, needed for sorting in maps and sets */
|
||||
bool operator<(const Reference<T>& p) const {
|
||||
return _toHandle < p._toHandle;
|
||||
}
|
||||
|
||||
/** Equal operator */
|
||||
bool operator==(const Reference<T>& p) const {
|
||||
return _toHandle == p._toHandle;
|
||||
}
|
||||
|
||||
bool operator!=(const Reference<T>& p) const {
|
||||
return _toHandle != p._toHandle;
|
||||
}
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// checking on the state
|
||||
|
||||
@@ -165,6 +150,7 @@ public:
|
||||
|
||||
void ref() const;
|
||||
void unref() const;
|
||||
int unrefNoDelete() const;
|
||||
|
||||
int getRefCount() const;
|
||||
const Handled& operator = (const Handled&);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,6 +51,7 @@ using PyObject = struct _object;
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <boost_signals2.hpp>
|
||||
#include <xercesc/util/XercesDefs.hpp>
|
||||
|
||||
#include "Handle.h"
|
||||
@@ -105,6 +106,10 @@ public:
|
||||
void importFrom(const char* FileName);
|
||||
/// insert from a file to this group, overwrite only the similar
|
||||
void insert(const char* FileName);
|
||||
/// revert to default value by deleting any parameter that has the same value in the given file
|
||||
void revert(const char* FileName);
|
||||
/// revert to default value by deleting any parameter that has the same value in the given group
|
||||
void revert(Base::Reference<ParameterGrp>);
|
||||
//@}
|
||||
|
||||
/** @name methods for group handling */
|
||||
@@ -124,7 +129,37 @@ public:
|
||||
/// rename a sub group from this group
|
||||
bool RenameGrp(const char* OldName, const char* NewName);
|
||||
/// clears everything in this group (all types)
|
||||
void Clear();
|
||||
/// @param notify: whether to notify on deleted parameters using the Observer interface.
|
||||
void Clear(bool notify = false);
|
||||
//@}
|
||||
|
||||
/** @name methods for generic attribute handling */
|
||||
//@{
|
||||
enum class ParamType {
|
||||
FCInvalid = 0,
|
||||
FCText = 1,
|
||||
FCBool = 2,
|
||||
FCInt = 3,
|
||||
FCUInt = 4,
|
||||
FCFloat = 5,
|
||||
FCGroup = 6,
|
||||
};
|
||||
static const char *TypeName(ParamType type);
|
||||
static ParamType TypeValue(const char *);
|
||||
void SetAttribute(ParamType Type, const char *Name, const char *Value);
|
||||
void RemoveAttribute(ParamType Type, const char *Name);
|
||||
const char *GetAttribute(ParamType Type,
|
||||
const char *Name,
|
||||
std::string &Value,
|
||||
const char *Default) const;
|
||||
std::vector<std::pair<std::string, std::string>>
|
||||
GetAttributeMap(ParamType Type, const char * sFilter = NULL) const;
|
||||
/** Return the type and name of all parameters with optional filter
|
||||
* @param sFilter only strings which name includes sFilter are put in the vector
|
||||
* @return std::vector of pair(type, name)
|
||||
*/
|
||||
std::vector<std::pair<ParamType,std::string>>
|
||||
GetParameterNames(const char * sFilter = NULL) const;
|
||||
//@}
|
||||
|
||||
/** @name methods for bool handling */
|
||||
@@ -201,6 +236,8 @@ public:
|
||||
//@{
|
||||
/// set a string value
|
||||
void SetASCII(const char* Name, const char *sValue);
|
||||
/// set a string value
|
||||
void SetASCII(const char* Name, const std::string &sValue) { SetASCII(Name, sValue.c_str()); }
|
||||
/// read a string values
|
||||
std::string GetASCII(const char* Name, const char * pPreset=nullptr) const;
|
||||
/// remove a string value from this group
|
||||
@@ -222,19 +259,33 @@ public:
|
||||
return _cName.c_str();
|
||||
}
|
||||
|
||||
/// return the full path of this group
|
||||
std::string GetPath() const;
|
||||
void GetPath(std::string &) const;
|
||||
|
||||
/** Notifies all observers for all entries except of sub-groups.
|
||||
*/
|
||||
void NotifyAll();
|
||||
|
||||
ParameterGrp *Parent() const {return _Parent;}
|
||||
ParameterManager *Manager() const {return _Manager;}
|
||||
|
||||
protected:
|
||||
/// constructor is protected (handle concept)
|
||||
ParameterGrp(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *GroupNode=nullptr,const char* sName=nullptr);
|
||||
ParameterGrp(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *GroupNode=nullptr,
|
||||
const char* sName=nullptr,
|
||||
ParameterGrp *Parent=nullptr);
|
||||
/// destructor is protected (handle concept)
|
||||
~ParameterGrp() override;
|
||||
/// helper function for GetGroup
|
||||
Base::Reference<ParameterGrp> _GetGroup(const char* Name);
|
||||
bool ShouldRemove() const;
|
||||
|
||||
void _Reset();
|
||||
|
||||
void _SetAttribute(ParamType Type, const char *Name, const char *Value);
|
||||
void _Notify(ParamType Type, const char *Name, const char *Value);
|
||||
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *FindNextElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *Prev, const char* Type) const;
|
||||
|
||||
/** Find an element specified by Type and Name
|
||||
@@ -250,7 +301,9 @@ protected:
|
||||
* element of Type and with the attribute Name=Name. On success it returns
|
||||
* the pointer to that element, otherwise it creates the element and returns the pointer.
|
||||
*/
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *FindOrCreateElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *Start, const char* Type, const char* Name) const;
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *FindOrCreateElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *Start, const char* Type, const char* Name);
|
||||
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *CreateElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *Start, const char* Type, const char* Name);
|
||||
|
||||
/** Find an attribute specified by Name
|
||||
*/
|
||||
@@ -262,7 +315,15 @@ protected:
|
||||
std::string _cName;
|
||||
/// map of already exported groups
|
||||
std::map <std::string ,Base::Reference<ParameterGrp> > _GroupMap;
|
||||
|
||||
ParameterGrp * _Parent = nullptr;
|
||||
ParameterManager *_Manager = nullptr;
|
||||
/// Means this group xml element has not been added to its parent yet.
|
||||
bool _Detached = false;
|
||||
/** Indicate this group is currently being cleared
|
||||
*
|
||||
* This is used to prevent anynew value/sub-group to be added in observer
|
||||
*/
|
||||
bool _Clearing = false;
|
||||
};
|
||||
|
||||
/** The parameter serializer class
|
||||
@@ -281,6 +342,7 @@ public:
|
||||
virtual void SaveDocument(const ParameterManager&);
|
||||
virtual int LoadDocument(ParameterManager&);
|
||||
virtual bool LoadOrCreateDocument(ParameterManager&);
|
||||
const std::string &GetFileName() const {return filename;}
|
||||
|
||||
protected:
|
||||
std::string filename;
|
||||
@@ -299,6 +361,33 @@ public:
|
||||
static void Init();
|
||||
static void Terminate();
|
||||
|
||||
/** Signal on parameter changes
|
||||
*
|
||||
* The signal is triggered on adding, removing, renaming or modifying on
|
||||
* all individual parameters and group. The signature of the signal is
|
||||
* \code
|
||||
* void (ParameterGrp *param, ParamType type, const char *name, const char *value)
|
||||
* \endcode
|
||||
* where 'param' is the parameter group causing the change, 'type' is the
|
||||
* type of the parameter, 'name' is the name of the parameter, and 'value'
|
||||
* is the current value.
|
||||
*
|
||||
* The possible values of 'type' are, 'FCBool', 'FCInt', 'FCUint',
|
||||
* 'FCFloat', 'FCText', and 'FCParamGroup'. The notification is triggered
|
||||
* when value is changed, in which case 'value' contains the new value in
|
||||
* text form, or, when the parameter is removed, in which case 'value' is
|
||||
* empty.
|
||||
*
|
||||
* For 'FCParamGroup' type, the observer will be notified in the following events.
|
||||
* - Group creation: both 'name' and 'value' contain the name of the new group
|
||||
* - Group removal: both 'name' and 'value' are empty
|
||||
* - Group rename: 'name' is the new name, and 'value' is the old name
|
||||
*/
|
||||
boost::signals2::signal<void (ParameterGrp* /*param*/,
|
||||
ParamType /*type*/,
|
||||
const char * /*name*/,
|
||||
const char * /*value*/)> signalParamChanged;
|
||||
|
||||
int LoadDocument(const char* sFileName);
|
||||
int LoadDocument(const XERCES_CPP_NAMESPACE_QUALIFIER InputSource&);
|
||||
bool LoadOrCreateDocument(const char* sFileName);
|
||||
@@ -313,6 +402,8 @@ public:
|
||||
void SetSerializer(ParameterSerializer*);
|
||||
/// Returns true if a serializer is set, otherwise false is returned.
|
||||
bool HasSerializer() const;
|
||||
/// Returns the filename of the serialize.
|
||||
const std::string & GetSerializeFileName() const;
|
||||
/// Loads an XML document by calling the serializer's load method.
|
||||
int LoadDocument();
|
||||
/// Loads or creates an XML document by calling the serializer's load method.
|
||||
|
||||
@@ -52,10 +52,15 @@ public:
|
||||
{
|
||||
inst = obj;
|
||||
}
|
||||
ParameterGrpObserver(const Py::Object& obj, const Py::Object &callable, ParameterGrp *target)
|
||||
: callable(callable), _target(target), inst(obj)
|
||||
{
|
||||
}
|
||||
~ParameterGrpObserver() override
|
||||
{
|
||||
Base::PyGILStateLocker lock;
|
||||
inst = Py::None();
|
||||
callable = Py::None();
|
||||
}
|
||||
void OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::MessageType Reason) override
|
||||
{
|
||||
@@ -81,6 +86,11 @@ public:
|
||||
return this->inst.is(obj);
|
||||
}
|
||||
|
||||
public:
|
||||
Py::Object callable;
|
||||
boost::signals2::scoped_connection conn;
|
||||
ParameterGrp *_target = nullptr; // no reference counted, do not access
|
||||
|
||||
private:
|
||||
Py::Object inst;
|
||||
};
|
||||
@@ -103,10 +113,14 @@ public:
|
||||
Py::Object remGroup(const Py::Tuple&);
|
||||
Py::Object hasGroup(const Py::Tuple&);
|
||||
|
||||
Py::Object getManager(const Py::Tuple&);
|
||||
Py::Object getParent(const Py::Tuple&);
|
||||
|
||||
Py::Object isEmpty(const Py::Tuple&);
|
||||
Py::Object clear(const Py::Tuple&);
|
||||
|
||||
Py::Object attach(const Py::Tuple&);
|
||||
Py::Object attachManager(const Py::Tuple& args);
|
||||
Py::Object detach(const Py::Tuple&);
|
||||
Py::Object notify(const Py::Tuple&);
|
||||
Py::Object notifyAll(const Py::Tuple&);
|
||||
@@ -165,10 +179,31 @@ void ParameterGrpPy::init_type()
|
||||
add_varargs_method("RemGroup",&ParameterGrpPy::remGroup,"RemGroup(str)");
|
||||
add_varargs_method("HasGroup",&ParameterGrpPy::hasGroup,"HasGroup(str)");
|
||||
|
||||
add_varargs_method("Manager",&ParameterGrpPy::getManager,"Manager()");
|
||||
add_varargs_method("Parent",&ParameterGrpPy::getParent,"Parent()");
|
||||
|
||||
add_varargs_method("IsEmpty",&ParameterGrpPy::isEmpty,"IsEmpty()");
|
||||
add_varargs_method("Clear",&ParameterGrpPy::clear,"Clear()");
|
||||
|
||||
add_varargs_method("Attach",&ParameterGrpPy::attach,"Attach()");
|
||||
add_varargs_method("AttachManager",&ParameterGrpPy::attachManager,
|
||||
"AttachManager(observer) -- attach parameter manager for notification\n\n"
|
||||
"This method attaches a user defined observer to the manager (i.e. the root)\n"
|
||||
"of the current parameter group to receive notification of all its parameters\n"
|
||||
"and those from its sub-groups\n\n"
|
||||
"The method expects the observer to have a callable attribute as shown below\n"
|
||||
" slotParamChanged(param, tp, name, value)\n"
|
||||
"where 'param' is the parameter group causing the change, 'tp' is the type of\n"
|
||||
"the parameter, 'name' is the name of the parameter, and 'value' is the current\n"
|
||||
"value.\n\n"
|
||||
"The possible value of type are, 'FCBool', 'FCInt', 'FCUint', 'FCFloat', 'FCText',\n"
|
||||
"and 'FCParamGroup'. The notification is triggered when value is changed, in which\n"
|
||||
"case 'value' contains the new value in text form, or, when the parameter is removed,\n"
|
||||
"in which case 'value' is empty.\n\n"
|
||||
"For 'FCParamGroup' type, the observer will be notified in the following events.\n"
|
||||
"* Group creation: both 'name' and 'value' contain the name of the new group\n"
|
||||
"* Group removal: both 'name' and 'value' are empty\n"
|
||||
"* Group rename: 'name' is the new name, and 'value' is the old name");
|
||||
add_varargs_method("Detach",&ParameterGrpPy::detach,"Detach()");
|
||||
add_varargs_method("Notify",&ParameterGrpPy::notify,"Notify()");
|
||||
add_varargs_method("NotifyAll",&ParameterGrpPy::notifyAll,"NotifyAll()");
|
||||
@@ -214,7 +249,8 @@ ParameterGrpPy::~ParameterGrpPy()
|
||||
{
|
||||
for (ParameterGrpObserverList::iterator it = _observers.begin(); it != _observers.end(); ++it) {
|
||||
ParameterGrpObserver* obs = *it;
|
||||
_cParamGrp->Detach(obs);
|
||||
if (!obs->_target)
|
||||
_cParamGrp->Detach(obs);
|
||||
delete obs;
|
||||
}
|
||||
}
|
||||
@@ -281,6 +317,40 @@ Py::Object ParameterGrpPy::getGroup(const Py::Tuple& args)
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object ParameterGrpPy::getManager(const Py::Tuple& args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||
throw Py::Exception();
|
||||
|
||||
// get the Handle of the wanted group
|
||||
Base::Reference<ParameterGrp> handle = _cParamGrp->Manager();
|
||||
if (handle.isValid()) {
|
||||
// create a python wrapper class
|
||||
ParameterGrpPy *pcParamGrp = new ParameterGrpPy(handle);
|
||||
// increment the ref count
|
||||
return Py::asObject(pcParamGrp);
|
||||
}
|
||||
else
|
||||
return Py::Object();
|
||||
}
|
||||
|
||||
Py::Object ParameterGrpPy::getParent(const Py::Tuple& args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||
throw Py::Exception();
|
||||
|
||||
// get the Handle of the wanted group
|
||||
Base::Reference<ParameterGrp> handle = _cParamGrp->Parent();
|
||||
if (handle.isValid()) {
|
||||
// create a python wrapper class
|
||||
ParameterGrpPy *pcParamGrp = new ParameterGrpPy(handle);
|
||||
// increment the ref count
|
||||
return Py::asObject(pcParamGrp);
|
||||
}
|
||||
else
|
||||
return Py::Object();
|
||||
}
|
||||
|
||||
Py::Object ParameterGrpPy::getGroupName(const Py::Tuple& args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||
@@ -593,6 +663,56 @@ Py::Object ParameterGrpPy::attach(const Py::Tuple& args)
|
||||
return Py::None();
|
||||
}
|
||||
|
||||
Py::Object ParameterGrpPy::attachManager(const Py::Tuple& args)
|
||||
{
|
||||
PyObject* obj;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "O", &obj))
|
||||
throw Py::Exception();
|
||||
|
||||
if (!_cParamGrp->Manager())
|
||||
throw Py::RuntimeError("Parameter has no manager");
|
||||
|
||||
Py::Object o(obj);
|
||||
if (!o.hasAttr(std::string("slotParamChanged")))
|
||||
throw Py::TypeError("Object has no slotParamChanged attribute");
|
||||
|
||||
Py::Object attr(o.getAttr("slotParamChanged"));
|
||||
if (!attr.isCallable())
|
||||
throw Py::TypeError("Object has no slotParamChanged callable attribute");
|
||||
|
||||
for (ParameterGrpObserverList::iterator it = _observers.begin(); it != _observers.end(); ++it) {
|
||||
if ((*it)->isEqual(o)) {
|
||||
throw Py::RuntimeError("Object is already attached.");
|
||||
}
|
||||
}
|
||||
|
||||
ParameterGrpObserver* obs = new ParameterGrpObserver(o, attr, _cParamGrp);
|
||||
obs->conn = _cParamGrp->Manager()->signalParamChanged.connect(
|
||||
[obs](ParameterGrp *Param, ParameterGrp::ParamType Type, const char *Name, const char *Value) {
|
||||
if (!Param) return;
|
||||
for (auto p = Param; p; p = p->Parent()) {
|
||||
if (p == obs->_target) {
|
||||
Base::PyGILStateLocker lock;
|
||||
Py::TupleN args(
|
||||
Py::asObject(new ParameterGrpPy(Param)),
|
||||
Py::String(ParameterGrp::TypeName(Type)),
|
||||
Py::String(Name ? Name : ""),
|
||||
Py::String(Value ? Value : ""));
|
||||
try {
|
||||
Py::Callable(obs->callable).apply(args);
|
||||
} catch (Py::Exception &) {
|
||||
Base::PyException e;
|
||||
e.ReportException();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
_observers.push_back(obs);
|
||||
return Py::None();
|
||||
}
|
||||
|
||||
Py::Object ParameterGrpPy::detach(const Py::Tuple& args)
|
||||
{
|
||||
PyObject* obj;
|
||||
|
||||
@@ -92,7 +92,7 @@ DlgParameterImp::DlgParameterImp( QWidget* parent, Qt::WindowFlags fl )
|
||||
#endif
|
||||
|
||||
ParameterManager* sys = App::GetApplication().GetParameterSet("System parameter");
|
||||
const std::map<std::string,ParameterManager *>& rcList = App::GetApplication().GetParameterSetList();
|
||||
const auto& rcList = App::GetApplication().GetParameterSetList();
|
||||
for (const auto & it : rcList) {
|
||||
if (it.second != sys) // for now ignore system parameters because they are nowhere used
|
||||
ui->parameterSet->addItem(tr(it.first.c_str()), QVariant(QByteArray(it.first.c_str())));
|
||||
|
||||
Reference in New Issue
Block a user