本文整理汇总了C++中KstCPluginPtr::label方法的典型用法代码示例。如果您正苦于以下问题:C++ KstCPluginPtr::label方法的具体用法?C++ KstCPluginPtr::label怎么用?C++ KstCPluginPtr::label使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KstCPluginPtr
的用法示例。
在下文中一共展示了KstCPluginPtr::label方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renderLabel
void renderLabel(RenderContext& rc, Label::Chunk *fi) {
// FIXME: RTL support
int oldSize = rc.size;
int oldY = rc.y;
int oldX = rc.x;
while (fi) {
if (fi->vOffset != Label::Chunk::None) {
if (fi->vOffset == Label::Chunk::Up) {
rc.y -= int(0.4 * rc.fontHeight());
} else { // Down
rc.y += int(0.4 * rc.fontHeight());
}
if (rc.size > 5) {
rc.size = (rc.size*2)/3;
}
}
QFont f = rc.font();
if (rc.fontSize() != rc.size) {
f.setPointSize(rc.size);
}
f.setBold(fi->attributes.bold);
f.setItalic(fi->attributes.italic);
f.setUnderline(fi->attributes.underline);
if (rc.p && fi->attributes.color.isValid()) {
rc.p->setPen(fi->attributes.color);
} else if (rc.p) {
rc.p->setPen(rc.pen);
}
rc.setFont(f);
if (fi->linebreak) {
rc.x = oldX;
rc.y += rc.fontAscent() + rc.fontDescent() + 1;
fi = fi->next;
continue;
}
if (!rc.substitute && (fi->scalar || fi->vector)) {
QString txt = QString("[") + fi->text + "]";
if (rc.p) {
rc.p->drawText(rc.x, rc.y, txt);
}
rc.x += rc.fontWidth(txt);
} else if (fi->scalar) {
// do scalar/string/fit substitution
QString txt;
if (!fi->text.isEmpty() && fi->text[0] == '=') {
// Parse and evaluate as an equation
bool ok = false;
const QString s = fi->text.mid(1);
const double eqResult(Equation::interpret(s.toLatin1(), &ok, s.length()));
txt = QString::number(eqResult, 'g', rc.precision);
if (rc._cache) {
rc._cache->append(DataRef(DataRef::DRExpression, fi->text, QString::null, 0.0, QVariant(eqResult)));
}
} else {
KST::scalarList.lock().readLock();
KstScalarPtr scp = KST::scalarList.retrieveObject(KstObjectTag::fromString(fi->text));
KST::scalarList.lock().unlock();
if (scp) {
scp->readLock();
txt = QString::number(scp->value(), 'g', rc.precision);
if (rc._cache) {
rc._cache->append(DataRef(DataRef::DRScalar, fi->text, QString::null, 0.0, QVariant(scp->value())));
}
scp->unlock();
} else {
KST::stringList.lock().readLock();
KstStringPtr stp = KST::stringList.retrieveObject(KstObjectTag::fromString(fi->text));
KST::stringList.lock().unlock();
if (stp) {
stp->readLock();
txt = stp->value();
if (rc._cache) {
rc._cache->append(DataRef(DataRef::DRString, fi->text, QString::null, 0.0, QVariant(stp->value())));
}
stp->unlock();
} else {
KST::dataObjectList.lock().readLock();
KstDataObjectList::Iterator oi = KST::dataObjectList.findTag(fi->text);
KST::dataObjectList.lock().unlock();
if (oi != KST::dataObjectList.end()) {
KstCPluginPtr fit = kst_cast<KstCPlugin>(*oi);
if (fit) {
fit->readLock();
const QString txtAll = fit->label(rc.precision);
fit->unlock();
const Q3ValueList<QString> strList = txtAll.split('\n');
Q3ValueListConstIterator<QString> last = --(strList.end());
for (Q3ValueListConstIterator<QString> iter = strList.begin(); iter != strList.end(); ++iter) {
txt = (*iter);
if (iter != last) {
if (rc.p) {
rc.p->drawText(rc.x, rc.y, txt);
} else {
//.........这里部分代码省略.........
示例2: switch
void KstViewLabel::DataCache::update() {
for (QValueVector<DataRef>::ConstIterator i = data.begin(); valid && i != data.end(); ++i) {
switch ((*i).type) {
case DataRef::DataRef::DRScalar:
{
KST::scalarList.lock().readLock();
KstScalarPtr p = *KST::scalarList.findTag((*i).name);
KST::scalarList.lock().unlock();
if (p) {
p->readLock();
if (QVariant(p->value()) != (*i).value) {
valid = false;
}
p->unlock();
}
}
break;
case DataRef::DRString:
{
KST::stringList.lock().readLock();
KstStringPtr p = *KST::stringList.findTag((*i).name);
KST::stringList.lock().unlock();
if (p) {
p->readLock();
if (QVariant(p->value()) != (*i).value) {
valid = false;
}
p->unlock();
}
}
break;
case DataRef::DRExpression:
{
bool ok = false;
const double val = Equation::interpret((*i).name.latin1(), &ok, (*i).name.length());
if (QVariant(val) != (*i).value) {
valid = false;
}
}
break;
case DataRef::DRVector:
{
bool ok = false;
const double idx = Equation::interpret((*i).index.latin1(), &ok, (*i).index.length());
if (idx != (*i).indexValue) {
valid = false;
break;
}
KST::vectorList.lock().readLock();
KstVectorPtr p = *KST::vectorList.findTag((*i).name);
KST::vectorList.lock().unlock();
if (p) {
p->readLock();
if (QVariant(p->value(int((*i).indexValue))) != (*i).value) {
valid = false;
}
p->unlock();
}
}
break;
case DataRef::DataRef::DRFit:
{
KST::dataObjectList.lock().readLock();
KstDataObjectList::Iterator oi = KST::dataObjectList.findTag((*i).name);
KST::dataObjectList.lock().unlock();
if (oi != KST::dataObjectList.end()) {
KstCPluginPtr fit = kst_cast<KstCPlugin>(*oi);
if (fit) {
fit->readLock();
if (fit->label((int)((*i).indexValue)) != (*i).index) {
valid = false;
}
fit->unlock();
}
}
}
break;
}
}
}