virtual void dialogClosed(const DialogWindowEventUnrecPtr e) { if(e->getOption() != DialogWindowEvent::DIALOG_OPTION_CANCEL) { //Create the Layer FieldContainer CreateFieldContainerCommandPtr CreateCommand = CreateFieldContainerCommand::create(e->getInput()); TheCommandManager->executeCommand(CreateCommand); //If the layer is a ColorLayer then give it a random color if(CreateCommand->getContainer()->getType() == ColorLayer::getClassType()) { Color4f RandColor(RandomPoolManager::getRandomReal32(0.0f,1.0f), RandomPoolManager::getRandomReal32(0.0f,1.0f), RandomPoolManager::getRandomReal32(0.0f,1.0f), 1.0f); dynamic_cast<ColorLayer*>(CreateCommand->getContainer())->setColor(RandColor); } //Set the background layer to use the newly create layer SetFieldValueCommandPtr SetFieldCommand = SetFieldValueCommand::create(SinglePtrFieldLabel,Component::BackgroundFieldId, boost::lexical_cast<std::string>(CreateCommand->getContainer()->getId())); TheCommandManager->executeCommand(SetFieldCommand); } }
void GenericMultiFieldEditor::insertAtIndex(FieldContainer* const fc, UInt32 fieldID, UInt32 index, const FieldContainerType* type, CommandManager* cmdMgr) { const FieldContainerType* ThePtrType(getFieldContainerTypeFromPtrType(fc->getFieldDescription(fieldID)->getFieldType().getContentType())); //Create the Container CreateFieldContainerCommandPtr CreateCommand; //If the type is a node, then create a NodeCore instead //and then insert it as the core of a newly created node if(*ThePtrType == Node::getClassType()) { CreateFieldContainerCommandPtr CreateCoreCommand = CreateFieldContainerCommand::create(type); cmdMgr->executeCommand(CreateCoreCommand); CreateCommand = CreateFieldContainerCommand::create(&Node::getClassType()); cmdMgr->executeCommand(CreateCommand); dynamic_cast<Node*>(CreateCommand->getContainer())->setCore(dynamic_cast<NodeCore*>(CreateCoreCommand->getContainer())); } else { CreateCommand = CreateFieldContainerCommand::create(type); cmdMgr->executeCommand(CreateCommand); } EditFieldHandlePtr TheFieldHandle = fc->editField(fieldID); EditMFieldHandle<FieldContainerPtrMFieldBase>* TheHandle(dynamic_cast<EditMFieldHandle<FieldContainerPtrMFieldBase>*>(TheFieldHandle.get())); if(index >= fc->getField(fieldID)->size() || !TheHandle->supportsInsert()) { //Set the value of the field AddFieldElementCommandPtr AddCommand = AddFieldElementCommand::create(fc, fieldID, boost::lexical_cast<std::string>(CreateCommand->getContainer()->getId())); cmdMgr->executeCommand(AddCommand); } else { //Set the value of the field InsertFieldElementCommandPtr InsertIndexCommand = InsertFieldElementCommand::create(fc, fieldID, boost::lexical_cast<std::string>(CreateCommand->getContainer()->getId()), index); cmdMgr->executeCommand(InsertIndexCommand); } }
void FCPtrFieldEditor::handleCreateContainerDialogClosed(DialogWindowEventDetails* const details) { if(details->getOption() != DialogWindowEventDetails::DIALOG_OPTION_CANCEL) { const FieldContainerType* ThePtrType(getFieldContainerTypeFromPtrType(getEditingFC()->getFieldDescription(getEditingFieldId())->getFieldType().getContentType())); const FieldContainerType* TheType(FieldContainerFactory::the()->findType(details->getInput().c_str())); if(TheType != NULL) { //Create the Container CreateFieldContainerCommandPtr CreateCommand; //If the type is a node, then create a NodeCore instead //and then insert it as the core of a newly created node if(*ThePtrType == Node::getClassType()) { CreateFieldContainerCommandPtr CreateCoreCommand = CreateFieldContainerCommand::create(TheType); getCommandManager()->executeCommand(CreateCoreCommand); CreateCommand = CreateFieldContainerCommand::create(&Node::getClassType()); getCommandManager()->executeCommand(CreateCommand); dynamic_cast<Node*>(CreateCommand->getContainer())->setCore(dynamic_cast<NodeCore*>(CreateCoreCommand->getContainer())); } else { CreateCommand = CreateFieldContainerCommand::create(TheType); getCommandManager()->executeCommand(CreateCommand); } //Set the value of the field SetFieldValueCommandPtr SetCommand = SetFieldValueCommand::create(getEditingFC(), getEditingFieldId(), boost::lexical_cast<std::string>(CreateCommand->getContainer()->getId()), getEditingFieldIndex()); getCommandManager()->executeCommand(SetCommand); } } _CreateContainerDialogClosedConnection.disconnect(); }