Exemplo n.º 1
0
Arquivo: ORTC.c Projeto: goncalor/ADRC
list * percolate_2_nodes(list * nodeA_list, list * nodeB_list)
{
    list * C = NULL;
    list * auxA = nodeA_list;
    list * auxB = nodeB_list;

    /* A#B = { intersection(A, B) if intersection(A, B) != empty set
    		  junction(A, B) if intersection(A, B) = empty set }

    A has interface list
    B has interface list

    create temporary list C

    for each element from A's list, if it is present on B's list add it to list C
    if no element from A's list exists on B's list, add both lists to C

    */

    /* fill list C if intersection(A, B) != empty set)  */
    while (auxA != NULL)
    {
        auxB = nodeB_list;
        while(auxB != NULL)
        {
            if(getItem(auxA) == getItem(auxB))
            {
                C = LSTadd(C, makeItem(getItem(auxA)));
            }
            auxB = LSTfollowing(auxB);
        }
        auxA = LSTfollowing(auxA);
    }

    auxA = nodeA_list;
    auxB = nodeB_list;

    /* if there were no matching elements from A's list and B's list, add both to C */
    if(C == NULL)
    {
        while (auxA != NULL)
        {
            C = LSTadd(C, makeItem(getItem(auxA)));
            auxA = LSTfollowing(auxA);
        }
        while (auxB != NULL)
        {
            C = LSTadd(C, makeItem(getItem(auxB)));
            auxB = LSTfollowing(auxB);
        }
    }

    return C;
}
Exemplo n.º 2
0
void addNodeItem(ML *E,char nombre[],char boleta[],char grupo[])
{
	if(!findSingleGroup(*E,grupo))
	{
		printf("\nEse grupo no existe.\n");
		return;
	}


	MR *group_pointer;
	MD *newNode,*current;

	group_pointer = findGroup(*E,grupo);

	newNode = makeItem(nombre,boleta);


	if(group_pointer->listDown == NULL)
	{
		group_pointer->listDown = newNode;
		return;
	}

	/*Si la lista no esta vacía. Insertamos el nodo en la posición según el orden ascendente en la lista */

	current = group_pointer->listDown;

	/*Agregamos nodo al principio de la lista no vacia*/

	if(current == group_pointer->listDown)
	{
		newNode->nextDown = group_pointer->listDown; // NULL
		group_pointer->listDown = newNode;
	}
}
Exemplo n.º 3
0
Arquivo: ORTC.c Projeto: goncalor/ADRC
void printToFile(node * tree, FILE * destination_file)
{
    list * queue_aux = queue;

    if (getItem(tree->interface_list) != -1) // if this node has a next-hop, write it to the file
    {
        queue_aux = queue;
        if(queue_aux == NULL) // still at root node, print '*' to simbolize default next-hop
        {
            fprintf(destination_file, "*\t%hd\n", *(short*)LSTgetitem(tree->interface_list));
        }
        else
        {   /* ugly hacks here to change LIFO to FIFO */
            list * queue_fix_head = NULL;
            list * queue_fix = NULL;
            while(queue_aux != NULL) // not root, print the prefix (path taken) of the next-hop
            {
                queue_fix = LSTadd(queue_fix, makeItem(*(short*)LSTgetitem(queue_aux)));
                queue_aux = LSTfollowing(queue_aux);
            }
            queue_fix_head = queue_fix;
            while(queue_fix != NULL) // not root, print the prefix (path taken) of the next-hop
            {
                fprintf(destination_file, "%hd", *(short*)LSTgetitem(queue_fix));
                queue_fix = LSTfollowing(queue_fix);
            }

            LSTdestroy(queue_fix_head, destroyItem);
            fprintf(destination_file, "\t%hd\n", *(short*)LSTgetitem(tree->interface_list)); // print the next-hop itself and change line
        }
    }

    // do the same for the rest of the tree
    if(tree->left != NULL)
    {
        queue = LSTadd(queue, makeItem(0));
        printToFile(tree->left, destination_file);
    }
    if(tree->right != NULL)
    {
        queue = LSTadd(queue, makeItem(1));
        printToFile(tree->right, destination_file);
    }

    // going back up, remove the last entered bit of the prefix
    queue = LSTremove(NULL, queue, destroyItem);
}
Exemplo n.º 4
0
LRESULT ToolbarPage::onInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	PropPage::translate((HWND)(*this), texts);
	PropPage::read((HWND)*this, items);
	
	ctrlCommands.Attach(GetDlgItem(IDC_TOOLBAR_POSSIBLE));
	CRect rc;
	ctrlCommands.GetClientRect(rc);
	ctrlCommands.InsertColumn(0, _T("Dummy"), LVCFMT_LEFT, rc.Width(), 0);

	ctrlCommands.SetImageList(MainFrame::getMainFrame()->ToolbarImages, LVSIL_SMALL);
		

	LVITEM lvi;
	lvi.mask = LVIF_TEXT | LVIF_IMAGE;
	lvi.iSubItem = 0;

	for(int i = -1; i < static_cast<int>(sizeof(ToolbarButtons) / sizeof(ToolbarButtons[0])); i++) {
		makeItem(&lvi, i);
		lvi.iItem = i+1;
		ctrlCommands.InsertItem(&lvi);
		ctrlCommands.SetItemData(lvi.iItem, i);
	}
	ctrlCommands.SetColumnWidth(0, LVSCW_AUTOSIZE);

	ctrlToolbar.Attach(GetDlgItem(IDC_TOOLBAR_ACTUAL));
	ctrlToolbar.GetClientRect(rc);
	ctrlToolbar.InsertColumn(0, _T("Dummy"), LVCFMT_LEFT, rc.Width(), 0);
	ctrlToolbar.SetImageList(MainFrame::getMainFrame()->ToolbarImages, LVSIL_SMALL);
	
	StringTokenizer<string> t(SETTING(TOOLBAR_ORDER), ',');
	StringList& l = t.getTokens();

	int n = 0;
	for(StringList::const_iterator k = l.begin(); k != l.end(); ++k) {
		int i = Util::toInt(*k);
		makeItem(&lvi, i);
		lvi.iItem = n++;
		ctrlToolbar.InsertItem(&lvi);
		ctrlToolbar.SetItemData(lvi.iItem, i);
	}

	ctrlToolbar.SetColumnWidth(0, LVSCW_AUTOSIZE);

	return TRUE;
}
Exemplo n.º 5
0
Arquivo: ORTC.c Projeto: goncalor/ADRC
void clean_redundancy(node * tree, list * ancestor_interfaces)
{
    if(tree == NULL)
        return;


    /* For each child, if it has a matching interface with it's parent,
       delete it's own list and tell it's own children
       (keep a memory of the last ancestor that didn't delete it's own list) */


    list * aux_self = tree->interface_list;
    list * aux_ancestor = ancestor_interfaces;
    list * temp = NULL;
    short match_found = 0;

    /* see if there are matching interfaces between current node and ancestor */
    while(aux_ancestor != NULL && match_found == 0)
    {
        aux_self = tree->interface_list;
        while(aux_self != NULL && match_found == 0)
        {
            if(getItem(aux_self) == getItem(aux_ancestor)) // match found, delete current node interfaces to avoid redundancy
            {
                LSTdestroy(tree->interface_list, destroyItem);
                tree->interface_list = NULL;
                match_found = 1;
            }
            aux_self = LSTfollowing(aux_self);
        }
        aux_ancestor = LSTfollowing(aux_ancestor);
    }

    /* no matches found, choose a random interface from the node (first is fine, no need for actual random choice) */
    if(match_found == 0)
    {
        temp = LSTadd(NULL, makeItem(getItem(tree->interface_list)));
        LSTdestroy(tree->interface_list, destroyItem);
        tree->interface_list = temp;
    }


    if(match_found == 1)
    {
        clean_redundancy(tree->left, ancestor_interfaces);
        clean_redundancy(tree->right, ancestor_interfaces);
    }
    else
    {
        clean_redundancy(tree->left, tree->interface_list);
        clean_redundancy(tree->right, tree->interface_list);
    }
}
Exemplo n.º 6
0
/**
	@param project A standard project.
	@param created if provided with a pointer to a boolean, this method will
	update it to reflect whether the returned item has been freshly created or
	not.
	@return the tree item representing the provided project. If it does not
	appear within this panel, it is created.
*/
QTreeWidgetItem *GenericPanel::getItemForProject(QETProject *project, bool *created) {
	if (!project) return(0);
	
	QTreeWidgetItem *project_qtwi = projects_.value(project, 0);
	if (project_qtwi) {
		if (created) *created = false;
		return(project_qtwi);
	}
	
	project_qtwi = makeItem(QET::Project);
	if (created) *created = true;
	return(project_qtwi);
}
Exemplo n.º 7
0
LRESULT ToolbarPage::onAdd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
	if(ctrlCommands.GetSelectedCount() == 1) {				
		LVITEM lvi;
		lvi.mask = LVIF_TEXT | LVIF_IMAGE;
		lvi.iSubItem = 0;
		int i = ctrlCommands.GetItemData(ctrlCommands.GetSelectedIndex());
		makeItem(&lvi, i);
		lvi.iItem = ctrlToolbar.GetSelectedIndex() + 1;//ctrlToolbar.GetSelectedIndex()>0?ctrlToolbar.GetSelectedIndex():ctrlToolbar.GetItemCount();
		ctrlToolbar.InsertItem(&lvi);
		ctrlToolbar.SetItemData(lvi.iItem, i);
	}
	return 0;
}
Exemplo n.º 8
0
Arquivo: ORTC.c Projeto: goncalor/ADRC
node *create_node(void)
{
    node *aux = malloc(sizeof(node));
    if(aux==NULL)
    {
        puts("ERROR: Unable to allocate memory.");
        exit(-1);
    }

    aux->interface_list = LSTadd(NULL, makeItem(DISCARD_VAL));
    aux->right = aux->left = NULL;
    return aux;
}
Exemplo n.º 9
0
LRESULT ToolbarPage::onAdd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	if (m_ctrlCommands.GetSelectedCount() == 1)
	{
		int iSelectedInd = m_ctrlCommands.GetSelectedIndex();
		bool bAlreadyExist = false;
		
		if (iSelectedInd != 0)
		{
			LVFINDINFO lvifi = { 0 };
			lvifi.flags  = LVFI_PARAM;
			lvifi.lParam = iSelectedInd - 1;
			const int iFoundInd = m_ctrlToolbar.FindItem(&lvifi, -1);
			
			if (iFoundInd != -1)
			{
				// item already in toolbar,
				// don't add new item, but hilite old one
				m_ctrlToolbar.SetItemState(iFoundInd, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
				bAlreadyExist = true;
			}
		}
		
		if (!bAlreadyExist)
		{
			// add new item to toolbar
			
			LVITEM lvi = {0};
			lvi.mask = LVIF_TEXT | LVIF_IMAGE;
			lvi.iSubItem = 0;
			const int i = m_ctrlCommands.GetItemData(iSelectedInd);
			makeItem(&lvi, i);
			lvi.iItem = m_ctrlToolbar.GetSelectedIndex() + 1;//ctrlToolbar.GetSelectedIndex()>0?ctrlToolbar.GetSelectedIndex():ctrlToolbar.GetItemCount();
			m_ctrlToolbar.InsertItem(&lvi);
			m_ctrlToolbar.SetItemData(lvi.iItem, i);
			m_ctrlCommands.SetItemState(i + 1, LVIS_CUT, LVIS_CUT);
		}
	}
	return 0;
}
Exemplo n.º 10
0
bool HelpScene::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
    touched = false;
    Size visibleSize = Director::getInstance()->getVisibleSize();

    //setKeyboardEnabled(true);
    auto keyboard = EventListenerKeyboard::create();
    keyboard->onKeyReleased = CC_CALLBACK_2(HelpScene::onKeyReleased, this);
    getEventDispatcher()->addEventListenerWithSceneGraphPriority(keyboard, this);

    //setTouchEnabled(true);
    auto listener = EventListenerTouchOneByOne::create();
    listener->onTouchBegan = CC_CALLBACK_2(HelpScene::onTouchBegan, this);
    listener->onTouchMoved = CC_CALLBACK_2(HelpScene::onTouchMoved, this);
    listener->onTouchEnded = CC_CALLBACK_2(HelpScene::onTouchEnded, this);
    getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);

    addChild(BackgroundWidget::create("bg", Color3B(20, 20, 80)));

    addChild(Vignette::create());

    auto layer = Layer::create();
    layer->setTag(1);
    addChild(layer);

    auto bg = LayerColor::create(C4Fto4B(0.12f, 0.02f, 0.15f, 1.0f), visibleSize.width, visibleSize.height);
    bg->setPositionY(PY(0.82f));
    addChild(bg);

    auto hooker = TopAnchor::create();
    addChild(hooker, 1);
    auto pMenu = Menu::create();
    pMenu->setPosition(Point::ZERO);
    //hooker->addChild(bg);
    hooker->addChild(pMenu);

    auto txt1 = Label::createWithTTF(LS("HowToPlay"), NORMAL_TTF, 48.0f);
    txt1->setPosition(VCP(0.22f, 0.935f));
    txt1->setAnchorPoint(Point(0, 0.5f));
    txt1->setHorizontalAlignment(TextHAlignment::LEFT);
    txt1->setColor(Color3B::WHITE);

    hooker->addChild(txt1);
    //addChild(txt1, 5);

    auto btnBack = MAKEBUTTON("btnBackBlackUp", "btnBackBlackDn", HelpScene::btnBackPressed);
    pMenu->addChild(btnBack, 2);
    btnBack->setPosition(VCP(0.03f, 0.935f));
    btnBack->setAnchorPoint(Point(0, 0.5f));

    auto playerLayer = makeItem("manRt1", LS("HelpPlayer"), '@');
    playerLayer->setPosition(CP(0.2f, 0.80f));
    layer->addChild(playerLayer);

    auto robotLayer = makeItem("robot", LS("HelpRobot"), 'R');
    robotLayer->setPosition(CP(0.2f, 0.50f));
    robotLayer->SPRITEREF->runAction(
        RepeatForever::create(Sequence::createWithTwoActions(
                                  ScaleTo::create(1.0f, 1.0f), ScaleTo::create(1.0f, 0.9f)
                              )));
    layer->addChild(robotLayer);

    auto holeLayer = makeItem("hazard", LS("HelpBlackhole"), '!');
    holeLayer->setPosition(CP(0.2f, 0.10f));
    holeLayer->SPRITEREF->runAction(RepeatForever::create(RotateBy::create(2.0f, 365.0f)));
    holeLayer->SPRITEREF->runAction(RepeatForever::create(Sequence::createWithTwoActions(
                                        TintTo::create(0.5f, 210, 255, 255), TintTo::create(0.5f, 255, 0, 0)
                                    )));
    layer->addChild(holeLayer);

    auto starLayer = makeItem("dronesGoal", LS("HelpStar"), 'X');
    starLayer->setPosition(CP(0.2f, -0.10f));
    starLayer->SPRITEREF->runAction(RepeatForever::create(Sequence::createWithTwoActions(
                                        TintTo::create(1.0f, 255, 255, 255), TintTo::create(1.0f, 255, 255, 0)
                                    )));
    starLayer->SPRITEREF->runAction(RepeatForever::create(Sequence::createWithTwoActions(
                                        DelayTime::create(10.0f), RotateBy::create(1.0, -360)
                                    )));
    layer->addChild(starLayer);

    auto gemLayer = makeItem("gem", LS("HelpGem"), 'g');
    gemLayer->setPosition(CP(0.2f, -0.30f));
    layer->addChild(gemLayer);

    auto creditsY = -0.20f;

    auto creditsLayer3 = makeText(LS("HelpConclusion"), 38.0f);
    creditsLayer3->setPosition(CP(0.5f, creditsY-0.3f));
    creditsLayer3->setHorizontalAlignment(TextHAlignment::CENTER);
    creditsLayer3->setAnchorPoint(Point(0.5f, 1.0f));
    layer->addChild(creditsLayer3);

    auto facebook = MAKESPRITE("facebook");
    facebook->setPosition(CP(0.5f, creditsY - 0.6f));
    layer->addChild(facebook);
    return true;
}
Exemplo n.º 11
0
 GraphicsItem6() : GraphicsItem(3){
     makeItem();
 }
Exemplo n.º 12
0
 GraphicsItem5() : GraphicsItem(2){
     makeItem();
 }
Exemplo n.º 13
0
 GraphicsItem2() : GraphicsItem(4),index(0) { makeItem();}
Exemplo n.º 14
0
LRESULT ToolbarPage::onInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	PropPage::translate((HWND)(*this), texts);
	PropPage::read((HWND)*this, items);
	
	m_ctrlCommands.Attach(GetDlgItem(IDC_TOOLBAR_POSSIBLE));
	CRect rc;
	m_ctrlCommands.GetClientRect(rc);
	m_ctrlCommands.InsertColumn(0, _T("Dummy"), LVCFMT_LEFT, rc.Width(), 0);
	
	m_ctrlCommands.SetImageList(MainFrame::getMainFrame()->largeImages, LVSIL_SMALL);
	
	
	LVITEM lvi = {0};
	lvi.mask = LVIF_TEXT | LVIF_IMAGE;
	lvi.iSubItem = 0;
	
	for (int i = -1; i < 0 || g_ToolbarButtons[i].id != 0; i++)
	{
// [-] brain-ripper
// follow block commented,
// it can brake custom toolbar creation.
// don't do this!
		/*
		#ifndef IRAINMAN_ENABLE_HUB_LIST
		        if (!i)
		            continue;
		#endif
		*/
		makeItem(&lvi, i);
		lvi.iItem = i + 1;
		m_ctrlCommands.InsertItem(&lvi);
		m_ctrlCommands.SetItemData(lvi.iItem, i);
	}
	m_ctrlCommands.SetColumnWidth(0, LVSCW_AUTOSIZE);
	
	m_ctrlToolbar.Attach(GetDlgItem(IDC_TOOLBAR_ACTUAL));
	m_ctrlToolbar.GetClientRect(rc);
	m_ctrlToolbar.InsertColumn(0, _T("Dummy"), LVCFMT_LEFT, rc.Width(), 0);
	m_ctrlToolbar.SetImageList(MainFrame::getMainFrame()->largeImagesHot, LVSIL_SMALL);
	
	const StringTokenizer<string> t(SETTING(TOOLBAR), ',');
	const StringList& l = t.getTokens();
	
	int n = 0;
	for (auto k = l.cbegin(); k != l.cend(); ++k)
	{
		int i = Util::toInt(*k);
		const int l_cnt = g_cout_of_ToolbarButtons;
		if (i < l_cnt)
		{
			makeItem(&lvi, i);
			lvi.iItem = n++;
			m_ctrlToolbar.InsertItem(&lvi);
			m_ctrlToolbar.SetItemData(lvi.iItem, i);
			
			// disable items that are already in toolbar,
			// to avoid duplicates
			if (i != -1)
				m_ctrlCommands.SetItemState(i + 1, LVIS_CUT, LVIS_CUT);
		}
	}
	
	m_ctrlToolbar.SetColumnWidth(0, LVSCW_AUTOSIZE);
	
	return TRUE;
}
Exemplo n.º 15
0
void MenuManager::setupMenus( Browse * client )
//---------------------------------------------
{
    int             i;
    WPopupMenu *    pop;
    WPopupMenu *    subPop;
    WMenu *         menu;

    _clientWin = client;
    menu = new WMenu;

    typedef WPopupMenu * popMenuStar;   // to use new []

    _topMenus = new popMenuStar[ MMNumMainMenus + CMNumCascadeMenus ];
    _receivers = new WCValHashDict< MIMenuID, MenuHandler * >( &MenuHash );

    for( i = 0; i < MMNumMainMenus; i += 1 ) {
        if( i == MMWindows ) {
            // Windows menu handled by WCLASS
            _topMenus[ i ] = NULL;
        } else {
            _topMenus[ i ] = new WPopupMenu( MainMenuInfo[ i ].menuName );
            _topMenus[ i ]->onPopup( this, (cbp) &MenuManager::menuPopup );
        }
    }

    for( i = 0; i < CMNumCascadeMenus; i += 1 ) {
        _topMenus[ i + MMNumMainMenus ] = new WPopupMenu( CascadeMenuInfo[ i ].menuName );
        _topMenus[ i + MMNumMainMenus ]->onPopup( this, (cbp) &MenuManager::menuPopup );
    }

    //------- File Menu ---------//
    pop = _topMenus[ MMFile ];
    menu->insertPopup( pop );
    for( i = 0; i < FMNumFileMenus; i += 1 ) {
        makeItem( pop, FileMenuInfo, i );
    }

    //-------  View Menu --------//
    pop = _topMenus[ MMView ];
    menu->insertPopup( pop );
    makeItem( pop, ViewMenuInfo, VMList );

    subPop = _topMenus[ CMViewInherit ];
    pop->insertPopup( subPop );
    for( i = 0; i < VMNumViewInheritMenus; i += 1 ) {
        makeItem( subPop, ViewInheritMenuInfo, i );
    }

    subPop = _topMenus[ CMViewCall ];
    pop->insertPopup( subPop );
    for( i = 0; i < VMNumViewCallMenus; i += 1 ) {
        makeItem( subPop, ViewCallMenuInfo, i );
    }

    //------- Detail Menu ---------//
    pop = _topMenus[ MMDetail ];
    menu->insertPopup( pop );
    for( i = 0; i < DMNumDetailMenus; i += 1 ) {
        makeItem( pop, DetailMenuInfo, i );
    }

    //------- Tree Menu ---------//
    pop = _topMenus[ MMTree ];
    menu->insertPopup( pop );
    for( i = 0; i < TMNumTreeMenus; i += 1 ) {
        makeItem( pop, TreeMenuInfo, i );
    }

    //------- Locate Menu ---------//
    pop = _topMenus[ MMLocate ];
    menu->insertPopup( pop );
    for( i = 0; i < LMNumLocateMenus; i += 1 ) {
        makeItem( pop, LocateMenuInfo, i );
    }

    //------- Options Menu ---------//
    pop = _topMenus[ MMOptions ];
    menu->insertPopup( pop );
    for( i = 0; i < OMNumOptionsMenus; i += 1 ) {
        makeItem( pop, OptionsMenuInfo, i );
    }

    //-------- Windows Menu ----------//
    // WCLASS handles this one for us //

    pop = _clientWin->getMdiPopup();
    menu->insertPopup( pop );

    //------- Help Menu ---------//
    pop = _topMenus[ MMHelp ];
    menu->insertPopup( pop );
    for( i = 0; i < HMNumHelpMenus; i += 1 ) {
        makeItem( pop, HelpMenuInfo, i );
    }

    _clientWin->setMenu( menu );

}