Esempio n. 1
0
void Meter::stepNonLogic()
{
	if (b_firstRun)
	{
		p_displayText->setText(displayText());
		updateAttachedPositioning();
		setChanged();
		property("0-minValue")->setUnit(m_unit);
		property("1-maxValue")->setUnit(m_unit);
		b_firstRun = false;
	}
		
	const double v = meterValue();
	if ( !b_timerStarted && std::abs(((v-m_old_value)/m_old_value)) > 1e-6 ) {
		b_timerStarted = true;
	}
	
	if (b_timerStarted) {
		m_timeSinceUpdate += LINEAR_UPDATE_PERIOD;
		m_avgValue += v * LINEAR_UPDATE_PERIOD;
// 		setChanged();
		if ( m_timeSinceUpdate > 0.05 )
		{
			if ( p_displayText->setText(displayText()) )
				updateAttachedPositioning();
		}
	}
}
Esempio n. 2
0
void FlowPart::updateNodePositions() {
	if (m_orientation > 7) {
		kdWarning() << k_funcinfo << "Invalid orientation: " << m_orientation << endl;
		return;
	}

	NodeInfo *stdInputInfo = m_stdInput ? &m_nodeMap["stdinput"] : 0;
	NodeInfo *stdOutputInfo = m_stdOutput ? &m_nodeMap["stdoutput"] : 0;
	NodeInfo *altOutputInfo = m_altOutput ? &m_nodeMap["altoutput"] : 0;

	if (m_stdInput && m_stdOutput && m_altOutput) {
		stdInputInfo->orientation = diamondNodePositioning[m_orientation][0];
		stdOutputInfo->orientation = diamondNodePositioning[m_orientation][1];
		altOutputInfo->orientation = diamondNodePositioning[m_orientation][2];
	} else if (m_stdInput && m_stdOutput) {
		stdInputInfo->orientation = inOutNodePositioning[m_orientation][0];
		stdOutputInfo->orientation = inOutNodePositioning[m_orientation][1];
	} else if (m_orientation < 4) {
		if (stdInputInfo)
			stdInputInfo->orientation = inNodePositioning[m_orientation];
		else if (stdOutputInfo)
			stdOutputInfo->orientation = outNodePositioning[m_orientation];
	} else {
		kdWarning() << k_funcinfo << "Invalid orientation: " << m_orientation << endl;
		return;
	}

	const NodeInfoMap::iterator end = m_nodeMap.end();

	for (NodeInfoMap::iterator it = m_nodeMap.begin(); it != end; ++it) {
		if (!it.data().node)
			kdError() << k_funcinfo << "Node in nodemap is null" << endl;
		else {
			switch (it.data().orientation) {

			case 0:
				it.data().x = offsetX() + width() + 8;
				it.data().y = 0;
				break;

			case 270:
				it.data().x = 0;
				it.data().y = offsetY() - 8;
				break;

			case 180:
				it.data().x = offsetX() - 8;
				it.data().y = 0;
				break;

			case 90:
				it.data().x = 0;
				it.data().y = offsetY() + height() + 8;;
				break;
			}
		}
	}

	updateAttachedPositioning();
}
Esempio n. 3
0
void FlowContainer::createBotContainerNode()
{
	m_ext_out = (FPNode*)createNode( width()/2, height()+8, 90, "ext_out", Node::fp_out );
	m_ext_out->setLevel( level() );
	m_rectangularOverlay->removeBotMiddle();
	updateAttachedPositioning();
}
Esempio n. 4
0
void FlowContainer::createTopContainerNode()
{
	m_ext_in = (FPNode*)createNode( width()/2, -8, 270, "ext_in", Node::fp_in );
	m_ext_in->setLevel( level() );
	m_rectangularOverlay->removeTopMiddle();
	updateAttachedPositioning();
}
Esempio n. 5
0
void ResistorDIP::updateDIPNodePositions()
{
	for ( int i=0; i<m_resistorCount; ++i )
	{
		m_nodeMap["n"+QString::number(i)].y = offsetY() + 8 + 16*i;
		m_nodeMap["p"+QString::number(i)].y = offsetY() + 8 + 16*i;
	}
	updateAttachedPositioning();
}
Esempio n. 6
0
void CNItem::setDisplayText( const QString &id, const QString &display )
{
	TextMap::iterator it = m_textMap.find(id);
	if ( it == m_textMap.end() )
	{
		kError() << "CNItem::setDisplayText: Could not find text with id \""<<id<<"\""<<endl;
		return;
	}
	it.data()->setText(display);
	updateAttachedPositioning();
}
Esempio n. 7
0
void ECDFlipFlop::initSymbolFromTrigger()
{
	int offset = (m_edgeTrigger == Rising) ? 0 : 6;
	
	int w = 64-offset;
	setSize( offset-32, -24, w, 48, true );
	m_pNNode[0]->setLength( 8+offset );
	addDisplayText( "D",	QRect( offset-28,	-16,	20, 16 ), "D", true, Qt::AlignLeft );
	addDisplayText( ">",	QRect( offset-28,	0,		20, 16 ), ">", true, Qt::AlignLeft ); 
	addDisplayText( "Set",	QRect( offset-28,	-20,	w-8, 16 ), "Set", true, Qt::AlignHCenter );
	addDisplayText( "Rst",	QRect( offset-28,	4,		w-8, 16 ), "Rst", true, Qt::AlignHCenter );
	
	updateAttachedPositioning();
}
Esempio n. 8
0
Node* CNItem::createNode( double _x, double _y, int orientation, const QString &name, uint type )
{
	orientation %= 360;
	if ( orientation < 0 )
		orientation += 360;
	
	Node *node = NULL;

	// TODO get rid of this switch statement... 
	switch(type) {
		case Node::ec_pin:
			node = new PinNode(p_icnDocument, orientation, QPoint( 0, 0) );
			break;
		case Node::ec_junction:
			node = new JunctionNode( p_icnDocument, orientation, QPoint( 0, 0) );
			break;
		case Node::fp_junction:
			node = new JunctionFlowNode(p_icnDocument, orientation, QPoint( 0, 0) );
			break;
		case Node::fp_in:
			node = new InputFlowNode( p_icnDocument, orientation, QPoint( 0, 0) );
			break;
		case Node::fp_out:
			node = new OutputFlowNode( p_icnDocument, orientation, QPoint( 0, 0) );
			break;
	}
			
	node->setLevel( level() );
	
	node->setParentItem(this);
	node->setChildId(name);
	
	NodeInfo info;
	info.id = node->id();
	info.node = node;
	info.x = _x;
	info.y = _y;
	info.orientation = orientation;
	
	m_nodeMap[name] = info;
	
	updateAttachedPositioning();
	
	return node;
}
Esempio n. 9
0
void MultiInputGate::updateInputs(int newNum) {
	if (newNum == m_numInputs) return;

	if (newNum < 2) newNum = 2;
	else if (newNum > maxGateInput)
		newNum = maxGateInput;

	int newWidth = logicSymbolShapeToWidth();

	QRect r(-newWidth / 2, -8 * newNum, newWidth, 16 * newNum);

	setSize(r, true);
	updateSymbolText();

	const bool added = (newNum > m_numInputs);

	if (added) {
		for (int i = m_numInputs; i < newNum; ++i) {
			ECNode *node = createPin(0, 0, 0, "in" + QString::number(i));
			inNode[i] = node;

			inLogic[i] = new LogicIn(LogicConfig());
			setup1pinElement(*(inLogic[i]), node->pin());

			inLogic[i]->setCallback(this, (CallbackPtr)(&MultiInputGate::inStateChanged));
		}
	} else {
		for (int i = newNum; i < m_numInputs; ++i) {
			removeNode("in" + QString::number(i));
			removeElement(inLogic[i], false);
			inNode[i] = 0;
			inLogic[i] = 0;
		}
	}

	m_numInputs = newNum;

	// We can't call a pure-virtual function if we haven't finished our constructor yet...

	if (m_bDoneInit)
		inStateChanged(!added);

	updateAttachedPositioning();
}
Esempio n. 10
0
FlowContainer::FlowContainer( ICNDocument *_icnDocument, bool newItem, const QString &id )
	: FlowPart( _icnDocument, newItem, id )
{
	m_ext_in = m_int_in = m_int_out = m_ext_out = 0l;
	b_expanded = true;
	
	addButton( "expandBtn", QRect( offsetX(), offsetY()+24 - 11, 22, 22 ), KIcon( "go-down" ), true );
	m_rectangularOverlay = new RectangularOverlay( this, 8, 8 );
	setSize( -160, -120, 320, 240 );
	
	
	m_int_in = (FPNode*)createNode( width()/2, 8+topStrip, 90, "int_in", Node::fp_out );
	m_int_out = (FPNode*)createNode( width()/2, height()-8-botStrip, 270, "int_out", Node::fp_in );
	
	button("expandBtn")->setState(true);
	
	updateAttachedPositioning();
	updateNodeLevels();
}
Esempio n. 11
0
void BusSplitter::dataChanged()
{
	unsigned busSize = dataInt("size");
	
	if ( busSize < 1 )
		busSize = 1;
	
	else if ( busSize > MAX_BUS_SIZE )
		busSize = MAX_BUS_SIZE;
	
	if ( busSize == m_busSize )
		return;
	
	m_pInNode->setNumPins(busSize);
	
	if ( busSize > m_busSize )
	{
		m_pWires.resize(busSize);
		for ( unsigned i = m_busSize; i < unsigned(busSize); i++ )
		{
			Pin * pin = createPin( 16, 0, 180, outNodeID(i) )->pin();
			m_pWires[i] = new Wire( m_pInNode->pin(i), pin );
		}
	}
	else
	{
		for ( unsigned i = busSize; i < unsigned(m_busSize); i++ )
		{
			removeNode( outNodeID(i) );
			delete m_pWires[i];
		}
		m_pWires.resize(busSize);
	}
	m_busSize = busSize;
	
	// Position pins
	setSize( 0, -int(m_busSize+1)*8, 8, int(m_busSize+1)*16, true );
	for ( int i = 0; i < int(m_busSize); i++ )
		m_nodeMap[ outNodeID(i) ].y = 16*i - int(m_busSize+1)*8 + 24;
	m_nodeMap["n1"].y = -int(m_busSize+1)*8 + 8;
	
	updateAttachedPositioning();
}
Esempio n. 12
0
void MultiInputGate::updateLogicSymbolShape() {
	// Set the canvas changed for the old shape
	setChanged();

	if(KTLConfig::logicSymbolShapes() == KTLConfig::EnumLogicSymbolShapes::Distinctive) {
		m_logicSymbolShape = Distinctive;
		setSize(-m_distinctiveWidth / 2, offsetY(), m_distinctiveWidth, height(), true);
	} else {
		m_logicSymbolShape = Rectangular;
		setSize(-16, offsetY(), 32, height(), true);
	}

	updateSymbolText();
	updateAttachedPositioning();

	if (p_itemDocument)
		p_itemDocument->requestEvent(ItemDocument::ItemDocumentEvent::RerouteInvalidatedConnectors);

	// Set the canvas changed for the new shape
	setChanged();
}
Esempio n. 13
0
void FlowContainer::setExpanded( bool expanded )
{
	if ( b_expanded == expanded )
		return;
	
	updateConnectorPoints(false);
	
	// Set this now, so that child items that we call know whether or not we actually are expanded
	b_expanded = expanded;
	
	updateContainedVisibility();
	updateAttachedPositioning();
	
	p_itemDocument->setModified(true);
	m_rectangularOverlay->setVisible(expanded);
	setFullBounds(false);
	
	bool nodesMoved = (m_ext_out != 0l);
	if (nodesMoved)
		p_icnDocument->requestRerouteInvalidatedConnectors();	
	
	p_icnDocument->requestStateSave();
}
Esempio n. 14
0
void MatrixDisplay::initPins(unsigned numRows, unsigned numCols) {
    if ((numRows == m_numRows) && (numCols == m_numCols))
        return;

    m_lastUpdatePeriod = 0.0;

    //BEGIN Create or destroy pins
// FIXME: Very Very broken. =( -- breaks on resize above initial size... 

    if (numCols >= m_numCols) {
        m_LEDs.resize(numCols);

        for (unsigned i = m_numCols; i < numCols; i++) {

            if (numRows == m_numRows) {
                std::vector<MatrixDisplayCell> *foo = &m_LEDs[i];
                foo->resize(numRows);

                for (unsigned j = 0; j < numRows; j++) {
                    MatrixDisplayCell *tmp = &(*foo)[j];

                    tmp->m_avgBrightness = 0.0;
                    tmp->m_lastBrightness = 255;
                }
            }

            m_pColNodes[i] = createPin(0, 0, 270, colPinID(i));
        }
    } else {
        for (unsigned i = numCols; i < m_numCols; i++) {
            std::vector<MatrixDisplayCell> *tmp = &m_LEDs[i];

            for (unsigned j = 0; j < m_numRows; j++) {
                removeElement(&((*tmp)[j].m_pDiode), false);
            }

            removeNode(colPinID(i));
            m_pColNodes[i] = 0;
        }

        m_LEDs.resize(numCols);
    }

    m_numCols = numCols;

    if (numRows >= m_numRows) {

        for (unsigned j = 0; j < m_numCols; j++)
            m_LEDs[j].resize(numRows);

        for (unsigned i = m_numRows; i < numRows; i++) {

            for (unsigned j = 0; j < m_numCols; j++) {
                MatrixDisplayCell *tmp = &(m_LEDs[j][i]);

                tmp->m_avgBrightness = 0.0;
                tmp->m_lastBrightness = 255;
            }

            m_pRowNodes[i] = createPin(0, 0, 0, rowPinID(i));
        }
    } else {

        for (unsigned i = numRows; i < m_numRows; i++) {
            for (unsigned j = 0; j < m_numCols; j++) {
                removeElement(&(m_LEDs[j][i].m_pDiode), false);
            }

            removeNode(rowPinID(i));
            m_pRowNodes[i] = 0;
        }

        for (unsigned j = 0; j < m_numCols; j++)
            m_LEDs[j].resize(numRows);
    }

    m_numRows = numRows;
    //END Create or destroy pins

    //BEGIN Position pins et al
    setSize(-int(numCols + 1) * 8,
            -int(numRows + 1) * 8,
            int(numCols + 1) * 16,
            int(numRows + 1) * 16, true);

    for (int i = 0; i < int(m_numCols); i++) {
        m_nodeMap[colPinID(i)].x = offsetX() + 16 + 16 * i;
        m_nodeMap[colPinID(i)].y = offsetY() + height() + 8;
    }

    for (int i = 0; i < int(m_numRows); i++) {
        m_nodeMap[rowPinID(i)].x = offsetX() - 8;
        m_nodeMap[rowPinID(i)].y = offsetY() + 16 + 16 * i;
    }

    updateAttachedPositioning();
    //END Position pins et al
}
Esempio n. 15
0
void ECKeyPad::initPins(unsigned numCols) {
    if (numCols < 3)
        numCols = 3;
    else if (numCols > 9)
        numCols = 9;

    if (numCols == m_numCols)
        return;

    int w = sideLength(numCols);
    int h = sideLength(4);

    setSize(-int(w / 16)*8, -int(h / 16)*8, w, h, true);

    if (numCols > m_numCols) {
        // Adding columns
        for (unsigned i = 0; i < 4; i++) {
            for (unsigned j = m_numCols; j < numCols; j++)
                addButton(buttonID(i, j), QRect(0, 0, 20, 20), text[i][j]);
        }

        ECNode *cols[9];

        for (unsigned j = m_numCols; j < numCols; j++)
            cols[j] = createPin(0, 64, 270, "col_" + QString::number(j));

        for (unsigned i = 0; i < 4; i++) {
            Pin *row = &ecNodeWithID("row_" + QString::number(i))->pin();

            for (unsigned j = m_numCols; j < numCols; j++)
                m_switch[i][j] = new Switch(this, cols[j]->pin(), *row, Switch::Open);
        }
    } else {
        // Remove columns
        for (unsigned i = 0; i < 4; i++) {
            for (unsigned j = numCols; j < m_numCols; j++)
                removeWidget(buttonID(i, j));
        }

        for (unsigned j = numCols; j < m_numCols; j++)
            removeNode("col_" + QString::number(j));

        for (unsigned i = 0; i < 4; i++) {
            for (unsigned j = m_numCols; j < numCols; j++)
                delete m_switch[i][j];
        }
    }

    //BEGIN Update Positions
    m_numCols = numCols;

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < int(m_numCols); j++) {
            widgetWithID(buttonID(i, j))->setOriginalRect(
                QRect(offsetX() + 6 + 24*j, offsetY() + 6 + 24*i, 20, 20));
        }
    }

    for (int i = 0; i < 4; i++)
        m_nodeMap["row_" + QString::number(i)].x = width() + offsetX();

    for (int j = 0; j < int(m_numCols); j++)
        m_nodeMap["col_" + QString::number(j)].x = 24 * j + offsetX() + 16;

    updateAttachedPositioning();
    //END Update Positions
}
Esempio n. 16
0
void CNItem::postResize()
{
	updateAttachedPositioning();
}
Esempio n. 17
0
void PICComponent::initPackage( MicroInfo * microInfo )
{
	MicroPackage * microPackage = microInfo ? microInfo->package() : 0l;
	
	if ( microPackage )
	{
		m_bCreatedInitialPackage = true;
		
		//BEGIN Get pin IDs
		QStringList allPinIDs = microPackage->pinIDs();
		QStringList ioPinIDs = microPackage->pinIDs( PicPin::type_bidir | PicPin::type_input | PicPin::type_open );
	
		// Now, we make the unwanted pin ids blank, so a pin is not created for them
		const QStringList::iterator allPinIDsEnd = allPinIDs.end();
		for ( QStringList::iterator it = allPinIDs.begin(); it != allPinIDsEnd; ++it )
		{
			if ( !ioPinIDs.contains(*it) )
				*it = "";
		}
		//END Get pin IDs
	
	
		//BEGIN Remove old stuff
		// Remove old text
		TextMap textMapCopy = m_textMap;
		const TextMap::iterator textMapEnd = textMapCopy.end();
		for ( TextMap::iterator it = textMapCopy.begin(); it != textMapEnd; ++it )
			removeDisplayText(it.key());
	
		// Remove the old pins
		deletePICComponentPins();
	
		// Remove old nodes
		NodeInfoMap nodeMapCopy = m_nodeMap;
		const NodeInfoMap::iterator nodeMapEnd = nodeMapCopy.end();
		for ( NodeInfoMap::iterator it = nodeMapCopy.begin(); it != nodeMapEnd; ++it )
		{
			if ( !ioPinIDs.contains(it.key()) )
				removeNode( it.key() );
		}
	
		removeElements();
		//END Remove old stuff
	
	
	
		//BEGIN Create new stuff
		initDIPSymbol( allPinIDs, 80 );
		initDIP(allPinIDs);
	
		PicPinMap picPinMap = microPackage->pins( PicPin::type_bidir | PicPin::type_input | PicPin::type_open );
		const PicPinMap::iterator picPinMapEnd = picPinMap.end();
		for ( PicPinMap::iterator it = picPinMap.begin(); it != picPinMapEnd; ++it )
			m_picComponentPinMap[it.key()] = new PICComponentPin( this, it.value() );
		//END Create new stuff
	
	
		removeDisplayText( "no_file" );
		addDisplayText( "picid", QRect(offsetX(), offsetY()-16, width(), 16), microInfo->id() );
	}
	else
	{
		setSize( -48, -72, 96, 144 );
		removeDisplayText( "picid" );
		addDisplayText( "no_file", sizeRect(), i18n("(No\nprogram\nloaded)") );
	}
	
	
	//BEGIN Update button positions
	int leftpos = (width()-88)/2+offsetX();
	button("run")->setOriginalRect( QRect( leftpos, height()+4+offsetY(), 20, 20 ) );
	button("pause")->setOriginalRect( QRect( leftpos+23, height()+4+offsetY(), 20, 20 ) );
	button("reset")->setOriginalRect( QRect( leftpos+46, height()+4+offsetY(), 20, 20 ) );
	button("reload")->setOriginalRect( QRect( leftpos+69, height()+4+offsetY(), 20, 20 ) );
	updateAttachedPositioning();
	//END Update button positions
}