diff --git a/src/wallitem.cpp b/src/wallitem.cpp --- a/src/wallitem.cpp +++ b/src/wallitem.cpp @@ -38,29 +38,29 @@ WallItem::WallItem( Wall *w, int wallnum extern Parameter par; - setColor(); - - // line with "PIN1"is a bit inside the cell wall - Vector edgevec = (*(w->N2())) - (*(w->N1())); - Vector perp = edgevec.Normalised().Perp2D(); - - Vector offs = Cell::Offset(); - double factor = Cell::Factor(); - - Vector from = ( offs + *(w->N1()) ) * factor + (wn==1?-1:1) * par.outlinewidth * 0.5 * factor * perp; - Vector to = ( offs + *(w->N2()) ) *factor + (wn==1?-1:1) * par.outlinewidth * 0.5 * factor * perp; - - - Vector tmp_centroid = ( *(w->N2()) + *(w->N1()) )/2.; - Vector centroid = ( offs + tmp_centroid ) * factor; - - QString text=QString("%1").arg(w->Index()); - setLine(( from.x ), - ( from.y ), - ( to.x ), - ( to.y ) ); - setZValue(12); - } + setColor(); + + // line with "PIN1"is a bit inside the cell wall + Vector edgevec = (*(w->N2())) - (*(w->N1())); + Vector perp = edgevec.Normalised().Perp2D(); + + Vector offs = Cell::Offset(); + double factor = Cell::Factor(); + + Vector from = ( offs + *(w->N1()) ) * factor + (wn==1?-1:1) * par.outlinewidth * 0.5 * factor * perp; + Vector to = ( offs + *(w->N2()) ) *factor + (wn==1?-1:1) * par.outlinewidth * 0.5 * factor * perp; + + + Vector tmp_centroid = ( *(w->N2()) + *(w->N1()) )/2.; + Vector centroid = ( offs + tmp_centroid ) * factor; + + QString text=QString("%1").arg(w->Index()); + setLine(( from.x ), + ( from.y ), + ( to.x ), + ( to.y ) ); + setZValue(12); +} void WallItem::setColor(void) { @@ -68,7 +68,7 @@ void WallItem::setColor(void) { QColor diffcolor; static const QColor purple("Purple"); static const QColor blue("blue"); - + Wall *w=&getWall(); double tr = wn==1?w->Transporters1(1):w->Transporters2(1); CellBase *c = wn==1?w->C1():w->C2(); @@ -85,46 +85,48 @@ void WallItem::setColor(void) { } void WallItem::OnClick(QMouseEvent *e) { - + + + Wall *w=&getWall(); +#ifdef QDEBUG + qDebug() << "Wall ID = " << w->Index() << ", this = " << w << endl; + qDebug() << "Wall item = " << this << endl; + qDebug() << "C1 = " << w->C1()->Index() << ", C2 = " << w->C2()->Index() << endl; + qDebug() << "N1 = " << w->N1()->Index() << ", N2 = " << w->N2()->Index() << endl; +#endif + CellBase *c = wn==1?w->C1():w->C2(); - Wall *w=&getWall(); - #ifdef QDEBUG - qDebug() << "Wall ID = " << w->Index() << ", this = " << w << endl; - qDebug() << "Wall item = " << this << endl; - qDebug() << "C1 = " << w->C1()->Index() << ", C2 = " << w->C2()->Index() << endl; - qDebug() << "N1 = " << w->N1()->Index() << ", N2 = " << w->N2()->Index() << endl; - #endif - CellBase *c = wn==1?w->C1():w->C2(); + TransporterDialog dialog(w, c, wn); + dialog.exec(); - TransporterDialog dialog(w, c, wn); - dialog.exec(); + if (e->button() == Qt::RightButton) { + QString message; + if (wn==1) { + message=QString("Transporter 1 = %1, color = %2, length = %3\n").arg(w->Transporters1(1)).arg(pen().color().red()).arg(getWall().Length()); + } else { + message=QString("Transporter 2 = %1, color = %2, length = %3\n").arg(w->Transporters2(1)).arg(pen().color().red()).arg(getWall().Length()); + } - if (e->button() == Qt::RightButton) { - QString message; - if (wn==1) { - message=QString("Transporter 1 = %1, color = %2, length = %3\n").arg(w->Transporters1(1)).arg(pen().color().red()).arg(getWall().Length()); - } else { - message=QString("Transporter 2 = %1, color = %2, length = %3\n").arg(w->Transporters2(1)).arg(pen().color().red()).arg(getWall().Length()); - } - - //extern MainBase *main_window; - + //extern MainBase *main_window; + + } else { + if (e->button() == Qt::LeftButton) { + if (c->BoundaryPolP()) { + w->cycleWallType(); + } else { + if (e->modifiers() == Qt::ShiftModifier) { + wn==1?w->setTransporters1(1,0):w->setTransporters2(1,0); + } else { - if (e->button() == Qt::LeftButton) { - if (c->BoundaryPolP()) { - w->cycleWallType(); - } else { - if (e->modifiers() == Qt::ShiftModifier) { - wn==1?w->setTransporters1(1,0):w->setTransporters2(1,0); - - } else { - // set high amount of PIN1 - //cerr << "Setting PIN1\n"; - wn==1?w->setTransporters1(1,10):w->setTransporters2(1,10); - } - } - setColor(); - update(boundingRect()); - } + // set high amount of PIN1 + //cerr << "Setting PIN1\n"; + wn==1?w->setTransporters1(1,10):w->setTransporters2(1,10); } + } + setColor(); + update(boundingRect()); + } + } } + +/* finis */