Exemple #1
0
//thread
void *inputHandler(void *vargp) {
    initTermios();
    char cc;
    pthread_t tid2;
    pthread_create(&tid2, NULL, drawGun, NULL);
    drawTarget(getTargetPosX(TP),getTargetPosY(TP),50,220,10);
    while(stop == 0) {
    	drawTarget(getTargetPosX(TP),getTargetPosY(TP),50,220,10);
    	usleep(1000);
    	
    	if (kbhit()) {
			cc = getch();resetTermios();
			switch (cc) {
				case 'w': case 'W' :
					clearTarget(getTargetPosX(TP),getTargetPosY(TP));
    				moveTarget(&TP,0,-15);
					break;
				case 'a': case 'A' :
					clearTarget(getTargetPosX(TP),getTargetPosY(TP));
    				moveTarget(&TP,-15,0);
					break;
				case 's': case 'S' :
					clearTarget(getTargetPosX(TP),getTargetPosY(TP));
    				moveTarget(&TP,0,15);
					break;
				case 'd': case 'D' :
					clearTarget(getTargetPosX(TP),getTargetPosY(TP));
    				moveTarget(&TP,15,0);
					break;
				case 'q' : case 'Q' :
					stop = 1;
					break;
				case 'i' : case 'I' :
					if(! isActive(B)) {
    					makeBomb(getTargetPosX(TP),getTargetPosY(TP),&B);
    					setActive(&B,1);
    				}
			}
			initTermios();
		}
    }
    pthread_join(tid2, NULL); 
}
Calamares::JobResult
MoveFileSystemJob::exec()
{
    Report report( nullptr );
    QString partitionPath = partition()->partitionPath();
    CopySourceDevice moveSource( *m_device, m_oldFirstSector, m_oldFirstSector + m_length - 1 );
    CopyTargetDevice moveTarget( *m_device, m_newFirstSector, m_newFirstSector + m_length - 1 );

    if ( !moveSource.open() )
        return Calamares::JobResult::error(
                   QString(),
                   tr( "Could not open file system on partition %1 for moving." ).arg( partitionPath )
               );

    if ( !moveTarget.open() )
        return Calamares::JobResult::error(
                   QString(),
                   tr( "Could not create target for moving file system on partition %1." ).arg( partitionPath )
               );

    bool ok = copyBlocks( report, moveTarget, moveSource );
    if ( !ok )
    {
        if ( rollbackCopyBlocks( report, moveTarget, moveSource ) )
            return Calamares::JobResult::error(
                       QString(),
                       tr( "Moving of partition %1 failed, changes have been rolled back." ).arg( partitionPath )
                       + '\n' + report.toText()
                   );
        else
            return Calamares::JobResult::error(
                       QString(),
                       tr( "Moving of partition %1 failed. Roll back of the changes have failed." ).arg( partitionPath )
                       + '\n' + report.toText()
                   );
    }

    FileSystem& fs = partition()->fileSystem();
    fs.setFirstSector( m_newFirstSector );
    fs.setLastSector( m_newFirstSector + m_length - 1 );

    if ( !fs.updateBootSector( report, partitionPath ) )
        return Calamares::JobResult::error(
                   QString(),
                   tr( "Updating boot sector after the moving of partition %1 failed." ).arg( partitionPath )
                   + '\n' + report.toText()
               );

    return Calamares::JobResult::ok();
}
Exemple #3
0
void QQuickDragHandler::handleEventPoint(QQuickEventPoint *point)
{
    point->setAccepted();
    switch (point->state()) {
    case QQuickEventPoint::Pressed:
        initializeTargetStartPos(point);
        setPassiveGrab(point);
        break;
    case QQuickEventPoint::Updated: {
        QPointF delta = point->scenePosition() - point->scenePressPosition();
        if (!m_xAxis.enabled())
            delta.setX(0);
        if (!m_yAxis.enabled())
            delta.setY(0);
        if (active()) {
            setTranslation(QVector2D(delta));
            if (target() && target()->parentItem()) {
                QPointF pos = target()->parentItem()->mapFromScene(m_targetStartPos + delta);
                enforceAxisConstraints(&pos);
                moveTarget(pos, point);
            }
        } else if (!point->exclusiveGrabber() &&
                   ((m_xAxis.enabled() && QQuickWindowPrivate::dragOverThreshold(delta.x(), Qt::XAxis, point)) ||
                    (m_yAxis.enabled() && QQuickWindowPrivate::dragOverThreshold(delta.y(), Qt::YAxis, point)))) {
            setExclusiveGrab(point);
            if (auto parent = parentItem()) {
                if (point->pointerEvent()->asPointerTouchEvent())
                    parent->setKeepTouchGrab(true);
                // tablet and mouse are treated the same by Item's legacy event handling, and
                // touch becomes synth-mouse for Flickable, so we need to prevent stealing
                // mouse grab too, whenever dragging occurs in an enabled direction
                parent->setKeepMouseGrab(true);
            }
        }
    } break;
    default:
        break;
    }
}
Exemple #4
0
void PlanRep::expandLowDegreeVertices(OrthoRep &OR)
{
	for(node v : nodes)
	{
		if (!(isVertex(v)) || expandAdj(v) != nullptr)
			continue;

		SList<edge> adjEdges;
		SListPure<Tuple2<node,int> > expander;

		node u = v;
		bool firstTime = true;

		setExpandedNode(v, v);

		for(adjEntry adj : v->adjEdges) {
			adjEdges.pushBack(adj->theEdge());

			if(!firstTime)
				u = newNode();

			setExpandedNode(u, v);
			typeOf(u) = Graph::lowDegreeExpander;
			expander.pushBack(Tuple2<node,int>(u,OR.angle(adj)));
			firstTime = false;
		}

		SListConstIterator<Tuple2<node,int>> itn = expander.begin().succ();

		for (SListConstIterator<edge> it = adjEdges.begin().succ(); it.valid(); ++it)
		{
			// Did we allocate enough dummy nodes?
			OGDF_ASSERT(itn.valid());

			if ((*it)->source() == v)
				moveSource(*it,(*itn).x1());
			else
				moveTarget(*it,(*itn).x1());
			++itn;
		}

		adjEntry adjPrev = v->firstAdj();
		itn = expander.begin();
		int nBends = (*itn).x2();

		for (++itn; itn.valid(); ++itn)
		{
			edge e = newEdge(adjPrev,(*itn).x1()->firstAdj());

			OR.bend(e->adjSource()).set(convexBend,nBends);
			OR.bend(e->adjTarget()).set(reflexBend,nBends);
			OR.angle(adjPrev) = 1;
			OR.angle(e->adjSource()) = 2;
			OR.angle(e->adjTarget()) = 1;

			nBends = (*itn).x2();

			typeOf(e) = association; //???
			setExpansionEdge(e, 2);

			adjPrev = (*itn).x1()->firstAdj();
		}

		edge e = newEdge(adjPrev,v->lastAdj());
		typeOf(e) = association; //???
		setExpansionEdge(e, 2);

		expandAdj(v) = e->adjSource();

		OR.bend(e->adjSource()).set(convexBend,nBends);
		OR.bend(e->adjTarget()).set(reflexBend,nBends);
		OR.angle(adjPrev) = 1;
		OR.angle(e->adjSource()) = 2;
		OR.angle(e->adjTarget()) = 1;

	}
}//expandlowdegreevertices
Exemple #5
0
void PlanRep::expand(bool lowDegreeExpand)
{
	for(node v : nodes)
	{

		// Replace vertices with high degree by cages and
		// replace degree 4 vertices with two generalizations
		// adjacent in the embedding list by a cage.
		if ((v->degree() > 4)  && (typeOf(v) != Graph::dummy) && !lowDegreeExpand)
		{
			edge e;

			//Set the type of the node v. It remains in the graph
			// as one of the nodes of the expanded face.
			typeOf(v) = Graph::highDegreeExpander;

			// Scan the list of edges of v to find the adjacent edges of v
			// according to the planar embedding. All except one edge
			// will get a new adjacent node
			SList<edge> adjEdges;
			{forall_adj_edges(e,v)
				adjEdges.pushBack(e);
			}

			//The first edge remains at v. remove it from the list.
			e = adjEdges.popFrontRet();

			// Create the list of high degree expanders
			// We need degree(v)-1 of them to construct a face.
			// and set expanded Node to v
			setExpandedNode(v, v);
			SListPure<node> expander;
			for (int i = 0; i < v->degree()-1; i++)
			{
				node u = newNode();
				typeOf(u) = Graph::highDegreeExpander;
				setExpandedNode(u, v);
				expander.pushBack(u);
			}

			// We move the target node of each ingoing generalization of v to a new
			// node stored in expander.
			// Note that, for each such edge e, the target node of the original
			// edge is then different from the original of the target node of e
			// (the latter is 0 because u is a new (dummy) node)
			SListConstIterator<node> itn;

			NodeArray<adjEntry> ar(*this);

			itn = expander.begin();

			for (edge ei : adjEdges)
			{
				// Did we allocate enough dummy nodes?
				OGDF_ASSERT(itn.valid());

				if (ei->source() == v)
					moveSource(ei,*itn);
				else
					moveTarget(ei,*itn);
				ar[*itn] = (*itn)->firstAdj();
				++itn;
			}
			ar[v] = v->firstAdj();

			// Now introduce the circular list of new edges
			// forming the border of the merge face. Keep the embedding.
			adjEntry adjPrev = v->firstAdj();

//			cout <<endl << "INTRODUCING CIRCULAR EDGES" << endl;
			for (node n : expander)
			{
//				cout << adjPrev << " " << (*itn)->firstAdj() << endl;
				e = Graph::newEdge(adjPrev,n->firstAdj());
				setExpansionEdge(e, 2);//can be removed if edgetypes work properly

				setExpansion(e);
				setAssociation(e);

				typeOf(e) = association; //???

				if (!expandAdj(v))
					expandAdj(v) = e->adjSource();
				adjPrev = n->firstAdj();
			}

			e = newEdge(adjPrev,v->lastAdj());

			typeOf(e) = association; //???
			setExpansionEdge(e, 2);//can be removed if edgetypes work properly
			setAssociation(e);

		}//highdegree

		// Replace all vertices with degree > 2 by cages.
		else if (v->degree() >= 2  && typeOf(v) != Graph::dummy &&
				 lowDegreeExpand)
		{
			edge e;

			//Set the type of the node v. It remains in the graph
			// as one of the nodes of the expanded face.
			typeOf(v) = Graph::lowDegreeExpander; //high??

			// Scan the list of edges of v to find the adjacent edges of v
			// according to the planar embedding. All except one edge
			// will get a new adjacent node
			SList<edge> adjEdges;
			{forall_adj_edges(e,v)
				adjEdges.pushBack(e);
			}

			//The first edge remains at v. remove it from the list.
			// Check if it is a generalization.
			e = adjEdges.popFrontRet();

			// Create the list of high degree expanders
			// We need degree(v)-1 of them to construct a face.
			// and set expanded Node to v
			setExpandedNode(v, v);
			SListPure<node> expander;
			for (int i = 0; i < v->degree()-1; i++)
			{
				node u = newNode();
				typeOf(u) = Graph::highDegreeExpander;
				setExpandedNode(u, v);
				expander.pushBack(u);
			}

			// We move the target node of each ingoing generalization of v to a new
			// node stored in expander.
			// Note that, for each such edge e, the target node of the original
			// edge is then different from the original of the target node of e
			// (the latter is 0 because u is a new (dummy) node)

			NodeArray<adjEntry> ar(*this);

			SListConstIterator<node> itn = expander.begin();

			for (edge ei : adjEdges)
			{
				// Did we allocate enough dummy nodes?
				OGDF_ASSERT(itn.valid());

				if (ei->source() == v)
					moveSource(ei,*itn);
				else
					moveTarget(ei,*itn);
				ar[*itn] = (*itn)->firstAdj();
				++itn;
			}
			ar[v] = v->firstAdj();

			// Now introduce the circular list of new edges
			// forming the border of the merge face. Keep the embedding.
			adjEntry adjPrev = v->firstAdj();

			for (node n : expander)
			{
				e = newEdge(adjPrev,n->firstAdj());
				if (!expandAdj(v)) expandAdj(v) = e->adjSource();
				typeOf(e) = association; //???
				setExpansionEdge(e, 2);

				//new types
				setAssociation(e); //should be dummy type?
				setExpansion(e);

				adjPrev = n->firstAdj();
			}
			e = newEdge(adjPrev,v->lastAdj());
			typeOf(e) = association; //???
			setExpansionEdge(e, 2);
		}

	}

}//expand