Exemplo n.º 1
0
// A function to insert first element of child to parent
node insertParent(node cur,int e,node sib)
{
	node temp=cur->p,temp2,temp1;
	int i=temp->num,t;
	
	//If the parent node has space
	
	if(temp->num<4)
	{
		while(temp->d[i-1]>e)
		{
			temp->d[i]=temp->d[i-1];
			temp->ptr[i+1]=temp->ptr[i];
			i--;
		}
		temp->d[i]=e;
		(temp->num)++;
		temp->ptr[i+1]=sib;
		sib->p=temp;
	}
	
	// If parent node is full
	
	else
	{
		temp2=makeNode();
		temp2->leaf=0;
		t=temp->d[2];
		temp2=split(temp,temp2);
		
		//If node in which to be inserted is 
		// root node then new root has to be
		// created
		
		if(temp->r==1)
		{
			temp1=makeNode();
			temp->r=0;
			temp1->r=1;
			temp->p=temp1;
			temp2->p=temp1;
			temp1->leaf=0;
			temp1->ptr[0]=temp;
			temp1->ptr[1]=temp2;
			temp1->d[0]=t;
			(temp1->num)++;
			root=temp1;
		}
		else
		{
			temp->p=insertParent(temp,t,temp2);	
		}
		sib->p=temp2;
		sib->p=insertParent(sib,sib->d[0],sib);
		
	}
	return cur->p;
}
Exemplo n.º 2
0
// A function to insert the element to the tree
node insertion(node cur,int e)
{	
	node sib,temp,r;
	
	// If node is not full
	
	if(cur->num<4)
	{
		cur=insertLeaf(cur,e);
		return cur;
	}
	
	//If node is full then split
	
	else if(cur->num==4)
	{
		sib=makeNode();
		sib=split(cur,sib);
		if(cur->leaf==1)
		{
			
			sib=insertLeaf(sib,e);
			// If node is root
			
			if(cur->r==1)
			{
				temp=makeNode();
				cur->r=0;
				temp->r=1;
				cur->p=temp;
				sib->p=temp;
				temp->leaf=0;
				temp->ptr[0]=cur;
				temp->ptr[1]=sib;
				temp->d[0]=sib->d[0];
				(temp->num)++;
				root=temp;
				return cur;
			}
			cur->p=insertParent(cur,sib->d[0],sib);
			return cur;
		}	
	}
}
Exemplo n.º 3
0
void MindMapWindow::createActions()
{
    // create mind map action
    _createMindMapAction = new QAction(tr("Create a new mind map"), this);
    _createMindMapAction->setIcon(QIcon("Resources\\new.png"));
    _createMindMapAction->setStatusTip(tr("create a new mind map"));
    connect(_createMindMapAction, SIGNAL(triggered()), this, SLOT(createMindMap()));
    // open mind map action
    _openMindMapAction = new QAction(tr("Open a new mind map"), this);
    _openMindMapAction->setIcon(QIcon("Resources\\open.png"));
    _openMindMapAction->setStatusTip(tr("open a new mind map"));
    connect(_openMindMapAction, SIGNAL(triggered()), this, SLOT(openMindMap()));
    // save mind map action
    _saveMindMapAction = new QAction(tr("Save a new mind map"), this);
    _saveMindMapAction->setIcon(QIcon("Resources\\save.png"));
    _saveMindMapAction->setStatusTip(tr("save a new mind map"));
    connect(_saveMindMapAction, SIGNAL(triggered()), this, SLOT(saveMindMap()));
    // exit action
    _exitAction = new QAction(tr("Exit"), this);
    _exitAction->setIcon(QIcon("Resources\\delete.png"));
    _exitAction->setStatusTip(tr("Exit"));
    connect(_exitAction, SIGNAL(triggered()), this, SLOT(exit()));
    // edit node action
    _editNodeAction = new QAction(tr("& Edit"), this);
    _editNodeAction->setIcon(QIcon("Resources\\edit.png"));
    _editNodeAction->setStatusTip(tr("Edit a node"));
    connect(_editNodeAction, SIGNAL(triggered()), this, SLOT(editNode()));
    // delete node action
    _deleteNodeAction = new QAction(tr("& Delete"), this);
    _deleteNodeAction->setIcon(QIcon("Resources\\delete.png"));
    _deleteNodeAction->setStatusTip(tr("Delete a node"));
    connect(_deleteNodeAction, SIGNAL(triggered()), this, SLOT(deleteNode()));
    // insert child action
    _insertChildAction = new QAction(tr("Insert a& Child"), this);
    _insertChildAction->setIcon(QIcon("Resources\\insertChild.png"));
    _insertChildAction->setStatusTip(tr("Insert a child"));
    connect(_insertChildAction, SIGNAL(triggered()), this, SLOT(insertChild()));
    // insert sibling action
    _insertSiblingAction = new QAction(tr("Insert a& Sibling"), this);
    _insertSiblingAction->setIcon(QIcon("Resources\\insertSibling.png"));
    _insertSiblingAction->setStatusTip(tr("Insert a sibling"));
    connect(_insertSiblingAction, SIGNAL(triggered()), this, SLOT(insertSibling()));
    // insert parent action
    _insertParentAction = new QAction(tr("Insert a& Parent"), this);
    _insertParentAction->setIcon(QIcon("Resources\\insertParent.png"));
    _insertParentAction->setStatusTip(tr("Insert a parent"));
    connect(_insertParentAction, SIGNAL(triggered()), this, SLOT(insertParent()));
    // cut action
    _cutAction = new QAction(tr("Cut"), this);
    _cutAction->setIcon(QIcon("Resources\\cut.png"));
    _cutAction->setStatusTip(tr("Cut"));
    connect(_cutAction, SIGNAL(triggered()), this, SLOT(cut()));
    // copy action
    _copyAction = new QAction(tr("Copy"), this);
    _copyAction->setIcon(QIcon("Resources\\copy.png"));
    _copyAction->setStatusTip(tr("Copy"));
    connect(_copyAction, SIGNAL(triggered()), this, SLOT(copy()));
    // paste action
    _pasteAction = new QAction(tr("Paste"), this);
    _pasteAction->setIcon(QIcon("Resources\\paste.png"));
    _pasteAction->setStatusTip(tr("Paste"));
    connect(_pasteAction, SIGNAL(triggered()), this, SLOT(paste()));
    // about action
    _aboutAction = new QAction("About", this);
    connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about()));
    // undo action
    _undoAction = new QAction(tr("Undo"), this);
    _undoAction->setIcon(QIcon("Resources\\undo.png"));
    _undoAction->setStatusTip(tr("Undo"));
    connect(_undoAction, SIGNAL(triggered()), this, SLOT(undo()));
    // redo action
    _redoAction = new QAction(tr("Redo"), this);
    _redoAction->setIcon(QIcon("Resources\\redo.png"));
    _redoAction->setStatusTip(tr("Redo"));
    connect(_redoAction, SIGNAL(triggered()), this, SLOT(redo()));
    // add rectangle action
    _rectangleStyleAction = new QAction(tr("Rectangle Style"), this);
    _rectangleStyleAction->setIcon(QIcon("Resources\\rectangle.png"));
    _rectangleStyleAction->setStatusTip(tr("Rectangle Style"));
    connect(_rectangleStyleAction, SIGNAL(triggered()), this, SLOT(addRectangleStyle()));
    // add triangle action
    _triangleStyleAction = new QAction(tr("Triangle Style"), this);
    _triangleStyleAction->setIcon(QIcon("Resources\\triangle.png"));
    _triangleStyleAction->setStatusTip(tr("Triangle Style"));
    connect(_triangleStyleAction, SIGNAL(triggered()), this, SLOT(addTriangleStyle()));
    // add ellipse action
    _ellipseStyleAction = new QAction(tr("Ellipse Style"), this);
    _ellipseStyleAction->setIcon(QIcon("Resources\\ellipse.png"));
    _ellipseStyleAction->setStatusTip(tr("Ellipse Style"));
    connect(_ellipseStyleAction, SIGNAL(triggered()), this, SLOT(addEllipseStyle()));
    // toggle collapse action
    _toggleCollapseAction = new QAction(tr("Toggle Collapse"), this);
    _toggleCollapseAction->setIcon(QIcon("Resources\\collapse.png"));
    _toggleCollapseAction->setStatusTip(tr("Toggle Collapse"));
    connect(_toggleCollapseAction, SIGNAL(triggered()), this, SLOT(toggleCollapse()));
}
Exemplo n.º 4
0
void ControlFlowAnalysis::BasicBlocks()
{
    for(auto i = _blockStarts.begin(); i != _blockStarts.end(); ++i)
    {
        uint start = *i;
        if(!IsValidAddress(start))
            continue;
        uint nextStart = _base + _size;
        auto next = std::next(i);
        if(next != _blockStarts.end())
            nextStart = *next;
        for(uint addr = start, prevaddr = 0; addr < _base + _size;)
        {
            prevaddr = addr;
            if(_cp.Disassemble(addr, TranslateAddress(addr), MAX_DISASM_BUFFER))
            {
                if(_cp.InGroup(CS_GRP_RET) || _cp.GetId() == X86_INS_INT3)
                {
                    insertBlock(BasicBlock(start, addr, 0, 0)); //leaf block
                    break;
                }
                else if(_cp.InGroup(CS_GRP_JUMP) || _cp.IsLoop())
                {
                    uint dest1 = GetReferenceOperand();
                    uint dest2 = _cp.GetId() != X86_INS_JMP ? addr + _cp.Size() : 0;
                    insertBlock(BasicBlock(start, addr, dest1, dest2));
                    insertParent(dest1, start);
                    insertParent(dest2, start);
                    break;
                }
                addr += _cp.Size();
            }
            else
                addr++;
            if(addr == nextStart)   //special case handling overlapping blocks
            {
                insertBlock(BasicBlock(start, prevaddr, 0, nextStart));
                insertParent(nextStart, start);
                break;
            }
        }
    }
    _blockStarts.clear();

#ifdef _WIN64
    int count = 0;
    EnumerateFunctionRuntimeEntries64([&](PRUNTIME_FUNCTION Function)
    {
        const uint funcAddr = _moduleBase + Function->BeginAddress;
        const uint funcEnd = _moduleBase + Function->EndAddress;

        // If within limits...
        if(funcAddr >= _base && funcAddr < _base + _size)
            _functionStarts.insert(funcAddr);
        count++;
        return true;
    });
    dprintf("%u functions from the exception directory...\n", count);
#endif // _WIN64

    dprintf("%u basic blocks, %u function starts detected...\n", _blocks.size(), _functionStarts.size());
}
Exemplo n.º 5
0
void GraphicUI::createActions()
{
	CreateAct = new QAction(QIcon("images/create.png"), tr("&Create a mind map"), this);
	connect(CreateAct, SIGNAL(triggered()), this, SLOT(create()));

	OpenAct = new QAction(QIcon("images/open.png"), tr("&Open a mind map"), this);
	OpenAct->setStatusTip(tr("Open an existing file"));
	connect(OpenAct, SIGNAL(triggered()), this, SLOT(open()));

	SaveAct = new QAction(QIcon("images/save.png"), tr("&Save a mind map"), this);
	connect(SaveAct, SIGNAL(triggered()), this, SLOT(save()));

	ExitAct = new QAction(QIcon("images/exit.png"), tr("&Exit"), this);
	ExitAct->setStatusTip(tr("Exit the application"));
	connect(ExitAct, SIGNAL(triggered()), this, SLOT(close()));

	EditAct = new QAction(QIcon("images/edit.png"), tr("&Edit"), this);
	connect(EditAct, SIGNAL(triggered()), this, SLOT(edit()));

	DeleteAct = new QAction(QIcon("images/delete.png"), tr("&Delete"), this);
	connect(DeleteAct, SIGNAL(triggered()), this, SLOT(deleteNode()));

	InsertAChildAct = new QAction(QIcon("images/child.png"), tr("&Insert a child"), this);
	connect(InsertAChildAct, SIGNAL(triggered()), this, SLOT(insertChild()));

	InsertASiblingAct = new QAction(QIcon("images/silbing.png"), tr("&Insert a silbing"), this);
	connect(InsertASiblingAct, SIGNAL(triggered()), this, SLOT(insertSilbing()));

	InsertAParentAct = new QAction(QIcon("images/parent.png"), tr("&Insert a parent"), this);
	connect(InsertAParentAct, SIGNAL(triggered()), this, SLOT(insertParent()));

	AboutAct = new QAction(QIcon("images/about.png"), tr("&About"), this);
	connect(AboutAct, SIGNAL(triggered()), this, SLOT(about()));

	CutAct = new QAction(QIcon("images/cut.png"), tr("&Cut"), this);
	connect(CutAct, SIGNAL(triggered()), this, SLOT(cut()));
	
	CopyAct = new QAction(QIcon("images/copy.png"), tr("&Copy"), this);
	connect(CopyAct, SIGNAL(triggered()), this, SLOT(copy()));

	PasteAct = new QAction(QIcon("images/paste.png"), tr("&Paste"), this);
	connect(PasteAct, SIGNAL(triggered()), this, SLOT(paste()));

	RedoAct = new QAction(QIcon("images/redo.png"), tr("&Redo"), this);
	connect(RedoAct, SIGNAL(triggered()), this, SLOT(redo()));

	UndoAct = new QAction(QIcon("images/undo.png"), tr("&Undo"), this);
	connect(UndoAct, SIGNAL(triggered()), this, SLOT(undo()));

	InsertARectangleAct = new QAction(QIcon("images/rectangle.png"), tr("&Insert a rectangle"), this);
	connect(InsertARectangleAct, SIGNAL(triggered()), this, SLOT(insertRectangle()));

	InsertACircleAct = new QAction(QIcon("images/circle.png"), tr("&Insert a circle"), this);
	connect(InsertACircleAct, SIGNAL(triggered()), this, SLOT(insertCircle()));

	InsertATriangleAct = new QAction(QIcon("images/triangle.png"), tr("&Insert a triangle"), this);
	connect(InsertATriangleAct, SIGNAL(triggered()), this, SLOT(insertTriangle()));

	UpAct = new QAction(QIcon("images/up.png"), tr("&Up"), this);
	connect(UpAct, SIGNAL(triggered()), this, SLOT(up()));

	DownAct = new QAction(QIcon("images/down.png"), tr("&Down"), this);
	connect(DownAct, SIGNAL(triggered()), this, SLOT(down()));

	ExpandAct = new QAction(QIcon("images/expand.png"), tr("&Expand"), this);
	connect(ExpandAct, SIGNAL(triggered()), this, SLOT(expand()));

	CollapseAct = new QAction(QIcon("images/collapse.png"), tr("&Collapse"), this);
	connect(CollapseAct, SIGNAL(triggered()), this, SLOT(collapse()));

	ExpandOneAct = new QAction(QIcon("images/expand2.png"), tr("&Expand"), this);
	connect(ExpandOneAct, SIGNAL(triggered()), this, SLOT(expandOne()));

	CollapseOneAct = new QAction(QIcon("images/collapse2.png"), tr("&Collapse"), this);
	connect(CollapseOneAct, SIGNAL(triggered()), this, SLOT(collapseOne()));

	ClearAct = new QAction(QIcon("images/clear.png"), tr("&Clear"), this);
	connect(ClearAct, SIGNAL(triggered()), this, SLOT(clear()));

	initialAction();
	GraphicAction.push_back(DeleteAct);
	GraphicAction.push_back(InsertAChildAct);
	GraphicAction.push_back(InsertASiblingAct);
	GraphicAction.push_back(InsertAParentAct);
	GraphicAction.push_back(EditAct);
	GraphicAction.push_back(CutAct);
	GraphicAction.push_back(CopyAct);
	GraphicAction.push_back(PasteAct);
	GraphicAction.push_back(RedoAct);
	GraphicAction.push_back(UndoAct);
	GraphicAction.push_back(InsertARectangleAct);
	GraphicAction.push_back(InsertACircleAct);
	GraphicAction.push_back(InsertATriangleAct);
	GraphicAction.push_back(UpAct);
	GraphicAction.push_back(DownAct);
	GraphicAction.push_back(ExpandAct);
	GraphicAction.push_back(CollapseAct);
	GraphicAction.push_back(ExpandOneAct);
	GraphicAction.push_back(CollapseOneAct);
	GraphicAction.push_back(ClearAct);

	Gui_presentation->setGraphicAction(GraphicAction);
}