int polyOverlap(Point p, Poly * pp, Point q, Poly * qp) { Point op, cp; Point oq, cq; /* translate bounding boxes */ addpt(&op, p, pp->origin); addpt(&cp, p, pp->corner); addpt(&oq, q, qp->origin); addpt(&cq, q, qp->corner); /* If bounding boxes don't overlap, done */ if (!pintersect(op, cp, oq, cq)) return 0; if (ISBOX(pp) && ISBOX(qp)) return 1; if (ISCIRCLE(pp) && ISCIRCLE(qp)) { double d = (pp->corner.x - pp->origin.x + qp->corner.x - qp->origin.x); double dx = p.x - q.x; double dy = p.y - q.y; if ((dx * dx + dy * dy) > (d * d) / 4.0) return 0; else return 1; } if (tp1 == NULL) { tp1 = N_GNEW(maxcnt, Point); tp2 = N_GNEW(maxcnt, Point); } transCopy(pp->verts, pp->nverts, p, tp1); transCopy(qp->verts, qp->nverts, q, tp2); return (edgesIntersect(tp1, tp2, pp->nverts, qp->nverts) || (inBox(*tp1, oq, cq) && inPoly(tp2, qp->nverts, *tp1)) || (inBox(*tp2, op, cp) && inPoly(tp1, pp->nverts, *tp2))); }
void firstPage::setUp_PolyTable(){ polyTable=ui->polyTable; polyTable->verticalHeader()->setVisible(false); polyTable->horizontalHeader()->setVisible(false); polyTable->setShowGrid(false); //Format 1. Column for(int i = 0; i<polyTable->rowCount() ; i++) { polyTable->item(i,0)->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); } ////////////////////////////////////////////////////////// // Put DoubleSpinBoxes in 2.Column of Table // ////////////////////////////////////////////////////////// for( int i = 0; i < polyTable->rowCount(); i++ ) { QDoubleSpinBox *spinBox = new QDoubleSpinBox(); spinBox->setValue(0); polyTable->setCellWidget( i, 1, spinBox ); } //Format SpinBoxes Manually static_cast<QSpinBox*>(polyTable->cellWidget(0,1))->setMinimum(0); static_cast<QSpinBox*>(polyTable->cellWidget(0,1))->setMaximum(maxA/2); static_cast<QSpinBox*>(polyTable->cellWidget(1,1))->setMinimum(0); static_cast<QSpinBox*>(polyTable->cellWidget(1,1))->setMaximum(1000); static_cast<QSpinBox*>(polyTable->cellWidget(2,1))->setMinimum(-1000); static_cast<QSpinBox*>(polyTable->cellWidget(2,1))->setMaximum(1000); static_cast<QSpinBox*>(polyTable->cellWidget(3,1))->setMinimum(-1000); static_cast<QSpinBox*>(polyTable->cellWidget(3,1))->setMaximum(1000); static_cast<QSpinBox*>(polyTable->cellWidget(4,1))->setMinimum(-1000); static_cast<QSpinBox*>(polyTable->cellWidget(4,1))->setMaximum(1000); static_cast<QSpinBox*>(polyTable->cellWidget(5,1))->setMinimum(0); static_cast<QSpinBox*>(polyTable->cellWidget(5,1))->setMaximum(veloMax); //////////////////////////////////////////////////////////////////////// // Load stored values and assign them in 3. and 2. Column // //////////////////////////////////////////////////////////////////////// cout<<mPoly.getStoredValuesPath()<<endl; QFile polyFile(QString::fromStdString(mPoly.getStoredValuesPath())); polyFile.open(QIODevice::ReadOnly | QIODevice::Text); QTextStream inPoly(&polyFile); for( int i = 0; i < polyTable->rowCount(); i++ ) { QLabel *label = new QLabel(); double x = inPoly.readLine().toDouble(); label->setNum(x); cout<<x<<endl; label->setAlignment(Qt::AlignVCenter); polyTable->setCellWidget( i, 3, label ); static_cast<QDoubleSpinBox*>(polyTable->cellWidget(i,1))->setValue(x); } polyFile.close(); //make 1. Column unaccesible for(int i = 0;i<polyTable->rowCount();i++){ polyTable->item(i,0)->setFlags(polyTable->item(i,0)->flags() ^ Qt::ItemIsEditable); polyTable->item(i,0)->setFlags(polyTable->item(i,0)->flags() ^ Qt::ItemIsSelectable); polyTable->item(i,0)->setFlags(polyTable->item(i,0)->flags() ^ Qt::ItemIsUserCheckable); //polyTable->item(i,0)->setFlags(polyTable->item(i,0)->flags() ^ Qt::ItemIsEnabled); } polyTable->setColumnWidth(2,cWidth); polyTable->setTabKeyNavigation(false); }