Esempio n. 1
0
void Circuit::addNetClass(NetClass& netclass) throw (Exception)
{
    if (&netclass.getCircuit() != this) {
        throw LogicError(__FILE__, __LINE__);
    }
    // check if there is no netclass with the same uuid in the list
    if (getNetClassByUuid(netclass.getUuid())) {
        throw RuntimeError(__FILE__, __LINE__, netclass.getUuid().toStr(),
            QString(tr("There is already a net class with the UUID \"%1\"!"))
            .arg(netclass.getUuid().toStr()));
    }
    // check if there is no netclass with the same name in the list
    if (getNetClassByName(netclass.getName())) {
        throw RuntimeError(__FILE__, __LINE__, netclass.getUuid().toStr(),
            QString(tr("There is already a net class with the name \"%1\"!"))
            .arg(netclass.getName()));
    }
    // add netclass to circuit
    netclass.addToCircuit(); // can throw
    mNetClasses.insert(netclass.getUuid(), &netclass);
    emit netClassAdded(netclass);
}
Esempio n. 2
0
void Circuit::removeNetClass(NetClass& netclass) throw (Exception)
{
    Q_ASSERT(mNetClasses.contains(netclass.getUuid()) == true);

    // the netclass cannot be removed if there are already netsignals with that netclass!
    if (netclass.getNetSignalCount() > 0)
    {
        throw RuntimeError(__FILE__, __LINE__, QString("%1:%2")
            .arg(netclass.getUuid().toStr()).arg(netclass.getNetSignalCount()),
            QString(tr("There are already signals in the netclass \"%1\"!"))
            .arg(netclass.getName()));
    }

    // remove netclass from project
    netclass.removeFromCircuit();
    mNetClasses.remove(netclass.getUuid());
    emit netClassRemoved(netclass);
}
Esempio n. 3
0
void Circuit::setNetClassName(NetClass& netclass, const QString& newName) throw (Exception)
{
    Q_ASSERT(mNetClasses.contains(netclass.getUuid()) == true);
    if (newName == netclass.getName()) return;

    // check the validity of the new name
    if (newName.isEmpty())
    {
        throw RuntimeError(__FILE__, __LINE__, netclass.getUuid().toStr(),
            QString(tr("The new netclass name must not be empty!")));
    }

    // check if there is no netclass with the same name in the list
    if (getNetClassByName(newName))
    {
        throw RuntimeError(__FILE__, __LINE__, netclass.getUuid().toStr(),
            QString(tr("There is already a netclass with the name \"%1\"!")).arg(newName));
    }

    // apply the new name
    netclass.setName(newName);
}