本文整理汇总了C++中pos2函数的典型用法代码示例。如果您正苦于以下问题:C++ pos2函数的具体用法?C++ pos2怎么用?C++ pos2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pos2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pos2
void TrillSegment::symbolLine(SymId start, SymId fill, SymId end)
{
qreal x1 = 0;
qreal x2 = pos2().x();
qreal w = x2 - x1;
qreal mag = magS();
ScoreFont* f = score()->scoreFont();
_symbols.clear();
_symbols.push_back(start);
qreal w1 = f->advance(start, mag);
qreal w2 = f->advance(fill, mag);
qreal w3 = f->advance(end, mag);
int n = lrint((w - w1 - w3) / w2);
for (int i = 0; i < n; ++i)
_symbols.push_back(fill);
_symbols.push_back(end);
QRectF r(f->bbox(_symbols, mag));
setbbox(r);
}
示例2: b1
void TrillSegment::layout()
{
QRectF b1(symBbox(SymId::ornamentTrill));
QRectF rr(b1.translated(-b1.x(), 0.0));
rr |= QRectF(0.0, rr.y(), pos2().x(), rr.height());
setbbox(rr);
if (parent())
rypos() += score()->styleS(ST_trillY).val() * spatium();
if (spannerSegmentType() == SEGMENT_SINGLE || spannerSegmentType() == SEGMENT_BEGIN) {
Accidental* a = trill()->accidental();
if (a) {
a->layout();
a->setMag(a->mag() * .6);
qreal _spatium = spatium();
a->setPos(_spatium*1.3, -2.2*_spatium);
a->adjustReadPos();
}
}
adjustReadPos();
}
示例3: Vector2D
//===========================================================================
void ftSurfaceSetPoint::resetPosition(Vector3D pos, int bnd)
//
//===========================================================================
{
xyz_ = pos;
uv_ = Vector2D(0.0, 0.0);
dist_ = -1.0;
at_boundary_ = bnd;
// Iterate to find parameter values
Point pos2(pos.begin(), pos.end());
Point close_pt;
double par_u, par_v, dist;
double eps = 1.0e-12; // A small number
for (size_t ki=0; ki<par_pts_.size(); ++ki)
{
par_pts_[ki].first->closestPoint(pos2, par_u, par_v, close_pt, dist, eps);
Vector2D param(par_u, par_v);
par_pts_[ki].second = param;
}
}
示例4: simpleCase
bool simpleCase()
{
XcMatrix cell1 ( 3.0, 0.0, 0.0, 2.0, 4.0, 0.0, 2.0, 5.0, 3.0 );
XcMatrix cell2 (cell1);
std::vector<XcVector> pos1;
pos1.reserve(4);
pos1.push_back(XcVector(0.0, 0.25, 0.25));
pos1.push_back(XcVector(0.25, 0.25, 0.25));
pos1.push_back(XcVector(0.0, 0.5, 0.25));
pos1.push_back(XcVector(0.0, 0.25, 0.75));
std::vector<XcVector> pos2 (pos1);
std::vector<unsigned int> types1;
types1.reserve(4);
types1.push_back(1);
types1.push_back(2);
types1.push_back(2);
types1.push_back(1);
std::vector<unsigned int> types2 (types1);
bool match = XtalComp::compare(cell1, types1, pos1,
cell2, types2, pos2,
NULL, 0.05, 0.25);
if (!match)
return false;
// Displace an atom, ensure that comparison fails.
pos2[0] += XcVector(0.5,0,0);
match = XtalComp::compare(cell1, types1, pos1,
cell2, types2, pos2,
NULL, 0.05, 0.25);
if (match)
return false;
return true;
}
示例5: pos
void RddcEvlDisplay::drawHopOver(){
if(this->m_dimClust==NULL)
return;
RddtClust* clust = this->m_dimClust->m_currentSelection;
if(clust==NULL)
return;
if(clust->m_nRddtDims.size()<1){
return;
}
int which = this->whichGlyph(m_x,m_y);
if(which<0 || which>=m_profileRects.size())
return;
QRect tmp = this->m_profileRects[which];
int size = clust->m_partitionPerVariable.size();
if(size<2)
return;
int numCols = (int)(sqrt((double)size))+1;
int numRows = (int)ceil((double)size/(double)numCols);
double glyphWidthData = (double)1/(double)numCols;
double glyphHeightData = (double)1/(double)numRows;
Vec2 pos(tmp.left(),tmp.bottom());
Vec2 pos2(tmp.left()+tmp.width(),tmp.bottom()-tmp.height());
Vec2 topCorner = this->m_canvas->mapScreenToData(pos);
Vec2 bottomRightCorner =
this->m_canvas->mapScreenToData(pos2);
glyphWidthData = bottomRightCorner.X - topCorner.X;
glyphHeightData = (topCorner.Y - bottomRightCorner.Y);
unsigned long c = this->cm->getColor(ColorManager::BRUSH_SELECTED1);
this->m_canvas->setForeground(c);
this->m_canvas->drawRectangle(topCorner.X,(double)1-topCorner.Y,
glyphWidthData,glyphHeightData);
}
示例6: exit
void Node::computeDistance(){
if(getNode(1) == NULL || getNode(2) == NULL){
std::cout << "undefined link" << std::endl;
exit(-1);
}
sf::Vector2f pos0(getPos());
sf::Vector2f pos1(getNode(1)->getPos());
sf::Vector2f pos2(getNode(2)->getPos());
float dis1x = pos0.x - pos1.x;
float dis1y = pos0.y - pos1.y;
float dis2x = pos0.x - pos2.x;
float dis2y = pos0.y - pos2.y;
_n1_distance = sqrt((dis1x*dis1x) + (dis1y*dis1y));
_n2_distance = sqrt((dis2x*dis2x) + (dis2y*dis2y));
}
示例7: lineName
bool WindowsManager::addLine (const char* lineNameCorba,
const value_type* posCorba1,
const value_type* posCorba2,
const value_type* colorCorba)
{
std::string lineName (lineNameCorba);
if (nodes_.find (lineName) != nodes_.end ()) {
std::cout << "You need to chose an other name, \"" << lineName
<< "\" already exist." << std::endl;
return false;
}
else {
mtx_.lock();
osgVector3 pos1 (posCorba1[0], posCorba1[1], posCorba1[2]);
osgVector3 pos2 (posCorba2[0], posCorba2[1], posCorba2[2]);
LeafNodeLinePtr_t line = LeafNodeLine::create
(lineName, pos1, pos2, getColor (colorCorba));
WindowsManager::initParent (lineName, line);
addNode (lineName, line);
mtx_.unlock();
return true;
}
}
示例8: pos
void Plane::addBullet(float dt)
{
if (m_bulletType == BULLET) {
auto pFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName("bullet1.png");
Point pos(getPositionX(), getPositionY() + getContentSize().height * 0.5);
float distance = Director::getInstance()->getWinSize().height + 100;
Sprite *bullet = createBullet(pFrame, pos, distance);
m_bullets->addChild(bullet);
} else if (m_bulletType == DOUBLE_BULLET) {
auto pFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName("bullet2.png");
float sx = getPositionX(); float sy = getPositionY();
Size content = getContentSize();
Point pos(sx - content.width * 0.25, sy + content.height * 0.5);
float distance = Director::getInstance()->getWinSize().height + 100;
Sprite *bullet1 = createBullet(pFrame, pos, distance);
m_bullets->addChild(bullet1);
Point pos2(sx + content.width * 0.25, sy + content.height * 0.5);
Sprite *bullet2 = createBullet(pFrame, pos2, distance);
m_bullets->addChild(bullet2);
}
}
示例9: pos1
void NodeLink::NodeCallback::operator()(::osg::Node* node, ::osg::NodeVisitor* nv)
{
osg::ref_ptr<osg::Node> f1 = node1.get();
osg::ref_ptr<osg::Node> f2 = node2.get();
if(!f1.get() || !f2.get())
return;
//transform local view2 to local view1
::osg::Matrix world2local = ::osg::computeWorldToLocal(nv->getNodePath());
::osg::Vec3 pos1(0,0,0);
::osg::MatrixList list1 = f1->getWorldMatrices();
assert(!list1.empty());
pos1 = pos1*list1.front();
pos1 = pos1*world2local;
::osg::Vec3 pos2(0,0,0);
::osg::MatrixList list2 = f2->getWorldMatrices();
assert(!list2.empty());
pos2 = pos2*list2.front();
pos2 = pos2*world2local;
::osg::Geode *geode = node->asGeode();
assert(geode);
assert(1 == geode->getNumDrawables());
::osg::Geometry* geometry = geode->getDrawable(0)->asGeometry();
assert(geometry);
assert(geometry->getVertexArray());
assert(geometry->getVertexArray()->getType() == ::osg::Array::Vec3ArrayType);
::osg::Vec3Array *osg_vertex= dynamic_cast< ::osg::Vec3Array*>(geometry->getVertexArray());
assert(osg_vertex);
(*osg_vertex)[0] = pos1;
(*osg_vertex)[1] = pos2;
geometry->dirtyBound();
traverse(node, nv);
}
示例10: pos
bool
url_type::read(const std::string& line)
{
// XXXXX:YYYYYYY/ZZZZZZZ
std::string::size_type pos(line.find(char(':')));
if ( pos == std::string::npos ) return false;
host.assign(line, 0, pos);
++pos;
std::string::size_type pos2(line.find(char('/'), pos));
if ( pos2 == std::string::npos )
{
service.assign(line, pos, std::string::npos);
page.clear();
}
else
{
service.assign(line, pos, pos2-pos);
page.assign(line, pos2, std::string::npos);
}
return true;
}
示例11: score
// s1 should be the original spectrum
DoubleReal CompNovoIdentificationBase::compareSpectra_(const PeakSpectrum & s1, const PeakSpectrum & s2)
{
DoubleReal score(0.0);
PeakSpectrum::ConstIterator it1 = s1.begin();
PeakSpectrum::ConstIterator it2 = s2.begin();
Size num_matches(0);
while (it1 != s1.end() && it2 != s2.end())
{
DoubleReal pos1(it1->getPosition()[0]), pos2(it2->getPosition()[0]);
if (fabs(pos1 - pos2) < fragment_mass_tolerance_)
{
score += it1->getIntensity();
++num_matches;
}
if (pos1 <= pos2)
{
++it1;
}
else
{
++it2;
}
}
if (num_matches == 0)
{
return 0;
}
score /= sqrt((DoubleReal)num_matches);
return score;
}
示例12: switch
void CInMapDraw::GotNetMsg(const unsigned char* msg)
{
const int playerID = msg[2];
switch (msg[3]) {
case NET_POINT: {
float3 pos(*(short*) &msg[4], 0, *(short*) &msg[6]);
const string label = (char*) &msg[8];
LocalPoint(pos, label, playerID);
break;
}
case NET_LINE: {
float3 pos1(*(short*) &msg[4], 0, *(short*) &msg[6]);
float3 pos2(*(short*) &msg[8], 0, *(short*) &msg[10]);
LocalLine(pos1, pos2, playerID);
break;
}
case NET_ERASE: {
float3 pos(*(short*) &msg[4], 0, *(short*) &msg[6]);
LocalErase(pos, playerID);
break;
}
}
}
示例13: pos1
QRectF Dynamic::drag(EditData* ed)
{
QRectF f = Element::drag(ed);
//
// move anchor
//
Qt::KeyboardModifiers km = qApp->keyboardModifiers();
if (km != (Qt::ShiftModifier | Qt::ControlModifier)) {
int si;
Segment* seg = 0;
_score->pos2measure(ed->pos, &si, 0, &seg, 0);
if (seg && (seg != segment() || staffIdx() != si)) {
QPointF pos1(pagePos());
score()->undo(new ChangeParent(this, seg, si));
setUserOff(QPointF());
layout();
QPointF pos2(pagePos());
setUserOff(pos1 - pos2);
ed->startMove = pos2;
}
}
return f;
}
示例14: magS
void TrillSegment::draw(QPainter* painter) const
{
qreal mag = magS();
int idx = score()->symIdx();
QRectF b2(symbols[idx][trillelementSym].bbox(mag));
qreal w2 = symbols[idx][trillelementSym].width(mag);
qreal x2 = pos2().x();
painter->setPen(curColor());
if (spannerSegmentType() == SEGMENT_SINGLE || spannerSegmentType() == SEGMENT_BEGIN) {
int sym = 0;
qreal x0 = 0.0, x1 = 0.0, y = 0.0;
int n = 0;
QRectF b1;
switch(trill()->trillType()) {
case Trill::TRILL_LINE:
sym = trillSym;
b1 = symbols[idx][sym].bbox(mag);
x0 = -b1.x();
x1 = x0 + b1.width();
n = int(floor((x2-x1) / w2));
y = 0.0;
break;
case Trill::UPPRALL_LINE:
sym = upprallSym;
b1 = symbols[idx][sym].bbox(mag);
x0 = -b1.x();
x1 = b1.width();
n = int(floor((x2-x1) / w2));
y = -b1.height();
break;
case Trill::DOWNPRALL_LINE:
sym = downprallSym;
b1 = symbols[idx][sym].bbox(mag);
x0 = -b1.x();
x1 = b1.width();
n = int(floor((x2-x1) / w2));
y = -b1.height();
break;
case Trill::PRALLPRALL_LINE:
sym = prallprallSym;
b1 = symbols[idx][sym].bbox(mag);
x0 = -b1.x();
x1 = b1.width();
n = int(floor((x2-x1) / w2));
y = -b1.height();
break;
case Trill::PURE_LINE:
sym = noSym;
x0 = 0;
x1 = 0;
n = int(floor((x2-x1) / w2));
y = 0.0;
}
if (n <= 0)
n = 1;
if (sym != noSym)
symbols[idx][sym].draw(painter, mag, QPointF(x0, y));
symbols[idx][trillelementSym].draw(painter, mag, QPointF(x1, b2.y() * .9), n);
}
else {
qreal x1 = 0.0;
int n = int(floor((x2-x1) / w2));
symbols[idx][trillelementSym].draw(painter, mag, QPointF(x1, b2.y() * .9), n);
}
}
示例15: spatium
void HairpinSegment::layout()
{
Dynamic* sd = 0;
Dynamic* ed = 0;
qreal _spatium = spatium();
if (autoplace()) {
setUserOff(QPointF());
setUserOff2(QPointF());
}
if (isSingleType() || isBeginType()) {
sd = lookupDynamic(hairpin()->startElement());
if (sd) {
if (autoplace()) {
qreal dx = sd->bbox().right() + sd->pos().x()
+ sd->segment()->pos().x() + sd->measure()->pos().x();
// hardcoded distance between Dynamic and Hairpin: 0.5sp
qreal dist = dx - pos().x() + score()->styleP(StyleIdx::autoplaceHairpinDynamicsDistance);
rUserXoffset() = dist;
rUserXoffset2() = -dist;
}
else
sd->doAutoplace();
}
}
if (isSingleType() || isEndType()) {
ed = lookupDynamic(hairpin()->endElement());
if (ed) {
if (autoplace()) {
rUserXoffset2() -= ed->bbox().width();
qreal dx = ed->bbox().left() + ed->pos().x()
+ ed->segment()->pos().x() + ed->measure()->pos().x();
// hardcoded distance between Hairpin and Dynamic: 0.5sp
ed->rUserXoffset() = pos2().x() + pos().x() - dx + score()->styleP(StyleIdx::autoplaceHairpinDynamicsDistance);
}
else
ed->doAutoplace();
}
}
Hairpin::Type type = hairpin()->hairpinType();
if (type == Hairpin::Type::DECRESC_LINE || type == Hairpin::Type::CRESC_LINE) {
twoLines = false;
TextLineSegment::layout();
drawCircledTip = false;
if (parent())
rypos() += score()->styleP(StyleIdx::hairpinY);
}
else {
delete _text;
delete _endText;
_text = 0;
_endText = 0;
QTransform t;
qreal h1 = hairpin()->hairpinHeight().val() * spatium() * .5;
qreal h2 = hairpin()->hairpinContHeight().val() * spatium() * .5;
qreal len;
qreal x = pos2().x();
if (x < _spatium) // minimum size of hairpin
x = _spatium;
qreal y = pos2().y();
len = sqrt(x * x + y * y);
t.rotateRadians(asin(y/len));
drawCircledTip = hairpin()->hairpinCircledTip();
circledTipRadius = drawCircledTip ? 0.6 * _spatium * .5 : 0.0;
QLine l1, l2;
twoLines = true;
switch (type) {
case Hairpin::Type::CRESC_HAIRPIN: {
switch (spannerSegmentType()) {
case SpannerSegmentType::SINGLE:
case SpannerSegmentType::BEGIN:
l1.setLine(circledTipRadius * 2.0, 0.0, len, h1);
l2.setLine(circledTipRadius * 2.0, 0.0, len, -h1);
circledTip.setX(circledTipRadius );
circledTip.setY(0.0);
break;
case SpannerSegmentType::MIDDLE:
case SpannerSegmentType::END:
drawCircledTip = false;
l1.setLine(.0, h2, len, h1);
l2.setLine(.0, -h2, len, -h1);
break;
}
}
break;
case Hairpin::Type::DECRESC_HAIRPIN: {
switch(spannerSegmentType()) {
case SpannerSegmentType::SINGLE:
case SpannerSegmentType::END:
l1.setLine(0.0, h1, len - circledTipRadius * 2, 0.0);
l2.setLine(0.0, -h1, len - circledTipRadius * 2, 0.0);
circledTip.setX(len - circledTipRadius);
circledTip.setY(0.0);
//.........这里部分代码省略.........