void QtUnit::_ToggleConnections(bool flag) { if (toggled == flag) return; toggled = flag; Column *col = (Column *)node; DendriteSegment *segment = col->GetProximalDendriteSegment(); std::vector<Synapse *> prox_syns = segment->GetSynapses(); int rfs = col->GetRecFieldSz(); //for (int i=0; i<rfs; i++) // prox_syns[i]->ShowSynapse(flag); }
void QtUnit::mousePressEvent(QMouseEvent *event) { if (event->button() != Qt::LeftButton) return; if (!this->IsClickable()) return; QVBoxLayout *objGroupLayout = new QVBoxLayout(); QScrollArea *objScroll = new QScrollArea(objDetail); objScroll->setStyleSheet("background-color: rgb(25, 25, 25);"); objScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); objScroll->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); QWidget *scrollChild = new QWidget(); QGridLayout *objGrid = new QGridLayout(scrollChild); objGrid->setSizeConstraint(QLayout::SetMinAndMaxSize); QLayout *currentLayout = NULL; QLayoutItem *child = NULL; if (objDetail) { if ((currentLayout = objDetail->layout())) { while ((child = currentLayout->takeAt(0)) != 0) delete child->widget(); delete currentLayout; } } objGroupLayout->addWidget(objScroll); QLabel *overlapLab = new QLabel("overlap: "); QLabel *overlapVal = new QLabel(QString::number(((Column *)node)->GetOverlap())); objGrid->addWidget(overlapLab, 0, 0); objGrid->addWidget(overlapVal, 0, 1); QLabel *synapsesLab = new QLabel("synaptic details"); objGrid->addWidget(synapsesLab, 1, 0, 1, 3); QLabel *idx = new QLabel("Idx"); QLabel *coord = new QLabel("Coord"); QLabel *firing = new QLabel("Firing"); QLabel *perm = new QLabel("Perm"); objGrid->addWidget(idx, 2, 0); objGrid->addWidget(coord, 2, 1); objGrid->addWidget(firing, 2, 2); objGrid->addWidget(perm, 2, 3); Column *col = (Column *)node; DendriteSegment *segment = col->GetProximalDendriteSegment(); std::vector<Synapse *> syns = segment->GetSynapses(); for (int i=0; i<col->GetRecFieldSz(); i++) { char synCoordStr[32]; memset(synCoordStr, 0, sizeof(synCoordStr)); unsigned int x = syns[i]->GetX(), y = syns[i]->GetY(); snprintf(synCoordStr, sizeof(synCoordStr), "(%d, %d)", x, y); float p = syns[i]->GetPerm(); QLabel *synIdx = new QLabel(QString("%1: ").arg(i)); QLabel *synCoordLab = new QLabel(synCoordStr); QLabel *synFiring = new QLabel(QString("%1").arg(syns[i]->IsFiring()? 1 : 0)); QLabel *synPerm = new QLabel(QString("%1: ").arg(p)); objGrid->addWidget(synIdx, 3+i, 0, 1, 1); objGrid->addWidget(synCoordLab, 3+i, 1, 1, 1); objGrid->addWidget(synFiring, 3+i, 2, 1, 1); objGrid->addWidget(synPerm, 3+i, 3, 1, 1); } // Note: must add the layout of widget before calling setWidget() or won't // be visible. objScroll->setWidget(scrollChild); objDetail->setLayout(objGroupLayout); }