本文整理汇总了C++中app::Property::getTypeId方法的典型用法代码示例。如果您正苦于以下问题:C++ Property::getTypeId方法的具体用法?C++ Property::getTypeId怎么用?C++ Property::getTypeId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app::Property
的用法示例。
在下文中一共展示了Property::getTypeId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Restore
void Chamfer::Restore(Base::XMLReader &reader)
{
reader.readElement("Properties");
int Cnt = reader.getAttributeAsInteger("Count");
for (int i=0 ;i<Cnt ;i++) {
reader.readElement("Property");
const char* PropName = reader.getAttribute("name");
const char* TypeName = reader.getAttribute("type");
App::Property* prop = getPropertyByName(PropName);
try {
if (prop && strcmp(prop->getTypeId().getName(), TypeName) == 0) {
prop->Restore(reader);
}
else if (prop && strcmp(TypeName,"App::PropertyFloatConstraint") == 0 &&
strcmp(prop->getTypeId().getName(), "App::PropertyQuantityConstraint") == 0) {
App::PropertyFloatConstraint p;
p.Restore(reader);
static_cast<App::PropertyQuantityConstraint*>(prop)->setValue(p.getValue());
}
}
catch (const Base::XMLParseException&) {
throw; // re-throw
}
catch (const Base::Exception &e) {
Base::Console().Error("%s\n", e.what());
}
catch (const std::exception &e) {
Base::Console().Error("%s\n", e.what());
}
reader.readEndElement("Property");
}
reader.readEndElement("Properties");
}
示例2: inspectDistance
QString ViewProviderInspection::inspectDistance(const SoPickedPoint* pp) const
{
QString info;
const SoDetail* detail = pp->getDetail(pp->getPath()->getTail());
if (detail && detail->getTypeId() == SoFaceDetail::getClassTypeId()) {
// get the distances of the three points of the picked facet
const SoFaceDetail * facedetail = static_cast<const SoFaceDetail*>(detail);
App::Property* pDistance = this->pcObject->getPropertyByName("Distances");
if (pDistance && pDistance->getTypeId() == Inspection::PropertyDistanceList::getClassTypeId()) {
Inspection::PropertyDistanceList* dist = static_cast<Inspection::PropertyDistanceList*>(pDistance);
int index1 = facedetail->getPoint(0)->getCoordinateIndex();
int index2 = facedetail->getPoint(1)->getCoordinateIndex();
int index3 = facedetail->getPoint(2)->getCoordinateIndex();
float fVal1 = (*dist)[index1];
float fVal2 = (*dist)[index2];
float fVal3 = (*dist)[index3];
App::Property* pActual = this->pcObject->getPropertyByName("Actual");
if (pActual && pActual->getTypeId().isDerivedFrom( App::PropertyLink::getClassTypeId())) {
float fSearchRadius = this->search_radius;
if (fVal1 > fSearchRadius || fVal2 > fSearchRadius || fVal3 > fSearchRadius) {
info = QObject::tr("Distance: > %1").arg(fSearchRadius);
}
else if (fVal1 < -fSearchRadius || fVal2 < -fSearchRadius || fVal3 < -fSearchRadius) {
info = QObject::tr("Distance: < %1").arg(-fSearchRadius);
}
else {
const SbVec3f& v1 = this->pcCoords->point[index1];
const SbVec3f& v2 = this->pcCoords->point[index2];
const SbVec3f& v3 = this->pcCoords->point[index3];
const SbVec3f& p = pp->getObjectPoint();
// get the weights
float w1, w2, w3;
calcWeights(v1,v2,v3,p,w1,w2,w3);
float fVal = w1*fVal1+w2*fVal2+w3*fVal3;
info = QObject::tr("Distance: %1").arg(fVal);
}
}
}
}
else if (detail && detail->getTypeId() == SoPointDetail::getClassTypeId()) {
// safe downward cast, know the type
const SoPointDetail * pointdetail = static_cast<const SoPointDetail*>(detail);
// get the distance of the picked point
int index = pointdetail->getCoordinateIndex();
App::Property* prop = this->pcObject->getPropertyByName("Distances");
if (prop && prop->getTypeId() == Inspection::PropertyDistanceList::getClassTypeId()) {
Inspection::PropertyDistanceList* dist = static_cast<Inspection::PropertyDistanceList*>(prop);
float fVal = (*dist)[index];
info = QObject::tr("Distance: %1").arg(fVal);
}
}
return info;
}
示例3: Restore
void Primitive::Restore(Base::XMLReader &reader)
{
reader.readElement("Properties");
int Cnt = reader.getAttributeAsInteger("Count");
for (int i=0 ;i<Cnt ;i++) {
reader.readElement("Property");
const char* PropName = reader.getAttribute("name");
const char* TypeName = reader.getAttribute("type");
App::Property* prop = getPropertyByName(PropName);
// For #0001652 the property types of many primitive features have changed
// from PropertyFloat or PropertyFloatConstraint to a more meaningful type.
// In order to load older project files there must be checked in case the
// types don't match if both inherit from PropertyFloat because all derived
// classes do not re-implement the Save/Restore methods.
try {
if (prop && strcmp(prop->getTypeId().getName(), TypeName) == 0) {
prop->Restore(reader);
}
else if (prop) {
Base::Type inputType = Base::Type::fromName(TypeName);
if (prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId()) &&
inputType.isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
// Do not directly call the property's Restore method in case the implmentation
// has changed. So, create a temporary PropertyFloat object and assign the value.
App::PropertyFloat floatProp;
floatProp.Restore(reader);
static_cast<App::PropertyFloat*>(prop)->setValue(floatProp.getValue());
}
}
}
catch (const Base::XMLParseException&) {
throw; // re-throw
}
catch (const Base::Exception &e) {
Base::Console().Error("%s\n", e.what());
}
catch (const std::exception &e) {
Base::Console().Error("%s\n", e.what());
}
catch (const char* e) {
Base::Console().Error("%s\n", e);
}
#ifndef FC_DEBUG
catch (...) {
Base::Console().Error("Primitive::Restore: Unknown C++ exception thrown");
}
#endif
reader.readEndElement("Property");
}
reader.readEndElement("Properties");
}
示例4: Restore
void Transformed::Restore(Base::XMLReader &reader)
{
reader.readElement("Properties");
int Cnt = reader.getAttributeAsInteger("Count");
for (int i=0 ;i<Cnt ;i++) {
reader.readElement("Property");
const char* PropName = reader.getAttribute("name");
const char* TypeName = reader.getAttribute("type");
App::Property* prop = getPropertyByName(PropName);
// The property 'Angle' of PolarPattern has changed from PropertyFloat
// to PropertyAngle and the property 'Length' has changed to PropertyLength.
try {
if (prop && strcmp(prop->getTypeId().getName(), TypeName) == 0) {
prop->Restore(reader);
}
else if (prop) {
Base::Type inputType = Base::Type::fromName(TypeName);
if (prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId()) &&
inputType.isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
// Do not directly call the property's Restore method in case the implmentation
// has changed. So, create a temporary PropertyFloat object and assign the value.
App::PropertyFloat floatProp;
floatProp.Restore(reader);
static_cast<App::PropertyFloat*>(prop)->setValue(floatProp.getValue());
}
}
}
catch (const Base::XMLParseException&) {
throw; // re-throw
}
catch (const Base::Exception &e) {
Base::Console().Error("%s\n", e.what());
}
catch (const std::exception &e) {
Base::Console().Error("%s\n", e.what());
}
catch (const char* e) {
Base::Console().Error("%s\n", e);
}
#ifndef FC_DEBUG
catch (...) {
Base::Console().Error("Primitive::Restore: Unknown C++ exception thrown");
}
#endif
reader.readEndElement("Property");
}
reader.readEndElement("Properties");
}
示例5: method
ViewProviderPythonFeatureImp::ValueT
ViewProviderPythonFeatureImp::canDropObject(App::DocumentObject* obj) const
{
// Run the onChanged method of the proxy object.
Base::PyGILStateLocker lock;
try {
App::Property* proxy = object->getPropertyByName("Proxy");
if (proxy && proxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) {
Py::Object vp = static_cast<App::PropertyPythonObject*>(proxy)->getValue();
if (vp.hasAttr(std::string("canDropObject"))) {
Py::Callable method(vp.getAttr(std::string("canDropObject")));
Py::Tuple args(1);
args.setItem(0, Py::Object(obj->getPyObject(), true));
Py::Boolean ok(method.apply(args));
return static_cast<bool>(ok) ? Accepted : Rejected;
}
else {
return NotImplemented;
}
}
}
catch (Py::Exception&) {
Base::PyException e; // extract the Python error text
e.ReportException();
}
return Rejected;
}
示例6: getDetail
SoDetail* ViewProviderPythonFeatureImp::getDetail(const char* name) const
{
// Run the onChanged method of the proxy object.
Base::PyGILStateLocker lock;
try {
App::Property* proxy = object->getPropertyByName("Proxy");
if (proxy && proxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) {
Py::Object vp = static_cast<App::PropertyPythonObject*>(proxy)->getValue();
if (vp.hasAttr(std::string("getDetail"))) {
Py::Callable method(vp.getAttr(std::string("getDetail")));
Py::Tuple args(1);
args.setItem(0, Py::String(name));
Py::Object det(method.apply(args));
void* ptr = 0;
Base::Interpreter().convertSWIGPointerObj("pivy.coin", "SoDetail *", det.ptr(), &ptr, 0);
SoDetail* detail = reinterpret_cast<SoDetail*>(ptr);
return detail ? detail->copy() : 0;
}
}
}
catch (const Base::Exception& e) {
e.ReportException();
}
catch (Py::Exception&) {
Base::PyException e; // extract the Python error text
e.ReportException();
}
return 0;
}
示例7: getElement
std::string ViewProviderPythonFeatureImp::getElement(const SoDetail *det) const
{
// Run the onChanged method of the proxy object.
Base::PyGILStateLocker lock;
try {
App::Property* proxy = object->getPropertyByName("Proxy");
if (proxy && proxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) {
Py::Object vp = static_cast<App::PropertyPythonObject*>(proxy)->getValue();
if (vp.hasAttr(std::string("getElement"))) {
PyObject* pivy = 0;
// Note: As there is no ref'counting mechanism for the SoDetail class we must
// pass '0' as the last parameter so that the Python object does not 'own'
// the detail object.
pivy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoDetail *", (void*)det, 0);
Py::Callable method(vp.getAttr(std::string("getElement")));
Py::Tuple args(1);
args.setItem(0, Py::Object(pivy, true));
Py::String name(method.apply(args));
return (std::string)name;
}
}
}
catch (const Base::Exception& e) {
e.ReportException();
}
catch (Py::Exception&) {
Base::PyException e; // extract the Python error text
e.ReportException();
}
return "";
}
示例8: setViewProviders
/**
* Sets the document objects and their view providers to manipulate the material.
*/
void DlgMaterialPropertiesImp::setViewProviders(const std::vector<Gui::ViewProvider*>& Obj)
{
Objects = Obj;
for (std::vector<ViewProvider*>::iterator it= Objects.begin();it!=Objects.end();++it) {
App::Property* prop = (*it)->getPropertyByName(material.c_str());
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) {
App::PropertyMaterial* ShapeMaterial = (App::PropertyMaterial*)prop;
App::Material mat = ShapeMaterial->getValue();
int r = int(mat.ambientColor.r * 255.0f);
int g = int(mat.ambientColor.g * 255.0f);
int b = int(mat.ambientColor.b * 255.0f);
ambientColor->setColor( QColor(r,g,b) );
r = int(mat.diffuseColor.r * 255.0f);
g = int(mat.diffuseColor.g * 255.0f);
b = int(mat.diffuseColor.b * 255.0f);
diffuseColor->setColor( QColor(r,g,b) );
r = int(mat.emissiveColor.r * 255.0f);
g = int(mat.emissiveColor.g * 255.0f);
b = int(mat.emissiveColor.b * 255.0f);
emissiveColor->setColor( QColor(r,g,b) );
r = int(mat.specularColor.r * 255.0f);
g = int(mat.specularColor.g * 255.0f);
b = int(mat.specularColor.b * 255.0f);
specularColor->setColor( QColor(r,g,b) );
shininess->blockSignals(true);
shininess->setValue((int)(100.0f * (mat.shininess+0.001f)));
shininess->blockSignals(false);
break;
}
}
}
示例9: method
std::vector<App::DocumentObject*> ViewProviderPythonFeatureImp::claimChildren(const std::vector<App::DocumentObject*>& base) const
{
std::vector<App::DocumentObject*> children;
Base::PyGILStateLocker lock;
try {
App::Property* proxy = object->getPropertyByName("Proxy");
if (proxy && proxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) {
Py::Object vp = static_cast<App::PropertyPythonObject*>(proxy)->getValue();
if (vp.hasAttr(std::string("claimChildren"))) {
Py::Callable method(vp.getAttr(std::string("claimChildren")));
Py::Tuple args(0);
Py::Sequence list(method.apply(args));
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
PyObject* item = (*it).ptr();
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr();
children.push_back(obj);
}
}
}
else {
children = base;
}
}
}
catch (Py::Exception&) {
Base::PyException e; // extract the Python error text
Base::Console().Error("ViewProviderPythonFeature::claimChildren: %s\n", e.what());
}
return children;
}
示例10: setattr
int DocumentObjectProtectorPy::setattr(const char * attr, const Py::Object & value)
{
if (!_dp) {
std::string s;
std::ostringstream s_out;
s_out << "Cannot access attribute '" << attr << "' of deleted object";
throw Py::RuntimeError(s_out.str());
}
else {
App::DocumentObject* obj = _dp->getObject();
App::Property* prop = obj->getPropertyByName(attr);
if (!prop) {
std::string s;
std::ostringstream s_out;
s_out << "No such attribute '" << attr << "'";
throw Py::AttributeError(s_out.str());
}
Base::PyGILStateRelease unlock;
std::unique_ptr<App::Property> copy(static_cast<App::Property*>
(prop->getTypeId().createInstance()));
if (PyObject_TypeCheck(value.ptr(), DocumentObjectProtectorPy::type_object())) {
copy->setPyObject(static_cast<const DocumentObjectProtectorPy*>(value.ptr())->getObject().ptr());
}
else {
copy->setPyObject(value.ptr());
}
return _dp->setProperty(attr, *copy) ? 0 : -1;
}
}
示例11: onChanged
void ViewProviderPythonFeatureImp::onChanged(const App::Property* prop)
{
// Run the onChanged method of the proxy object.
Base::PyGILStateLocker lock;
try {
App::Property* proxy = object->getPropertyByName("Proxy");
if (proxy && proxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) {
Py::Object vp = static_cast<App::PropertyPythonObject*>(proxy)->getValue();
if (vp.hasAttr(std::string("onChanged"))) {
if (vp.hasAttr("__object__")) {
Py::Callable method(vp.getAttr(std::string("onChanged")));
Py::Tuple args(1);
std::string prop_name = object->getName(prop);
args.setItem(0, Py::String(prop_name));
method.apply(args);
}
else {
Py::Callable method(vp.getAttr(std::string("onChanged")));
Py::Tuple args(2);
args.setItem(0, Py::Object(object->getPyObject(), true));
std::string prop_name = object->getName(prop);
args.setItem(1, Py::String(prop_name));
method.apply(args);
}
}
}
}
catch (Py::Exception&) {
Base::PyException e; // extract the Python error text
const char* name = object->getObject()->Label.getValue();
Base::Console().Error("ViewProviderPythonFeature::onChanged (%s): %s\n", name, e.what());
}
}
示例12: updateAlias
void Sheet::updateAlias(CellAddress key)
{
std::string alias;
Property * prop = props.getDynamicPropertyByName(key.toString().c_str());
if (!prop)
return;
Cell * cell = getCell(key);
if (cell && cell->getAlias(alias)) {
App::Property * aliasProp = props.getDynamicPropertyByName(alias.c_str());
/* Update or create alias? */
if (aliasProp) {
// Type of alias and property must always be the same
if (aliasProp->getTypeId() != prop->getTypeId()) {
props.removeDynamicProperty(alias.c_str());
aliasProp = 0;
}
}
if (!aliasProp)
aliasProp = props.addDynamicProperty(prop->getTypeId().getName(), alias.c_str(), 0, 0, Prop_ReadOnly | Prop_Transient, true, true);
aliasProp->Paste(*prop);
}
}
示例13: attach
void ViewProviderPythonFeatureImp::attach(App::DocumentObject *pcObject)
{
// Run the attach method of the proxy object.
Base::PyGILStateLocker lock;
try {
App::Property* proxy = object->getPropertyByName("Proxy");
if (proxy && proxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) {
Py::Object vp = static_cast<App::PropertyPythonObject*>(proxy)->getValue();
if (vp.hasAttr(std::string("attach"))) {
if (vp.hasAttr("__object__")) {
Py::Callable method(vp.getAttr(std::string("attach")));
Py::Tuple args(0);
method.apply(args);
}
else {
Py::Callable method(vp.getAttr(std::string("attach")));
Py::Tuple args(1);
args.setItem(0, Py::Object(object->getPyObject(), true));
method.apply(args);
}
// #0000415: Now simulate a property change event to call
// claimChildren if implemented.
pcObject->Label.touch();
}
}
}
catch (Py::Exception&) {
Base::PyException e; // extract the Python error text
const char* name = object->getObject()->Label.getValue();
Base::Console().Error("ViewProviderPythonFeature::attach (%s): %s\n", name, e.what());
}
}
示例14: getDefaultDisplayMode
const char* ViewProviderPythonFeatureImp::getDefaultDisplayMode() const
{
// Run the getDefaultDisplayMode method of the proxy object.
Base::PyGILStateLocker lock;
static std::string mode;
try {
App::Property* proxy = object->getPropertyByName("Proxy");
if (proxy && proxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) {
Py::Object vp = static_cast<App::PropertyPythonObject*>(proxy)->getValue();
if (vp.hasAttr(std::string("getDefaultDisplayMode"))) {
Py::Callable method(vp.getAttr(std::string("getDefaultDisplayMode")));
Py::Tuple args(0);
Py::String str(method.apply(args));
if (str.isUnicode())
str = str.encode("ascii"); // json converts strings into unicode
mode = str.as_std_string();
return mode.c_str();
}
}
}
catch (Py::Exception&) {
Base::PyException e; // extract the Python error text
const char* name = object->getObject()->Label.getValue();
Base::Console().Error("ViewProviderPythonFeature::getDefaultDisplayMode (%s): %s\n", name, e.what());
}
return 0;
}
示例15: setDisplayMode
std::string ViewProviderPythonFeatureImp::setDisplayMode(const char* ModeName)
{
// Run the setDisplayMode method of the proxy object.
Base::PyGILStateLocker lock;
try {
App::Property* proxy = object->getPropertyByName("Proxy");
if (proxy && proxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) {
Py::Object vp = static_cast<App::PropertyPythonObject*>(proxy)->getValue();
if (vp.hasAttr(std::string("setDisplayMode"))) {
Py::Callable method(vp.getAttr(std::string("setDisplayMode")));
Py::Tuple args(1);
args.setItem(0, Py::String(ModeName));
Py::String str(method.apply(args));
return str.as_std_string();
}
}
}
catch (Py::Exception&) {
Base::PyException e; // extract the Python error text
const char* name = object->getObject()->Label.getValue();
Base::Console().Error("ViewProviderPythonFeature::setDisplayMode (%s): %s\n", name, e.what());
}
return ModeName;
}