void HierarchyUI::showHierarchy(Lumix::Entity entity, bool has_parent)
{
	auto* hierarchy = m_editor->getHierarchy();
	char name[50];
	getEntityListDisplayName(*m_editor, name, sizeof(name), entity);
	ImGui::BulletText(name);
	if (has_parent)
	{
		ImGui::SameLine();

		if (ImGui::Button(StringBuilder<50>("Remove##r") << entity))
		{
			auto* command = m_editor->getAllocator().newObject<SetParentEditorCommand>(
				*m_editor, *hierarchy, entity, -1);
			m_editor->executeCommand(command);
		}
	}
	auto* children = hierarchy->getChildren(entity);

	if (!children || children->empty()) return;

	ImGui::Indent();
	for (auto c : *children)
	{
		showHierarchy(c.m_entity, true);
	}
	ImGui::Unindent();
}
void HierarchyUI::onGUI()
{
	if (!m_is_opened) return;

	if (!ImGui::Begin("Hierarchy", &m_is_opened))
	{
		ImGui::End();
		return;
	}

	auto* hierarchy = m_editor->getHierarchy();

	if (m_editor->getSelectedEntities().size() == 2)
	{
		if (ImGui::Button("Connect selected entities"))
		{
			auto* command =
				m_editor->getAllocator().newObject<SetParentEditorCommand>(*m_editor,
				*hierarchy,
				m_editor->getSelectedEntities()[0],
				m_editor->getSelectedEntities()[1]);
			m_editor->executeCommand(command);
		}
	}
	else
	{
		ImGui::Text("Select two entities to connect them");
	}

	ImGui::Separator();

	if (ImGui::BeginChild("hierarchy_view"))
	{
		const auto& all_children = hierarchy->getAllChildren();
		for (auto i = all_children.begin(), e = all_children.end(); i != e; ++i)
		{
			if ((*i.value()).empty()) continue;
			if (hierarchy->getParent(i.key()) < 0) showHierarchy(i.key(), false);
		}
	}
	ImGui::EndChild();

	ImGui::End();
}
Exemple #3
0
/* setRequest
**
** Purpose:
**	To build the N-SET response message and send it back to the
**	requesting SCU.
**
** Parameter Dictionary:
**	association	The key which describes the association
**	ctx		Pointer to the context for this command
**	request		Pointer to the N-SET request message
**
** Return Values:
**	SRV_NORMAL under error free conditions
**
**	SRV_CALLBACKABORTEDSERVICE
**	SRV_ILLEGALPARAMETER
**	SRV_NOCALLBACK
**	SRV_NORMAL
**	SRV_OBJECTBUILDFAILED
**	SRV_RESPONSEFAILED
**
** Algorithm:
**	First determine for which SOP Class, the request has arrived.
**	Accordingly call SRV_NSetResponse with the appropriate
**	call back function.
*/
CONDITION
setRequest(DUL_ASSOCIATIONKEY ** association,
	   DUL_PRESENTATIONCONTEXT * ctx, MSG_N_SET_REQ ** request,
	   CTNBOOLEAN * sendBack)
{
    MSG_N_SET_RESP
	setResponse;
    CONDITION
	cond = SRV_NORMAL;

    /* clear the contents of the response message */
    memset((void *) &setResponse, 0, sizeof(MSG_N_SET_RESP));

    /*
     * Here we first need to find out for which SOP class, the SET request
     * has arrived
     */
    if (strcmp((*request)->classUID,
	       DICOM_SOPCLASSBASICGREYSCALEIMAGEBOX) == 0) {
	(void) COND_PopCondition(TRUE);
	cond = SRV_NSetResponse(association, ctx, request, &setResponse,
				nsetImageBoxCallback, sendBack, ".");
	if (cond != SRV_NORMAL) {
	    printf("In setRequest : SRV_NSetResponse failed\n");
	    return cond;
	}
	if (traceFlag) {
	    printf("AFTER setting attributes of Grayscale IMAGE BOX\n");
	    showHierarchy();
	}
	return cond;
    } else if (strcmp((*request)->classUID,
		      DICOM_SOPCLASSBASICCOLORIMAGEBOX) == 0) {
	(void) COND_PopCondition(TRUE);
	cond = SRV_NSetResponse(association, ctx, request, &setResponse,
				nsetImageBoxCallback, sendBack, ".");
	if (cond != SRV_NORMAL) {
	    printf("In setRequest : SRV_NSetResponse failed\n");
	    return cond;
	}
	if (traceFlag) {
	    printf("AFTER setting attributes of Color IMAGE BOX\n");
	    showHierarchy();
	}
	return cond;
    } else if (strcmp((*request)->classUID,
		      DICOM_SOPCLASSBASICFILMSESSION) == 0) {
	(void) COND_PopCondition(TRUE);
	cond = SRV_NSetResponse(association, ctx, request, &setResponse,
				nsetBFSCallback, sendBack, ".");
	if (cond != SRV_NORMAL) {
	    printf("In setRequest : SRV_NSetResponse failed\n");
	    return cond;
	}
	if (traceFlag) {
	    printf("AFTER setting attributes of BASIC FILM SESSION\n");
	    showHierarchy();
	}
	return cond;
#ifdef ASG
    } else if (strcmp((*request)->classUID,
		      DICOM_SOPCLASSBASICFILMBOX) == 0) {
	(void) COND_PopCondition(TRUE);
	cond = SRV_NSetResponse(association, ctx, request, &setResponse,
				nsetBFBCallback, sendBack, ".");
	if (cond != SRV_NORMAL) {
	    printf("In setRequest : SRV_NSetResponse failed\n");
	    return cond;
	}
	if (traceFlag) {
	    printf("AFTER setting attributes of BASIC FILM BOX\n");
	    showHierarchy();
	}
	return cond;
#endif
    } else {
	/* unsupported command for the given SOP class */
	cond = SRV_NSetResponse(association, ctx, request, &setResponse,
				unsupportedCallback, sendBack, ".");
	if (cond != SRV_NORMAL) {
	    printf("In setRequest : SRV_NSetResponse failed\n");
	    return cond;
	}
	return cond;
    }
}