void CPropertiesCanvas::OnPropertyGridSelect( wxPropertyGridEvent& event ) { wxPGProperty* p = event.GetPropertyPtr(); Property* property = GetProperty(p); if(property == NULL)return; if(property->m_selectcallback) (*(property->m_selectcallback))(((PropertyChoice*)property)->m_object); }
void ObjectPropertyEditor::OnPropertyChanged(wxPropertyGridEvent& e) { // Skip parent properties if (e.GetPropertyPtr()->GetParentingType() != 0) return; // Skip if no current selected object Fairy::ObjectPtr object = mCurrentObject.lock(); if (!object) return; Ogre::String propertyName = AS_STRING(e.GetPropertyName()); Ogre::String propertyValue = AS_STRING(e.GetPropertyValueAsString()); if(propertyName == "position" || propertyName == "scale") { Ogre::Vector3 vValue = Ogre::StringConverter::parseVector3(propertyValue); object->setProperty(propertyName,vValue); } else if(propertyName == "orientation") { Ogre::Quaternion qValue = Ogre::StringConverter::parseQuaternion(propertyValue); object->setProperty(propertyName,qValue); } else if(propertyName == "actor name") { m_Frame->ClearAllSelectorObject(); m_Frame->GetActorSettingEditor()->SetCurrentObject(Ogre::String(propertyValue.c_str())); return; } mPropertiesViewer->Freeze(); const Fairy::PropertyList& properties = object->getProperties(); for (Fairy::PropertyList::const_iterator it = properties.begin(); it != properties.end(); ++it) { const Fairy::PropertyDef& propertyDef = *it; Fairy::uint propertyFlags = object->getPropertyFlags(propertyDef.name); wxPGId id = mPropertiesViewer->GetPropertyByName(propertyDef.name.c_str()); assert(id.IsOk()); if (!id.IsOk()) continue; if (propertyFlags & Fairy::PF_READONLY) { if (mPropertiesViewer->IsPropertyEnabled(id)) mPropertiesViewer->DisableProperty(id); } else { if (!mPropertiesViewer->IsPropertyEnabled(id)) mPropertiesViewer->EnableProperty(id); } } mPropertiesViewer->Thaw(); }
void ObjectPropertyEditor::OnPropertyChanged(wxPropertyGridEvent& e) { // Skip parent properties if (e.GetPropertyPtr()->GetParentingType() != 0) return; // Skip if no current selected object WX::ObjectPtr object = mCurrentObject.lock(); if (!object) return; WX::String propertyName = AS_STRING(e.GetPropertyName()); WX::String propertyValue = AS_STRING(e.GetPropertyValueAsString()); WX::Variant oldValue = object->getProperty(propertyName); object->setPropertyAsString(propertyName, propertyValue); mSceneManipulator->_fireObjectPropertyChanged(object, propertyName, this); WX::Variant newValue = object->getProperty(propertyName); WX::ModifyObjectPropertyOperator* op = new WX::ModifyObjectPropertyOperator(mSceneManipulator); op->add(object->getName(), propertyName, oldValue, newValue); mSceneManipulator->getOperatorManager()->addOperator(op); mPropertiesViewer->Freeze(); const WX::PropertyList& properties = object->getProperties(); for (WX::PropertyList::const_iterator it = properties.begin(); it != properties.end(); ++it) { const WX::PropertyDef& propertyDef = *it; WX::uint propertyFlags = object->getPropertyFlags(propertyDef.name); wxPGId id = mPropertiesViewer->GetPropertyByName(propertyDef.name.c_str()); assert(id.IsOk()); if (!id.IsOk()) continue; if (propertyFlags & WX::PF_READONLY) { if (mPropertiesViewer->IsPropertyEnabled(id)) mPropertiesViewer->DisableProperty(id); } else { if (!mPropertiesViewer->IsPropertyEnabled(id)) mPropertiesViewer->EnableProperty(id); } } mPropertiesViewer->Thaw(); }
//----------------------------------------------------------------------- void PhysXFluidExternPropertyWindow::onPropertyChanged(wxPropertyGridEvent& event) { // Perform additional validations. if (!_validatePropertyFloatPositive(event.GetPropertyPtr(), PRNL_PHYSX_STIFFNESS)) return; if (!_validatePropertyFloatPositive(event.GetPropertyPtr(), PRNL_PHYSX_SURFACE_TENSION)) return; if (!_validatePropertyFloatPositive(event.GetPropertyPtr(), PRNL_PHYSX_VISCOSITY)) return; if (!_validatePropertyFloatPositive(event.GetPropertyPtr(), PRNL_PHYSX_DAMPING)) return; if (!_validatePropertyFloatPositive(event.GetPropertyPtr(), PRNL_PHYSX_COLLISION_RESPONSE_COEFFICIENT)) return; if (!_validatePropertyFloatPositive(event.GetPropertyPtr(), PRNL_PHYSX_COLLISION_GROUP)) return; ExternPropertyWindow::onPropertyChanged(event); }
void FairySkillEditDialog::OnPropertyChanged(wxPropertyGridEvent& e) { unsigned short numOfEffectInfos = mSkill->getNumAnimationEffectInfos(); unsigned short numOfRibbons = mSkill->getNumAnimationRibbons(); unsigned short numOfSounds = mSkill->getNumAnimationSounds(); unsigned short unmOfLights = mSkill->getNumAnimationSceneLightInfos(); // Skip parent properties if (e.GetPropertyPtr()->GetParentingType() != 0) return; wxPGId id = e.GetPropertyPtr()->GetId(); wxPGId parentId = mPropertiesViewer->GetPropertyParent(id); WX::String propertyName = e.GetPropertyName().c_str(); WX::String propertyValue = e.GetPropertyValueAsString().c_str(); if (propertyName == "AttachTime") { float inputValue = Ogre::StringConverter::parseReal(propertyValue); float outputTime = inputValue / ( mDObject->getCurrentAnimationLength() * mFramePerSecond ); if ( outputTime >= 1.0f ) { wxMessageBox(_("Wrong parameter!")); return; } propertyValue = Ogre::StringConverter::toString(outputTime); } else if (propertyName == "HitTime" || propertyName == "BreakTime" || propertyName == "ShakeTime") { Ogre::StringVector valueArray = Ogre::StringUtil::split(propertyValue); propertyValue.clear(); for (size_t i=0; i<valueArray.size(); ++i) { float inputValue = Ogre::StringConverter::parseReal(valueArray[i]); float outputTime = inputValue / ( mDObject->getCurrentAnimationLength() * mFramePerSecond ); if ( outputTime >= 1.0f ) { wxMessageBox(_("Wrong parameter!")); return; } propertyValue += Ogre::StringConverter::toString(outputTime); propertyValue += " "; } } unsigned short index = mPropertiesViewer->GetPropertyIndex(parentId); if ( index == 0 ) { mSkill->setParameter(propertyName, propertyValue); } else if ( index > 0 && index <= numOfEffectInfos ) { mSkill->getAnimationEffectInfo(index-1)->setParameter(propertyName, propertyValue); } else if ( index > numOfEffectInfos && index <= (numOfEffectInfos + numOfRibbons) ) { mSkill->getAnimationRibbon(index-numOfEffectInfos-1)->setParameter(propertyName, propertyValue); } else if ( index > numOfEffectInfos + numOfRibbons && index <= (numOfEffectInfos + numOfRibbons + numOfSounds) ) { mSkill->getAnimationSound(index-numOfEffectInfos-numOfRibbons-1)->setParameter(propertyName, propertyValue); } else if ( index > numOfEffectInfos + numOfRibbons + numOfSounds && index <= (numOfEffectInfos + numOfRibbons + numOfSounds + unmOfLights) ) { mSkill->getAnimationSceneLightInfo(index-numOfEffectInfos-numOfRibbons-numOfSounds-1)->setParameter(propertyName, propertyValue); } // 更新模板 WX::Skill *skill = WX::EffectManager::getSingleton().getSkill(mSkill->getSkillName()); *skill = *mSkill; }
void CPropertiesCanvas::OnPropertyGridChange( wxPropertyGridEvent& event ) { wxPGProperty* p = event.GetPropertyPtr(); Property* property = GetProperty(p); if(property == NULL)return; wxGetApp().CreateUndoPoint(); switch(property->get_property_type()){ case StringPropertyType: { wxString value; if (property->Evaluate(GetProperties(), event.GetPropertyValue().GetString(), value)) { (*(((PropertyString*)property)->m_callbackfunc))(value, ((PropertyString*)property)->m_object); } } break; case DoublePropertyType: { wxString value; if (property->Evaluate(GetProperties(), event.GetPropertyValue().GetString(), value)) { (*(((PropertyDouble*)property)->m_callbackfunc))(strtod(value.utf8_str(),NULL), ((PropertyDouble*)property)->m_object); } } break; case LengthPropertyType: { wxString value; if (property->Evaluate(GetProperties(), event.GetPropertyValue().GetString(), value)) { (*(((PropertyLength*)property)->m_callbackfunc))(strtod(value.utf8_str(),NULL) * wxGetApp().m_view_units, ((PropertyDouble*)property)->m_object); } } break; case IntPropertyType: { (*(((PropertyInt*)property)->m_callbackfunc))(event.GetPropertyValue().GetLong(), ((PropertyInt*)property)->m_object); } break; case ColorPropertyType: { wxVariant var = event.GetPropertyValue(); const wxColour* wcol = wxGetVariantCast(var,wxColour); HeeksColor col(wcol->Red(), wcol->Green(), wcol->Blue()); (*(((PropertyColor*)property)->m_callbackfunc))(col, ((PropertyColor*)property)->m_object); } break; case VertexPropertyType: { if(p->GetName()[0] == 'x'){ ((PropertyVertex*)property)->m_x[0] = event.GetPropertyValue().GetDouble(); if(((PropertyVertex*)property)->m_affected_by_view_units)((PropertyVertex*)property)->m_x[0] *= wxGetApp().m_view_units; } else if(p->GetName()[0] == 'y'){ ((PropertyVertex*)property)->m_x[1] = event.GetPropertyValue().GetDouble(); if(((PropertyVertex*)property)->m_affected_by_view_units)((PropertyVertex*)property)->m_x[1] *= wxGetApp().m_view_units; } else if(p->GetName()[0] == 'z'){ ((PropertyVertex*)property)->m_x[2] = event.GetPropertyValue().GetDouble(); if(((PropertyVertex*)property)->m_affected_by_view_units)((PropertyVertex*)property)->m_x[2] *= wxGetApp().m_view_units; } (*(((PropertyVertex*)property)->m_callbackfunc))(((PropertyVertex*)property)->m_x, ((PropertyVertex*)property)->m_object); } break; case TrsfPropertyType: { double pos[3]; extract(((PropertyTrsf*)property)->m_trsf.TranslationPart(), pos); gp_Dir xaxis(1, 0, 0); xaxis.Transform(((PropertyTrsf*)p)->m_trsf); gp_Dir yaxis(0, 1, 0); yaxis.Transform(((PropertyTrsf*)p)->m_trsf); double vertical_angle = 0; double horizontal_angle = 0; double twist_angle = 0; CoordinateSystem::AxesToAngles(xaxis, yaxis, vertical_angle, horizontal_angle, twist_angle); if(p->GetName()[0] == 'x'){ pos[0] = event.GetPropertyValue().GetDouble(); } else if(p->GetName()[0] == 'y'){ pos[1] = event.GetPropertyValue().GetDouble(); } else if(p->GetName()[0] == 'z'){ pos[2] = event.GetPropertyValue().GetDouble(); } else if(p->GetName()[0] == 'v'){ vertical_angle = event.GetPropertyValue().GetDouble(); } else if(p->GetName()[0] == 'h'){ horizontal_angle = event.GetPropertyValue().GetDouble(); } else if(p->GetName()[0] == 't'){ twist_angle = event.GetPropertyValue().GetDouble(); } CoordinateSystem::AnglesToAxes(vertical_angle, horizontal_angle, twist_angle, xaxis, yaxis); ((PropertyTrsf*)property)->m_trsf = make_matrix(make_point(pos), xaxis, yaxis); (*(((PropertyTrsf*)property)->m_callbackfunc))(((PropertyTrsf*)property)->m_trsf, ((PropertyTrsf*)property)->m_object); } break; case ChoicePropertyType: { (*(((PropertyChoice*)property)->m_callbackfunc))(event.GetPropertyValue().GetLong(), ((PropertyChoice*)property)->m_object); } break; case CheckPropertyType: { (*(((PropertyCheck*)property)->m_callbackfunc))(event.GetPropertyValue().GetBool(), ((PropertyCheck*)property)->m_object); } break; case ListOfPropertyType: { } break; case FilePropertyType: { (*(((PropertyFile*)property)->m_callbackfunc))(event.GetPropertyValue().GetString(), ((PropertyFile*)property)->m_object); } break; case DirectoryPropertyType: { (*(((PropertyDir*)property)->m_callbackfunc))(event.GetPropertyValue().GetString(), ((PropertyDir*)property)->m_object); } break; } wxGetApp().Changed(); }
void WXEffectEditDialog::OnPropertyChanged(wxPropertyGridEvent& e) { // Skip parent properties if (e.GetPropertyPtr()->GetParentingType() != 0) return; wxPGId id = e.GetPropertyPtr()->GetId(); wxPGId parentId = mPropertiesViewer->GetPropertyParent(id); const wxString &parentLabel = mPropertiesViewer->GetPropertyLabel(parentId); unsigned short index = mPropertiesViewer->GetPropertyIndex(parentId); Fairy::String propertyName = e.GetPropertyName().c_str(); Fairy::String propertyValue = e.GetPropertyValueAsString().c_str(); Fairy::Scene::ObjectsByTypeRange effects = mSceneManipulator->getSceneInfo()->findObjectsByType(Fairy::EffectObject::msType); for (Fairy::Scene::ObjectsByTypeIterator it = effects.first; it != effects.second; ++it) { const Fairy::ObjectPtr& object = *it; const Fairy::EffectObject* effectObject = static_cast<Fairy::EffectObject *>(object.get()); Fairy::Effect *effect = effectObject->getEffect(); assert (effect); // 现在做的是直接对模板的修改,所以要修改全部的同个模板的特效 if ( effect->getTemplateName() == mEffect->getTemplateName() ) { if (index < effect->getNumElements()) { Fairy::EffectElement *element = effect->getElement(index); assert (element); element->setParameter(propertyName, propertyValue); } else { effect->setParameter(propertyName, propertyValue); } } } // 更新当前的skill if (gEffectSettingGlobalData.mCurrentSkill) { for ( unsigned short i = 0; i < gEffectSettingGlobalData.mCurrentSkill->getNumAnimationEffectInfos(); ++i ) { Fairy::AnimationEffectInfo *effectInfo = gEffectSettingGlobalData.mCurrentSkill->getAnimationEffectInfo(i); assert (effectInfo); Fairy::Effect *effect = effectInfo->getEffect(); assert (effect); // 现在做的是直接对模板的修改,所以要修改全部的同个模板的特效 if ( effect->getTemplateName() == mEffect->getTemplateName() ) { if (index < effect->getNumElements()) { Fairy::EffectElement *element = effect->getElement(index); assert (element); element->setParameter(propertyName, propertyValue); } else { effect->setParameter(propertyName, propertyValue); } } } } }