AnchorTarget WMenuItem::linkTarget() const { WAnchor *a = anchor(); if (a) return anchor()->target(); else return TargetSelf; }
void MemberGroup::writeDeclarations(OutputList &ol, ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd, bool showInline) { //printf("MemberGroup::writeDeclarations() %s\n",grpHeader.data()); QCString ldoc = doc; if (!ldoc.isEmpty()) ldoc.prepend("<a name=\""+anchor()+"\" id=\""+anchor()+"\"></a>"); memberList->writeDeclarations(ol,cd,nd,fd,gd,grpHeader,ldoc,DefinitionIntf::TypeGroup,FALSE,showInline); }
void label(const cv::Mat &edges, cv::Mat &labels, const uchar edge, const unsigned int threshold) { assert(edges.type() == CV_8UC1); unsigned short label = FLOOD_LABEL_START; labels = cslibs_vision::labels(edges); const uchar* ptr_edge = edges.ptr<uchar>(); ushort* ptr_lab = labels.ptr<ushort>(); for(int y = 0 ; y < edges.rows ; ++y) { for(int x = 0 ; x < edges.cols ; ++x) { if(*ptr_edge != edge && *ptr_lab == FLOOD_LABEL_DEFAULT) { cv::Point anchor(x,y); cslibs_vision::flood(edges, anchor, label, labels, edge, threshold); ++label; } ++ptr_edge; ++ptr_lab; } } unsigned short *ptr = labels.ptr<unsigned short>(); for(int i = 0 ; i < labels.rows * labels.cols ; ++i, ++ptr) { if(*ptr == FLOOD_LABEL_IMPLODE) *ptr = FLOOD_LABEL_DEFAULT; } }
// Record an observation void* traceStream::observe(properties::iterator props) { //cout << "traceStream::observe() props="<<props.str()<<endl; long traceID = properties::getInt(props, "traceID"); assert(active.find(traceID) != active.end()); traceStream* ts = active[traceID]; //cout << " t="<<t<<endl; //cout << " #ts->traceAttrs="<<ts->traceAttrs.size()<<endl; long numTraceAttrs = properties::getInt(props, "numTraceAttrs"); long numCtxtAttrs = properties::getInt(props, "numCtxtAttrs"); // Maps that record the observation to be forwarded to any observers listening on this traceStream map<string, string> ctxtToObs, traceToObs; map<std::string, anchor> traceAnchorToObs; // If some observers are listening on this traceStream, record the current observation so they can look at it if(ts->numObservers()>0) { for(long i=0; i<numTraceAttrs; i++) { string tKey = properties::get(props, txt()<<"tKey_"<<i); traceToObs[tKey] = properties::get(props, txt()<<"tVal_"<<i); traceAnchorToObs[tKey] = anchor(properties::getInt(props, txt()<<"tAnchorID_"<<i)); } for(long i=0; i<numCtxtAttrs; i++) ctxtToObs[properties::get(props, txt()<<"cKey_"<<i)] = properties::get(props, txt()<<"cVal_"<<i); // Inform any observers listening on this traceStream of the new observation ts->emitObservation(traceID, ctxtToObs, traceToObs, traceAnchorToObs); } return NULL; }
//------------------------------------------------------------------------------ //! int hingeJointVM( VMState* vm ) { WorldContext* context = getContext(vm); RigidEntity* entityA = 0; RigidEntity* entityB = 0; if( VM::geti( vm, -1, 1 ) ) { entityA = (RigidEntity*)VM::toPtr( vm, -1 ); VM::pop( vm, 1 ); } if( VM::geti( vm, -1, 2 ) ) { entityB = (RigidEntity*)VM::toPtr( vm, -1 ); VM::pop( vm, 1 ); } HingeJoint* joint = context->_world->createHingeJoint( entityA, entityB ); Vec3f anchor(0.0f); VM::get( vm, -1, "anchor", anchor ); Vec3f axis(0.0f, 1.0f, 0.0f ); VM::get( vm, -1, "axis", axis ); joint->anchor( anchor ); joint->axis( axis ); return 0; }
void WMenuItem::setChecked(bool checked) { if (isCheckable()) { WCheckBox *cb = dynamic_cast<WCheckBox *>(anchor()->widget(0)); cb->setChecked(checked); } }
void WMenuItem::setMenu(WMenu *menu) { subMenu_ = menu; subMenu_->parentItem_ = this; Wt::WContainerWidget *sparent = dynamic_cast<Wt::WContainerWidget *>(subMenu_->parent()); if (sparent) sparent->removeWidget(subMenu_); addWidget(subMenu_); if (subMenu_->isPopup() && parentMenu() && parentMenu()->isPopup()) { subMenu_->webWidget()->setZIndex(std::max(parentMenu()->zIndex() + 100, subMenu_->zIndex())); } WPopupMenu *popup = dynamic_cast<WPopupMenu *>(subMenu_); if (popup) { popup->setJavaScriptMember("wtNoReparent", "true"); setSelectable(false); popup->setButton(anchor()); updateInternalPath(); // WPopupMenus are hidden by default, 'show' this WPopupMenu // but not really, since the parent is still hidden. This fixes // an issue where child widgets would remain unexposed, even // though this submenu was open (e.g. in a submenu where items // are checkable) if (dynamic_cast<WPopupMenu*>(menu_)) popup->show(); } }
ustring resource_viewer_produce_anchor(unsigned int book, unsigned int chapter, unsigned int verse) // Produces the anchor, e.g.: Matthew_1_1 or Song_of_Solomon_2_2. { ustring anchor(books_id_to_english(book) + "_" + convert_to_string(chapter) + "_" + convert_to_string(verse)); replace_text(anchor, " ", "_"); return anchor; }
void CCPageScaleAnimation::zoomTo(const IntSize& finalScroll, float finalPageScale, double duration) { if (m_pageScaleStart != finalPageScale) { // For uniform-looking zooming, infer the anchor (point that remains in // place throughout the zoom) from the start and end rects. FloatRect startRect(IntPoint(m_scrollStart), m_windowSize); FloatRect endRect(IntPoint(finalScroll), m_windowSize); endRect.scale(m_pageScaleStart / finalPageScale); // The anchor is the point which is at the same ratio of the sides of // both startRect and endRect. For example, a zoom-in double-tap to a // perfectly centered rect will have anchor ratios (0.5, 0.5), while one // to a rect touching the bottom-right of the screen will have anchor // ratios (1.0, 1.0). In other words, it obeys the equations: // anchorX = start_width * ratioX + start_x // anchorX = end_width * ratioX + end_x // anchorY = start_height * ratioY + start_y // anchorY = end_height * ratioY + end_y // where both anchor{x,y} and ratio{x,y} begin as unknowns. Solving // for the ratios, we get the following formulas: float ratioX = (startRect.x() - endRect.x()) / (endRect.width() - startRect.width()); float ratioY = (startRect.y() - endRect.y()) / (endRect.height() - startRect.height()); IntSize anchor(m_windowSize.width() * ratioX, m_windowSize.height() * ratioY); zoomWithAnchor(anchor, finalPageScale, duration); } else { // If this is a pure translation, then there exists no anchor. Linearly // interpolate the scroll offset instead. m_scrollEnd = finalScroll; m_pageScaleEnd = finalPageScale; m_duration = duration; m_anchorMode = false; } }
void QUProfileController::drawLoadingMessage(QPainter & p) { if( avail() < m_total || m_total == 0) { p.save(); p.setFont ( m_captionFont); p.setOpacity(1); QString txt = QString( "Loading %1/%2").arg( avail()).arg(m_total); QRectF anchor( m_buffer.width()/2.0, m_buffer.height()/2.0, 1, 1); QRectF brect = p.boundingRect( anchor, Qt::AlignCenter | Qt::TextDontClip, txt); brect.adjust( -3, -3, 3, 3); QColor bg( 255, 255, 255, 225); QColor border( 128, 0, 0, 225); p.setPen( border); p.setBrush( bg); p.drawRoundedRect( brect, 5, 5); p.setPen( QColor(0, 0, 0)); p.drawText(anchor, Qt::AlignCenter | Qt::TextDontClip, txt); p.setPen( QPen(QColor( 0, 0, 0, 128), 1, Qt::DashLine)); p.restore(); } }
dReal ServoMotor::getTorque() { // code from Jeff Shim osg::Vec3 torque1(fback_.t1[0], fback_.t1[1], fback_.t1[2] ); osg::Vec3 torque2(fback_.t2[0], fback_.t2[1], fback_.t2[2] ); osg::Vec3 force1(fback_.f1[0], fback_.f1[1], fback_.f1[2] ); osg::Vec3 force2(fback_.f2[0], fback_.f2[1], fback_.f2[2] ); const double* p1 = dBodyGetPosition( dJointGetBody(joint_->getJoint(),0) ); const double* p2 = dBodyGetPosition( dJointGetBody(joint_->getJoint(),1) ); osg::Vec3 pos1(p1[0], p1[1], p1[2]); osg::Vec3 pos2(p2[0], p2[1], p2[2]); dVector3 odeAnchor; dJointGetHingeAnchor ( joint_->getJoint(), odeAnchor ); osg::Vec3 anchor(odeAnchor[0], odeAnchor[1], odeAnchor[2]); osg::Vec3 ftorque1 = torque1 - (force1^(pos1-anchor));// torq by motor = total torq - constraint torq osg::Vec3 ftorque2 = torque2 - (force2^(pos2-anchor));// opposite direction - use if this is necessary dVector3 odeAxis; dJointGetHingeAxis ( joint_->getJoint(), odeAxis); osg::Vec3 axis(odeAxis[0], odeAxis[1], odeAxis[2] ); axis.normalize(); double torque = ftorque1 * axis; //printf ("torque: % 1.10f\n", torque); return torque; }
void WMenuItem::setText(const WString& text) { if (!text_) { text_ = new WLabel(anchor()); text_->setTextFormat(Wt::PlainText); } text_->setText(text); if (!customPathComponent_) { std::string result; #ifdef WT_TARGET_JAVA WString t = text; #else const WString& t = text; #endif if (t.literal()) result = t.narrow(); else result = t.key(); for (unsigned i = 0; i < result.length(); ++i) { if (std::isspace((unsigned char)result[i])) result[i] = '-'; else if (std::isalnum((unsigned char)result[i])) result[i] = std::tolower((unsigned char)result[i]); else result[i] = '_'; } setPathComponent(result); customPathComponent_ = false; } }
void MessageCursor::fillFrom(not_null<const Ui::InputField*> field) { const auto cursor = field->textCursor(); position = cursor.position(); anchor = cursor.anchor(); const auto top = field->scrollTop().current(); scroll = (top != field->scrollTopMax()) ? top : QFIXED_MAX; }
void PendulumApplication::clientMoveAndDisplay() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //simple dynamics world doesn't handle fixed-time-stepping m_dt = getDeltaTimeMicroseconds()/1000000.f; temp += m_dt; ///step the simulation if (m_dynamicsWorld) { m_dynamicsWorld->stepSimulation(m_dt); //optional but useful: debug drawing m_dynamicsWorld->debugDrawWorld(); } btTransform trans; m_pendulumBody->getMotionState()->getWorldTransform(trans); Integrator_rk4(); trans.getOrigin() = btVector3(0,20,0)+pol2cart(m_r.m_value,m_theta.m_value); //printf("%f %f %f\n",m_position.x(),m_po sition.y(),m_position.z()); m_pendulumBody->getMotionState()->setWorldTransform(trans); m_r.m_value = m_r.m_value + 0.1 * sin (temp); //draw the rope btVector3 anchor(0,20,0); glLineWidth(2.0); glBegin(GL_LINES); glVertex3fv(anchor.m_floats); glVertex3fv(trans.getOrigin()); glEnd(); renderme(); swapBuffers(); }
void SLine::writeProperties(Xml& xml, const SLine* proto) const { Element::writeProperties(xml); if (_diagonal && (proto == 0 || proto->diagonal() != _diagonal)) xml.tag("diagonal", _diagonal); if (anchor() != ANCHOR_SEGMENT && (proto == 0 || proto->anchor() != anchor())) xml.tag("anchor", anchor()); if (score() == gscore) { // when used as icon if (!spannerSegments().isEmpty()) { LineSegment* s = frontSegment(); xml.tag("length", s->pos2().x()); } else xml.tag("length", spatium() * 4); return; } // // check if user has modified the default layout // bool modified = false; int n = spannerSegments().size(); for (int i = 0; i < n; ++i) { const LineSegment* seg = segmentAt(i); if (!seg->userOff().isNull() || !seg->userOff2().isNull() || !seg->visible()) { modified = true; break; } } if (!modified) return; // // write user modified layout // qreal _spatium = spatium(); for (int i = 0; i < n; ++i) { const LineSegment* seg = segmentAt(i); xml.stag("Segment"); xml.tag("subtype", seg->subtype()); xml.tag("off2", seg->userOff2() / _spatium); seg->Element::writeProperties(xml); xml.etag(); } }
Anchors resample(const GeometryCoordinates &line, const float offset, const float spacing, const float angleWindowSize, const float maxAngle, const float labelLength, const bool continuedLine, const bool placeAtMiddle) { const float halfLabelLength = labelLength / 2.0f; float lineLength = 0; for (auto it = line.begin(), end = line.end() - 1; it != end; it++) { lineLength += util::dist<float>(*(it), *(it + 1)); } float distance = 0; float markedDistance = offset - spacing; Anchors anchors; assert(spacing > 0.0); int i = 0; for (auto it = line.begin(), end = line.end() - 1; it != end; it++, i++) { const GeometryCoordinate &a = *(it); const GeometryCoordinate &b = *(it + 1); const float segmentDist = util::dist<float>(a, b); const float angle = util::angle_to(b, a); while (markedDistance + spacing < distance + segmentDist) { markedDistance += spacing; float t = (markedDistance - distance) / segmentDist, x = util::interpolate(float(a.x), float(b.x), t), y = util::interpolate(float(a.y), float(b.y), t); // Check that the point is within the tile boundaries and that // the label would fit before the beginning and end of the line // if placed at this point. if (x >= 0 && x < util::EXTENT && y >= 0 && y < util::EXTENT && markedDistance - halfLabelLength >= 0.0f && markedDistance + halfLabelLength <= lineLength) { Anchor anchor(::round(x), ::round(y), angle, 0.5f, i); if (!angleWindowSize || checkMaxAngle(line, anchor, labelLength, angleWindowSize, maxAngle)) { anchors.push_back(anchor); } } } distance += segmentDist; } if (!placeAtMiddle && anchors.empty() && !continuedLine) { // The first attempt at finding anchors at which labels can be placed failed. // Try again, but this time just try placing one anchor at the middle of the line. // This has the most effect for short lines in overscaled tiles, since the // initial offset used in overscaled tiles is calculated to align labels with positions in // parent tiles instead of placing the label as close to the beginning as possible. anchors = resample(line, distance / 2, spacing, angleWindowSize, maxAngle, labelLength, continuedLine, true); } return anchors; }
void WMenuItem::setLink(const WLink& link) { WAnchor *a = anchor(); if (a) a->setLink(link); customLink_ = true; }
void WMenuItem::setItemPadding(bool padding) { if (!checkBox_ && !icon_) { WAnchor *a = anchor(); if (a) a->toggleStyleClass("Wt-padded", padding); } }
bool WMenuItem::isChecked() const { if (isCheckable()) { WCheckBox *cb = dynamic_cast<WCheckBox *>(anchor()->widget(0)); return cb->isChecked(); } else return false; }
void test_anchor() { xlnt::workbook wb; auto cell = wb.active_sheet().cell("A1"); auto anchor = cell.anchor(); xlnt_assert_equals(anchor.first, 0); xlnt_assert_equals(anchor.second, 0); }
WLink WMenuItem::link() const { WAnchor *a = anchor(); if (a) return a->link(); else return std::string(); }
void Requirement::Maker::anchor(int slot, const void *cert, size_t length) { SHA1 hasher; hasher(cert, length); SHA1::Digest digest; hasher.finish(digest); anchor(slot, digest); }
LineSegment* TextLine::createLineSegment() { TextLineSegment* seg = new TextLineSegment(score()); // note-anchored line segments are relative to system not to staff if (anchor() == Spanner::Anchor::NOTE) seg->setFlag(ElementFlag::ON_STAFF, false); return seg; }
QVariant Articulation::getProperty(P_ID propertyId) const { switch(propertyId) { case P_DIRECTION: return int(direction()); case P_ARTICULATION_ANCHOR: return int(anchor()); default: return Element::getProperty(propertyId); } }
void WMenuItem::updateInternalPath() { if (menu_ && menu_->internalPathEnabled() && internalPathEnabled()) { std::string internalPath = menu_->internalBasePath() + pathComponent(); WLink link(WLink::InternalPath, internalPath); WAnchor *a = anchor(); if (a) a->setLink(link); } else { WAnchor *a = anchor(); if (a && !customLink_) { if (WApplication::instance()->environment().agent() == WEnvironment::IE6) a->setLink(WLink("#")); else a->setLink(WLink()); } } }
int main(){ connect(); GraphWin win("Cascading Windows", 400, 300); for (int i = 0; i < 10; i++){ Point anchor(10+i*30, 10+i*20); Image img(anchor, robot.takePicture()); img.draw(win); } disconnect(); }
QPointF SLine::linePos(int grip, System** sys) { qreal _spatium = spatium(); qreal x = 0.0; if (anchor() == ANCHOR_SEGMENT) { Segment* seg = static_cast<Segment*>(grip == 0 ? startElement() : endElement()); Measure* m = seg->measure(); *sys = m->system(); if (*sys == 0) return QPointF(x, 0.0); x = seg->pos().x() + m->pos().x(); if (grip == GRIP_LINE_END) { if (((*sys)->firstMeasure() == m) && (seg->tick() == m->tick())) { m = m->prevMeasure(); if (m) { *sys = m->system(); x = m->pos().x() + m->width(); } } } } else { // anchor() == ANCHOR_MEASURE Measure* m; if (grip == GRIP_LINE_START) { m = static_cast<Measure*>(startElement()); x = m->pos().x(); } else { m = static_cast<Measure*>(endElement()); x = m->pos().x() + m->bbox().right(); if (type() == VOLTA) { Segment* seg = m->last(); if (seg->subtype() == SegEndBarLine) { Element* e = seg->element(0); if (e && e->type() == BAR_LINE) { if (static_cast<BarLine*>(e)->subtype() == START_REPEAT) x -= e->width() - _spatium * .5; else x -= _spatium * .5; } } } } *sys = m->system(); } //DEBUG: if ((*sys)->staves()->isEmpty()) return QPointF(x, 0.0); qreal y = (*sys)->staff(staffIdx())->y(); return QPointF(x, y); }
int MapWidget::getMaximumMarkerWidth() { int maxWidth = 0; QPointF anchor(0, 0); for (const MapMarker &marker : markers) { int markerWidth = getMarkerRect(marker, anchor).width(); if (markerWidth > maxWidth) maxWidth = markerWidth; } return maxWidth; }
void createEntity(tmx::MapObject mapObject, b2World& box2dWorld, anax::World& anaxWorld) { b2Vec2 statingPosition = tmx::SfToBoxVec(mapObject.GetPosition()); b2Vec2 endPosition = tmx::SfToBoxVec(sf::Vector2f(mapObject.GetPosition().x + mapObject.GetAABB().width, mapObject.GetPosition().y)); b2Body* firstBodyToJoinWith = createStartingBody(statingPosition, box2dWorld); b2Body* prevBody = firstBodyToJoinWith; { b2PolygonShape shape; shape.SetAsBox(0.5f, 0.125f); b2FixtureDef fd = getRopeFixture(shape); b2RevoluteJointDef jd; jd.collideConnected = false; const int32 N = ceilf((mapObject.GetAABB().width / 30) / (1.0f )) + 1; for (int32 xVal = 1; xVal < N; ++xVal) { b2BodyDef bd; bd.type = b2_dynamicBody; bd.position.Set(statingPosition.x + xVal , statingPosition.y ); if (xVal == N - 1) { bd.type = b2_staticBody; shape.SetAsBox(0.1f, 0.1f); fd.density = 1.0f; bd.position.Set(endPosition.x, endPosition.y); } b2Body* body = box2dWorld.CreateBody(&bd); body->CreateFixture(&fd); auto objectEntity = anaxWorld.createEntity(); auto& texCoordsComp = objectEntity.addComponent<Texcoords>(); auto& physComp = objectEntity.addComponent<PhysicsComponent>(); auto& splitDirectionComp = objectEntity.addComponent<SplitDirectionComponent>(); auto& breakableJointComp = objectEntity.addComponent<BreakableJointComponent>(); breakableJointComp.maxWeight = 1 ; b2Vec2 anchor( statingPosition.x + xVal , statingPosition.y ); jd.Initialize(prevBody, body, anchor); box2dWorld.CreateJoint(&jd); physComp.physicsBody = body; objectEntity.activate(); prevBody = body; } } }
QVariant Articulation::getProperty(P_ID propertyId) const { switch(propertyId) { case P_ID::DIRECTION: return int(direction()); case P_ID::ARTICULATION_ANCHOR: return int(anchor()); case P_ID::TIME_STRETCH: return timeStretch(); case P_ID::ORNAMENT_STYLE: return int(ornamentStyle()); case P_ID::PLAY: return bool(playArticulation()); default: return Element::getProperty(propertyId); } }