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); }
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(); }
// return true if there is at least one pair of tiles // that can be swapped so that a tripel tile can be // eliminated const bool GameField::isPlayable(void) const { bool playable = false; // we go through each column and row and swap single elements for ( unsigned int i = 0; i < FIELD_WIDTH-1; i++ ) { for ( unsigned int j = 0; j < FIELD_HEIGHT-1; j++ ) { // set positions for swapping FieldPos pos1(i,j); FieldPos pos2(i,j+1); if (isPlayable(pos1,pos2)) { playable = true; // leave for-loop break; } // set positions for swapping pos1.set(i,j); pos2.set(i+1,j); if ( isPlayable(pos1,pos2) ) { playable = true; // leave for-loop break; } } if ( playable ) { // leave for-loop break; } } return playable; }
//=========================================================================== 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; } }
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; }
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); }
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)); }
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; } }
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); } }
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); }
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; }
// 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; }
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; } } }
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; }
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); } }
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); break; case SpannerSegmentType::BEGIN: case SpannerSegmentType::MIDDLE: drawCircledTip = false; l1.setLine(.0, h1, len, + h2); l2.setLine(.0, -h1, len, - h2); break; } } break; default: break; } // Do Coord rotation l1 = t.map(l1); l2 = t.map(l2); if (drawCircledTip ) circledTip = t.map(circledTip); points[0] = l1.p1(); points[1] = l1.p2(); points[2] = l2.p1(); points[3] = l2.p2(); npoints = 4; QRectF r = QRectF(l1.p1(), l1.p2()).normalized() | QRectF(l2.p1(), l2.p2()).normalized(); qreal w = score()->styleP(StyleIdx::hairpinLineWidth); setbbox(r.adjusted(-w*.5, -w*.5, w, w)); if (parent()) rypos() += score()->styleP(StyleIdx::hairpinY); } if (autoplace() && parent()) { qreal minDistance = spatium() * .7; Shape s1 = shape().translated(pos()); qreal d = system()->bottomDistance(staffIdx(), s1); qreal ymax = pos().y(); if (d > -minDistance) ymax += d + minDistance; qreal sdy; if (sd) { sdy = -sd->bbox().top() * .4; sd->doAutoplace(); if (sd->pos().y() - sdy > ymax) ymax = sd->pos().y() - sdy; } qreal edy; if (ed) { edy = -ed->bbox().top() * .4; ed->doAutoplace(); if (ed->pos().y() - edy > ymax) ymax = ed->pos().y() - edy; } rUserYoffset() = ymax - pos().y(); if (sd) moveDynamic(sd, ymax - sd->ipos().y() + sdy); if (ed) moveDynamic(ed, ymax - ed->ipos().y() + edy); } else adjustReadPos(); }
int main(int argc, char **argv){ vector pos1( 1, 2 ), pos2( 12, 33 ); std::cout << pos1 << " " << pos2 << "\n"; }
void CStartPosSelecter::Draw() { if(gu->spectating){ delete this; return; } glPushMatrix(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glMatrixMode(GL_MODELVIEW); glColor4f(0.2f,0.8f,0.2f,0.5f); glDisable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); glBegin(GL_QUADS); float by= gameSetup->allyStartingData[gu->myAllyTeam].startRectTop *gs->mapy*8; float bx= gameSetup->allyStartingData[gu->myAllyTeam].startRectLeft *gs->mapx*8; float dy = (gameSetup->allyStartingData[gu->myAllyTeam].startRectBottom - gameSetup->allyStartingData[gu->myAllyTeam].startRectTop) *gs->mapy*8/10; float dx = (gameSetup->allyStartingData[gu->myAllyTeam].startRectRight - gameSetup->allyStartingData[gu->myAllyTeam].startRectLeft) *gs->mapx*8/10; for(int a=0;a<10;++a){ //draw start rect restrictions float3 pos1(bx+a*dx,0,by); pos1.y=ground->GetHeight(pos1.x,pos1.z); float3 pos2(bx+(a+1)*dx,0,by); pos2.y=ground->GetHeight(pos2.x,pos2.z); glVertexf3(pos1); glVertexf3(pos2); glVertexf3(pos2+UpVector*100); glVertexf3(pos1+UpVector*100); pos1=float3(bx+a*dx,0,by+dy*10); pos1.y=ground->GetHeight(pos1.x,pos1.z); pos2=float3(bx+(a+1)*dx,0,by+dy*10); pos2.y=ground->GetHeight(pos2.x,pos2.z); glVertexf3(pos1); glVertexf3(pos2); glVertexf3(pos2+UpVector*100); glVertexf3(pos1+UpVector*100); pos1=float3(bx,0,by+dy*a); pos1.y=ground->GetHeight(pos1.x,pos1.z); pos2=float3(bx,0,by+dy*(a+1)); pos2.y=ground->GetHeight(pos2.x,pos2.z); glVertexf3(pos1); glVertexf3(pos2); glVertexf3(pos2+UpVector*100); glVertexf3(pos1+UpVector*100); pos1=float3(bx+dx*10,0,by+dy*a); pos1.y=ground->GetHeight(pos1.x,pos1.z); pos2=float3(bx+dx*10,0,by+dy*(a+1)); pos2.y=ground->GetHeight(pos2.x,pos2.z); glVertexf3(pos1); glVertexf3(pos2); glVertexf3(pos2+UpVector*100); glVertexf3(pos1+UpVector*100); } glEnd(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glDisable(GL_DEPTH_TEST); float mx=float(mouse->lastx)/gu->viewSizeX; float my=(gu->viewSizeY-float(mouse->lasty))/gu->viewSizeY; glDisable(GL_TEXTURE_2D); glEnable(GL_BLEND); glDisable(GL_ALPHA_TEST); if (!showReady) { return; } if (InBox(mx, my, readyBox)) { glColor4f(0.7f, 0.2f, 0.2f, guiAlpha); } else { glColor4f(0.7f, 0.7f, 0.2f, guiAlpha); } DrawBox(readyBox); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); if (InBox(mx, my, readyBox)) { glColor4f(0.7f, 0.2f, 0.2f, guiAlpha); } else { glColor4f(0.7f, 0.7f, 0.2f, guiAlpha); } DrawBox(readyBox); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // fit text into box const float unitWidth = font->GetSize() * font->GetTextWidth("Ready") * gu->pixelX; const float unitHeight = font->GetSize() * font->GetLineHeight() * gu->pixelY; const float ySize = (readyBox.y2 - readyBox.y1); const float xSize = (readyBox.x2 - readyBox.x1); const float fontScale = 0.9f * std::min(xSize/unitWidth, ySize/unitHeight); const float yPos = 0.5f * (readyBox.y1 + readyBox.y2); const float xPos = 0.5f * (readyBox.x1 + readyBox.x2); font->Begin(); font->SetColors(); // default font->glPrint(xPos, yPos, fontScale, FONT_OUTLINE | FONT_CENTER | FONT_VCENTER | FONT_SCALE | FONT_NORM, "Ready"); font->End(); }
bool Game::init() { mShouldExit = false; //create Timers mpLoopTimer = new Timer; mpMasterTimer = new Timer; //startup allegro if(!al_init()) { fprintf(stderr, "failed to initialize allegro!\n"); return false; } //create and init GraphicsSystem mpGraphicsSystem = new GraphicsSystem(); bool goodGraphics = mpGraphicsSystem->init( WIDTH, HEIGHT ); if(!goodGraphics) { fprintf(stderr, "failed to initialize GraphicsSystem object!\n"); return false; } mpGraphicsBufferManager = new GraphicsBufferManager(); mpSpriteManager = new SpriteManager(); //startup a lot of allegro stuff //load image loader addon if( !al_init_image_addon() ) { fprintf(stderr, "image addon failed to load!\n"); return false; } //install audio stuff if( !al_install_audio() ) { fprintf(stderr, "failed to initialize sound!\n"); return false; } if(!al_init_acodec_addon()) { fprintf(stderr, "failed to initialize audio codecs!\n"); return false; } if (!al_reserve_samples(1)) { fprintf(stderr, "failed to reserve samples!\n"); return false; } //should probably be done in the InputSystem! if( !al_install_keyboard() ) { printf( "Keyboard not installed!\n" ); return false; } //should probably be done in the InputSystem! if( !al_install_mouse() ) { printf( "Mouse not installed!\n" ); return false; } //should be somewhere else! al_init_font_addon(); if( !al_init_ttf_addon() ) { printf( "ttf font addon not initted properly!\n" ); return false; } //actually load the font mpFont = al_load_ttf_font( "cour.ttf", 20, 0 ); if( mpFont == NULL ) { printf( "ttf font file not loaded properly!\n" ); return false; } //show the mouse if( !al_hide_mouse_cursor( mpGraphicsSystem->getDisplay() ) ) { printf( "Mouse cursor not able to be hidden!\n" ); return false; } if( !al_init_primitives_addon() ) { printf( "Primitives addon not added!\n" ); return false; } //load the sample mpSample = al_load_sample( "clapping.wav" ); if (!mpSample) { printf( "Audio clip sample not loaded!\n" ); return false; } mpMessageManager = new GameMessageManager(); //load buffers mBackgroundBufferID = mpGraphicsBufferManager->loadBuffer("wallpaper.bmp"); mPlayerIconBufferID = mpGraphicsBufferManager->loadBuffer("arrow.bmp"); mEnemyIconBufferID = mpGraphicsBufferManager->loadBuffer("enemy-arrow.bmp"); //setup sprites GraphicsBuffer* pBackGroundBuffer = mpGraphicsBufferManager->getBuffer( mBackgroundBufferID ); if( pBackGroundBuffer != NULL ) { mpSpriteManager->createAndManageSprite( BACKGROUND_SPRITE_ID, pBackGroundBuffer, 0, 0, pBackGroundBuffer->getWidth(), pBackGroundBuffer->getHeight() ); } GraphicsBuffer* pPlayerBuffer = mpGraphicsBufferManager->getBuffer( mPlayerIconBufferID ); Sprite* pArrowSprite = NULL; if( pPlayerBuffer != NULL ) { pArrowSprite = mpSpriteManager->createAndManageSprite( PLAYER_ICON_SPRITE_ID, pPlayerBuffer, 0, 0, pPlayerBuffer->getWidth(), pPlayerBuffer->getHeight() ); } GraphicsBuffer* pAIBuffer = mpGraphicsBufferManager->getBuffer( mEnemyIconBufferID ); Sprite* pEnemyArrow = NULL; if( pAIBuffer != NULL ) { pEnemyArrow = mpSpriteManager->createAndManageSprite( AI_ICON_SPRITE_ID, pAIBuffer, 0, 0, pAIBuffer->getWidth(), pAIBuffer->getHeight() ); } //setup units Vector2D pos( 0.0f, 0.0f ); Vector2D vel( 0.0f, 0.0f ); mpUnit = new KinematicUnit( pArrowSprite, pos, 1, vel, 0.0f, 200.0f, 10.0f ); Vector2D pos2( 1000.0f, 500.0f ); Vector2D vel2( 0.0f, 0.0f ); mpAIUnit = new KinematicUnit( pEnemyArrow, pos2, 1, vel2, 0.0f, 180.0f, 100.0f ); //give steering behavior mpAIUnit->dynamicArrive( mpUnit ); Vector2D pos3( 500.0f, 500.0f ); mpAIUnit2 = new KinematicUnit( pEnemyArrow, pos3, 1, vel2, 0.0f, 180.0f, 100.0f ); //give steering behavior mpAIUnit2->dynamicSeek( mpUnit ); return true; }
bool Transporter::GenerateWaypoints() { TransportPath path; FillPathVector(GetInfo()->SpellFocus, path); if (path.Size() == 0) return false; vector<keyFrame> keyFrames; int mapChange = 0; for (int i = 1; i < (int)path.Size() - 1; i++) { if (mapChange == 0) { if ((path[i].mapid == path[i + 1].mapid)) { keyFrame k(path[i].x, path[i].y, path[i].z, path[i].mapid, path[i].actionFlag, path[i].delay); keyFrames.push_back(k); } else { mapChange = 1; } } else { mapChange--; } } int lastStop = -1; int firstStop = -1; // first cell is arrived at by teleportation :S keyFrames[0].distFromPrev = 0; if (keyFrames[0].actionflag == 2) { lastStop = 0; } // find the rest of the distances between key points for (size_t i = 1; i < keyFrames.size(); i++) { if ((keyFrames[i - 1].actionflag == 1) || (keyFrames[i].mapid != keyFrames[i - 1].mapid)) { keyFrames[i].distFromPrev = 0; } else { keyFrames[i].distFromPrev = sqrt(pow(keyFrames[i].x - keyFrames[i - 1].x, 2) + pow(keyFrames[i].y - keyFrames[i - 1].y, 2) + pow(keyFrames[i].z - keyFrames[i - 1].z, 2)); } if (keyFrames[i].actionflag == 2) { if (firstStop < 0) firstStop = (int)i; lastStop = (int)i; } } float tmpDist = 0; for (int i = 0; i < (int)keyFrames.size(); i++) { int j = (i + lastStop) % (int)keyFrames.size(); if (keyFrames[j].actionflag == 2) tmpDist = 0; else tmpDist += keyFrames[j].distFromPrev; keyFrames[j].distSinceStop = tmpDist; } for (int i = int(keyFrames.size()) - 1; i >= 0; i--) { int j = (i + (firstStop + 1)) % (int)keyFrames.size(); tmpDist += keyFrames[(j + 1) % keyFrames.size()].distFromPrev; keyFrames[j].distUntilStop = tmpDist; if (keyFrames[j].actionflag == 2) tmpDist = 0; } for (size_t i = 0; i < keyFrames.size(); i++) { if (keyFrames[i].distSinceStop < (30 * 30 * 0.5)) keyFrames[i].tFrom = sqrt(2 * keyFrames[i].distSinceStop); else keyFrames[i].tFrom = ((keyFrames[i].distSinceStop - (30 * 30 * 0.5f)) / 30) + 30; if (keyFrames[i].distUntilStop < (30 * 30 * 0.5)) keyFrames[i].tTo = sqrt(2 * keyFrames[i].distUntilStop); else keyFrames[i].tTo = ((keyFrames[i].distUntilStop - (30 * 30 * 0.5f)) / 30) + 30; keyFrames[i].tFrom *= 1000; keyFrames[i].tTo *= 1000; } // for (int i = 0; i < keyFrames.size(); i++) { // sLog.outString("%f, %f, %f, %f, %f, %f, %f", keyFrames[i].x, keyFrames[i].y, keyFrames[i].distUntilStop, keyFrames[i].distSinceStop, keyFrames[i].distFromPrev, keyFrames[i].tFrom, keyFrames[i].tTo); // } // Now we're completely set up; we can move along the length of each waypoint at 100 ms intervals // speed = max(30, t) (remember x = 0.5s^2, and when accelerating, a = 1 unit/s^2 int t = 0; bool teleport = false; if (keyFrames[keyFrames.size() - 1].mapid != keyFrames[0].mapid) teleport = true; TWayPoint pos(keyFrames[0].mapid, keyFrames[0].x, keyFrames[0].y, keyFrames[0].z, teleport); uint32 last_t = 0; m_WayPoints[0] = pos; t += keyFrames[0].delay * 1000; int cM = keyFrames[0].mapid; for (size_t i = 0; i < keyFrames.size() - 1; i++) // { float d = 0; float tFrom = keyFrames[i].tFrom; float tTo = keyFrames[i].tTo; // keep the generation of all these points; we use only a few now, but may need the others later if (((d < keyFrames[i + 1].distFromPrev) && (tTo > 0))) { while ((d < keyFrames[i + 1].distFromPrev) && (tTo > 0)) { tFrom += 100; tTo -= 100; if (d > 0) { float newX, newY, newZ; newX = keyFrames[i].x + (keyFrames[i + 1].x - keyFrames[i].x) * d / keyFrames[i + 1].distFromPrev; newY = keyFrames[i].y + (keyFrames[i + 1].y - keyFrames[i].y) * d / keyFrames[i + 1].distFromPrev; newZ = keyFrames[i].z + (keyFrames[i + 1].z - keyFrames[i].z) * d / keyFrames[i + 1].distFromPrev; teleport = false; if ((int)keyFrames[i].mapid != cM) { teleport = true; cM = keyFrames[i].mapid; } // sLog.outString("T: %d, D: %f, x: %f, y: %f, z: %f", t, d, newX, newY, newZ); TWayPoint pos2(keyFrames[i].mapid, newX, newY, newZ, teleport); if (teleport || ((t - last_t) >= 1000)) { m_WayPoints[t] = pos2; last_t = t; } } if (tFrom < tTo) // caught in tFrom dock's "gravitational pull" { if (tFrom <= 30000) { d = 0.5f * (tFrom / 1000) * (tFrom / 1000); } else { d = 0.5f * 30 * 30 + 30 * ((tFrom - 30000) / 1000); } d = d - keyFrames[i].distSinceStop; } else { if (tTo <= 30000) { d = 0.5f * (tTo / 1000) * (tTo / 1000); } else { d = 0.5f * 30 * 30 + 30 * ((tTo - 30000) / 1000); } d = keyFrames[i].distUntilStop - d; } t += 100; } t -= 100; } if (keyFrames[i + 1].tFrom > keyFrames[i + 1].tTo) t += 100 - ((long)keyFrames[i + 1].tTo % 100); else t += (long)keyFrames[i + 1].tTo % 100; teleport = false; if ((keyFrames[i + 1].actionflag == 1) || (keyFrames[i + 1].mapid != keyFrames[i].mapid)) { teleport = true; cM = keyFrames[i + 1].mapid; } TWayPoint pos2(keyFrames[i + 1].mapid, keyFrames[i + 1].x, keyFrames[i + 1].y, keyFrames[i + 1].z, teleport); // sLog.outString("T: %d, x: %f, y: %f, z: %f, t:%d", t, pos.x, pos.y, pos.z, teleport); //if (teleport) //m_WayPoints[t] = pos; if (keyFrames[i + 1].delay > 5) pos2.delayed = true; m_WayPoints.insert(WaypointMap::value_type(t, pos2)); last_t = t; t += keyFrames[i + 1].delay * 1000; // sLog.outString("------"); } uint32 timer = t; mCurrentWaypoint = m_WayPoints.begin(); //mCurrentWaypoint = GetNextWaypoint(); mNextWaypoint = GetNextWaypoint(); m_pathTime = timer; m_timer = 0; return true; }
void MeshFusion::intoMesh(Matrix4f invm, MyTri *scanned) { int nnode[2048]; int ocase = -1; int nface = scanned->totalFace / 3; for (int i = 0; i < nface; i++) { int n0 = scanned->meshTri[3 * i]; int n1 = scanned->meshTri[3 * i + 1]; int n2 = scanned->meshTri[3 * i + 2]; Point2 first_vertex = scanned->meshProj[n0]; Point2 second_vertex = scanned->meshProj[n1]; Point2 third_vertex = scanned->meshProj[n2]; bool s0 = scanned->stat[n0]; bool s1 = scanned->stat[n1]; bool s2 = scanned->stat[n2]; if (!s0 && !s1 && !s2) { Vector3f pos0(scanned->meshVertex[n0].x, scanned->meshVertex[n0].y, scanned->meshVertex[n0].z); Vector3f pos1(scanned->meshVertex[n1].x, scanned->meshVertex[n1].y, scanned->meshVertex[n1].z); Vector3f pos2(scanned->meshVertex[n2].x, scanned->meshVertex[n2].y, scanned->meshVertex[n2].z); Vector3f ipos0 = invm *pos0; Vector3f ipos1 = invm *pos1; Vector3f ipos2 = invm *pos2; // if (nnode[n0] <= 0) { mytriData.meshVertex[mytriData.totalVertex].x = ipos0.x; mytriData.meshVertex[mytriData.totalVertex].y = ipos0.y; mytriData.meshVertex[mytriData.totalVertex].z = ipos0.z; nnode[n0] = mytriData.totalVertex; mytriData.totalVertex++; } //if (nnode[n1] <= 0) { mytriData.meshVertex[mytriData.totalVertex].x = ipos1.x; mytriData.meshVertex[mytriData.totalVertex].y = ipos1.y; mytriData.meshVertex[mytriData.totalVertex].z = ipos1.z; nnode[n1] = mytriData.totalVertex; mytriData.totalVertex++; } //if (nnode[n2] <= 0) { mytriData.meshVertex[mytriData.totalVertex].x = ipos2.x; mytriData.meshVertex[mytriData.totalVertex].y = ipos2.y; mytriData.meshVertex[mytriData.totalVertex].z = ipos2.z; nnode[n2] = mytriData.totalVertex; mytriData.totalVertex++; } mytriData.meshTri[mytriData.totalFace++] = nnode[n0]; mytriData.meshTri[mytriData.totalFace++] = nnode[n1]; mytriData.meshTri[mytriData.totalFace++] = nnode[n2]; } } }
/** * This test checks various generic API methods in DateFormat to achieve 100% * API coverage. */ void IntlTestDateFormatAPI::testAPI(/* char* par */) { UErrorCode status = U_ZERO_ERROR; // ======= Test constructors logln("Testing DateFormat constructors"); DateFormat *def = DateFormat::createInstance(); DateFormat *fr = DateFormat::createTimeInstance(DateFormat::FULL, Locale::getFrench()); DateFormat *it = DateFormat::createDateInstance(DateFormat::MEDIUM, Locale::getItalian()); DateFormat *de = DateFormat::createDateTimeInstance(DateFormat::LONG, DateFormat::LONG, Locale::getGerman()); if (def == NULL || fr == NULL || it == NULL || de == NULL){ dataerrln("Error creating instnaces."); } // ======= Test equality if (fr != NULL && def != NULL) { logln("Testing equality operator"); if( *fr == *it ) { errln("ERROR: == failed"); } } // ======= Test various format() methods if (fr != NULL && it != NULL && de != NULL) { logln("Testing various format() methods"); UDate d = 837039928046.0; Formattable fD(d, Formattable::kIsDate); UnicodeString res1, res2, res3; FieldPosition pos1(0), pos2(0); status = U_ZERO_ERROR; res1 = fr->format(d, res1, pos1, status); if(U_FAILURE(status)) { errln("ERROR: format() failed (French)"); } logln( (UnicodeString) "" + d + " formatted to " + res1); res2 = it->format(d, res2, pos2); logln( (UnicodeString) "" + d + " formatted to " + res2); res3 = de->format(d, res3); logln( (UnicodeString) "" + d + " formatted to " + res3); } // ======= Test parse() if (def != NULL) { logln("Testing parse()"); UnicodeString text("02/03/76 2:50 AM, CST"); Formattable result1; UDate result2, result3; ParsePosition pos(0), pos01(0); def->parseObject(text, result1, pos); if(result1.getType() != Formattable::kDate) { errln("ERROR: parseObject() failed for " + text); } logln(text + " parsed into " + result1.getDate()); status = U_ZERO_ERROR; result2 = def->parse(text, status); if(U_FAILURE(status)) { errln("ERROR: parse() failed, stopping testing"); return; } logln(text + " parsed into " + result2); result3 = def->parse(text, pos01); logln(text + " parsed into " + result3); } // ======= Test getters and setters if (fr != NULL && it != NULL && de != NULL) { logln("Testing getters and setters"); int32_t count = 0; const Locale *locales = DateFormat::getAvailableLocales(count); logln((UnicodeString) "Got " + count + " locales" ); for(int32_t i = 0; i < count; i++) { UnicodeString name; name = locales[i].getName(); logln(name); } fr->setLenient(it->isLenient()); if(fr->isLenient() != it->isLenient()) { errln("ERROR: setLenient() failed"); } const Calendar *cal = def->getCalendar(); Calendar *newCal = cal->clone(); de->adoptCalendar(newCal); it->setCalendar(*newCal); if( *(de->getCalendar()) != *(it->getCalendar())) { errln("ERROR: adopt or set Calendar() failed"); } const NumberFormat *nf = def->getNumberFormat(); NumberFormat *newNf = (NumberFormat*) nf->clone(); de->adoptNumberFormat(newNf); it->setNumberFormat(*newNf); if( *(de->getNumberFormat()) != *(it->getNumberFormat())) { errln("ERROR: adopt or set NumberFormat() failed"); } const TimeZone& tz = def->getTimeZone(); TimeZone *newTz = tz.clone(); de->adoptTimeZone(newTz); it->setTimeZone(*newTz); if( de->getTimeZone() != it->getTimeZone()) { errln("ERROR: adopt or set TimeZone() failed"); } } // ======= Test getStaticClassID() logln("Testing getStaticClassID()"); status = U_ZERO_ERROR; DateFormat *test = new SimpleDateFormat(status); if(U_FAILURE(status)) { errln("ERROR: Couldn't create a DateFormat"); } if(test->getDynamicClassID() != SimpleDateFormat::getStaticClassID()) { errln("ERROR: getDynamicClassID() didn't return the expected value"); } delete test; delete def; delete fr; delete it; delete de; }
void EndlessGameWidget::dealStableEliminate(Connections connections) { // Calculate the bonus for (int i = 0;i < gameboardInfo->totalBallCounts();++i) { QVector<QVector<int> *>& connect = connections.connectionsOfIndex[i]; int connectionCountOfThePosition = 0; for (int j = 0;j < 10;++j) { if (j == 3 || connect[j] == NULL) continue; ++connectionCountOfThePosition; } if (connectionCountOfThePosition > 0) effectPainter->highlightAt(i); if (connectionCountOfThePosition > 1) { if (connectionCountOfThePosition >= 2) effectPainter->flash(); if (connectionCountOfThePosition == 2) { // Add sound effect PublicGameSounds::addSound(PublicGameSounds::GetFlame); // Get a flame flame->addOne(); statistic.changeStatistic(Statistic::FlameGetCount, 1, true); } if (connectionCountOfThePosition >= 3) { // Add sound effect PublicGameSounds::addSound(PublicGameSounds::GetStar); // Get a star star->addOne(); statistic.changeStatistic(Statistic::StarGetCount, 1, true); } } } for (int i = 0;i < connections.connections.size();++i) { int size = connections.connections[i]->size(); QPointF pos1(gameboardInfo->positionOfIndex(connections.connections[i]->at(0))); QPointF pos2(gameboardInfo->positionOfIndex(connections.connections[i]->at(size - 1))); effectPainter->wordsAt(QPointF((pos1.x() + pos2.x()) / 2, (pos1.y() + pos2.y()) / 2), tr("%1").arg(size), size); if (size >= 4) effectPainter->flash(); if (size == 4) { // Add sound effect PublicGameSounds::addSound(PublicGameSounds::GetFlame); // Get a flame flame->addOne(); statistic.changeStatistic(Statistic::FlameGetCount, 1, true); } if (size >= 5) { // Add sound effect PublicGameSounds::addSound(PublicGameSounds::GetStar); // Get a star star->addOne(); statistic.changeStatistic(Statistic::StarGetCount, 1, true); } } }
void UpgradeUILayer::createStoneMaxUI() { std::string fontFile = "DS-Digital.ttf";//"arial.ttf"; int fontSize = 25; auto infoColor = DIY_COLOR_BLUE5; auto bk = Scale9Sprite::create("helpCellBG.png"); auto bkSize = panelSize - Size(30,150); bk->setAnchorPoint(Point::ANCHOR_MIDDLE_TOP); bk->setPosition(Point(panelSize.width/2,panelSize.height-70)); bk->setContentSize(bkSize); _panel->addChild(bk); Point pos1(60,bkSize.height/2+80); Point pos2(260,bkSize.height/2+80); Point pos3(360,bkSize.height/2+80); Point pos4(400,bkSize.height/2+80); Point offset(0,-70); auto level_text = TextSprite::create(s_gameStrings.base->upgradeLevel,GameConfig::defaultFontName,fontSize); level_text->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); level_text->setPosition(pos1); bk->addChild(level_text); auto level_before = TextSprite::create(Value(s_playerConfig.stonecapacitylevel+1).asString(),GameConfig::defaultFontName,fontSize); level_before->setColor(infoColor); level_before->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); level_before->setPosition(pos2); bk->addChild(level_before); auto arrow_upgrade_0 = Sprite::create("upgrade_arrow.png"); arrow_upgrade_0->setPosition(pos3); bk->addChild(arrow_upgrade_0); auto level_after = TextSprite::create(Value(s_playerConfig.stonecapacitylevel+2).asString(),GameConfig::defaultFontName,fontSize); level_after->setColor(infoColor); level_after->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); level_after->setPosition(pos4); bk->addChild(level_after); auto init_text = TextSprite::create(s_gameStrings.base->stoneinit,GameConfig::defaultFontName,fontSize); init_text->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); init_text->setPosition(pos1+offset); bk->addChild(init_text); auto init_before = TextSprite::create(Value(s_stoneCapacity[s_playerConfig.stonecapacitylevel].initstone).asString(),GameConfig::defaultFontName,fontSize); init_before->setColor(infoColor); init_before->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); init_before->setPosition(pos2+offset); bk->addChild(init_before); auto arrow_upgrade_1 = Sprite::create("upgrade_arrow.png"); arrow_upgrade_1->setPosition(pos3+offset); bk->addChild(arrow_upgrade_1); auto init_after = TextSprite::create(Value(s_stoneCapacity[s_playerConfig.stonecapacitylevel+1].initstone).asString(),GameConfig::defaultFontName,fontSize); init_after->setColor(infoColor); init_after->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); init_after->setPosition(pos4+offset); bk->addChild(init_after); auto max_text = TextSprite::create(s_gameStrings.base->stonemax,GameConfig::defaultFontName,fontSize); max_text->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); max_text->setPosition(pos1+offset*2); bk->addChild(max_text); auto max_before = TextSprite::create(Value(s_stoneCapacity[s_playerConfig.stonecapacitylevel].maxstone).asString(),GameConfig::defaultFontName,fontSize); max_before->setColor(infoColor); max_before->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); max_before->setPosition(pos2+offset*2); bk->addChild(max_before); auto arrow_upgrade_2 = Sprite::create("upgrade_arrow.png"); arrow_upgrade_2->setPosition(pos3+offset*2); bk->addChild(arrow_upgrade_2); auto max_after = TextSprite::create(Value(s_stoneCapacity[s_playerConfig.stonecapacitylevel+1].maxstone).asString(),GameConfig::defaultFontName,fontSize); max_after->setColor(infoColor); max_after->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); max_after->setPosition(pos4+offset*2); bk->addChild(max_after); }
void HairpinSegment::layout() { if (hairpin()->useTextLine()) { if (parent()) rypos() += score()->styleS(StyleIdx::hairpinY).val() * spatium(); TextLineSegment::layout(); return; } QTransform t; qreal _spatium = spatium(); 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 = 0; if( drawCircledTip ) circledTipRadius = 0.6 * _spatium * .5; if (hairpin()->hairpinType() == Hairpin::Type::CRESCENDO) { // crescendo switch (spannerSegmentType()) { case SpannerSegmentType::SINGLE: case SpannerSegmentType::BEGIN: l1.setLine(.0 + circledTipRadius*2, .0, len, h1); l2.setLine(.0 + circledTipRadius*2, .0, len, -h1); circledTip.setX( 0 + circledTipRadius ); circledTip.setY( 0 ); break; case SpannerSegmentType::MIDDLE: case SpannerSegmentType::END: drawCircledTip = false; l1.setLine(.0, h2, len, h1); l2.setLine(.0, -h2, len, -h1); break; } } else { // decrescendo switch(spannerSegmentType()) { case SpannerSegmentType::SINGLE: case SpannerSegmentType::END: l1.setLine(.0, h1, len - circledTipRadius*2, 0.0); l2.setLine(.0, -h1, len - circledTipRadius*2, 0.0); circledTip.setX( len - circledTipRadius ); circledTip.setY( 0 ); break; case SpannerSegmentType::BEGIN: case SpannerSegmentType::MIDDLE: drawCircledTip = false; l1.setLine(.0, h1, len, + h2); l2.setLine(.0, -h1, len, - h2); break; } } // Do Coord rotation l1 = t.map(l1); l2 = t.map(l2); if( drawCircledTip ) circledTip = t.map(circledTip); QRectF r = QRectF(l1.p1(), l1.p2()).normalized() | QRectF(l2.p1(), l2.p2()).normalized(); qreal w = point(score()->styleS(StyleIdx::hairpinLineWidth)); setbbox(r.adjusted(-w*.5, -w*.5, w, w)); if (parent()) rypos() += score()->styleS(StyleIdx::hairpinY).val() * _spatium; adjustReadPos(); }
void UpgradeUILayer::createFlightUI() { std::string fontFile = "DS-Digital.ttf";//"arial.ttf"; int fontSize = 25; auto infoColor = DIY_COLOR_BLUE5; auto bk = Scale9Sprite::create("helpCellBG.png"); auto bkSize = panelSize - Size(30,150); bk->setAnchorPoint(Point::ANCHOR_MIDDLE_TOP); bk->setPosition(Point(panelSize.width/2,panelSize.height-70)); bk->setContentSize(bkSize); _panel->addChild(bk); Point pos1(80,bkSize.height/2+120); Point pos2(260,bkSize.height/2+120); Point pos3(360,bkSize.height/2+120); Point pos4(400,bkSize.height/2+120); Point offset(0,-40); auto level_text = TextSprite::create(s_gameStrings.base->upgradeLevel,GameConfig::defaultFontName,fontSize); level_text->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); level_text->setPosition(pos1); bk->addChild(level_text); auto level_before = TextSprite::create(Value(s_playerConfig.fighterslevel[_index]+1).asString(),GameConfig::defaultFontName,fontSize); level_before->setColor(infoColor); level_before->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); level_before->setPosition(pos2); bk->addChild(level_before); auto arrow_upgrade_0 = Sprite::create("upgrade_arrow.png"); arrow_upgrade_0->setPosition(pos3); bk->addChild(arrow_upgrade_0); auto level_after = TextSprite::create(Value(s_playerConfig.fighterslevel[_index]+2).asString(),GameConfig::defaultFontName,fontSize); level_after->setColor(infoColor); level_after->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); level_after->setPosition(pos4); bk->addChild(level_after); auto life_text = TextSprite::create(s_gameStrings.base->upgradeLife,GameConfig::defaultFontName,fontSize); life_text->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); life_text->setPosition(pos1+offset); bk->addChild(life_text); auto life_before = TextSprite::create(Value(s_plainConfigs[_index][s_playerConfig.fighterslevel[_index]].life).asString(),GameConfig::defaultFontName,fontSize); life_before->setColor(infoColor); life_before->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); life_before->setPosition(pos2+offset); bk->addChild(life_before); auto arrow_upgrade_1 = Sprite::create("upgrade_arrow.png"); arrow_upgrade_1->setPosition(pos3+offset); bk->addChild(arrow_upgrade_1); auto life_after = TextSprite::create(Value(s_plainConfigs[_index][s_playerConfig.fighterslevel[_index]+1].life).asString(),GameConfig::defaultFontName,fontSize); life_after->setColor(infoColor); life_after->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); life_after->setPosition(pos4+offset); bk->addChild(life_after); auto attack_text = TextSprite::create(s_gameStrings.base->upgradeAtt,GameConfig::defaultFontName,fontSize); attack_text->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); attack_text->setPosition(pos1+offset*2); bk->addChild(attack_text); auto attack_before = TextSprite::create(Value(s_plainConfigs[_index][s_playerConfig.fighterslevel[_index]].attack).asString(),GameConfig::defaultFontName,fontSize); attack_before->setColor(infoColor); attack_before->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); attack_before->setPosition(pos2+offset*2); bk->addChild(attack_before); auto arrow_upgrade_2 = Sprite::create("upgrade_arrow.png"); arrow_upgrade_2->setPosition(pos3+offset*2); bk->addChild(arrow_upgrade_2); auto attack_after = TextSprite::create(Value(s_plainConfigs[_index][s_playerConfig.fighterslevel[_index]+1].attack).asString(),GameConfig::defaultFontName,fontSize); attack_after->setColor(infoColor); attack_after->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); attack_after->setPosition(pos4+offset*2); bk->addChild(attack_after); auto defense_text = TextSprite::create(s_gameStrings.base->upgradeDef,GameConfig::defaultFontName,fontSize); defense_text->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); defense_text->setPosition(pos1+offset*3); bk->addChild(defense_text); auto defense_before = TextSprite::create(Value(s_plainConfigs[_index][s_playerConfig.fighterslevel[_index]].defense).asString(),GameConfig::defaultFontName,fontSize); defense_before->setColor(infoColor); defense_before->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); defense_before->setPosition(pos2+offset*3); bk->addChild(defense_before); auto arrow_upgrade_3 = Sprite::create("upgrade_arrow.png"); arrow_upgrade_3->setPosition(pos3+offset*3); bk->addChild(arrow_upgrade_3); auto defense_after = TextSprite::create(Value(s_plainConfigs[_index][s_playerConfig.fighterslevel[_index]+1].defense).asString(),GameConfig::defaultFontName,fontSize); defense_after->setColor(infoColor); defense_after->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); defense_after->setPosition(pos4+offset*3); bk->addChild(defense_after); auto speed_text = TextSprite::create(s_gameStrings.base->upgradeSpd,GameConfig::defaultFontName,fontSize); speed_text->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); speed_text->setPosition(pos1+offset*4); bk->addChild(speed_text); auto speed_before = TextSprite::create(Value(s_plainConfigs[_index][s_playerConfig.fighterslevel[_index]].speed).asString(),GameConfig::defaultFontName,fontSize); speed_before->setColor(infoColor); speed_before->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); speed_before->setPosition(pos2+offset*4); bk->addChild(speed_before); auto arrow_upgrade_4 = Sprite::create("upgrade_arrow.png"); arrow_upgrade_4->setPosition(pos3+offset*4); bk->addChild(arrow_upgrade_4); auto speed_after = TextSprite::create(Value(s_plainConfigs[_index][s_playerConfig.fighterslevel[_index]+1].speed).asString(),GameConfig::defaultFontName,fontSize); speed_after->setColor(infoColor); speed_after->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); speed_after->setPosition(pos4+offset*4); bk->addChild(speed_after); auto range_text = TextSprite::create(s_gameStrings.base->upgradeRange,GameConfig::defaultFontName,fontSize); range_text->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); range_text->setPosition(pos1+offset*5); bk->addChild(range_text); auto range_before = TextSprite::create(Value(s_plainConfigs[_index][s_playerConfig.fighterslevel[_index]].range).asString(),GameConfig::defaultFontName,fontSize); range_before->setColor(infoColor); range_before->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); range_before->setPosition(pos2+offset*5); bk->addChild(range_before); auto arrow_upgrade_5 = Sprite::create("upgrade_arrow.png"); arrow_upgrade_5->setPosition(pos3+offset*5); bk->addChild(arrow_upgrade_5); auto range_after = TextSprite::create(Value(s_plainConfigs[_index][s_playerConfig.fighterslevel[_index]+1].range).asString(),GameConfig::defaultFontName,fontSize); range_after->setColor(infoColor); range_after->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); range_after->setPosition(pos4+offset*5); bk->addChild(range_after); auto usestone_text = TextSprite::create(s_gameStrings.base->useStone,GameConfig::defaultFontName,fontSize); usestone_text->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); usestone_text->setPosition(pos1+offset*6); bk->addChild(usestone_text); auto usestone_before = TextSprite::create(Value(s_plainConfigs[_index][s_playerConfig.fighterslevel[_index]].sparForMake).asString(),GameConfig::defaultFontName,fontSize); usestone_before->setColor(infoColor); usestone_before->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); usestone_before->setPosition(pos2+offset*6); bk->addChild(usestone_before); auto arrow_upgrade_6 = Sprite::create("upgrade_arrow.png"); arrow_upgrade_6->setPosition(pos3+offset*6); bk->addChild(arrow_upgrade_6); auto usestone_after = TextSprite::create(Value(s_plainConfigs[_index][s_playerConfig.fighterslevel[_index]+1].sparForMake).asString(),GameConfig::defaultFontName,fontSize); usestone_after->setColor(infoColor); usestone_after->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); usestone_after->setPosition(pos4+offset*6); bk->addChild(usestone_after); }
/** ** Check Distance Restriction */ bool CBuildRestrictionDistance::Check(const CUnit *builder, const CUnitType &type, const Vec2i &pos, CUnit *&) const { Vec2i pos1(0, 0); Vec2i pos2(0, 0); int distance = 0; if (this->DistanceType == LessThanEqual || this->DistanceType == GreaterThan || this->DistanceType == Equal || this->DistanceType == NotEqual) { pos1.x = std::max<int>(pos.x - this->Distance, 0); pos1.y = std::max<int>(pos.y - this->Distance, 0); pos2.x = std::min<int>(pos.x + type.TileWidth + this->Distance, Map.Info.MapWidth); pos2.y = std::min<int>(pos.y + type.TileHeight + this->Distance, Map.Info.MapHeight); distance = this->Distance; } else if (this->DistanceType == LessThan || this->DistanceType == GreaterThanEqual) { pos1.x = std::max<int>(pos.x - this->Distance - 1, 0); pos1.y = std::max<int>(pos.y - this->Distance - 1, 0); pos2.x = std::min<int>(pos.x + type.TileWidth + this->Distance + 1, Map.Info.MapWidth); pos2.y = std::min<int>(pos.y + type.TileHeight + this->Distance + 1, Map.Info.MapHeight); distance = this->Distance - 1; } std::vector<CUnit *> table; Select(pos1, pos2, table); for (size_t i = 0; i != table.size(); ++i) { if (builder != table[i] && // unit has RestrictType or no RestrictType was set, but a RestrictTypeOwner (this->RestrictType == table[i]->Type || (!this->RestrictType && this->RestrictTypeOwner.size() > 0)) && // RestrictTypeOwner is not set or unit belongs to a suitable player (this->RestrictTypeOwner.size() == 0 || (!this->RestrictTypeOwner.compare("self") && ThisPlayer == table[i]->Player) || (!this->RestrictTypeOwner.compare("allied") && (ThisPlayer == table[i]->Player || ThisPlayer->IsAllied(*table[i]->Player))) || (!this->RestrictTypeOwner.compare("enemy") && ThisPlayer->IsEnemy(*table[i]->Player)))) { switch (this->DistanceType) { case GreaterThan : case GreaterThanEqual : if (MapDistanceBetweenTypes(type, pos, *table[i]->Type, table[i]->tilePos) <= distance) { return false; } break; case LessThan : case LessThanEqual : if (MapDistanceBetweenTypes(type, pos, *table[i]->Type, table[i]->tilePos) <= distance) { return true; } break; case Equal : if (MapDistanceBetweenTypes(type, pos, *table[i]->Type, table[i]->tilePos) == distance) { return true; } break; case NotEqual : if (MapDistanceBetweenTypes(type, pos, *table[i]->Type, table[i]->tilePos) == distance) { return false; } break; } } } return (this->DistanceType == GreaterThan || this->DistanceType == GreaterThanEqual || this->DistanceType == NotEqual); }
void UpgradeUILayer::createWeaponUI() { std::string fontFile = "DS-Digital.ttf";//"arial.ttf"; int fontSize = 25; auto infoColor = DIY_COLOR_BLUE5; auto bk = Scale9Sprite::create("helpCellBG.png"); auto bkSize = panelSize - Size(30,150); bk->setAnchorPoint(Point::ANCHOR_MIDDLE_TOP); bk->setPosition(Point(panelSize.width/2,panelSize.height-70)); bk->setContentSize(bkSize); _panel->addChild(bk); Point pos1(60,bkSize.height/2+95); Point pos2(220,bkSize.height/2+95); Point pos3(350,bkSize.height/2+95); Point pos4(400,bkSize.height/2+95); Point offset(0,-50); auto level_text = TextSprite::create(s_gameStrings.base->upgradeLevel,GameConfig::defaultFontName,fontSize); level_text->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); level_text->setPosition(pos1); bk->addChild(level_text); auto level_before = TextSprite::create(Value(s_playerConfig.weaponslevel[_index-FIGHTER_MAX]+1).asString(),GameConfig::defaultFontName,fontSize); level_before->setColor(infoColor); level_before->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); level_before->setPosition(pos2); bk->addChild(level_before); auto arrow_upgrade_0 = Sprite::create("upgrade_arrow.png"); arrow_upgrade_0->setPosition(pos3); bk->addChild(arrow_upgrade_0); auto level_after = TextSprite::create(Value(s_playerConfig.weaponslevel[_index-FIGHTER_MAX]+2).asString(),GameConfig::defaultFontName,fontSize); level_after->setColor(infoColor); level_after->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); level_after->setPosition(pos4); bk->addChild(level_after); auto attack_text = TextSprite::create(s_gameStrings.base->upgradeAtt,GameConfig::defaultFontName,fontSize); attack_text->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); attack_text->setPosition(pos1+offset); bk->addChild(attack_text); auto attack_before = TextSprite::create(Value(s_weaponConfigs[_index-FIGHTER_MAX][s_playerConfig.weaponslevel[_index-FIGHTER_MAX]].attack).asString(),GameConfig::defaultFontName,fontSize); attack_before->setColor(infoColor); attack_before->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); attack_before->setPosition(pos2+offset); bk->addChild(attack_before); auto arrow_upgrade_1 = Sprite::create("upgrade_arrow.png"); arrow_upgrade_1->setPosition(pos3+offset*1); bk->addChild(arrow_upgrade_1); auto attack_after = TextSprite::create(Value(s_weaponConfigs[_index-FIGHTER_MAX][s_playerConfig.weaponslevel[_index-FIGHTER_MAX]+1].attack).asString(),GameConfig::defaultFontName,fontSize); attack_after->setColor(infoColor); attack_after->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); attack_after->setPosition(pos4+offset); bk->addChild(attack_after); auto duration_text = TextSprite::create(s_gameStrings.base->upgradeDuration,GameConfig::defaultFontName,fontSize); duration_text->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); duration_text->setPosition(pos1+offset*2); bk->addChild(duration_text); char p[30]; float duration_before_data = s_weaponConfigs[_index-FIGHTER_MAX][s_playerConfig.weaponslevel[_index-FIGHTER_MAX]].duration; sprintf(p, "%.2f",duration_before_data); auto duration_before = TextSprite::create(p,GameConfig::defaultFontName,fontSize); duration_before->setColor(infoColor); duration_before->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); duration_before->setPosition(pos2+offset*2); bk->addChild(duration_before); auto arrow_upgrade_2 = Sprite::create("upgrade_arrow.png"); arrow_upgrade_2->setPosition(pos3+offset*2); bk->addChild(arrow_upgrade_2); float duration_after_data = s_weaponConfigs[_index-FIGHTER_MAX][s_playerConfig.weaponslevel[_index-FIGHTER_MAX]+1].duration; sprintf(p, "%.2f",duration_after_data); auto duration_after = TextSprite::create(p,GameConfig::defaultFontName,fontSize); duration_after->setColor(infoColor); duration_after->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); duration_after->setPosition(pos4+offset*2); bk->addChild(duration_after); auto buyusegem_text = TextSprite::create(s_gameStrings.base->buyusegem,GameConfig::defaultFontName,fontSize); buyusegem_text->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); buyusegem_text->setPosition(pos1+offset*3); bk->addChild(buyusegem_text); auto buyusegem_before = TextSprite::create(Value(s_weaponConfigs[_index-FIGHTER_MAX][s_playerConfig.weaponslevel[_index-FIGHTER_MAX]].costGem).asString(),GameConfig::defaultFontName,fontSize); buyusegem_before->setColor(infoColor); buyusegem_before->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); buyusegem_before->setPosition(pos2+offset*3); bk->addChild(buyusegem_before); auto arrow_upgrade_3 = Sprite::create("upgrade_arrow.png"); arrow_upgrade_3->setPosition(pos3+offset*3); bk->addChild(arrow_upgrade_3); auto buyusegem_after = TextSprite::create(Value(s_weaponConfigs[_index-FIGHTER_MAX][s_playerConfig.weaponslevel[_index-FIGHTER_MAX]+1].costGem).asString(),GameConfig::defaultFontName,fontSize); buyusegem_after->setColor(infoColor); buyusegem_after->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); buyusegem_after->setPosition(pos4+offset*3); bk->addChild(buyusegem_after); auto buymax_text = TextSprite::create(s_gameStrings.base->buymax,GameConfig::defaultFontName,fontSize); buymax_text->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); buymax_text->setPosition(pos1+offset*4); bk->addChild(buymax_text); auto buymax_before = TextSprite::create(Value(s_weaponConfigs[_index-FIGHTER_MAX][s_playerConfig.weaponslevel[_index-FIGHTER_MAX]].capacity).asString(),GameConfig::defaultFontName,fontSize); buymax_before->setColor(infoColor); buymax_before->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); buymax_before->setPosition(pos2+offset*4); bk->addChild(buymax_before); auto arrow_upgrade_4 = Sprite::create("upgrade_arrow.png"); arrow_upgrade_4->setPosition(pos3+offset*4); bk->addChild(arrow_upgrade_4); auto buymax_after = TextSprite::create(Value(s_weaponConfigs[_index-FIGHTER_MAX][s_playerConfig.weaponslevel[_index-FIGHTER_MAX]+1].capacity).asString(),GameConfig::defaultFontName,fontSize); buymax_after->setColor(infoColor); buymax_after->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT); buymax_after->setPosition(pos4+offset*4); bk->addChild(buymax_after); }
/** * This test does round-trip testing (format -> parse -> format -> parse -> etc.) of * NumberFormat. */ void IntlTestNumberFormatAPI::testAPI(/* char* par */) { UErrorCode status = U_ZERO_ERROR; // ======= Test constructors logln("Testing NumberFormat constructors"); NumberFormat *def = NumberFormat::createInstance(status); if(U_FAILURE(status)) { errln("ERROR: Could not create NumberFormat (default)"); } status = U_ZERO_ERROR; NumberFormat *fr = NumberFormat::createInstance(Locale::getFrench(), status); if(U_FAILURE(status)) { errln("ERROR: Could not create NumberFormat (French)"); } NumberFormat *cur = NumberFormat::createCurrencyInstance(status); if(U_FAILURE(status)) { errln("ERROR: Could not create NumberFormat (currency, default)"); } status = U_ZERO_ERROR; NumberFormat *cur_fr = NumberFormat::createCurrencyInstance(Locale::getFrench(), status); if(U_FAILURE(status)) { errln("ERROR: Could not create NumberFormat (currency, French)"); } NumberFormat *per = NumberFormat::createPercentInstance(status); if(U_FAILURE(status)) { errln("ERROR: Could not create NumberFormat (percent, default)"); } status = U_ZERO_ERROR; NumberFormat *per_fr = NumberFormat::createPercentInstance(Locale::getFrench(), status); if(U_FAILURE(status)) { errln("ERROR: Could not create NumberFormat (percent, French)"); } // ======= Test equality if (per_fr != NULL && cur_fr != NULL) { logln("Testing equality operator"); if( *per_fr == *cur_fr || ! ( *per_fr != *cur_fr) ) { errln("ERROR: == failed"); } } // ======= Test various format() methods if (cur_fr != NULL) { logln("Testing various format() methods"); double d = -10456.0037; int32_t l = 100000000; Formattable fD(d); Formattable fL(l); UnicodeString res1, res2, res3, res4, res5, res6; FieldPosition pos1(0), pos2(0), pos3(0), pos4(0); res1 = cur_fr->format(d, res1); logln( (UnicodeString) "" + (int32_t) d + " formatted to " + res1); res2 = cur_fr->format(l, res2); logln((UnicodeString) "" + (int32_t) l + " formatted to " + res2); res3 = cur_fr->format(d, res3, pos1); logln( (UnicodeString) "" + (int32_t) d + " formatted to " + res3); res4 = cur_fr->format(l, res4, pos2); logln((UnicodeString) "" + (int32_t) l + " formatted to " + res4); status = U_ZERO_ERROR; res5 = cur_fr->format(fD, res5, pos3, status); if(U_FAILURE(status)) { errln("ERROR: format(Formattable [double]) failed"); } logln((UnicodeString) "" + (int32_t) fD.getDouble() + " formatted to " + res5); status = U_ZERO_ERROR; res6 = cur_fr->format(fL, res6, pos4, status); if(U_FAILURE(status)) { errln("ERROR: format(Formattable [long]) failed"); } logln((UnicodeString) "" + fL.getLong() + " formatted to " + res6); } // ======= Test parse() if (fr != NULL) { logln("Testing parse()"); double d = -10456.0037; UnicodeString text("-10,456.0037"); Formattable result1, result2, result3; ParsePosition pos(0), pos01(0); fr->parseObject(text, result1, pos); if(result1.getType() != Formattable::kDouble && result1.getDouble() != d) { errln("ERROR: Roundtrip failed (via parse()) for " + text); } logln(text + " parsed into " + (int32_t) result1.getDouble()); fr->parse(text, result2, pos01); if(result2.getType() != Formattable::kDouble && result2.getDouble() != d) { errln("ERROR: Roundtrip failed (via parse()) for " + text); } logln(text + " parsed into " + (int32_t) result2.getDouble()); status = U_ZERO_ERROR; fr->parse(text, result3, status); if(U_FAILURE(status)) { errln("ERROR: parse() failed"); } if(result3.getType() != Formattable::kDouble && result3.getDouble() != d) { errln("ERROR: Roundtrip failed (via parse()) for " + text); } logln(text + " parsed into " + (int32_t) result3.getDouble()); } // ======= Test getters and setters if (fr != NULL && def != NULL) { logln("Testing getters and setters"); int32_t count = 0; const Locale *locales = NumberFormat::getAvailableLocales(count); logln((UnicodeString) "Got " + count + " locales" ); for(int32_t i = 0; i < count; i++) { UnicodeString name(locales[i].getName(),""); logln(name); } fr->setParseIntegerOnly( def->isParseIntegerOnly() ); if(fr->isParseIntegerOnly() != def->isParseIntegerOnly() ) { errln("ERROR: setParseIntegerOnly() failed"); } fr->setGroupingUsed( def->isGroupingUsed() ); if(fr->isGroupingUsed() != def->isGroupingUsed() ) { errln("ERROR: setGroupingUsed() failed"); } fr->setMaximumIntegerDigits( def->getMaximumIntegerDigits() ); if(fr->getMaximumIntegerDigits() != def->getMaximumIntegerDigits() ) { errln("ERROR: setMaximumIntegerDigits() failed"); } fr->setMinimumIntegerDigits( def->getMinimumIntegerDigits() ); if(fr->getMinimumIntegerDigits() != def->getMinimumIntegerDigits() ) { errln("ERROR: setMinimumIntegerDigits() failed"); } fr->setMaximumFractionDigits( def->getMaximumFractionDigits() ); if(fr->getMaximumFractionDigits() != def->getMaximumFractionDigits() ) { errln("ERROR: setMaximumFractionDigits() failed"); } fr->setMinimumFractionDigits( def->getMinimumFractionDigits() ); if(fr->getMinimumFractionDigits() != def->getMinimumFractionDigits() ) { errln("ERROR: setMinimumFractionDigits() failed"); } } // ======= Test getStaticClassID() logln("Testing getStaticClassID()"); status = U_ZERO_ERROR; NumberFormat *test = new DecimalFormat(status); if(U_FAILURE(status)) { errln("ERROR: Couldn't create a NumberFormat"); } if(test->getDynamicClassID() != DecimalFormat::getStaticClassID()) { errln("ERROR: getDynamicClassID() didn't return the expected value"); } delete test; delete def; delete fr; delete cur; delete cur_fr; delete per; delete per_fr; }
void RddcEvlDisplay::drawLocalDetail(){ 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 size = clust->m_partitionPerVariable.size(); if(size<1) return; int which = this->whichGlyph(m_x,m_y); if(which<0 || which>= clust->m_partitionPerVariable.size()) return; //m_parIdxMouseOver = -1; QRect current = this->m_profileRects[which]; int x = current.left(); int x_right = current.right(); int width = current.width(); //int height = current.height(); DataPartitions* partitions = dynamic_cast<DataPartitions*> (clust->m_partitionPerVariable[which]); int nBins = partitions->m_partitions.size(); double binWidth = (double)width/(double)nBins; int offset = -1; if(m_x>x && m_x <x_right){ offset = m_x-x; } //qDebug()<<"glyph idx "<<which; //qDebug()<<"m_x "<<m_x<<" x "<<x; m_parIdxMouseOver = (int)(floor((double)offset/binWidth)); //qDebug()<<"mouse over par idx "<<m_parIdxMouseOver<<" offset "<<offset; if(offset>=width || offset <= 0) { m_parIdxMouseOver = -1; return; } DataPartition* partitionMouseOver = dynamic_cast<DataPartition*> (partitions->m_partitions[m_parIdxMouseOver]); IntIterator itDimOutofGroup = partitionMouseOver->m_dimOutofGroup.begin(); for(;itDimOutofGroup!=partitionMouseOver->m_dimOutofGroup.end();itDimOutofGroup++){ int varIdx = (*itDimOutofGroup); int locIdx = -1; for(int i=0; i<clust->m_order.size(); i++){ int tmp = clust->m_order[i]; if(tmp==varIdx) locIdx = i; } //int locIdx = clust->m_order[varIdx]; if(locIdx<0 || locIdx>=clust->m_partitionPerVariable.size()) return; QRect tmp = this->m_profileRects[locIdx]; int size = clust->m_partitionPerVariable.size(); if(size<2) return; 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); double glyphWidthData = bottomRightCorner.X - topCorner.X; double glyphHeightData = (topCorner.Y - bottomRightCorner.Y); //unsigned long c = this->cm->getColor(RGBt(0.0,1.0,0.0)); this->m_canvas->setForeground(RGBt(1.0,0.8,0.0)); this->m_canvas->fillRectangle(topCorner.X,(double)1-topCorner.Y, glyphWidthData,glyphHeightData); } }