本文整理汇总了C++中SegmentList类的典型用法代码示例。如果您正苦于以下问题:C++ SegmentList类的具体用法?C++ SegmentList怎么用?C++ SegmentList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SegmentList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: s
void QSegmentWidget::clearSegment(int cyl, qreal startAngle, qreal stopAngle)
{
Segment s(startAngle, stopAngle, QColor(Qt::black));
SegmentList sl;
sl.push_back(s);
clearSegments(cyl, sl);
}
示例2: DrawSegments
void QSegmentWidget::DrawSegments(QPainter *painter,
const SegmentList &s, qreal radius)
{
for (SegmentList::const_iterator i = s.begin(); i != s.end(); i++) {
painter->setRenderHint(QPainter::Antialiasing);
painter->setRenderHint(QPainter::SmoothPixmapTransform);
QBrush b(i->color);
painter->setBrush(b);
QBrush c(i->color.darker(200));
painter->setPen(QPen(c, 0));
int startAngle = qRound(i->first * 16.0);
qreal dAngle = i->second - i->first;
if (dAngle < 0.0)
dAngle += 360.0;
int spanAngle = qRound(dAngle * 16.0);
QRectF r(-radius, -radius, radius * 2.0, radius * 2.0);
if (spanAngle >= 360 * 16) {
// qDebug() << QString("DrawSegments drawEllipse (%1, %2)").arg(-radius).arg(radius * 2.0);
painter->drawEllipse(r);
} else {
// qDebug() << QString("DrawSegments drawPie (%1, %2, %3, %4)").arg(-radius).arg(radius * 2.0).arg(startAngle).arg(spanAngle);
painter->drawPie(r, startAngle, spanAngle);
}
}
}
示例3: generateExtrusionContour
void Tessellation::generateExtrusionContour()
{
for( auto& pos : positions )
extrusionContourVertices.push_back( pos );
extrusionContourIndices = segments;
SegmentList additionalSegments;
Vector n;
int originalSegments = extrusionContourIndices.size();
for( auto& segment : extrusionContourIndices )
{
auto& a = positions[ segment.i1 ];
auto& b = positions[ segment.i2 ];
n.x = (float)(a.y - b.y);
n.y = (float)(b.x - a.x);
n = n.normalized();
_assignNormal( n, segment, 0, additionalSegments );
_assignNormal( n, segment, 1, additionalSegments );
}
//add the created segments to the extrusion segments
extrusionContourIndices.insert( extrusionContourIndices.end(), additionalSegments.begin(), additionalSegments.end() );
}
示例4: if
bool SegmentInformation::getSegmentNumberByTime(mtime_t time, uint64_t *ret) const
{
SegmentList *segList;
MediaSegmentTemplate *mediaTemplate;
uint64_t timescale = 1;
mtime_t duration = 0;
if( (mediaTemplate = inheritSegmentTemplate()) )
{
timescale = mediaTemplate->inheritTimescale();
duration = mediaTemplate->duration.Get();
}
else if ( (segList = inheritSegmentList()) )
{
timescale = segList->inheritTimescale();
duration = segList->getDuration();
}
if(duration)
{
*ret = time / (CLOCK_FREQ * duration / timescale);
return true;
}
return false;
}
示例5: getIncludedIntervals
void BoxShape::getIncludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const
{
const FloatRoundedRect& paddingBounds = shapePaddingBounds();
if (paddingBounds.isEmpty())
return;
const FloatRect& rect = paddingBounds.rect();
float y1 = logicalTop;
float y2 = logicalTop + logicalHeight;
if (y1 < rect.y() || y2 > rect.maxY())
return;
if (!paddingBounds.isRounded()) {
result.append(LineSegment(rect.x(), rect.maxX()));
return;
}
float x1 = rect.x();
float x2 = rect.maxX();
float minXIntercept;
float maxXIntercept;
if (paddingBounds.xInterceptsAtY(y1, minXIntercept, maxXIntercept)) {
x1 = std::max<float>(x1, minXIntercept);
x2 = std::min<float>(x2, maxXIntercept);
}
if (paddingBounds.xInterceptsAtY(y2, minXIntercept, maxXIntercept)) {
x1 = std::max<float>(x1, minXIntercept);
x2 = std::min<float>(x2, maxXIntercept);
}
result.append(LineSegment(x1, x2));
}
示例6: logicalTopOffset
void ShapeOutsideInfo::updateDeltasForContainingBlockLine(const RenderBlockFlow& containingBlock, const FloatingObject& floatingObject, LayoutUnit lineTop, LayoutUnit lineHeight)
{
LayoutUnit borderBoxTop = containingBlock.logicalTopForFloat(&floatingObject) + containingBlock.marginBeforeForChild(&m_renderer);
LayoutUnit borderBoxLineTop = lineTop - borderBoxTop;
if (isShapeDirty() || m_borderBoxLineTop != borderBoxLineTop || m_lineHeight != lineHeight) {
m_borderBoxLineTop = borderBoxLineTop;
m_referenceBoxLineTop = borderBoxLineTop - logicalTopOffset();
m_lineHeight = lineHeight;
LayoutUnit floatMarginBoxWidth = containingBlock.logicalWidthForFloat(&floatingObject);
if (lineOverlapsShapeBounds()) {
SegmentList segments = computeSegmentsForLine(borderBoxLineTop, lineHeight);
if (segments.size()) {
LayoutUnit logicalLeftMargin = containingBlock.style()->isLeftToRightDirection() ? containingBlock.marginStartForChild(&m_renderer) : containingBlock.marginEndForChild(&m_renderer);
LayoutUnit rawLeftMarginBoxDelta = segments.first().logicalLeft + logicalLeftMargin;
m_leftMarginBoxDelta = clampToLayoutUnit(rawLeftMarginBoxDelta, LayoutUnit(), floatMarginBoxWidth);
LayoutUnit logicalRightMargin = containingBlock.style()->isLeftToRightDirection() ? containingBlock.marginEndForChild(&m_renderer) : containingBlock.marginStartForChild(&m_renderer);
LayoutUnit rawRightMarginBoxDelta = segments.last().logicalRight - containingBlock.logicalWidthForChild(&m_renderer) - logicalRightMargin;
m_rightMarginBoxDelta = clampToLayoutUnit(rawRightMarginBoxDelta, -floatMarginBoxWidth, LayoutUnit());
m_lineOverlapsShape = true;
return;
}
}
// Lines that do not overlap the shape should act as if the float
// wasn't there for layout purposes. So we set the deltas to remove the
// entire width of the float.
m_leftMarginBoxDelta = floatMarginBoxWidth;
m_rightMarginBoxDelta = -floatMarginBoxWidth;
m_lineOverlapsShape = false;
}
}
示例7: getScaledPlaybackTimeByElementNumber
mtime_t SegmentInformation::getPlaybackTimeBySegmentNumber(uint64_t number) const
{
SegmentList *segList;
MediaSegmentTemplate *mediaTemplate;
mtime_t time = 0;
if( (mediaTemplate = inheritSegmentTemplate()) )
{
uint64_t timescale = mediaTemplate->inheritTimescale();
if(mediaTemplate->segmentTimeline.Get())
{
time = mediaTemplate->segmentTimeline.Get()->
getScaledPlaybackTimeByElementNumber(number);
}
else
{
time = number * mediaTemplate->duration.Get();
}
time = CLOCK_FREQ * time / timescale;
}
else if ( (segList = inheritSegmentList()) )
{
time = segList->getPlaybackTimeBySegmentNumber(number);
}
return time;
}
示例8: Bounds
FileInfo*
PieView::_FileAt(const BPoint& where)
{
BRect b = Bounds();
float cx = b.left + b.Width() / 2.0;
float cy = b.top + b.Height() / 2.0;
float dx = where.x - cx;
float dy = where.y - cy;
float dist = sqrt(dx*dx + dy*dy);
int level;
if (dist < kPieCenterSize)
level = 0;
else
level = 1 + (int)((dist - kPieCenterSize) / kPieRingSize);
float angle = rad2deg(atan(dy / dx));
angle = ((dx < 0.0) ? 180.0 : (dy < 0.0) ? 0.0 : 360.0) - angle;
if (fMouseOverInfo.find(level) == fMouseOverInfo.end()) {
// No files in this level (ring) of the pie.
return NULL;
}
SegmentList s = fMouseOverInfo[level];
SegmentList::iterator i = s.begin();
while (i != s.end() && (angle < (*i).begin || (*i).end < angle))
i++;
if (i == s.end()) {
// Nothing at this angle.
return NULL;
}
return (*i).info;
}
示例9: QGraphicsScene
QGraphicsScene * ClusteredArranger::arrange(SegmentList const & segments) const {
QGraphicsScene * arrangement = new QGraphicsScene();
QTime time;
time.start();
// determine background
Segment * background = determineBackground(segments);
SegmentList segmentsWOBack = removeBackground(segments, background);
arrangement->setBackgroundBrush(QBrush(QColor(background->color().toQRgb())));
segmentsWOBack.calculateFeatureVariances();
// initialize layout
//initializeLayout(segmentsWOBack, segmentsWOBack.featX(), segmentsWOBack.featY());
initializeLayout(segmentsWOBack, xAxisBox->currentIndex(), yAxisBox->currentIndex());
// find clusters
time.restart();
QList<SegmentList> clusters = meanShift(segmentsWOBack);
qDebug("Segments clustered in %f seconds", time.restart()/1000.0);
qDebug(" %d clusters found", clusters.size());
// refine clusters
//int counter = 0;
foreach (SegmentList cluster, clusters) {
if (clusterBox->currentIndex() == 0) {
refineLayoutCircles(cluster);
}
else if (clusterBox->currentIndex() == 1) {
refineLayoutPiles(cluster);
}
// debug output
/*QGraphicsScene scene;
scene.setBackgroundBrush(QBrush(QColor(255, 255, 255)));
foreach(Segment * const segment, cluster) {
scene.addItem(segment->toQGraphicsItem());
// without the following line QPainter tends to crash
scene.width();
}
++counter;
saveScene(&scene, QString("Test%1.png").arg(counter, 2));*/
}
// refine layout
if (clusterBox->currentIndex() == 0) {
refineLayoutByPlace(clusters);
}
else if (clusterBox->currentIndex() == 1) {
refineLayoutBySize(clusters);
}
// convert the segments to QGraphicsItems and add to QGraphicsScene
foreach(Segment const * const segment, segmentsWOBack) {
arrangement->addItem(segment->toQGraphicsItem());
// without the following line QPainter tends to crash
arrangement->width();
}
示例10: parseInitSegment
size_t IsoffMainParser::parseSegmentList(Node * segListNode, SegmentInformation *info)
{
size_t total = 0;
if(segListNode)
{
std::vector<Node *> segments = DOMHelper::getElementByTagName(segListNode, "SegmentURL", false);
SegmentList *list;
if((list = new (std::nothrow) SegmentList(info)))
{
parseInitSegment(DOMHelper::getFirstChildElementByName(segListNode, "Initialization"), list, info);
if(segListNode->hasAttribute("duration"))
list->duration.Set(Integer<stime_t>(segListNode->getAttributeValue("duration")));
if(segListNode->hasAttribute("timescale"))
list->timescale.Set(Integer<uint64_t>(segListNode->getAttributeValue("timescale")));
uint64_t nzStartTime = 0;
std::vector<Node *>::const_iterator it;
for(it = segments.begin(); it != segments.end(); ++it)
{
Node *segmentURL = *it;
Segment *seg = new (std::nothrow) Segment(info);
if(!seg)
continue;
std::string mediaUrl = segmentURL->getAttributeValue("media");
if(!mediaUrl.empty())
seg->setSourceUrl(mediaUrl);
if(segmentURL->hasAttribute("mediaRange"))
{
std::string range = segmentURL->getAttributeValue("mediaRange");
size_t pos = range.find("-");
seg->setByteRange(atoi(range.substr(0, pos).c_str()), atoi(range.substr(pos + 1, range.size()).c_str()));
}
if(list->duration.Get())
{
seg->startTime.Set(nzStartTime);
seg->duration.Set(list->duration.Get());
nzStartTime += list->duration.Get();
}
seg->setSequenceNumber(total);
list->addSegment(seg);
total++;
}
info->setSegmentList(list);
}
}
return total;
}
示例11: clone
SegmentList SegmentList::clone() const
{
SegmentList dl;
Segment* s = _first;
for (int i = 0; i < _size; ++i) {
Segment* ns = s->clone();
dl.push_back(ns);
s = s->next();
}
dl.check();
return dl;
}
示例12: addSegment
void QSegmentWidget::addSegment(int cyl, qreal startAngle, qreal stopAngle, QColor color)
{
// Segment s(startAngle, stopAngle, color);
QSegmentWidget::Segment s;
s.first = startAngle;
s.second = stopAngle;
s.color = color;
SegmentList sl;
sl.push_back(s);
addSegments(cyl, sl);
}
示例13: ASSERT
SegmentList ShapeOutsideInfo::computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) const
{
ASSERT(lineHeight >= 0);
SegmentList segments;
computedShape().getExcludedIntervals((lineTop - logicalTopOffset()), std::min(lineHeight, shapeLogicalBottom() - lineTop), segments);
for (size_t i = 0; i < segments.size(); i++) {
segments[i].logicalLeft += logicalLeftOffset();
segments[i].logicalRight += logicalLeftOffset();
}
return segments;
}
示例14: if
size_t IsoffMainParser::parseSegmentBase(Node * segmentBaseNode, SegmentInformation *info)
{
size_t list_count = 0;
if(!segmentBaseNode)
return 0;
else if(segmentBaseNode->hasAttribute("indexRange"))
{
SegmentList *list = new SegmentList();
Segment *seg;
size_t start = 0, end = 0;
if (std::sscanf(segmentBaseNode->getAttributeValue("indexRange").c_str(), "%zu-%zu", &start, &end) == 2)
{
IndexSegment *index = new DashIndexSegment(info);
index->setByteRange(start, end);
list->indexSegment.Set(index);
/* index must be before data, so data starts at index end */
seg = new Segment(info);
seg->setByteRange(end + 1, 0);
}
else
{
seg = new Segment(info);
}
list_count++;
list->addSegment(seg);
info->setSegmentList(list);
Node *initSeg = DOMHelper::getFirstChildElementByName(segmentBaseNode, "Initialization");
if(initSeg)
{
SegmentBase *base = new SegmentBase();
parseInitSegment(initSeg, base, info);
info->setSegmentBase(base);
}
}
else
{
SegmentBase *base = new SegmentBase();
parseInitSegment(DOMHelper::getFirstChildElementByName(segmentBaseNode, "Initialization"), base, info);
info->setSegmentBase(base);
}
return list_count;
}
示例15: AddCurve
/// arc in radians
void TrackData::AddCurve (SegmentList& segments, float arc, float radius, float end_width_l, float end_width_r)
{
arc = arc * PI/180.0f;
float length = fabs(arc) * radius;
int N = 1 + (int) floor(length/step);
float s = length / (float) N;
float d_width_l = (end_width_l - width_l) / (float) N;
float d_width_r = (end_width_r - width_r) / (float) N;
float d_angle = arc / (float) N;
float start_angle = angle;
float hpi = (float) (PI/2.0);
for (int i=0; i<N; ++i) {
mid.x += s*sin(angle);
mid.y += s*cos(angle);
Point left(mid.x + width_l*sin(angle - hpi),
mid.y + width_l*cos(angle - hpi),
mid.z);
Point right(mid.x + width_r*sin(angle + hpi),
mid.y + width_r*cos(angle + hpi),
mid.z);
segments.Add (Segment (left, right));
angle += d_angle;
width_l += d_width_l;
width_r += d_width_r;
}
width_l = end_width_l;
width_r = end_width_r;
angle = start_angle + arc;
}