QString QTikzPicturePrivate::toTikzPath(const QRectF & rect) const { if (rect.isEmpty()) return QString(); const QString path = toCoord(rect.topLeft()) + " rectangle " + toCoord(rect.bottomRight()); return path; }
QString QTikzPicturePrivate::toTikzPath(const QPainterPath & path) const { if (path.isEmpty()) return QString(); QStringList pathList; QString currentPath; int currentControlPoint = 0; // convert QPainterPath to a TikZ path string for (int i = 0; i < path.elementCount(); i++) { const QPainterPath::Element & element = path.elementAt(i); switch (element.type) { case QPainterPath::MoveToElement: { // close current path + append to path list if (!currentPath.isEmpty()) { currentPath += " -- cycle"; pathList << currentPath; } // indent with spaces for better readability const char * indentString = pathList.count() ? " " : ""; // start new path currentPath.clear(); currentPath += indentString + toCoord(element); break; } case QPainterPath::LineToElement: { currentPath += " -- " + toCoord(element); break; } case QPainterPath::CurveToElement: { currentPath += " .. controls " + toCoord(element); currentControlPoint = 1; break; } case QPainterPath::CurveToDataElement: { if (currentControlPoint == 1) { currentPath += " and " + toCoord(element); ++currentControlPoint; } else if (currentControlPoint == 2) { currentPath += " .. " + toCoord(element); currentControlPoint = 0; } break; } } } return pathList.join("\n"); }
QString QTikzPicturePrivate::toTikzPath(const QPointF & circleCenter, qreal radius) const { if (radius < 0) return QString(); QLocale l = QLocale::c(); const QString path = toCoord(circleCenter) + " circle (" + l.toString(radius, 'g', precision) + "cm)"; return path; }
QString QTikzPicturePrivate::toTikzPath(const QPolygonF & polygon) const { if (polygon.isEmpty()) return QString(); const int end = polygon.size() - polygon.isClosed() ? 1 : 0; QString path; for (int i = 0; i < end; ++i) { if (i == 0) { path = toCoord(polygon[i]); } else if (i == end - 1) { path += " -- cycle"; } else { path += " -- " + toCoord(polygon[i]); } } return path; }
BoardItem::BoardItem( QGraphicsItem * parent , QGraphicsScene * scene ) : QGraphicsItem(), d( new Private) { d->squares.resize(64); for(Game::Square sq = 0; sq < 64; sq++) { QPoint coord = toCoord(sq); bool white = (coord.x()+coord.y()) % 2 == 0; SquareItem *square = new SquareItem( this, sq, white); square->setPos(coord.x() * 32, coord.y() * 32 ); d->squares[sq] = square; } }
void MapKnowledge::discover(const Position& i_Pos, const RangeOfSight& i_ROS) { m_LastTile = toSCoord(i_Pos.tileCoord()); m_LastDir = i_Pos.facingDir(); m_LastROS = &i_ROS; SCoord ulCorner(i_ROS.getWindowULCorner(m_LastDir)); SCoord lrCorner(i_ROS.getWindowLRCorner(m_LastDir)); SCoord centered; for ( centered.y = ulCorner.y; centered.y < lrCorner.y; ++centered.y) { for (centered.x = ulCorner.x; centered.x < lrCorner.x; ++centered.x) { Coord onMap(toCoord(m_LastTile + centered)); if (!(onMap < m_Dim)) { continue; } std::vector<bool>::reference curr(operator()(onMap)); curr = curr || i_ROS.isVisible(centered, m_LastDir); } } }
/*----------------------------------------------------------------------------*/ void SAO::onParse(StreamAccessLayer &streamAccessLayer, Decoder::State &decoder) { /* start: derived from arguments */ auto saoCoord = get<Coord>()->inUnits(); /* end: derived from arguments */ const auto rx = saoCoord.x(); const auto ry = saoCoord.y(); /* start: inferrable */ auto saoMergeLeftFlag = embed<SaoMergeLeftFlag>(*this); auto saoMergeUpFlag = embed<SaoMergeUpFlag>(*this); auto saoTypeIdxLuma = embed<SaoTypeIdxLuma>(*this); auto saoTypeIdxChroma = embed<SaoTypeIdxChroma>(*this); auto saoOffsetAbs = embed<SaoOffsetAbs>(*this); auto saoOffsetSign = embed<SaoOffsetSign>(*this); auto saoBandPosition = embed<SaoBandPosition>(*this); auto saoEoClassLuma = embed<SaoEoClassLuma>(*this); auto saoEoClassChroma = embed<SaoEoClassChroma>(*this); auto saoTypeIdx = embed<SaoTypeIdx>(*this); auto saoOffsetVal = embed<SaoOffsetVal>(*this); auto saoEoClass = embed<SaoEoClass>(*this); /* end: inferrable */ const auto picture = decoder.picture(); const auto chromaFormatIdc = picture->chromaFormatIdc; const auto slice = picture->slice(saoCoord); const auto sh = slice->header(); const auto ctu = picture->getCodingTreeUnit(saoCoord); typedef SliceSegmentHeader SSH; typedef CodingTreeUnit CTU; const auto sliceAddrInRs = slice->addr().inRs; const auto ctbAddrInRs = ctu->get<CTU::CtbAddrInRs>()->inUnits(); if(0_pel < rx) { const auto leftCtbInSliceSeg = ctbAddrInRs > sliceAddrInRs; const auto leftCtbInTile = picture->tileId(picture->toCoord(ctbAddrInRs)) == picture->tileId(picture->toCoord(ctbAddrInRs - 1_ctb)); if(leftCtbInSliceSeg && leftCtbInTile) { parse(streamAccessLayer, decoder, *saoMergeLeftFlag); } } if(0_pel < ry && !*saoMergeLeftFlag) { const auto picWidthInCtbsY = picture->widthInCtbsY; const auto upCtbInSliceSeg = (ctbAddrInRs - picWidthInCtbsY) >= sliceAddrInRs; const auto upCtbInTile = picture->tileId(picture->toCoord(ctbAddrInRs)) == picture->tileId(picture->toCoord(ctbAddrInRs - picWidthInCtbsY)); if(upCtbInSliceSeg && upCtbInTile) { parse(streamAccessLayer, decoder, *saoMergeUpFlag); } } if(*saoMergeLeftFlag || *saoMergeUpFlag) { const auto deriveAdjCoord = [saoCoord, saoMergeLeftFlag, saoMergeUpFlag]() { if(*saoMergeLeftFlag) { syntaxCheck(0_pel < saoCoord.x()); return PelCoord{saoCoord.x() - 1_pel, saoCoord.y()}; } else if(*saoMergeUpFlag) { syntaxCheck(0_pel < saoCoord.y()); return PelCoord{saoCoord.x(), saoCoord.y() - 1_pel}; } else { syntaxCheck(false); } return PelCoord{saoCoord}; }; const auto adjCoord = deriveAdjCoord(); const auto adj = picture->getCodingTreeUnit(adjCoord)->getSAO(); saoTypeIdx->merge(*adj); saoOffsetVal->merge(*adj); saoBandPosition->merge(*adj); saoEoClass->merge(*adj); } else { for(const auto cIdx : EnumRange<Plane>()) { const auto component = toComponent(cIdx); const auto isLuma = Component::Luma == component; const auto isChroma = !isLuma; if( isLuma && !(*sh->get<SSH::SliceSaoLumaFlag>()) || ChromaFormatIdc::f400 == chromaFormatIdc && isChroma || isChroma && !(*sh->get<SSH::SliceSaoChromaFlag>())) { continue; } if(Plane::Y == cIdx) { parse(streamAccessLayer, decoder, *saoTypeIdxLuma); saoTypeIdx->set(*saoTypeIdxLuma); } else if(Plane::Cb == cIdx) { parse(streamAccessLayer, decoder, *saoTypeIdxChroma); saoTypeIdx->set(*saoTypeIdxChroma); } if(SaoType::NotApplied != (*saoTypeIdx)[component]) { for(auto i = 0; i < 4; ++i) { parse(streamAccessLayer, decoder, *saoOffsetAbs, cIdx, i); } saoOffsetSign->init(cIdx, (*saoTypeIdx)[component]); if(SaoType::BandOffset == (*saoTypeIdx)[component]) { for(auto i = 0; i < 4; ++i) { if(0 != (*saoOffsetAbs)[makeTuple(cIdx, i)]) { parse(streamAccessLayer, decoder, *saoOffsetSign, cIdx, i); } } parse(streamAccessLayer, decoder, *saoBandPosition, cIdx); } else { syntaxCheck(SaoType::EdgeOffset == (*saoTypeIdx)[component]); if(Plane::Y == cIdx) { parse(streamAccessLayer, decoder, *saoEoClassLuma); } if(Plane::Cb == cIdx) { parse(streamAccessLayer, decoder, *saoEoClassChroma); } } } } typedef PpsRangeExtension PPSRE; const auto ppsre = picture->ppsre; const auto saoOffsetScaleLuma = ppsre ? ppsre->get<PPSRE::SaoOffsetScaleLuma>()->inUnits() : 0_log2; const auto saoOffsetScaleChroma = ppsre ? ppsre->get<PPSRE::SaoOffsetScaleChroma>()->inUnits() : 0_log2; saoOffsetVal->set( *saoOffsetAbs, *saoOffsetSign, saoOffsetScaleLuma, saoOffsetScaleChroma); saoEoClass->set(*saoEoClassLuma, *saoEoClassChroma); } }
QString QTikzPicturePrivate::toTikzPath(const QLineF & line) const { const QString path = toCoord(line.p1()) + " -- " + toCoord(line.p2()); return path; }