Ejemplo n.º 1
0
void DGameTree::SetViewStyle(GameListStyle newStyle)
{
	if (newStyle == STYLE_LIST)
	{
		m_current_style = STYLE_LIST;
		setIndentation(0);
		RebuildTree();
	}
	else
	{
		m_current_style = STYLE_TREE;
		setIndentation(20);
		RebuildTree();
	}
}
Ejemplo n.º 2
0
void DGameTree::AddGame(GameFile* item)
{
	if (m_items.values().contains(item))
		return;

	QString folder = item->GetFolderName();
	if (!m_path_nodes.contains(folder))
	{
		QTreeWidgetItem* i = new QTreeWidgetItem;
		i->setText(0, folder);
		m_path_nodes.insert(folder, i);
		if (m_current_style == STYLE_TREE)
			addTopLevelItem(i);
	}

	QTreeWidgetItem* i = new QTreeWidgetItem;
	i->setIcon(COL_TYPE, QIcon(Resources::GetPlatformPixmap(item->GetPlatform())));
	i->setIcon(COL_BANNER, QIcon(item->GetBitmap()));
	i->setText(COL_TITLE, item->GetName(true));
	i->setText(COL_DESCRIPTION, item->GetDescription());
	i->setIcon(COL_REGION, QIcon(Resources::GetRegionPixmap(item->GetCountry())));
	i->setText(COL_SIZE, NiceSizeFormat(item->GetFileSize()));
	i->setIcon(COL_STATE, QIcon(Resources::GetRatingPixmap(item->GetEmuState())));
	if (item->IsCompressed())
	{
		for (int col = 0; col < columnCount(); col++)
			i->setTextColor(col, QColor("#00F"));
	}
	m_items.insert(i, item);

	RebuildTree(); // TODO: only call this once per group of items added
}
Ejemplo n.º 3
0
void HuffmanCoDec::UpdateModel( int nextSymbol )
{
	int currentNode;
	int newNode;

	if ( nodes[ iROOT_NODE ].dwWeight == ( DWORD )iMAX_WEIGHT )
		RebuildTree();

	currentNode = iLeaf[ nextSymbol ];
	while( currentNode != -1 )
	{
		nodes[ currentNode ].dwWeight++;
		for( newNode = currentNode; newNode > iROOT_NODE; newNode-- )
		{
			if ( nodes[ newNode - 1 ].dwWeight >= nodes[ currentNode ].dwWeight )
				break;
		}

		if ( currentNode != newNode )
		{
			SwapNodes( currentNode, newNode );
			currentNode = newNode;
		}

		currentNode = nodes[ currentNode ].iParent;
	}

#ifdef _DEBUG
	VerifyTree();
#endif
}
Ejemplo n.º 4
0
// ----------------------------------------------------------------------------
void IKSolver::Solve()
{
    URHO3D_PROFILE(IKSolve);

    if (treeNeedsRebuild)
        RebuildTree();

    if (chainTreesNeedUpdating_)
        RebuildChainTrees();

    if (IsSolverTreeValid() == false)
        return;

    if (features_ & UPDATE_ORIGINAL_POSE)
        ApplySceneToOriginalPose();

    if (features_ & UPDATE_ACTIVE_POSE)
        ApplySceneToActivePose();

    if (features_ & USE_ORIGINAL_POSE)
        ApplyOriginalPoseToActivePose();

    for (auto & it : effectorList_)
    {
        it->UpdateTargetNodePosition();
    }

    ik_solver_solve(solver_);

    if (features_ & JOINT_ROTATIONS)
        ik_solver_calculate_joint_rotations(solver_);

    ApplyActivePoseToScene();
}
Ejemplo n.º 5
0
// ----------------------------------------------------------------------------
void IKSolver::SetAlgorithm(IKSolver::Algorithm algorithm)
{
    algorithm_ = algorithm;

    /* We need to rebuild the tree so make sure that the scene is in the
     * initial pose when this occurs.*/
    if (node_ != nullptr)
        ApplyOriginalPoseToScene();

    // Initial flags for when there is no solver to destroy
    uint8_t initialFlags = 0;

    // Destroys the tree and the solver
    if (solver_ != nullptr)
    {
        initialFlags = solver_->flags;
        DestroyTree();
        ik_solver_destroy(solver_);
    }

    switch (algorithm_)
    {
        case ONE_BONE : solver_ = ik_solver_create(SOLVER_ONE_BONE); break;
        case TWO_BONE : solver_ = ik_solver_create(SOLVER_TWO_BONE); break;
        case FABRIK   : solver_ = ik_solver_create(SOLVER_FABRIK);   break;
        /*case MSD      : solver_ = ik_solver_create(SOLVER_MSD);      break;*/
    }

    solver_->flags = initialFlags;

    if (node_ != nullptr)
        RebuildTree();
}
Ejemplo n.º 6
0
// ----------------------------------------------------------------------------
void IKSolver::OnNodeSet(Node* node)
{
    ApplyOriginalPoseToScene();
    DestroyTree();

    if (node != nullptr)
        RebuildTree();
}
Ejemplo n.º 7
0
	void btnRemove_OnClick(CCtrlFilterListView *)
	{
		int idx = m_lstNotes.GetCurSel();
		if (idx != LB_ERR) {
			if (CNoteItem *pItem = (CNoteItem *)m_lstNotes.GetItemData(idx)) {
				m_lstNotes.DeleteString(idx);
				m_proto->m_notes.remove(pItem);
			}
			RebuildTree();
		}
		EnableControls();
	}
Ejemplo n.º 8
0
	void btnEdit_OnClick(CCtrlFilterListView *)
	{
		int idx = m_lstNotes.GetCurSel();
		if (idx != LB_ERR) {
			if (CNoteItem *pItem = (CNoteItem *)m_lstNotes.GetItemData(idx)) {
				CJabberDlgNoteItem dlg(this, pItem);
				if (dlg.DoModal()) {
					m_proto->m_notes.Modify();
					RebuildTree();
				}
			}
		}
		EnableControls();
	}
Ejemplo n.º 9
0
BOOL DlgConfigDevices::OnInitDialog() 
{
	CDialog::OnInitDialog();

	m_image_list.Create(16, 16, ILC_COLOR4, 0, 2);
	m_bitmap_device.LoadBitmap(IDB_BITMAP_DEVICE);
	m_bitmap_channel.LoadBitmap(IDB_BITMAP_CHANNEL);
	m_image_list.Add(&m_bitmap_device, 0x01);
	m_image_list.Add(&m_bitmap_channel, 0x01);

	m_devices_tree.SetImageList(&m_image_list, TVSIL_NORMAL);

	{
		CHECK(SERV_current_device_cfg != NULL);
		MutexWrap cfg_access(SERV_current_device_cfg_mutex);
		m_tmp_cfg = SERV_current_device_cfg->MakeCopy();
	}

	RebuildTree();
	return TRUE;
}
Ejemplo n.º 10
0
void KX_Terrain::NextFront()
{
	feenableexcept(FE_INVALID | FE_OVERFLOW);
	// Construction d'un nouveau front si celui ci est vide.
	if (m_currentFront.empty()) {
		/* La cellule de collision actuelle est après la dernière.
		 * Cela signifie aussi que toutes les propagations de velocités des
		 * cellules en collisions ont été effectué.
		 * On peut donc appliquer la velocité au positions des cellules,
		 * reconstruire l'arbre et rechercher les cellules adjacentes.
		 */
		if (m_currentCollider >= m_colliders.size()) {
			// Reconstruction de l'arbre.
			RebuildTree();

#ifdef STOP_ON_FIRST_FRAME
			if (m_time > 1.0f) {
				fedisableexcept(FE_INVALID | FE_OVERFLOW);
				return;
			}
			else {
				for (KX_CellList::iterator it = m_cells.begin(), end = m_cells.end(); it != end; ++it) {
					KX_Cell *cell = *it;
					// Aplication de la vélocité sur la position de la cellule.
					cell->Translate(m_time);
					// Reservation des calques.
					cell->ResizeVelocityLayers(m_colliders.size());
					// Recherche de toutes les cellules adjacentes à celle ci.
					cell->FindAdjacents(m_tree, m_cells);
				}
			}
			std::cout << "=================== NEXT FRAME ====================" << std::endl;
#else
			for (KX_CellList::iterator it = m_cells.begin(), end = m_cells.end(); it != end; ++it) {
				KX_Cell *cell = *it;
				// Aplication de la vélocité sur la position de la cellule.
				cell->Translate(m_time);
				// Reservation des calques.
				cell->ResizeVelocityLayers(m_colliders.size());
				// Recherche de toutes les cellules adjacentes à celle ci.
				cell->FindAdjacents(m_tree, m_cells);
			}
#endif

			// On remet à la première cellule.
			m_currentCollider = 0;
			// On incremnte le temps.
			m_time += 1.0f;
		}

		// Toutes les cellules sont remit dans l'état non calculé.
		for (KX_CellList::iterator it = m_cells.begin(), end = m_cells.end(); it != end; ++it) {
			KX_Cell *cell = *it;
			cell->ResetComputed();
		}

		const KX_ColliderInfo& colliderInfo = m_colliders[m_currentCollider];
		KX_Cell *collider = colliderInfo.cell;
		MT_Vector3 velocity = colliderInfo.velocity;

		// Application d'une velocity par défaut aux cellules de collision.
		collider->AddVelocity(velocity, m_currentCollider);

		// Création du front originel contenant que la cellule en collision.
		m_currentFront.push_back(collider);
		++m_currentCollider;
	}

	for (KX_CellList::iterator it = m_currentFront.begin(), end = m_currentFront.end(); it != end; ++it) {
		KX_Cell *cell = *it;
		/* Porpagation de la vélocité de cette cellule au cellules
		 * adjacentes pas encore calculées.
		 */
		cell->PropagateVelocity(m_currentCollider - 1);
	}

	// Nouveau front temporaire.
	KX_CellList temporaryFront;
	// Ajout des cellules adjacentes au front non calculées.
	for (KX_CellList::iterator it = m_currentFront.begin(), end = m_currentFront.end(); it != end; ++it) {
		KX_Cell *cell = *it;
		cell->AppendAjacents(temporaryFront);
	}

	// Replacment de l'ancien front.
	m_currentFront = temporaryFront;
	fedisableexcept(FE_INVALID | FE_OVERFLOW);
}
Ejemplo n.º 11
0
void UzblTreeTab::Command(char* c)
{
    char** cmd = g_strsplit(c, " ", -1);
    do {
    if (!g_strcmp0(cmd[0], "new")) {
        if (cmd[1]) {
            char* u = g_strjoinv(" ",cmd+1);
            NewTab(u);
            g_free(u);
        }
        else 
            NewTab("about:blank");
        SaveSession();
    }
    if (!g_strcmp0(cmd[0], "cnew")) {
        if (cmd[2]) {
            int i = 0;
            for(GList* l = uzblinstances; l != NULL; l = g_list_next(l), i++) {
                UzblInstance* uzin = (UzblInstance*)l->data;
                if (!g_strcmp0(uzin->GetName(), cmd[1])) {
                    char* u = g_strjoinv(" ",cmd+2);
                    NewTab(u, i);
                    g_free(u);
                    break;
                }
            }
        }
        else 
            NewTab("about:blank", currenttab);
        SaveSession();
    }
    if (!g_strcmp0(cmd[0], "close")) {
        for(GList* l = uzblinstances; l != NULL; l = g_list_next(l)) {
            UzblInstance* uzin = (UzblInstance*)l->data;
            if (!g_strcmp0(uzin->GetName(), cmd[1])) {
                CloseTab(uzin, false);
                break;
            }
        }
    }
    if (!g_strcmp0(cmd[0], "treeclose")) {
        for(GList* l = uzblinstances; l != NULL; l = g_list_next(l)) {
            UzblInstance* uzin = (UzblInstance*)l->data;
            if (!g_strcmp0(uzin->GetName(), cmd[1])) {
                CloseTab(uzin, true);
                break;
            }
        }
    }
    if (!g_strcmp0(cmd[0], "next")) {
        GotoTab(currenttab+1);
    }
    if (!g_strcmp0(cmd[0], "prev")) {
        GotoTab(currenttab-1);
    }
    if (!g_strcmp0(cmd[0], "first")) {
        GotoTab(0);
    }
    if (!g_strcmp0(cmd[0], "last")) {
        GotoTab(totaltabs-1);
    }
    if (!g_strcmp0(cmd[0], "goto")) {
        int a;
        if (cmd[1]) {
            sscanf(cmd[1], "%d", &a);
            GotoTab(a);
        }
    }
    if (!g_strcmp0(cmd[0], "attach")) {
        int a;
        if (cmd[1]) {
            sscanf(cmd[1], "%d", &a);
            if (a > totaltabs)
                break;
            
            UzblInstance* cuz = (UzblInstance*)g_list_nth(uzblinstances, currenttab)->data;
            UzblInstance* puz = (UzblInstance*)g_list_nth(uzblinstances, a)->data;
            
            if (cuz == puz)
                break;
            
            if (cuz->GetNum() < puz->GetNum()) {
                uzblinstances = g_list_remove(uzblinstances, cuz);
                uzblinstances = g_list_insert(uzblinstances, cuz, puz->GetNum()+1);
            }
            
            cuz->SetParent(puz);
            RebuildTree();
            UpdateTablist();
            SaveSession();
        }
    }
    if (!g_strcmp0(cmd[0], "move")) {
        int a;
        if (cmd[1]) {
            sscanf(cmd[1], "%d", &a);
            UzblInstance* cuz = (UzblInstance*)g_list_nth(uzblinstances, currenttab)->data;
            uzblinstances = g_list_remove(uzblinstances, cuz);
            
            if (a > totaltabs)
                a = totaltabs;
            
            uzblinstances = g_list_insert(uzblinstances, cuz, a);
            currenttab = a;
            RebuildTree();
            UpdateTablist();
            SaveSession();
        }
    }
    if (!g_strcmp0(cmd[0], "tabtitle")) {
        for(GList* l = uzblinstances; l != NULL; l = g_list_next(l)) {
           if (!strcmp(cmd[1], ((UzblInstance*)l->data)->GetName())) {
               char* title = g_strjoinv(" ", cmd+2);
               ((UzblInstance*)l->data)->SetTitle(title);
               g_free(title);
           }
        }
        UpdateTablist();
    }
    if (!g_strcmp0(cmd[0], "taburi")) {
        for(GList* l = uzblinstances; l != NULL; l = g_list_next(l)) {
           if (!strcmp(cmd[1], ((UzblInstance*)l->data)->GetName())) {
               char* url = g_strjoinv(" ", cmd+2);
               ((UzblInstance*)l->data)->SetURL(url);
               g_free(url);
               SaveSession();
           }
        }
    }
    if (!g_strcmp0(cmd[0], "showtree")) {
        gtk_paned_set_position(pane, panepos);
    }
    if (!g_strcmp0(cmd[0], "hidetree")) {
        panepos = gtk_paned_get_position(pane);
        gtk_paned_set_position(pane, 0);
    }
    } while(0);
    g_strfreev(cmd);
}
Ejemplo n.º 12
0
void UzblTreeTab::CloseTab(UzblInstance* uz, bool closeall)
{
    closing = true;
    
    
    UzblInstance* nuz = NULL;
    UzblInstance* puz = uz->GetParent();
    if (puz) {
        if (g_list_length(puz->GetChildren()) > 1) {
            GList* l = g_list_find(puz->GetChildren(), uz);
            int len = g_list_length(puz->GetChildren())-1;
            if (g_list_position(puz->GetChildren(), l) == len) {
                nuz = ((UzblInstance*)g_list_nth(puz->GetChildren(), len-1)->data);
            }
            else {
                nuz = ((UzblInstance*)g_list_next(l)->data);
            }
        }
        else {
            nuz = puz;
        }
    }
    else {
        if (g_list_last(uzblinstances)->data != uz) {
            for(GList* l = g_list_last(uzblinstances); l != g_list_find(uzblinstances, uz); l = g_list_previous(l)) {
                UzblInstance* luz = (UzblInstance*)l->data;
                if (luz->GetParent() == NULL && luz != uz) {
                    nuz = luz;
                    //break;
                }
            }
        }
        else {
            for(GList* l = g_list_last(uzblinstances); l != g_list_first(uzblinstances); l = g_list_previous(l)) {
                UzblInstance* luz = (UzblInstance*)l->data;
                if (luz->GetParent() == NULL && luz != uz) {
                    nuz = luz;
                    break;
                }
            }
        }
    }
    
    if (closeall) {
        GList* todelete = NULL;
        for(GList* l = uzblinstances; l != NULL; l = g_list_next(l)) {
            UzblInstance* cuz = (UzblInstance*)l->data;
            UzblInstance* cuz2 = cuz;
            
            while (cuz2->GetParent() != uz && cuz2->GetParent() != NULL) {
                cuz2 = cuz2->GetParent();
            }
            if (cuz2->GetParent() != NULL) {
                todelete = g_list_append(todelete, cuz);
            }
        }
        for(GList* l = todelete; l != NULL; l = g_list_next(l)) {
            uzblinstances = g_list_remove(uzblinstances, l->data);
            delete (UzblInstance*)l->data;
        }
        
        uzblinstances = g_list_remove(uzblinstances, uz);
        delete uz;
        g_list_free(todelete);
    }
    else {
        UzblInstance* puz = uz->GetParent();
        GList* children = uz->GetChildren();
        for(GList* l = children; l != NULL; l = g_list_next(l)) {
            UzblInstance* cuz = (UzblInstance*)l->data;

            cuz->SetParent(puz);
        }
        uzblinstances = g_list_remove(uzblinstances, uz);
        delete uz;
    }
    
    RebuildTree();
    UpdateTablist();
    
    if (nuz)
        GotoTab(nuz->GetNum());
    else
        GotoTab(gtk_notebook_get_current_page(notebook));
    
    SaveSession();
    closing = false;
}
Ejemplo n.º 13
0
void CJabberDlgNotes::UpdateData()
{
	RebuildTree();
	//ListItems(NULL);
	EnableControls();
}