Exemplo n.º 1
0
void ECBJT::drawShape( QPainter &p )
{
	const int _x = int(x());
	const int _y = int(y());
	
	initPainter(p);
	
	p.drawLine( _x-8, _y-8, _x-8, _y+8 );
	p.drawLine( _x+8, _y-8, _x-8, _y );
	p.drawLine( _x+8, _y+8, _x-8, _y );
	
	QPolygon pa(3);
	if ( m_bIsNPN )
	{
		pa[0] = QPoint( _x+6, _y+7 );
		pa[1] = QPoint( _x+2, _y+8 );
		pa[2] = QPoint( _x+5, _y+3 );
	}
	else
	{
		pa[0] = QPoint( _x-7, _y+1 );
		pa[1] = QPoint( _x-4, _y+5 );
		pa[2] = QPoint( _x-2, _y );
	}
	p.setBrush( p.pen().color() );
	p.drawPolygon(pa);
	
	deinitPainter(p);
}
Exemplo n.º 2
0
void ECLogicOutput::drawShape( QPainter &p )
{
	unsigned long long newTime = m_pSimulator->time();
	unsigned long long runTime = newTime - m_lastDrawTime;
	m_lastDrawTime = newTime;
	
	if (m_bLastState)
	{
		// Logic in is currently high
		m_highTime += newTime - m_lastSwitchTime;
	}
	
	double state;
	
	if ( runTime == 0 )
		state = m_lastDrawState;
	
	else
		state = m_lastDrawState = double(m_highTime)/double(runTime);
	
	initPainter(p);
	p.setBrush( QColor( 255, uint(255-state*(255-166)), uint((1-state)*255) ) );
	p.drawEllipse( int(x()-8), int(y()-8), width(), height() );
	deinitPainter(p);
	
	m_lastSwitchTime = newTime;
	m_highTime = 0;
}
Exemplo n.º 3
0
void VariableCapacitor::drawShape(QPainter &p) {
	initPainter(p);

	// Get centre point of component.
	int _y = (int)y();
	int _x = (int)x();

	p.drawRect(_x - 8, _y - 8, 5, 16);
	p.drawRect(_x + 3, _y - 8, 5, 16);

// 	p.drawLine( _x-8, _y, _x-16, _y );
// 	p.drawLine( _x+8, _y, _x+16, _y );

	// Diagonally pointing arrow
	QPointArray pa(3);
	pa[0] = QPoint(-4, 0);
	pa[1] = QPoint(-2, 4);
	pa[2] = QPoint(0, 0);

	pa.translate(_x + 16, _y - 8);
	p.setBrush(p.pen().color());
	p.drawPolygon(pa);

	p.drawLine(_x - 16, _y + 8, _x + 16, _y - 8);

	deinitPainter(p);
}
Exemplo n.º 4
0
void ECCCCS::drawShape(QPainter &p) {
	initPainter(p);
	drawOutline(p);
	drawTopArrow(p);
	drawBottomArrow(p);
	deinitPainter(p);
}
Exemplo n.º 5
0
void ECPotentiometer::drawShape( QPainter &p )
{
	initPainter(p);
	int _x = int(x());
	int _y = int(y());
	
	p.drawRect( _x-14, _y-16, 12, 32 );
	
	Q3PointArray pa(3);
	pa[0] = QPoint( 0, 0 );
	pa[1] = QPoint( 4, -3 );
	pa[2] = QPoint( 4, 3 );
	
	int space = m_pSlider->style().pixelMetric( QStyle::PM_SliderSpaceAvailable, m_pSlider );
	int base_y = _y + int( space * m_sliderProp );
	
	pa.translate( _x + 16, base_y );
	
//	QColor c = m_p1->isSelected() ? m_selectedCol : black;
// FIXME ^ > 	
//	p.setPen(c);
//	p.setBrush(c);
	p.drawPolygon(pa);
	
	p.drawLine( _x + 20, base_y, _x + 24, base_y );
	p.drawLine( _x + 24, base_y, _x + 24, _y );
	
	deinitPainter(p);
}
Exemplo n.º 6
0
void Text::drawShape( QPainter & p )
{
	initPainter(p);
	p.setFont( p_parent->font() );
	p.drawText( drawRect(), m_flags, m_text );
	deinitPainter(p);
}
Exemplo n.º 7
0
void BiDirLED::drawShape(QPainter &p) {
	initPainter(p);

	for (unsigned i = 0; i < 2; i++) {
		uint _b;

		if (lastUpdatePeriod == 0.)
			_b = last_brightness[i];
		else {
			_b = uint(avg_brightness[i] / lastUpdatePeriod);
			last_brightness[i] = _b;
		}

		avg_brightness[i] = 0.;

		p.setBrush(QColor(uint(255 - (255 - _b)*(1 - r[i])), uint(255 - (255 - _b)*(1 - g[i])), uint(255 - (255 - _b)*(1 - b[i]))));


		QPointArray pa(3);

		if (i == 0) {
			pa[0] = QPoint(8, -8);
			pa[1] = QPoint(-8, -16);
			pa[2] = QPoint(-8, 0);
		} else {
			pa[0] = QPoint(-8, 8);
			pa[1] = QPoint(8, 0);
			pa[2] = QPoint(8, 16);
		}

		pa.translate(int(x()), int(y()));

		p.drawPolygon(pa);
		p.drawPolyline(pa);
	}

	lastUpdatePeriod = 0.;

	// Draw the arrows indicating it's a LED
	int _x = (int)x() - 2;
	int _y = (int)y() - 21;

	p.drawLine(_x + 9, _y + 3, _x + 12, _y); // Tail of left arrow
	p.drawLine(_x + 12, _y, _x + 10, _y); // Left edge of left arrow tip
	p.drawLine(_x + 12, _y, _x + 12, _y + 2); // Right edge of left arrow tip

	p.drawLine(_x + 12, _y + 6, _x + 15, _y + 3); // Tail of right arrow
	p.drawLine(_x + 15, _y + 3, _x + 13, _y + 3); // Left edge of right arrow tip
	p.drawLine(_x + 15, _y + 3, _x + 15, _y + 5); // Right edge of right arrow tip

	p.drawLine(_x + 10, _y, _x + 15, _y + 5); // Diagonal line that forms base of both arrow tips

	_x = int(x());
	_y = int(y());
	p.drawLine(_x + 8, _y - 16, _x + 8, _y);
	p.drawLine(_x - 8, _y, _x - 8, _y + 16);

	deinitPainter(p);
}
Exemplo n.º 8
0
void ResistorDIP::drawShape( QPainter &p )
{
	int _x = int(x()+offsetX());
	int _y = int(y()+offsetY());
	
	initPainter(p);
	for ( int i=0; i<m_resistorCount; ++i )
		p.drawRect( _x, _y+16*i+2, 32, 12 );
	deinitPainter(p);
}
Exemplo n.º 9
0
void VoltageRegulator::drawShape( QPainter &p )
{
    initPainter(p);

    // Get centre point of component.
    //int _y = (int)y();
    //int _x = (int)x();

    deinitPainter(p);
}
Exemplo n.º 10
0
void ECLogicInput::drawShape( QPainter &p )
{
	initPainter(p);
	if (b_state)
		p.setBrush( QColor( 255, 166, 0 ) );
	else
		p.setBrush( Qt::white );
	p.drawEllipse( (int)x()-4, (int)y()-6, 12, 12 );
	deinitPainter(p);
}
Exemplo n.º 11
0
void PinNode::drawShape( QPainter & p )
{
	initPainter( p );

	double v = pin() ? pin()->voltage() : 0.0;
	QColor voltageColor = Component::voltageColor( v );

	QPen pen = p.pen();

	if ( isSelected() )
		pen = m_selectedColor;
	else if ( m_bShowVoltageColor )
		pen = voltageColor;

	if (m_pinPoint) {
		bool drawDivPoint;
		QPoint divPoint = findConnectorDivergePoint(&drawDivPoint);
		m_pinPoint->setVisible(drawDivPoint);
		m_pinPoint->move( divPoint.x()-1, divPoint.y()-1 );
		m_pinPoint->setBrush( pen.color() );
		m_pinPoint->setPen( pen.color() );
	}

	// Now to draw on our current/voltage bar indicators
	int length = calcLength( v );

	if ( (numPins() == 1) && m_bShowVoltageBars && length != 0 ) {
		// we can assume that v != 0 as length != 0
		double i = pin()->current();
		double iProp = calcIProp(i);
		int thickness = calcThickness(iProp);

		p.setPen( QPen( voltageColor, thickness ) );

		// The node line (drawn at the end of this function) will overdraw
		// some of the voltage bar, so we need to adapt the length
		if ( (v > 0) && (((225 < m_dir) && (m_dir < 315)) || ((45 < m_dir) && (m_dir < 135))) )
			length--;

		else if ( (v < 0) && (((135 < m_dir) && (m_dir < 225)) || ((315 < m_dir) || (m_dir < 45))) )
			length++;

		if ( (m_dir > 270) || (m_dir <= 90) )
			p.drawLine( 3, 0, 3, length );
		else	p.drawLine( 3, 0, 3, -length );
	}

	pen.setWidth( (numPins() > 1) ? 2 : 1 );
	p.setPen( pen );

	p.drawLine( 0, 0, m_length, 0 );

	deinitPainter( p );
}
Exemplo n.º 12
0
void ECJKFlipFlop::drawShape( QPainter & p )
{
	Component::drawShape( p );
	
	if ( m_edgeTrigger == Falling )
	{
		initPainter( p );
		p.drawEllipse( int(x()-32), int(y()-3), 6, 6 );
		deinitPainter( p );
	}
}
Exemplo n.º 13
0
ImageBufferData::ImageBufferData(const IntSize& size, QOpenGLContext* compatibleContext)
{
    m_painter = new QPainter;

    m_impl = new ImageBufferDataPrivateAccelerated(size, compatibleContext);

    if (!m_impl->paintDevice())
        return;
    if (!m_painter->begin(m_impl->paintDevice()))
        return;

    initPainter();
}
Exemplo n.º 14
0
ImageBufferData::ImageBufferData(const IntSize& size)
{
    m_painter = new QPainter;

    m_impl = new ImageBufferDataPrivateUnaccelerated(size);

    if (!m_impl->paintDevice())
        return;
    if (!m_painter->begin(m_impl->paintDevice()))
        return;

    initPainter();
}
Exemplo n.º 15
0
void Buffer::drawShape( QPainter &p )
{
	initPainter(p);
	int _x = (int)x()-8;
	int _y = (int)y()-8;
	Q3PointArray pa(3);
	pa[0] = QPoint( _x, _y );
	pa[1] = QPoint( _x+width(), _y+(height()/2) );
	pa[2] = QPoint( _x, _y+height() );
	p.drawPolygon(pa);
	p.drawPolyline(pa);
	deinitPainter(p);
}
Exemplo n.º 16
0
void ECCell::drawShape(QPainter &p) {
    initPainter(p);

    int _x = (int)x() - 8;
    int _y = (int)y() - 24;

    p.drawLine(_x,  _y + 20, _x, _y + 28);
    p.drawLine(_x + 5, _y + 16, _x + 5, _y + 32);
    p.drawLine(_x + 10, _y + 20, _x + 10, _y + 28);
    p.drawLine(_x + 15, _y + 16, _x + 15, _y + 32);

    deinitPainter(p);
//  p.drawPolyline( areaPoints() );
}
Exemplo n.º 17
0
void ECNand::drawShape(QPainter &p) {
	if (m_logicSymbolShape == Rectangular) {
		MultiInputGate::drawShape(p);
		return;
	}

	initPainter(p);

	int _x = (int)x() + offsetX();
	int _y = (int)y() + offsetY();
	p.drawChord(_x - width() + 6, _y, 2 * width() - 12, height(), -16 * 90, 16 * 180);
	p.drawEllipse(_x + width() - 6, _y + (height() / 2) - 3, 6, 6);
	deinitPainter(p);
}
Exemplo n.º 18
0
void ECGround::drawShape( QPainter &p )
{
	initPainter(p);
	int _x = (int)x()-8;
	int _y = (int)y()-8;
	QPen pen;
	pen.setWidth(2);
	pen.setColor( p.pen().color() );
	p.setPen(pen);
	p.drawLine( _x+15, _y, _x+15, _y+16 );
	p.drawLine( _x+10, _y+3, _x+10, _y+13 );
	p.drawLine( _x+5, _y+6, _x+5, _y+10 );
	deinitPainter(p);
}
Exemplo n.º 19
0
void LEDBarGraphDisplay::drawShape(QPainter &p) {
	Component::drawShape(p);
	initPainter(p);

	// Init _x and _y to top left hand corner of component.
	int _x = (int)(x() + offsetX());
	int _y = (int)(y() + offsetY());

	// Draw LED elements, passing in a position for each.

	for (unsigned i = 0; i < m_numRows; i++)
		m_LEDParts[i]->draw(p, _x + 4, _y + (i*16) + 10, 24, 12);

	deinitPainter(p);
}
Exemplo n.º 20
0
void Capacitor::drawShape(QPainter &p) {
	initPainter(p);

	int _y = (int)y() - 8;
	int _x = (int)x() - 8;

	QPen pen;
	pen.setWidth(1);
	pen.setColor(p.pen().color());
	p.setPen(pen);
	p.drawRect(_x, _y, 5, 16);
	p.drawRect(_x + 11, _y, 5, 16);

	deinitPainter(p);
}
Exemplo n.º 21
0
void ECAnd::drawShape(QPainter &p) {
	if (m_logicSymbolShape == Rectangular) {
		MultiInputGate::drawShape(p);
		return;
	}

	initPainter(p);

	int _x = (int)x() + offsetX();
	int _y = (int)y() + offsetY();

	p.drawChord(_x - width(), _y, 2 * width(), height(), -16 * 90, 16 * 180);

	deinitPainter(p);
}
Exemplo n.º 22
0
void MultiInputGate::drawShape(QPainter & p) {
	initPainter(p);

	int _x = int(x() + offsetX());
	int _y = int(y() + offsetY());

	if (m_bInvertedOutput) {
		p.drawRect(_x, _y, 32 - 6, height());
		p.drawEllipse(_x + 32 - 6, int(y()) - 3, 6, 6);
	} else {
		p.drawRect(_x, _y, 32, height());
	}

	deinitPainter(p);
}
Exemplo n.º 23
0
void LED::drawShape( QPainter &p )
{
	int _x = int(x());
	int _y = int(y());
	
	initPainter(p);
	
	//BEGIN draw "Diode" part
	uint _b;

	if(lastUpdatePeriod != 0.) {
		last_brightness = (uint)(avg_brightness/lastUpdatePeriod);
	}

	_b = last_brightness;

	avg_brightness   = 0.;
	lastUpdatePeriod = 0.;

	p.setBrush(QColor(uint(255 - (255 - _b) * (1 - r)),
			  uint(255 - (255 - _b) * (1 - g)),
			  uint(255 - (255 - _b) * (1 - b))));

	Q3PointArray pa(3);
	pa[0] = QPoint(  8,  0 );
	pa[1] = QPoint( -8, -8 );
	pa[2] = QPoint( -8,  8 );
	pa.translate( _x, _y   );
	p.drawPolygon(pa);
	p.drawPolyline(pa);

	p.drawLine( _x+8,  _y-8,  _x+8,  _y+8 );
	//END draw "Diode" part

	//BEGIN draw "Arrows" part
	p.drawLine( _x+7,  _y-10, _x+10, _y-13 ); // Tail of left arrow
	p.drawLine( _x+10, _y-13, _x+8,  _y-13 ); // Left edge of left arrow tip
	p.drawLine( _x+10, _y-13, _x+10, _y-11 ); // Right edge of left arrow tip
	p.drawLine( _x+10, _y-7,  _x+13, _y-10 ); // Tail of right arrow
	p.drawLine( _x+13, _y-10, _x+11, _y-10 ); // Left edge of right arrow tip
	p.drawLine( _x+13, _y-10, _x+13, _y-8  ); // Right edge of right arrow tip
	p.drawLine( _x+8,  _y-13, _x+13, _y-8  ); // Diagonal line that forms base of both arrow tips
	//END draw "Arrows" part1

	deinitPainter(p);
}
Exemplo n.º 24
0
void BusSplitter::drawShape( QPainter &p )
{
	initPainter(p);
	
// 	QPen pen(p.pen());
// 	pen.setWidth();
// 	p.setPen(pen);
	
	int _x = int(x());
	int _y = int(y());
	
	QRect r = m_sizeRect;
	r.translate( _x, _y );
	p.drawRect(r);
	
	deinitPainter(p);
}
Exemplo n.º 25
0
void MatrixDisplay::drawShape(QPainter &p) {
    if (isSelected())
        p.setPen(m_selectedCol);

    p.drawRect(boundingRect());

    initPainter(p);

    const int _x = int(x() + offsetX());
    const int _y = int(y() + offsetY());

    // To avoid flicker, require at least a 10 ms sample before changing
    // the brightness
    double minUpdatePeriod = 0.0099;

    for (int i = 0; i < int(m_numCols); i++) {
        for (int j = 0; j < int(m_numRows); j++) {
            if (m_lastUpdatePeriod > minUpdatePeriod)
                m_LEDs[i][j].m_lastBrightness = unsigned(m_LEDs[i][j].m_avgBrightness / m_lastUpdatePeriod);

            double _b = m_LEDs[i][j].m_lastBrightness;
// FIXME: we find ourselves with RGB out of range errors after resizing. 
            QColor brush = QColor(uint(255 - (255 - _b) * (1 - m_r)),
                                  uint(255 - (255 - _b) * (1 - m_g)),
                                  uint(255 - (255 - _b) * (1 - m_b)));

            p.setBrush(brush);
            p.setPen(Qt::NoPen);
            p.drawEllipse(_x + 10 + i * 16,
			  _y + 10 + j * 16, 12, 12);
        }
    }

    if (m_lastUpdatePeriod > minUpdatePeriod) {
        m_lastUpdatePeriod = 0.0;

        for (unsigned i = 0; i < m_numCols; i++) {
            for (unsigned j = 0; j < m_numRows; j++)
                m_LEDs[i][j].m_avgBrightness = 0.0;
        }
    }

    deinitPainter(p);
}
Exemplo n.º 26
0
void FloatingProbe::drawShape(QPainter &p) {
	initPainter(p);

	int _x = int(x()) - 16;
	int _y = int(y()) - 8;

	p.drawRect(_x, _y, 32, 16);

	QPointArray bezier(4);

	bezier[0] = QPoint(_x + 4, _y + 10);
	bezier[1] = QPoint(_x + 12, _y - 6);
	bezier[2] = QPoint(_x + 20, _y + 24);
	bezier[3] = QPoint(_x + 28, _y + 4);

	p.setPen(QPen(m_color, 2));
	p.drawCubicBezier(bezier);

	deinitPainter(p);
}
Exemplo n.º 27
0
void ECJFET::drawShape( QPainter &p )
{
	const int _x = int(x());
	const int _y = int(y());
	
	initPainter( p );
	
	// back lines
	p.drawLine( _x-8, _y, _x+2, _y );
	p.drawLine( _x+2, _y-8, _x+2, _y+8 );
	
	// top corner
	p.drawLine( _x+2, _y-5, _x+8, _y-5 );
	p.drawLine( _x+8, _y-5, _x+8, _y-8 );
	
	// bottom corner
	p.drawLine( _x+2, _y+5, _x+8, _y+5 );
	p.drawLine( _x+8, _y+5, _x+8, _y+8 );
	
	Q3PointArray pa(3);
	if ( m_JFET_type == JFET::nJFET )
	{
		// right pointing arrow
		pa[0] = QPoint( 1, 0 );
		pa[1] = QPoint( -4, -3 );
		pa[2] = QPoint( -4, +3 );
	}
	else
	{
		// left pointing arrow
		pa[0] = QPoint( -8, 0 );
		pa[1] = QPoint( -3, -3 );
		pa[2] = QPoint( -3, +3 );
	}
	pa.translate( _x, _y );
	p.setBrush( p.pen().color() );
	p.drawPolygon( pa );
	
	deinitPainter( p );
}
Exemplo n.º 28
0
void ECXor::drawShape(QPainter &p) {
	if (m_logicSymbolShape == Rectangular) {
		MultiInputGate::drawShape(p);
		return;
	}

	initPainter(p);

	int _x = (int)x() + offsetX();
	int _y = (int)y() + offsetY();

	p.save();
	p.setPen(Qt::NoPen);
	p.drawChord(_x - width() + 16, _y, 2 * width() - 16, height(), -16 * 81, 16 * 162);
	p.restore();

	p.drawArc(_x - width() + 16, _y, 2 * width() - 16, height(), -16 * 90, 16 * 180);
	p.drawArc(_x - 8, _y, 16, height(), -16 * 90, 16 * 180);
	p.drawArc(_x, _y, 16, height(), -16 * 90, 16 * 180);

	deinitPainter(p);
}
Exemplo n.º 29
0
void ECSignalLamp::drawShape( QPainter &p )
{
	initPainter(p);

	int _x = int(x());
	int _y = int(y());

	// Calculate the brightness as a linear function of power, bounded below by
	// 25 milliWatts and above by 500 milliWatts.
	int brightness = (avgPower < LIGHTUP) ? 255 :
			((avgPower > WATTAGE) ? 0 : (int)(255 * (1 - ((avgPower - LIGHTUP) / (WATTAGE - LIGHTUP)))));
	advanceSinceUpdate = 0;
	
	p.setBrush( QColor( 255, 255, brightness ) );
	p.drawEllipse( _x-8, _y-8, 16, 16 );
	
	int pos = 8 - int(8 * M_SQRT1_2);
	
	p.drawLine( _x-8+pos, _y-8+pos, _x+8-pos, _y+8-pos );
	p.drawLine( _x+8-pos, _y-8+pos, _x-8+pos, _y+8-pos );
	
	deinitPainter(p);
}
Exemplo n.º 30
0
void VariableResistor::drawShape( QPainter &p )
{
    initPainter(p);

    // Get centre point of component.
    int _y = (int)y();
    int _x = (int)x();

    p.drawRect( _x-16, _y-6, width(), 12 );
    p.drawLine( _x-12, _y+12, _x+13, _y-13 );

    Q3PointArray pa(3);

    // Diagonally pointing arrow
    pa[0] = QPoint( 0, 0 );
    pa[1] = QPoint( -4, 0 );
    pa[2] = QPoint( 0, 4 );

    pa.translate( _x+13, _y-13 );
    p.setBrush( p.pen().color() );
    p.drawPolygon( pa );

    deinitPainter(p);
}