Пример #1
0
void core::RestrictedLineF::setP1(const QPointF &p1)
{
	switch(lineConstrain){
		case RestrictedLineF::HorizontalLeft:
			QLineF::setP1(p1);

			if(p2().x() <= p1.x()){
				setP2(QPointF(p2().x(), p1.y()));
			}else{
				setP2(p1);
			}

			break;
		case RestrictedLineF::HorizontalRight:
			QLineF::setP1(p1);

			if(p2().x() >= p1.x()){
				setP2(QPointF(p2().x(), p1.y()));
			}else{
				setP2(p1);
			}
			break;
		case RestrictedLineF::Horizontal:
			QLineF::setP1(p1);
			setP2(QPointF(p2().x(), p1.y()));
			break;

		case RestrictedLineF::VerticalUp:
			QLineF::setP1(p1);

			if(p2().y() <= p1.y()){
				setP2(QPointF(p1.x(), p2().y()));
			}else{
				setP2(p1);
			}
			break;
		case RestrictedLineF::VerticalDown:
			QLineF::setP1(p1);

			if(p2().y() >= p1.y()){
				setP2(QPointF(p1.x(), p2().y()));
			}else{
				setP2(p1);
			}
			break;
		case RestrictedLineF::Vertical:
			QLineF::setP1(p1);
			setP2(QPointF(p1.x(), p2().y()));
			break;
		case RestrictedLineF::None:
			QLineF::setP1(p1);
			break;
		case RestrictedLineF::Both:
		default:
			break;
	}
}
Пример #2
0
core::RestrictedLineF::RestrictedLineF(const QPointF &p1, const QPointF &p2, Constrain lc)
//	QLineF(p1, p2)
{
//    Q_INIT_RESOURCE(core_media);
	lineConstrain = lc;
	setP1(p1);
	setP2(p2);
}
Пример #3
0
core::RestrictedLineF::RestrictedLineF(qreal x1, qreal y1, qreal x2, qreal y2, Constrain lc)
//	QLineF(x1, x2, y1, y2)
{
//    Q_INIT_RESOURCE(core_media);
	lineConstrain = lc;
	setP1(QPointF(x1, y1));
	setP2(QPointF(x2, y2));
}
Пример #4
0
    /**
     * @brief Relation::recalculateLine
     */
    void Relation::recalculateLine()
    {
        QPolygonF fromRect(m_From->mapToScene(m_From->frameRect()));
        QPolygonF toRect(m_To->mapToScene(m_To->frameRect()));
        setVisible(fromRect.intersected(toRect).isEmpty());

        if (isVisible()) {
            setP1(intersection(fromRect, QLineF(m_From->pos(), line().p2())));
            setP2(intersection(toRect, QLineF(line().p1(), m_To->pos())));
        }
    }
Пример #5
0
void core::RestrictedLineF::setConstrain(RestrictedLineF::Constrain lc)
{
	lineConstrain = lc;
	switch(lineConstrain){
		case RestrictedLineF::HorizontalLeft:
		case RestrictedLineF::HorizontalRight:
		case RestrictedLineF::Horizontal:
			setP2(QPointF(p2().x(), p1().y()));
			break;
		case RestrictedLineF::VerticalUp:
		case RestrictedLineF::VerticalDown:
		case RestrictedLineF::Vertical:
			setP2(QPointF(p1().x(), p2().y()));
			break;
		case RestrictedLineF::Both:
		case RestrictedLineF::None:
			break;

	}
}
Пример #6
0
void main(void)
{
	uint16_t color = BLUE;

    //P1 config data to be OR'ed with the current state
    //of each reg
    uint8_t p1dir = 0b00000001;
    uint8_t p1ren = 0b00010010;
    uint8_t p1out = 0b00010010;

    //P2 config data to be OR'ed with the current state
    //of each reg
    uint8_t p2dir = BIT0|BIT1|BIT2;
    uint8_t p2ren = 0b00000000;
	uint8_t p2out = 0b00000000;

    setup(SETUP);
    setP2(p2dir,p2ren,p2out);
    setP1(p1dir,p1ren,p1out);
    setP3P4P5P6P7P8P9P20();

    int previousState = 0;
    enum STATE state= RS;

    while(true)
      {
    	int currentState = myDebounce(SW2, 50);
    	int latched = 0;
    	if (currentState > previousState)
    	{
    		latched = 1;
    		state ^= 1;
    	}
    	if (latched == 1)
    	{
    		switch (state)
    		{
    		case RS:
    			P2OUT = 0;
    			P1OUT = 0;
    			P1OUT = 0b00010010;
    			break;
    		case S:
    			P2OUT ^= color;
    			break;
    		}
    	}
    	previousState = currentState;
      }
}
Пример #7
0
bool Line::sceneEvent(QEvent *event)
{
	switch (event->type()) {
	case FreeSCH::KnobMovedEventType: {
		KnobMovedEvent *e = static_cast<KnobMovedEvent *>(event);
		if (Knob::StartPoint == e->index)
			setP1(e->loc);
		else
			setP2(e->loc);
		return true;
	}
	default:
		break;
	}
	return QGraphicsLineItem::sceneEvent(event);
}
Пример #8
0
void MidiMessage::setData(uchar aCommand, uchar aP1, uchar aP2, uchar aP3) {
   setCommand(aCommand);
   setP1(aP1);
   setP2(aP2);
   setP3(aP3);
}