void Widget::display() { delete layout(); QSpacerItem *space1 = new QSpacerItem(100,10); QSpacerItem *space2 = new QSpacerItem(100,10); QSpacerItem *space3 = new QSpacerItem(10,10); QHBoxLayout *hlayout = new QHBoxLayout; hlayout->addSpacerItem(space1); hlayout->addWidget(integral); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(numerator); if(this->isVisibleDenominator){ QPixmap lineP(max(lineSizePixels((QString)numerator->text()),lineSizePixels((QString)denominator->text())),2); QPainter paint; paint.begin(&lineP); paint.setBrush(QBrush(Qt::black)); paint.eraseRect(0,0,1000,1000); paint.drawRect(0,0,1000,1000); paint.end(); line->setPixmap(lineP); layout->addWidget(line); layout->addWidget(denominator); } hlayout->addLayout(layout); hlayout->addSpacerItem(space3); hlayout->addWidget(diff); hlayout->addSpacerItem(space2); QVBoxLayout *vlayout = new QVBoxLayout; vlayout->addLayout(hlayout); vlayout->addWidget(answer); setLayout(vlayout); }
/* http://geomalgorithms.com/a07-_distance.html */ void intersectLines(const Eigen::Vector3f &p0, const Eigen::Vector3f &p1, const Eigen::Vector3f &q0, const Eigen::Vector3f &q1, Eigen::Vector3f &pointOnP, Eigen::Vector3f &pointOnQ) { Eigen::Vector3f w0 = p0 - q0; /* the two vectors on the lines */ Eigen::Vector3f u = p1 - p0; u.normalize(); Eigen::Vector3f v = q0 - q1; v.normalize(); float a = u.dot(u); float b = u.dot(v); float c = v.dot(v); float d = u.dot(w0); float e = v.dot(w0); float normFactor = a*c - b*b; float sc = (b*e - c*d) / normFactor; float tc = (a*e - b*d) / normFactor; /* the two nearest points on the lines */ Eigen::ParametrizedLine<float, 3> lineP(p0, u); pointOnP = lineP.pointAt(sc); Eigen::ParametrizedLine<float, 3> lineQ(q0, v); pointOnQ = lineQ.pointAt(tc); }
bool PNS_DIFF_PAIR_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem ) { if( !m_fitOk ) return false; if( m_currentTrace.CP().SegmentCount() < 1 || m_currentTrace.CN().SegmentCount() < 1 ) return false; if( m_currentTrace.CP().SegmentCount() > 1 ) m_initialDiagonal = !DIRECTION_45( m_currentTrace.CP().CSegment( -2 ) ).IsDiagonal(); PNS_TOPOLOGY topo( m_lastNode ); if( !m_snapOnTarget && !m_currentTrace.EndsWithVias() ) { SHAPE_LINE_CHAIN newP( m_currentTrace.CP() ); SHAPE_LINE_CHAIN newN( m_currentTrace.CN() ); if( newP.SegmentCount() > 1 && newN.SegmentCount() > 1 ) { newP.Remove( -1, -1 ); newN.Remove( -1, -1 ); } m_currentTrace.SetShape( newP, newN ); } if( m_currentTrace.EndsWithVias() ) { m_lastNode->Add( m_currentTrace.PLine().Via().Clone() ); m_lastNode->Add( m_currentTrace.NLine().Via().Clone() ); m_chainedPlacement = false; } else { m_chainedPlacement = !m_snapOnTarget; } PNS_LINE lineP( m_currentTrace.PLine() ); PNS_LINE lineN( m_currentTrace.NLine() ); m_lastNode->Add( &lineP ); m_lastNode->Add( &lineN ); topo.SimplifyLine( &lineP ); topo.SimplifyLine( &lineN ); m_prevPair = m_currentTrace.EndingPrimitives(); Router()->CommitRouting( m_lastNode ); m_lastNode = NULL; m_placingVia = false; if( m_snapOnTarget ) { m_idle = true; return true; } else { initPlacement(); return false; } }