@stephane-redon It works. Thanks.
Khoa
@Khoa
Posts made by Khoa
-
RE: Bug in SBMInteractionModelParticleSystem?
-
Bug in SBMInteractionModelParticleSystem?
I have
- MyInteractionModel which inherits SBMInteractionModelParticleSystem, and
- MyInteractionModelFactory which inherits SBGInteractionModelParticleSystemFactory
In MyInteractionModelFactory, I have a function which overrides the parent class function as follows:
MyInteractionModel * MyInteractionModelFactory ::create(SBParticleSystem* particleSystem) { MyInteractionModel *interactionModel = new MyInteractionModel(particleSystem); interactionModel->initializeInteractions(); if (!interactionModel->setupOK) { delete interactionModel; return NULL; } return interactionModel; }
I had a crash at 'delete interactionModel;'
When debugging, I got "Access violation reading ...." exception. And the final break point is at the end of the destructor of MyInteractionModel. The destructor of MyInteractionModel is empty, i.e.
MyInteractionModel ::~MyInteractionModel () { }
It seems there is an attempt to delete a memory location which had not been allocated inside one of the parent classes of **MyInteractionModel **.
At the top of my stack, i see SBCReference. Perhaps, it is where the error comes from.
-
RE: Help with introspection
@stephane-redon Actually I had that line in the first place and it didn't work
-
RE: Add new items in context menu when right-clicking on a selection
@stephane-redon I think it can be nice for the developers to be able to register more actions in the context menu. But it can also make the context menu too crowded. Perhaps, you can make something in the Preferences so that the users can select to add which actions to show in the context menu.
Actually, I am developing an app to convert a list of conformations to a path and vice versa for my work.
So I was thinking it can be useful to add an action in the context menu so that after selecting a list of conformations in the Document View, I would right-click and choose "Convert to Path". Do you have any suggestion to do it for this case? -
RE: Conversion from radian to degree does not work
Thanks.
It helps.SBQuantity::radian radianValue(1.5); SBQuantity::degree degreeValue = radianValue * SBConstant::RadToDeg;
-
Conversion from radian to degree does not work
SBQuantity::radian radianValue(1.5); SBQuantity::degree degreeValue = radianValue; double val = degreeValue.getValue();
I've got val equal to 1.5 !!!
Perhaps it is a bug ? -
Add new items in context menu when right-clicking on a selection
How can I add new items in the context menu when right-clicking on selected nodes in the Document View?
For example, after selecting a few nodes in the Document View, I do a right-click to open a context menu. There, I would like to add a function call "Do This For Me". How can I implement "Do This For Me" ?
-
RE: Help with introspection
I just figured out one work-around, that is add a down-casting in SBCMetaCast.hpp as such
static SBCMetaValueBase* castFrom(SBCMetaValueBase* fromValue) { if (!fromValue) return 0; std::string fromTypeName = fromValue->getTypeName(); std::string toTypeName = SBCMetaType<ToType*>::getTypeName(); if (fromTypeName.compare(toTypeName) == 0) return new SBCMetaValueHolder<ToType*>((static_cast<SBCMetaValueHolder<ToType*>*>(fromValue))->getValue()); else if (fromValue->isPointerType()) { // determine whether the type in fromValue inherits from ToType SBCMetaValueBase* currentType = fromValue->getParentType(); std::string toTypeParentName = SBCMetaType<ToType>::getTypeName(); while (currentType->hasBaseType()) { currentType = currentType->getBaseType(); if (currentType->getTypeName().compare(toTypeParentName) == 0) { ToType* value = (static_cast<SBCMetaValueHolder<ToType*>*>(fromValue))->getValue(); return new SBCMetaValueHolder<ToType*>(value); } } // down casting (determine whether the type in toType inherits from the type of fromValue) SBCMetaValueType<ToType*> toType; currentType = toType.getParentType(); while (currentType->hasBaseType()) { currentType = currentType->getBaseType(); std::string currentTypeName = currentType->getTypeName() + "*"; if (currentTypeName.compare(fromTypeName) == 0) { ToType* value = (static_cast<SBCMetaValueHolder<ToType*>*>(fromValue))->getValue(); return new SBCMetaValueHolder<ToType*>(value); } } }
It may not be good because I have to modify SBCMetaCast.hpp which is provided by the SDK. But at least it solves my problem for now.
If anyone has a better solution, please let me know.Have a great weekend.
Khoa
-
RE: Help with introspection
It seems it can perform upcasting but not downcasting (see SBCMetaCast.hpp)
static SBCMetaValueBase* castFrom(SBCMetaValueBase* fromValue) { if (!fromValue) return 0; std::string classTypeName = fromValue->getClassTypeName(); std::string fromTypeName = fromValue->getTypeName(); std::string toTypeName = SBCMetaType<ToType*>::getTypeName(); if (fromTypeName.compare(toTypeName) == 0) return new SBCMetaValueHolder<ToType*>((static_cast<SBCMetaValueHolder<ToType*>*>(fromValue))->getValue()); else if (fromValue->isPointerType()) { // determine whether the type in fromValue inherits from ToType SBCMetaValueBase* currentType = fromValue->getParentType(); std::string toTypeParentName = SBCMetaType<ToType>::getTypeName(); while (currentType->hasBaseType()) { currentType = currentType->getBaseType(); if (currentType->getTypeName().compare(toTypeParentName) == 0) { ToType* value = (static_cast<SBCMetaValueHolder<ToType*>*>(fromValue))->getValue(); return new SBCMetaValueHolder<ToType*>(value); } } } return 0; }``` Anyone has a workaround ?