Example #1
0
/**add mtk40641*/
status_t Composer::setComposing3DImpl(int dpy , int threeDType){
	
	sp<ISurfaceComposer> sm(ComposerService::getComposerService());
	return sm->setComposing3D(dpy,threeDType);
}
Example #2
0
void EndScene::_draw(float time)
{
	std::vector<vec3> path;

	skrand(625734);
	for (int i = 0; i < 10; i++)
		path.push_back(endCamPos + vec3(rand(-1.f, 1.f), rand(-1.f, 1.f), rand(-1.f, 1.f)));

	mat4 mPersp = perspective(45.0f, demo.aspect, 0.5f, 1000.0f);
	mat4 mCamera = lookAt(interpolatePath(path, time / Duration()) * 0.1f, endLookAt * 0.1f, vec3(0, 1, 0));

	setDepthMode(DEPTH_FULL);
	for (int i = 0; i < ARRAY_SIZE(tPark); i++) {
		GlslShader *sDraw = sPark[i];
		sDraw->bind();
		sDraw->uniform("u_matrix", mPersp * mCamera);
		sDraw->uniform("u_modelview", mCamera);
		sDraw->uniform("u_projection", mPersp);
		sDraw->uniform("u_alpha", 1.0f);
		sDraw->bindTexture("tex", tPark[i], 0);
		oPark->draw(i);
		sDraw->unbind();
	}

	sDrawFlat->bind();
	sDrawFlat->bindTexture("tex", tSmoke, 0);
	setBlendMode(BLEND_ALPHA);
	sDrawFlat->uniform("u_alpha", smokeAlpha);
	mat4 sm(1);
	sm = translate(sm, smokeCenter * 0.1f);
	sm = rotate(sm, smokeRot, vec3(0, 1, 0));
	sm = scale(sm, vec3(smokeSize, 1));
	sDrawFlat->uniform("u_matrix", mPersp * mCamera * sm);

	int animStep = int(floor(time * 24.0f));
	int animX = animStep & 7;
	int animY = (animStep >> 3) & 3;
	float l = float(animX) / 8, r = float(animX + 1) / 8;
	float b = float(animY) / 4, t = float(animY + 1) / 4;

	drawRect(vec2(-0.5, -0.5), vec2(0.5, 0.5), vec2(l, t), vec2(r, b));
	sDrawFlat->unbind();

	setDepthMode(NO_DEPTH);

	float logoFade = clamp((time - logoFadeStart) / (logoFadeEnd - logoFadeStart), 0.f, 1.f);

	setBlendMode(BLEND_ALPHA);
	sDrawFlat->bind();
	sDrawFlat->bindTexture("tex", tLogo, 0);
	sDrawFlat->uniform("u_alpha", logoFade);
	mat4 lm(demo.fix_aspect(mat4(1)));
	lm = translate(lm, logoCenter + vec3(sin(time) * 2, cos(2 * time), 0) * .01f);
	lm = scale(lm, vec3(tLogo->aspect, 1, 1) * logoSize);
	sDrawFlat->uniform("u_matrix", lm);
	drawUnitQuad();
	lm = demo.fix_aspect(mat4(1));
	lm = translate(lm, textCenter + vec3(cos(time + .6135), sin(-2 * time - .6135), 0) * .003f);
	lm = scale(lm, vec3(tText->aspect, 1, 1) * textSize);
	sDrawFlat->uniform("u_matrix", lm);
	sDrawFlat->bindTexture("tex", tText, 0);
	drawUnitQuad();
	sDrawFlat->unbind();
	setBlendMode(NO_BLEND);
}
void SurfaceComposerClient::enableExternalDisplay(int disp_type, int enable)
{
    sp<ISurfaceComposer> sm(getComposerService());
    return sm->enableExternalDisplay(disp_type, enable);
}
Example #4
0
void test1()
{
    ses::EntityManager::Ptr em = std::shared_ptr<ses::EntityManager>(new MyEntityManager());
    //EntityManager::Ptr em = std::shared_ptr<EntityManager>(new EntityManager()); // This one don't have packet handling
    std::cout << "entity manager created" << std::endl;

    ses::SystemManager sm(em);
    std::cout << "system manager created" << std::endl;

    sm.addSystem<RenderSystem>();
    std::cout << "render system added" << std::endl;

    sm.addSystem<InputSystem>();
    std::cout << "input system added" << std::endl;

    // One way
    sf::Int32 id1 = em->usePrefab("Sprite");
    std::cout << "entity added : " << id1 << std::endl;
    if (sm.getSystem<RenderSystem>().entitiesCount() >= 1)
    {
        std::cout << "entity handled by sprite system" << std::endl;
    }

    // Other way
    sf::Packet packet;
    packet << 11 << 11 << "Rectangle";
    em->handlePacket(packet);
    std::cout << "entity added" << std::endl;
    if (sm.getSystem<RenderSystem>().entitiesCount() >= 2)
    {
        std::cout << "entity handled by sprite system" << std::endl;
    }

    sf::RenderWindow window(sf::VideoMode(800,600),"Test");
    std::cout << "window created" << std::endl;

    sf::Clock clock;
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                window.close();
            }
        }

        sm.getSystem<InputSystem>().update(clock.restart());

        window.clear();
        sm.getSystem<RenderSystem>().render(window);
        window.display();
    }

    std::cout << "em : " << em->entitiesCount() << " / ss : " << sm.getSystem<RenderSystem>().entitiesCount() << std::endl;
    em->removeEntity(id1);
    std::cout << "em : " << em->entitiesCount() << " / ss : " << sm.getSystem<RenderSystem>().entitiesCount() << std::endl;
    em->removeEntities();
    std::cout << "em : " << em->entitiesCount() << " / ss : " << sm.getSystem<RenderSystem>().entitiesCount() << std::endl;
}
Example #5
0
void initialize_images(void) {
  {
    wxMemoryInputStream sm(
        "\211PNG\r\n\032\n\000\000\000\rIHDR\000\000\000 \000\000\000 "
        "\b\006\000\000\000szz\364\000\000\000\004sBIT\b\b\b\b|"
        "\bd\210\000\000\000\011pHYs\000\000\r\327\000\000\r\327\001B("
        "\233x\000\000\000\031tEXtSoftware\000www.inkscape.org\233\356<"
        "\032\000\000\005\013IDATX\205\305\227\177h\225e\024\307?"
        "\347\275\233N\227\215Ls\342\335\330\014)\177b\233\246\313&"
        "\003a\266\32754\020\313\224\025\375\221b*"
        "\014R\024EF\246\204\240\226k&\375#%c\271 "
        "c\367\275WG\326\222h\332~\251\023Y\226-\335\204\241S\031\356\252\271{\337\323\037{"
        "w\275\367\356n^"
        "Q\361\300\363\307y\236s\276\347\373\234\367\274\317y\036QU\236\246\030O5:\220\3600\306R#"
        "i\364\262\030\203E("
        "\231\300\004\300F\271\214\360/"
        "\3121\0229\242\371\332\0367f<\237@j%\211\333\354\000\326\001'"
        "Q\2521\370\023\245\243\317\00076/"
        "!\274\011\314\005\276`$\2335O\357>2\001\361\312L\224C\bA`\205\232\332\362\000\373\351\300!"
        "\024\027\302\n5\365\364P\366C\326\200\370d\003P\207\340\305\317l\346\321!7$_"
        "n\312\353\203\371\250\251-"
        "\370\231\215\340\005\352\034\214\301c\014\226\001\361\312r\240\034(RSO\310uY\000\b\317SK-"
        "\011\3640\003\027\331\200\213 "
        "\215\334\341\264.\325;Q\030\363\201\037\200\265jjE\334\004\304'"
        "cQZ\201D\014V3\207\313\030\\\341\024=\004)"
        "\303\246\000\241\025\245\331\3714\257\240LE\250\305f\225\026\352\2250\022+\201\335\bS\264@"
        "\257\305G\300+\225("
        "\243p\261\011\301G\n\225\\\347$\006{Q\3663\216\3174[{#|\252\304E2\353\200\r\300&5\365`"
        "h\315\022\013\341\226\232\372\366\200`\252\0321\360P\204E7^"
        "\334\252\n\325\244c\321\216\305M\252\311\212\266\037\340_"
        "\315\313X\234\301\303\a\2419/"
        "n,\272\361P\024m\037\253\b?\004vk\201v8\372m\372\212\365\037\204MR+I1|\356o\250P["
        "\021\336B\370Dj$\r\300\301\332\355`"
        "G\310@\002B\026B]\230\276\027\341+F2\317\241S#\3252N|R*^"
        "\251\027\257\324\213OJ\245J\206\205H\024\350E\224\235\004\330\037\206S\207\2205$\0019&"
        "\343\201T\2024\001H\251\030\b&#"
        "\330\245yz\227\006\226\001\315\270\270\2102\031\241\030\241\030%\235d\216\n\"!"
        "\260\006\276\004^\223*\031\001\340`"
        "\246\212WR\a\317@\200,\240]\013\265\013\2009L\002:\372O4\335\2466\302\357@'"
        "\220\203\220\240\005z^M}"
        "\037A\260X\026\312\3026\265\201s$3\003\300\301l\307\210\314B$"
        "\201\276\305\246\220\256\314B\302\364\276\271\\\224\235\300Fl\216\367\177gl\016!"
        "D\037PM\300\254\b\335\036\212\200\362\340\306\240("
        "\202\250\251\025\270\310\0115\036A\342\362\217\222\350\0144A\030C\241\001\035P8'"
        "P\212\005\021]\250\177;"
        "\261\005\245\030\203_\243l\263\200\206\b\335\210\314h$\001\233& "
        "M<2\006\200S\374\005\270\303\177=]\244U\030\370\361Q!"
        "\036\311\022\217d\341\243\002\003\277\026\350\367!"
        "\356\245b\000\323\360s\026\300\301Lsb\304&"
        "\240\246v\002\235\270\372v\355\024\3351\356\360q\004\321\021\024\002-"
        "\030\224cP\016\2648s\367e\026k\200S\241\376\320\207\331\351\304\b\311\300\013\211\322\004"
        "\344\0005\216\343z\2024\313Q"
        "\371Q\337\320\263\000\232\247\001`"
        "\2073\006\210\370\344E\204\315\364\335\r\372qs\034\354\b\211u\022\036\000J\304'"
        "n\000\315\327\253\300zl*\305'Sb\005\214\bn\311D\3400\260UM\275\344\020r\003%"
        "\016v\324\206c\235\347\026\225x\260\242z\304R,\332\361\260\021/"
        "\303\a\3704\220\210\227\325Xt`\361^\224\257\205Ee\254XC\265\343\363@\211\232\372mh\276F^ "
        "H\031\212\011\234\a\376\000\202\300\253\300t\340\227\307\322\216\035\307\345\300>`"
        "\211\232z\"b\255V\222\036\366B\222\2615\34300\315Y:\327\326\330\026\030\222\200\223\211\r("
        "\245\300>"
        "\374l\321\245zoP\343p\277*"
        "\031F2\333\201\265\b\3332\266d4\002\3053\307\377w\331\235\022\030u\241+"
        "1\375B\327\260\262\266\306\266\343O\374R\232\2615\243\aX\333Zr\351\310\360\004\235\017\344"
        "\335\013J\356\247??"
        "\367\3237\315\317~\364\304\257\345\231\331\231\273\266\347_\257\177w\346\255\311@"
        "\2363\350\350N\350\312=\340>"
        "\030\327\303\304\351\206%R#{\350e1\302BlV\"\244\003`\207\036&\337\221\310;"
        "\341\017\023\227\241\243\227L\355\231\006\344\366\a\ap\247\004\306\244\216\nNx\250\227\221"
        "\003\274\317\031\361\371\250"
        "t_\351N\230>iLo^\370\374\215\333\256[\327\374\256\253O\374mh+\345_\327\247$"
        "\372\357\031\241W\322\335\200\004\366\374\226R\027\264)"
        "\213\253\006\036U2\2633\027L\034\335\273j\315\334\356\261\bv\345\231gz\352;\222>\217\353/"
        "x\214$\022\210q\016\374\017/"
        "\030\266~j\223\234\027\000\000\000\000IEND\256B`\202",
        1422);
    _img_radar_amber = new wxBitmap(wxImage(sm));
  }
  {
    wxMemoryInputStream sm(
        "\211PNG\r\n\032\n\000\000\000\rIHDR\000\000\000 \000\000\000 "
        "\b\006\000\000\000szz\364\000\000\000\004sBIT\b\b\b\b|"
        "\bd\210\000\000\000\011pHYs\000\000\r\327\000\000\r\327\001B("
        "\233x\000\000\000\031tEXtSoftware\000www.inkscape.org\233\356<"
        "\032\000\000\004\376IDATX\205\305\227["
        "l\224E\024\307\177\347\333m)\024l,\240E\026\322\242\304\b\024\353\026\020\210%"
        "M\214\205\335\202\201\230\032\024H\361\211*\002I\0231A\b!V|0\341b\261\004\365\301\b!"
        "\225\232\210q/"
        "\320x\251D\303\255\335bK\032D\223\002-I\003U\322\320\005lw\277\343\303~]"
        "v\267\355\262\210\r'"
        "\231\2079s\316\371\377\347\314\314\231\031QU\036\246\030\017\025\035\260\337\217\261\324"
        "\313\024\372Y\216A)"
        "J\0360\0310Q\256 "
        "\\B9N\032G\265D;"
        "R\216\231\312\022H\203dp\213\235\300F\340\024\312w\030\374\216\322\0311\300\201\311\323\b"
        "\313\200\371\300\307\214a\213"
        "\026\353\235\a& "
        ">)@9\204\020\006V\253[[\357a\237\017\034B\261!\254V\267\236Kf\237t\017\210_6\003'\021|"
        "\004\231{/"
        "p\000uk+A\346\"\370\200SV\214\3411\206\313\200\370\344u\240\032X\241n=\0217\326 "
        "\031\3642\033\033\205\200\2150M\334\346\234\226\351\355\250\3151\231\215\311\200\337["
        "\352\326\303)\023\020\277LDi\003*"
        "\325\255\a\243\372zy\2140\3730q!\\@i\266\226\3469\224\231\b\r\230T\0006\014~"
        "\305\316VB\230\300."
        "\204\031\352\322\353\211XC\237\002\245\032\345\214\226\306\200{\245\014\203=("
        "\373\311a\225\026j\177\034\351:"
        "\261\221\311F\014\002@\2104jpr\223\361x\360\262\322\312\346\312D\250A{@\274\3622\340\302`]"
        "T\347\223W\020\252PJ\325\255U\211\340\000Z\246a\306\260\037\350\000\322\351\243\013;"
        "\315\334\340%+"
        "\226\313\212\235\234\000\260\016\330\245.\355\004\020\217L\000\366`"
        "P\226lG\313\0161\br\020\245\035\223\205\b\357s\232\020J\013\363\230\004\354\262b\307\311"
        "\340%\020\234\b{c\372{\020>"
        "\325%\332\022U\325I:cy\017\305m\331\370\230\313x\340q\306P\242\305zG\274\362!!"
        "\366\223\3152n\220\217p\022\250H\232\0019."
        "\223\200\034\302\004\242\263\022\334\214\346\243\273|"
        "D\310\344\030\312T\204r\204r\213\310Zl,\217\026\237F>\001\026RG\006\312%\236\340\n\220#>"
        "\311\031\226\000!\234@\207."
        "\325n\000\236g:\320\031W\321\374\274\212 "
        "\352\3267\324\245m(\005@\016\320J\210\222\0013\335\256&"
        "p\236Lfk\266\266\351\263z\001\350\300\3009<\201\310` \332W\346 "
        "1\375\210\256\b\223CV\306\236\002\366Zw\303\347\b/"
        "$d8\000\314\211\353\233\311\b(\367\276\030\024E\020\000]"
        "\254\177b\307\251K\264\005AR\362O\220\304\014\004 "
        "\206\241\320\210\3063\006N\240\224\013\022!Q\242\035\202\bJ9\006?'\330:"
        "\201\306\270\276\021\237\321x\002&\001`"
        "\212u\364\3404\177\000\016i\220\214\001\023-\325:\014\202\3709,\036q\212G\234\3709\214AP]"
        "\372u\224\373\0161\200Y\004i\201\350q\236ba\014M@"
        "\335\332\005ta\213\314Z\267\253\211p\234\333\274\023Gt4K\201V\014j0\250\001Z-\335]"
        "\231\303z\340t\364~"
        "\210\304\354\2620\2422\270\016(\001`\001Po9n\"L\263\034\223o\aj\201\026k\b\330i\265A\"~"
        "y\022a\013\221\267\301@"
        "\334\005V\3548\031\252\022\036\000*\305/\016\000-\321k\300&Lj\305/"
        "3\206\002\214\003\367\3124\340\b\260M\335z\331\"\344\000*"
        "\255\330\011\023V\035\324\360R\213\ao\234\316C\031^:\360\360."
        ">F\r\362i$\r\037o\342\245\023/"
        "k\023|\275x\251\035\n\353\277]\307\221\312\327\006\234\001\302\300< "
        "\037\370\011\223\n]\252W\243>>YC\222\353x\304\036$"
        "V\214E\3007\300\206\334m\271G\200Y\326\320\371\366\246\366PR\002V&"
        "6\243\354\000\252\011\262U\313\264oX\343X\277:I'\223*`\003\302\366\334\255\271M@"
        "y\301\244\177\2568\262B\343."
        "v\247M\275\330\235\276\257\275\251\375\207\021\177\224\346n\313\355\0056\\\250\274|t\224]"
        "\027\001\305}a)"
        "\372\340\307G\277\377\262\371\221\267G\374Y\236W\230\367QU\311_gW\025\334|\006("
        "\266\032\235=\366\356\242\003\216/"
        "R\372\230X\267a\245\324\313n\372Y\216\260\030\2235\bS\0010\243\037\223\257H\343\265\330"
        "\217\211\315\320\354\0253{"
        "g\001E\003\340\000\216\254\320\204\234q\341\311\367\3653\262\002W[-5\037\225\236\253="
        "\366\374\351\023\372\213c\365\177\337\262\335\274\036\264]\033\361\277\241\251\324|v6+-"
        "\330gD\337\024wB\022\332\375K\326\311\260\311\276\224\366\300\203J^a\336\213\323\262\373+"
        "\326\317\357\231\210`"
        "\326\3766\266\367lg\306\336\224N\301\377H\302\316\020u\340_DS}"
        "\331\342Y\013\312\000\000\000\000IEND\256B`\202",
        1409);
    _img_radar_amber_slave = new wxBitmap(wxImage(sm));
  }
  {
    wxMemoryInputStream sm(
        "\211PNG\r\n\032\n\000\000\000\rIHDR\000\000\000 \000\000\000 "
        "\b\006\000\000\000szz\364\000\000\000\004sBIT\b\b\b\b|"
        "\bd\210\000\000\000\011pHYs\000\000\r\327\000\000\r\327\001B("
        "\233x\000\000\000\031tEXtSoftware\000www.inkscape.org\233\356<\032\000\000\004("
        "IDATX\205\355\327]\210]"
        "\325\025\a\360\337:\223\304\304 "
        ">h5\305I\250J\321Z\025\035\343G\374(\001!:\3274\264\005\261\004%\212\017*R\205@#"
        "\021\212\004A\321B\020?"
        "b\373Vh\bC\"h\2339\367\232\001\351\230\207\306\230\351D\215\204\210Z\252\031!"
        "h\255H\035G0sW\037\346\344:"
        "\367\316GF\252\304\a\027\234\207\265\367Z\377\365\337k\357\263\327\332\221\231N\244\024'4:"
        "\346}"
        "\035\343\030\210\245\276\364\013\205\233\244\263q\026\232\322\373\302\277\244]\346{!"
        "W\345\3419c\316e\013b0\026\372\334#\270\017\257H;\025\336\222F&\014tk:"
        "O\3709\256\302\223N\366`\256\314/"
        "\376o\002Q\217K\244\255\3028n\315Z\0368\216\375E\330*u\011\267f-_\233\315~"
        "\3263\020\215\330\200=B\335\250\313]c$"
        "\376\023\253\342\223\270v&\237\254\345\001\243.\027\352\330Sa\314\034c\246\014D="
        "\326b\013\326d-w\307\307q="
        "\302i\006\r\232\3473\027\353r\031\272\214\373\2071\257\345\3159\326\201\3613<\217\337d-"
        "\267\315\231@4\342\a8$"
        "\315\027\356q\225\367\025>\260\327g\306=\255\251W8$"
        "\355\257\266\346R\351\247\302\240\246\273su~0\211\304m\330,"
        "\\\220\275\371\321\334\b\324\243O:E\227\215B\303\251\372|\354\025\205'"
        "\244g\235\351\261\274,\277l\363\331\021]"
        "\026\273\017\033\2601k\371\247\326\\\031\245\360\337\254\345\257\247\004\313\314\266O\2775"
        "J\237\252\353\316LvZ\246tX"
        "\277O\354\324\323i?\305\177\247\363\225^\327\357\316\326X]"
        "\267\322\247\372\255\351\264\237\356\020\336\205\315\331\233#\225\376\271T("
        "\374S\330\030\203\261p\272\275l-hu\036\022~"
        "%<\034\003\261\024*\254\315\025v\233L%\020z\204=\223\364'\024\376`\221k*:"
        "\003\361\32783\032\261)\352\261/\352\261/"
        "\032\261)v\304\202\026\211\336|Wz\324Q\317N\302\331#\364\314J "
        "v\305\017\261\304\270a\210MQ\b5\213\374>W\346\027\206\334\202\375\346y\027?"
        "\021\326\011\353\244e\026{1D\264\300\206<"
        "\203\253cG,"
        "\202\nsI\324c\311\314\0318\252\a\207su\376\033\\\351\307\0309v\243\345C\331\024\376."
        "\034\221V\b\363\2627\017f-\357\020B\351\226V\026\036\312&"
        "\336\264\330\305Pa\036V\264g\241\235\300\304\344pKO\313\305$}"
        "b\354:M\217\342\001M/"
        "\035\333gM[\205\316\013j\030\313\333\364\346l\004\322\361\013CJ!\262\226\333tY\321*<!"
        "\346\344\337!"
        "\235\031\030f\022\3030$\247\034\234\335\322\272\020\2217\344;U\354\220\326)"
        "\274\334a\333\203\2416\275h\317h;\201\246a,"
        "\215\3768\035\354\3656\272'\377zyS\356P\030\325\260-\372\243'"
        "\372\243G\3036\205\321\354\315\347Z\3347E\201\013\215z\003*\314\245U\214\351\011d-"
        "\217\340\210\256\211UW\207n\2271\277m#\272\310j\034P\330\242\260\005\a\252\261\257d\271{"
        "\261\267U\037&0\217T1Z2\265!"
        "I\303X\201\201\312\361~"
        "\343\366\307\213\361\227\2741\337\200\\\231G\361H\365M\221h\304\271\302\203&z\203c\270+*"
        "\3546\231\356&\374#\326G#\272!W\345\207\270_S_4\342\202\351\002\266\005/"
        "\343\034l\307\357\262\226\357U\204\272\261\276\302\356X\360t\367y\251O\277\262\243F\334\\"
        "\325\204\a\324\2354\305g\310|"
        "u\367(\215(\335\336\341[*\365M\027k\346r\234\016b}"
        "\326\362\317\255\361\2018\303\270\247\245\032\016\342U\214\343\n\\\204\277}#"
        "\345\270r\\\213\247\360\313\254\345\356\266\271\301X\370M5$"
        "\263\227\326\272\rJcJ\217\333n\301\361Jq\313o\273\005J\217+"
        "\215\251\3330\233\355\011oJ\277\373my\233\361\261\207I\270A\372\221\260\014\276\365\207"
        "\311\267)'\374m\370="
        "\201\377\001\312\351\235\226\272B\301\307\000\000\000\000IEND\256B`\202",
        1195);
    _img_radar_blank = new wxBitmap(wxImage(sm));
  }
  {
    wxMemoryInputStream sm(
        "\211PNG\r\n\032\n\000\000\000\rIHDR\000\000\000 \000\000\000 "
        "\b\006\000\000\000szz\364\000\000\000\004sBIT\b\b\b\b|"
        "\bd\210\000\000\000\011pHYs\000\000\r\327\000\000\r\327\001B("
        "\233x\000\000\000\031tEXtSoftware\000www.inkscape.org\233\356<"
        "\032\000\000\004\036IDATX\205\355\327_"
        "\210U\327\025\006\360\337:3Z\243}J\322vB\307\220\266)\205\264J:jZC[|\311\230\271jI(S$"
        "5L\372\024\333R\005!"
        "\026\322\026\221J\002\026D\233FI\310[DD\013M\310\334;\352Km\240\370\a;\212\023$!"
        "\205\246\031\013\322\026|h\247#"
        "8sW\036\346\314u\356\235\231\253m\021\373\220\005\347a\357\363\255\365}{\355\275\327\336;"
        "2\323\235\264\342\216\262\243\363?\001\307\211X\352\272'\024\326I\237\303gQ\227>\024>"
        "\220\216[\340\215\354\315\321["
        "\216y+S\020'c\221\177{\001[pZzK\341=\351\362\024@\267\272/"
        "\011\033\360u\374\312b\317\347\232\274\366?\013\210Z<,\035\024&\261)+9r\023\3742\034\224:"
        "\204MY\311\013\355\360m\327@"
        "\014\305v\234\022j\306\254\272\0319d%G\214Y%\324p\272\2141?\307|\031\210Z<"
        "\205\227\360dV\362\355\246\177'"
        "c\221\177Y\256\303\nt\230\364G\343.d\177\21670\307b\271\272i\277\037f%"
        "\017\335\262\200\030\212OI\227\260-+"
        "\371z\243\377D|\332\244_"
        "\253\353\023\336\225\316\227S\363U\351\313\302Iu\233\321\241\360\a\235~fB\035{"
        "\204\207\262/"
        "\377\336\3125\367.H/"
        "Igs\335\014\362j\364+\354\225\016\350\362\275\\\221\327\233D\037\215\016KlQ\030\226&"
        "t\332o\205\177\272\307\240\252\215e67\266R\315Z\003Q\215o\243O\341\331F_-\276#"
        "\354\222\326e%"
        "w\265\222C\366\347\244\305\016`TX\350\272+:\235w\325ce\254\2762v{\001x\026{\262//"
        "C\014\306\275\330\253\320\337nE\307\316(\214y]\372\263\272G\205_"
        "8cB\272\350\021\367aO\031\273\311fOA\350\021\366\315h\357\025^\315\307\363b\243\353h,"
        "\364I?\225*%\246f\225{"
        "\360\031\213\365\346\232\274\026\325x\321\204\003\356\266\301U\313\204S\330\3346\003q<"
        "\356C\227I\303\215Q\205\212\273\374\362\206\236\bK\034\223\356\027\006\204\201R\3103:<"
        "\321(>"
        "\347\274\214G\035\265H\372@\267\017\321\025\265\350\232W\200\011="
        "\030\315\365\371\017\3605_"
        "\304\345\246\2126\344\273Bd%\277\237}yIz\030]\0301\241w\032\226;\262\216w,\261<"
        "\357\316K\271,"
        "\337\305\250B\317\374\002\246~"
        "\0167\332i\245\230\321\236\352\373\246\272\203e\306\036\304\276\362lxM\370FK\206\207\261"
        "\262\251]o' "
        "\335\374`H)\004\344\332\374\223N=\371x^\024\342\226\374["
        "\2545\003\303\314P\030\316\311f\305x[\032\b1%"
        "\2427GC\2044\240\360\373\026l\017\3165\265\213\346\2146\013\250\033\306\322r\353q\306\373"
        "\350\216\223\261h\032\222\353"
        "\362\250\302\230!\207b0zb0z\0149\2440\226}\371\233\206\366\235Q\340+"
        "\306\\\244\261\235\227\226\034s\013\310J^"
        "\301\025\035S\243\316\035Y\027\216\033\367\\\223\320\273\254\307\210\302~\205\375\030)"
        "\373n\330J?"
        "\302\231\306\3710\025\363J\311\321\260\331u "
        "\rc5N\224\216[M:\037\307\342\315\351Z\220kr\002/"
        "\224\337,\213\241\370\202\360\274\251\273\301t\334\325e\354&"
        "\233\253\022\276\202m1\024\335\220\275\3717lUw8\206\342\241\271\b\233\310\253\361y\034\301"
        "\317\263\222\177)\005uc["
        "\031\273e\300\231\263>U\207\r\2526\365\r\352W5j\320O\324|b\226\3179\013\324\374@"
        "\325eU\317\264\370VU\035\236\213\353\277;\216\247*\337%\234\305$"
        "\036\3012\374N\335\346\\\237\177m\370\324\342im\216\343\333v!)c|"
        "\013\277\305\217\347\273\220\3149\005\215\324\325lW5\256j\267#"
        "\026\266\3036\371\035\261P\325nU\343j\266\267\303\336\361K\351\377\377\265\274\011<"
        "\3750\011k\245\a\204\373\341\266?"
        "Ln\247\335\361\267\341\307\002>\002B\374d\362\341\330\200\177\000\000\000\000IEND\256B`"
        "\202",
        1185);
    _img_radar_blank_slave = new wxBitmap(wxImage(sm));
  }
  {
    wxMemoryInputStream sm(
        "\211PNG\r\n\032\n\000\000\000\rIHDR\000\000\000 \000\000\000 "
        "\b\006\000\000\000szz\364\000\000\000\004sBIT\b\b\b\b|"
        "\bd\210\000\000\000\011pHYs\000\000\r\327\000\000\r\327\001B("
        "\233x\000\000\000\031tEXtSoftware\000www.inkscape.org\233\356<"
        "\032\000\000\005\"IDATX\205\305\227\177h\225e\024\307?"
        "\347\276\333\272\333\254Q\315\037\3416\266\",S\251M\263i\205 "
        "h\273N\261`X\242\314\350\217\224Ra\220\242)2\n%"
        "\204ei\263\376\023\222\261\232P\261\373\336\253#"
        "i\0115\315\3750gb\224\315\334\204\241N\233\367\336\335{"
        "w\177\234\376\330\353\365\336\273\273yE\305\003\317\037\347y\316\371\236\357s\336\363>"
        "\347yDUy\220b{\240\321\201\214;"
        "1\226\026)$\304rl,A)\001\246\002Q\224\213\b\027P\216\220\311\367\272H{"
        "\323\306L\347\023H\253\330\031b'"
        "\260\0018\216\322\214\215?Q\372F\014( "
        "\3124\204\245\300K\300\347\344\260U\027h\340\256\011\210K\236G9\210\020\001V\251C\273oc?"
        "\0238\210b "
        "\254R\207\236\032\317~\334\032\020\267l\002\332\020\\\370\230\303|\372\344\232,"
        "\222\353\362\362X>\352\320n|"
        "\314Ap\001m\026\306\3301\306\312\200\270d%P\017,S\207\036\223\001Y\b\b\217\323J+"
        "\031x\231\205A\031`\020\241\003?"
        "\247\264J\375I\030\257\002\337\001\353\325\241\ri\023\020\267LD9\adbc\035s\271\210\215K"
        "\234\300K\204}D\251@8\207\322e}"
        "\232\027P\236Ch%\312Z\255\324Kq$V\003u\b\323\265B\257\244G\300%\215("
        "\017c\260\005\301M\036\215\014p\034\033{"
        "P\3663\231O\264LC\011>Mb\220\313\006`\023\260E\035z "
        "\266f\212\211\340Q\207\2769*\230\252&\014\234,"
        "\303d\020\027\005\252\n\315\024a\322\213\311u\232)"
        "M\266\037\345\337\3143\230\374\216\223wbs.\n0\031\304\311\262d\373TE\370."
        "P\247\025\332g\351C\214\024\353?\b[\244U\354)"
        "|nm\250R\317!\274\201\360\221\264H!\200\205Uga'\310h\002B)B["
        "\234\276\a\341Kr\230o\321i\221f\231,"
        "n\251\025\227\234\024\227\234\024\267\324J\223d\305HT\350y\224]\204\331\037\207\323\206P:."
        "\0019\"O\000S\210\320\011 "
        "\265bCp\220\315n]\240\001\332Y\001tap\036\345Y\204j\204j\224\"r9,"
        "\210\304\300\332\371\002\230'M\222\r`aN\021\227L\031;"
        "\003aJ\201^\255\324\253\000\314\345i\240\357\346\211\246;4\212\360+\320\017\224#"
        "dh\205\236U\207\276\215 "
        "\230\254\210ea\207F\2013\3442\013\300\302\354\305\226\230\205D\002#\213\2351]"
        "\231\215\304\351#"
        "s\257\240\354\0026\023\345\350\315\357L\224\203\b\311\aT'0;A\217\216G@\271}"
        "cP\024A\324\241\r\030\224\307\032\217 "
        "i\371'Ir\006:!\216\241\320\216\216*\234c(\325\202\210."
        "\326\277\255\330\202R\215\215\237\223lK\201\366\004\335\226\230\321D\002Q:\201BqJ>\000'"
        "\370\013("
        "\210\377\365t\2116a\303\207\233\006qJ\2518\245\0247\r\330\360i\205\036\212q\257\025\0330"
        "\003\037\247\001,\314B+"
        "Fj\002\352\320~"
        "\240\037cd\327V\321\035\301\317\a\011D\263\251\004\272\261Q\217\215z\240\333\232\273%"
        "\263y\0178\021\353\017#\230\375V\214\230\214\276\220(\235@9\320b9n$B\227\034\226\037\3645="
        "\r\240\0134\014\354\264\306("
        "\021\267<\205\260\225\221\273\301M\334r\013;AR\235\204_\0015\342\226\002\000]"
        "\244\227\201\215Di\024\267LO\0250!\270)"
        "O\002\337\002\333\325\241\377Z\204\n\200\032\013;i\303\251\316s\223F\234\230I=\242\n\223^"
        "\234l\306\305C\243|"
        "\332\311\304\305:L\3720Y\223\344kb\322\230*\326x\355\370,P\243\016\375:"
        "6\337\"\223\210\260\017\305\001\234\005~"
        "\003\"\300\213\300L\340\247{\322\216-\307\225\300^"
        "\340uu\350\261\204\265V\261\337\351\205\244x{"
        "\361\267\300\014k\351LOGOx\\\002V&6\241\324\002{\361\261M\253txL\343x\277&"
        "\311\"\227\217\201\365\b;\212\267\025w<"
        "Z\222\265a\322\274\254\234\301\301\200o\240+d\204."
        "\311\236\236\216\236\243\367\375RZ\274\275\330[4?\247\256\260*"
        "k\351\025\257\217\001\357\020\036_0\342o\315\370\321\350\266\277\177\337\257\345%e%\273g}"
        "\230\273\306\223\345\317\277\346\363\343\011\004\361\004\203\004\a\242W\037;4\371@"
        "Z\017\023\253\033\326H\213|"
        "J\210\345\b\213\211\262\032\241\b\200h\354a\362\r\231\274\025\37701\3542q\000o\376\240'"
        "\020\013\356\037\016\021\310\n\347\347eG\246\336\321\313\310\002\336k\215\264$"
        "\022\322k\003\375\376\013^{"
        "\240\330\023\030&\020\n\021\014E0n\030\036#`"
        "\\\276\377o\303\b\365C\277\030\177\334\030\034\016\014\r\017\023\014F\020\257\204\363N\347"
        "\265\241\354K\253\006\356VJ"
        "\312J\026\206\037\011\255\375o\332\340D\302D'\\\230\340\265_\267\177\226\326_"
        "p\017Id\220\342\034\370\037/"
        "\364\337W\033O\206\n\000\000\000\000IEND\256B`\202",
        1445);
    _img_radar_green = new wxBitmap(wxImage(sm));
  }
  {
    wxMemoryInputStream sm(
        "\211PNG\r\n\032\n\000\000\000\rIHDR\000\000\000 \000\000\000 "
        "\b\006\000\000\000szz\364\000\000\000\004sBIT\b\b\b\b|"
        "\bd\210\000\000\000\011pHYs\000\000\r\327\000\000\r\327\001B("
        "\233x\000\000\000\031tEXtSoftware\000www.inkscape.org\233\356<"
        "\032\000\000\005\025IDATX\205\305\227mh\223W\024\307\177\347I\333\305V&"
        "\323\252u\266\322\356\005\301i\347Ru\323\275 "
        "\214U\233\352p\214\016\267)u\237\354^T(\314\201/"
        "\210L\334\a\241\253\253\253l\354\303@\021g\205m\254I\264l\254\023\304\027\372\"\255+"
        "\216\r\332\331\nE\255\256&i\222&"
        "y\316>\344il\3226\306\271\342\201\373\341\336{\316\371\377\357\271\367\236s\257\250*"
        "\017S\214\207\212\016d\334\217\2624I\001a\326aP\216R\004\314\005L\224\253\b=("
        "\247\311\344\a-\325\336\264}"
        "\246\263\005\322,v\206\330\017l\005\316\243\374\204\301\037(}"
        "1\005\3621\231\217\260\026x\001\370\202lv\350J\r>"
        "0\001q\313b\224\243\bQ`\203:\265\363\036\372\213\200\243("
        "6\204\r\352\324K\251\364S\236\001\361\310v\340\034\202\033?"
        "K\357\005\016\240N\355\304\317R\0047p\336\36211\306D\021\020\267\274\003\324\001o\250S\317"
        "$\3145\213\035\037\305\330("
        "\001lDi%\300%\255\320@\\\347\224\024c2b\367\201:\365X\332\004\304#"
        "3Q\272\200ju\352\221\370x\223\314\"\312!"
        "L\312\020\256\240\264[[\363\034\3123\b\315\230T\0016\014\316\222\301.\"\230@\r\302\002-"
        "\323\033\311X\343\337\002\245\016\345\242\226\217\002wI\005\006\265(\207\311\343]-"
        "\321p\002\351\006\261\221\303V\014\332\200\b\231\324\343\300\313\014\032q\261\336\212\346"
        "\372d\2501g@\\\362:"
        "P\206\301\346\370\230[\336D\330\207R\256N\335\227\014\016\240\025\032%\233\303@/"
        "\220\3050\375d\320\316m^\263|\225Y\276S\023\0006\0035Z\246}\000\322(\271@-"
        "\006\025\251N\264\354\025\003?"
        "GP\2721Y\201\360)\027\210\240t\260\2149@\215\345;A\306n\201\340@88\252_"
        "\213\360\265\256\326\216\370P\203d1\225\235("
        "NK\307\315Rf\000\263\311\246TWjP\\\362\031\021\0163\235\265\334f\021\3029\240*"
        "e\004\344\264\314\001\362\210\322\026_"
        "\225\340d\n\a\356\362\021!\207S(\363\020*\021*-\"\233\260\261.\236|"
        "Z\370\022XA\003v\224\036\036\347*\220'"
        "n\311\233\220\000\021\034@\257\256\321\233\000<\317\323@_"
        "BF\363\360\026\202\250S\337\3232\355BY\014\344\001\235D("
        "\035Q\323=j\002\227\311\241X\247k\227>\253W\200^"
        "\014\034\023\023\210M\266\305\373\312\022dT?6\3662&G\255\210="
        "\005\034\264j\3037\b/"
        "%E\270\rX\222\3207S\021P\356]\030\024E\020\000]\245\177\221\201CWk\a\202\244e\237$"
        "\311\021h\203Q\014\205\0264\2211p\006\245R\220\030\211R\355\025DP*1\370-I\327\001\264$"
        "\364\215\304\210&"
        "\0220i\003\n\254\253\a\027\370\023\310\227f\261\217\250h\2716`"
        "\340\307\3031i\024\2074\212\003\017\3070\360k\231\236\214s\337+\006\260\020?"
        "\035\020\277\316\005\026\306\370\004\324\251\375@?"
        "\266\330\252u\217\232\b\247\011\360q\002\321)\254\001:"
        "1\250\307\240\036\350\264\306\356\312\022>\004.\304\353C\314g\277\205\021\227\261y@"
        "i\003\226\003M\226\3416\242\264\313)\371q$\027\350J\215\000\373\2556F\304#O\"\354 "
        "\3666\030\361\273\334\362\235 "
        "\343e\302\257\200j\361H>\200\226\352u`\033&\307\305#\013\306\003L\000w\311\023\300\011`"
        "\267:\365o\213P>"
        "Pm\371NZ\260\352\230\206\213\3434\342J\030k\244\002\027\2754\362\011n\036\031c\323B&"
        "n\336\307E\037.6%\331\272pq|<"
        "\254\377V\216c\231\257\013\270\bD\201e\300\"\340WL\252t\215^\213\333\270e#)\312\361\244=H,"
        "\037\257\000\337\003["
        "\nw\027\236\000\026ZS\227\273[\273#)\011X\221\330\216\262\027\250\303\317."
        "\255\320\341\011\225G\3335H\0269\354\003\266 "
        "\354)\334U\330\372XQ\326\326Y+\262\262\a\a\203\376\201\366\260-|Mj\273["
        "\273\177\231\364Gi\341\356B\337\274\027\263k\n*"
        "\262\326\336\360\371\031\360\r\341\365\207\242\201\346\214\237m\235\366\217&\375Y^"
        "TRt\240xg\316&oV "
        "\367\226?\2007\030\302\033\n\021\0320oN?9\373\333\264>&V5\254\226&"
        "\371\2340\353\020Va\262\021a\036\000f\374c\362\035\231\274=\372cb\263\313\314\001|"
        "\271\203\336`\034<0\034&"
        "\230\025\311\2356%:\367\276~F\226\343:\253\245%"
        "\321\260\336\032\350\017\364\370\354\301Bop\230`8L("
        "\034\305v\307\346\265\005m\327'\377o\030\245~\350\254\355\367;\203\303\301\241\341aB\241("
        "\342\223\310\264\216i\347P\016\245u\006\036T\212J\212^\215<\032\256\372g\376\340L\"\230S{"
        "\246\372\354\267\355\a\323\272\005\377#\211\014\306\311\003\377\002E/"
        "\246\262\377\233x\r\000\000\000\000IEND\256B`\202",
        1432);
    _img_radar_green_slave = new wxBitmap(wxImage(sm));
  }
  {
    wxMemoryInputStream sm(
        "\211PNG\r\n\032\n\000\000\000\rIHDR\000\000\000 \000\000\000 "
        "\b\006\000\000\000szz\364\000\000\000\004sBIT\b\b\b\b|"
        "\bd\210\000\000\000\011pHYs\000\000\r\327\000\000\r\327\001B("
        "\233x\000\000\000\031tEXtSoftware\000www.inkscape.org\233\356<"
        "\032\000\000\005\014IDATX\205\305\227\177h\225e\024\307?"
        "\347\275wss\206a3'\336\215M1sS\251M\263e\206 "
        "h{]b\201X\242\254\360\217\024\231\302\"ESd\024J\bj\3154\351\037!"
        "\031\313\005\026\273\357\275:"
        "\220\226\1774\315m\2323\261\322\226n\312\324\374\225\233[\356\336\367\364\307}"
        "w\275\2776\257\244x\340\371\343<"
        "\3179\337\363}\316{\336\347<\217\250*OR\214'\032\035p?\214\261\324K6},\300`"
        "\036J\0360\006\260Q."
        "\"\374\205r\210\024\276\3239\332\2364f2\237@\032$\215\273l\006V\001GQ\3520\370\r\245#"
        "d\200\a\233\011\bo\000/"
        "\003\2373\224\365:K{\3777\001\361\311\013(\373\020\202\300\0225\265\365\001\366\223\201}(."
        "\204%"
        "j\352\311\301\354\a\255\001\361\313\032\240\021\301G7\323\230A\207\334\2209rS^"
        "\035\310GMm\245\233i\b>"
        "\240\321\301\0308\306@\031\020\237,\006v\001\363\325\324#r]f\003\30234\320\200\233."
        "\246\340\242\bp\021\244\231\036N\352B\355\211\301x\r8\000\224\253\251\325I\023\020\277\214"
        "D9\013\244`"
        "\260\202\351\\\304\340\022\307\350\"\310NlJ\020\316\242\234p>\315\213(\005\b\r\330,"
        "\327R\275\024Ab)\260\r!_"
        "K\364Zr\004|R\203\362\024.\326!\370\031N\r\3279\212\301\016\224\335\214\342S-\322\276("
        "\237Zq\221\301*`"
        "\r\260NM\335\033^\263\304B\270\243\246\276\035\027LU\243\006^\346cq\033\037\036U\205:"
        "r\260h\307\342&"
        "u\024\306\332\307\371\327\361<"
        "\026\277\340eYx\316\207\a\213\333x\231\037k\237\250\b\337\a\266i\211v8\372]B\305\372'"
        "\302:i\220\264\004>\3677T\252g\021\336B\370X\352%\033\300\301\332\346`GI<"
        "\001\241\020\2411B\337\201\360%"
        "C\231\341\320\251\227:\031%~"
        "\251\024\237\034\027\237\034\027\277TJ\255\244\206I\224\350y\224-"
        "\004\330\035\201\323\210P8(\0019$\243\201,\202\264\000H\245\030\b&"
        "\351l\325Y\332K\023\213\200\023\2708\2172\021\241\014\241\014%\207\014\016\n\"a\260&"
        "\276\000^\221ZI\ap0\263\304'"
        "Y\003g "
        "@!\320\256\245\3727\000\323\031\017t\364\237h\272Im\204\237\200N\240\030\301\255%zFM}"
        "\017A\260X\024\316\302&"
        "\265\201\323d0\005\300\301l\307\210\316B4\201\320bKXW\246\"\021zhn&\312\026`-"
        "6\207\373\27736\373\020b\017\250\026`"
        "j\224n\017F@ypcP\024A\324\324j\\\024\207\033\217 I\371\307Hl\006Z "
        "\202\241\320\204\306\025\316\021\2242AD\347\3529'\266\240\224a\360c\214m!"
        "\320\024\245\033\321\031\215&`"
        "\323\002d\213W2\0018\306\037\200'\362\327\323yZ\213A7~\252\305+"
        "\205\342\225B\374Tc\320\255%\372m\230{\245\030\300$"
        "\2729\005\340`f;1\022\023PS;\201N\\\241];Ew\210\036>\214\"\232N)\320\212\301."
        "\014v\001\255\316\334}\231\312J\340X\270?"
        "\2040;\235\030a\211\277\220(-@1P\3578\256&\310\0119(\337\353\353z\n@"
        "gi\000\330\354\2148\021\277\214CXO\350n\320\217["
        "\354`GI\242\223p\017P!~\361\000\350\034\275\n\254\306\246F\374\222\237(`"
        "TpK\306\002\373\201\215j\352\005\207\220\a\250p\260c6\234\350<\267\250\301\213\025\323#"
        "\026b\321\216\227\265\370\030\022\347\323D\n>V`"
        "\321\201\305\2731\276\026\0265\211b\r\326\216\317\000\025j\352\327\341\371zy\226 "
        ";QL\340\014\3603\020\004^\002&\003?<\222v\3548.\006\252\2007\325\324#"
        "Qk\r\222\366\260\027\222\334\215\271\373\201I\316\322\351\266\346\266\300\240\004\234L\254"
        "A\251\004\252\350f\203.\324{"
        "\003\032G\372\325J*\031|\002\224#l\312\335\220\333\014\224\215\3757pnd_ "
        "\275=\325=\356r\252{O[s\333\341\307~)"
        "\315\335\230\333\005\224\377z\362\302WCm\235\b\344\367\030R\360QN\346\220\003#2>"
        "x\354\327\362\274\242\274\255\345\235\267\352+."
        "\337z\032\310\a\n\200\374\216T\367\250\231\223<{"
        "\223z\2308\335\260B\352e;},@\230\213\315R\204\034\000\354\360\303\344\033Rx'\362a\342RF,"
        "\273\362O&"
        "\360\\\177p\240\300s/"
        "@\326\275\340\230\207z\0319\300U\316H\316G\270\365{z\352\204i]"
        "\275\371\334\317\0007\334\256;"
        "\327R\\W\037\373\333\320\206\335U\243\207O\274\3432\306\367\a\3575$\260}"
        "\364\360\306\240\2603\251\032\370\277\222W\2247{"
        "lo\337\362\225Wn\217D\261k2\207u\035\037\226\366YR\177\301#$\341&"
        "\3019\360\037K{\256\233\221\024lt\000\000\000\000IEND\256B`\202",
        1423);
    _img_radar_red = new wxBitmap(wxImage(sm));
  }
  {
    wxMemoryInputStream sm(
        "\211PNG\r\n\032\n\000\000\000\rIHDR\000\000\000 \000\000\000 "
        "\b\006\000\000\000szz\364\000\000\000\004sBIT\b\b\b\b|"
        "\bd\210\000\000\000\011pHYs\000\000\r\327\000\000\r\327\001B("
        "\233x\000\000\000\031tEXtSoftware\000www.inkscape.org\233\356<"
        "\032\000\000\005\002IDATX\205\305\327ol\326W\025\a\360\317yZ\312\337\004Ep\220\001)"
        "\314\271\25402\0138G\234!"
        "Y\302\326\202\006cj\246na\306\027C\027\266\004\343\214\333\b!\222\371b\011\003\231#\250/"
        "LF\b\016\223i\354\323\002\211\021\227\030\366\a:\204It.a\263la\303 "
        "8*\b\355s|\321_\037\372\217\3229\311Nr_\334{\3179\337\357=\367\336s\356\215\314\364QJ\351#"
        "EG\355\aQ\216}1\313%+\225,"
        "\227\346\340zT\244\277\013oJ{\215\361\353\\\226\235\243\3669\232-\210\3751\316\277="
        "\201\207\360\242\364[%"
        "\177\225N\364*\230\251\342&\341\213\370\034~l\202Gsi^\370\320\004\242-n\225v\b="
        "\2707\233\363\350U\364o\301\016\251F\2707\233\363\360H\372#\236\201h\217Gp@"
        "h\323e\361\325\300!\233\363\250."
        "\213\2056\274X\370\2702\306\225\"\020m\361ul\305\227\2639_\0300\267?"
        "\3069g\201\032\013Q\243\307!\347\035\316\226<_"
        "\325\331\023\013T\364\331}'\233s\347\250\011D{L\223\216am6\347\263\325\361}\361I="
        "\236V\321$"
        "\374Ez\265\330\232\317H\363\204\375*V\243F\311\037\225\374@E`\223\320\220Myj0\326\360\267 "
        "m\225^"
        "\316\345\375\300\313\321\242d\263\264\315t\337\310\205yi\000\351\335Qc\242\207\224t\240"
        "\333X\3335:"
        "\353\343\312\312\356)\242y\317`\250!g "
        "\312\361%4)y\240:\326\026_\0216J\313\26397\016\006\207l\311\036\023lC'"
        "\352\\\3606\216\373\247%"
        "\205\257\246\302\367\310\004\360\0006eS\236\200h\215\251\330\254\244e\244\023\035\033\242"
        "\244\313\263\322q\025K\204"
        "\037z\305Y\351\264\333L\306\246\302\367\000\031\272\005\241Q\330\322\257\277Y\370i\336\235"
        "G\252C\273\243\316$"
        "\217I\315\205N\233\305>\201\353L\260,\227\346\205(\307\217t\333f\212\225N\273S8\200\325#F "
        "\366\306\014L\327\243\243\272\252\320l\274'/"
        "\363\2110\321\036i\266\260JXU\020\271_"
        "\215\225\325\344s\320O\260\304ncT\2342\313\233\230\036m1\375\212\004tkDg\256\310\177\200"
        "\333\334\210\023\0032Z\273\257"
        "\n\221\315\371\315l\312c\322\255\230\216\243\272-\353S\313\365Y\301k&Z`\252?\345\374|"
        "\035\235J\032\257L\240w\262\243\332O\213D\277~\357\330\035*"
        "v\024\021\373\024\266\024\265\341\347\302\347\aE\270\003\213R\366T\373\225\221\b\244\253"
        "\027\206\224B@"
        "\336\225o\250\325\230w\347\021!Fe?H\006G\240\203~\014\303A9\2201^\220V\205\350%\261,;"
        "C\204\264J\311\037\006\3516\342\340\200~i`"
        "D\a\022\250\350\300\254\342\352\361\222\277af\354\217q}*\271<w+"
        "\351\322ng\264Fc\264F\243v;\225teS\376\252\312}C\2240_\227#"
        "T\257\363\254\002cx\002\331\234'qRM\357\252s}"
        "V\204\275\316\373\336\000\242\343\255\300Q%\317(y\006G\213\261\313\262\310\203x\251Z\037z}"
        "\236,"
        "0\25224\017\244\016\334\216}\205\341\303z\274\032{\3427}\271 "
        "\227f7\236(\332\020\211\366\270AxT\357\333\240\317\357\355\205\357\0012\\&"
        "\334\216\265\321\0363!\227\345{"
        "xX\305\256h\217\206\341\000\a\200\227c.\236\303\272l\316\267\nB3\261\266\360="
        "h\301\231C\232\262]"
        "Z\225\a\214\265jQ\326\251\325\367\265\031;\304\346\2401\332|[\331\011e\367\017\262-+"
        "\3335\034\326\377V\216{"
        "3\3371\274\214\036|\026\267\340\367*V\347\212|\273j\323\026\367\031\241\034_"
        "\263\aI\341\343\013x\036k\352\327\325?"
        "\207\371\305\324k\307\017\035\357\036\221@"
        "\021\211G\244\r\330\252\313\343\331\222\027\257\250\334\337nw\324\231h#"
        "\326\b\353\353\037\257?\204Us\377\323\375\306\264K\335\343;"
        "\353jox\247\256v\373\361C\307\177w\315\037\245\365\353\352\317a\315\237\017\277\365\263"
        "\011\225\274\031\r\347K1\357"
        "\261\331S\307>?e\342w\257\371\263|\316\3029O\2569yf\337\332w\316|"
        "\014\r\230\207\206\023u\265\327\3351\177\346/"
        "F\3651)\252\341\332\330\027O\271d\245p\227\212\373\204\331\240R\375\230\374\322\030_"
        "\353\3771\251IS\276\365\356\277\246\342\323}\340\2307\363b\267\351\027{\256\377@?"
        "\243\302\361\326\242\215\316&\234y}|"
        "\335M\213\317]hp9\002N\327\326\274\177jL\315{\327\374oXa\333\326\031\223o~"
        "\277\246tc\037\370\205Rt?"
        "5c\362\201\236\360\364\250\316\300\207\2259\013\347\3349\367\302\245\325\017\276{"
        "v\232T\3315u\322\271W&\215\3332\252["
        "\360\177$Qk\230<\360_-\027v\027\246\342\357\011\000\000\000\000IEND\256B`\202",
        1413);
    _img_radar_red_slave = new wxBitmap(wxImage(sm));
  }
  return;
}
Example #6
0
int main(
	int _argc,
	char *_argv[])
try
{
	fcppt::log::activate_levels(
		sge::log::global(),
		fcppt::log::level::debug);
	
	sgetris::program_options().add_options()
		(
			"help",
			"produce help message")
		(
			"screen-size",
			boost::program_options::value<sge::renderer::screen_size>()->default_value(
				sge::renderer::screen_size(
					1024,
					768)),
			"Change screen resolution (format: (w,h))")
		(
			"fps",
			boost::program_options::value<bool>()->default_value(
				true),
			"Show frames per second");
			
	sgetris::log_switcher 
		sge_log(
			&sgetris::program_options,
			FCPPT_TEXT("sge"),
			sge::log::global_context()),
		sgetris_log(
			&sgetris::program_options,
			FCPPT_TEXT("sgetris"),
			sgetris::log::context());
	
	boost::program_options::variables_map vm;
	boost::program_options::store(
		boost::program_options::parse_command_line(
			_argc,
			_argv,
			sgetris::program_options()),
		vm);
	
	boost::program_options::notify(
		vm);

	sge_log.apply(
		vm);

	sgetris_log.apply(
		vm);

	if (vm.count("help"))
	{
		std::cout << sgetris::program_options() << "\n";
		return 0;
	}

	sge::renderer::screen_size const screens =
		vm["screen-size"].as<sge::renderer::screen_size>();

	sge::systems::instance sys(
		sge::systems::list()
		(
			sge::window::parameters(
				FCPPT_TEXT("sgetris snowflaketest")
			)
		)
		(	sge::renderer::parameters(
				sge::renderer::display_mode(
					screens,
					sge::renderer::bit_depth::depth32,
					sge::renderer::refresh_rate_dont_care
				),
				sge::renderer::depth_buffer::off,
				sge::renderer::stencil_buffer::off,
				sge::renderer::window_mode::windowed,
				sge::renderer::vsync::on,
				sge::renderer::no_multi_sampling
			)
		)
		(sge::systems::parameterless::input)
		(sge::systems::parameterless::audio_player)
		(
			sge::systems::image_loader(
				sge::image::capabilities_field::null(),
				fcppt::assign::make_container<
					sge::extension_set
				>(
					FCPPT_TEXT("png")
				)
			)
		)
		(
			sge::systems::audio_loader(
				sge::audio::loader_capabilities_field::null(),
				sge::all_extensions
			)
		)
		(sge::systems::parameterless::font)
	);

	bool running = true;

	sgetris::sound_manager sm(
		sys.audio_loader(),
		sys.audio_player());
	
	sgetris::texture_manager tm(
		sys.image_loader(),
		sys.renderer()
	);

	fcppt::signal::scoped_connection const cb(
		sys.input_system()->register_callback(
			sge::input::action(
				sge::input::kc::key_escape,
				boost::phoenix::ref(running) = false)));
	
	fcppt::scoped_ptr<sgetris::backgrounds::base> bg(
		new sgetris::backgrounds::flakes::object(
			vm,
			sys.renderer(),
			tm));

	sge::font::metrics_ptr const metrics(
		sys.font_system()->create_font(
			sge::config::media_path() / FCPPT_TEXT("fonts") / FCPPT_TEXT("default.ttf"),
			static_cast<sge::font::size_type>(
				15)));

	sge::font::drawer_ptr const drawer(
		fcppt::make_shared_ptr<
			sge::font::drawer_3d
		>(
			sys.renderer(),
			sge::image::colors::green()));

	sge::font::object font(
		metrics,
		drawer);
	
	sge::time::frames_counter frames_counter;

	sgetris::machine m(
		vm,
		sys,
		tm);
	m.initiate();

	sge::time::duration t = 
		sge::time::now().time_since_epoch();

	while(running)
	{
		frames_counter.update();

		sge::time::duration const
			newtime = 
				sge::time::now().time_since_epoch(),
			diff_duration = 
				newtime - t;

		t = newtime;

		sgetris::time_delta const diff(
			diff_duration.count()
		);

		sge::mainloop::dispatch();
		sge::renderer::scoped_block const block_(
			sys.renderer());
		bg->update(
			diff);
		m.process_event(
			sgetris::events::tick(
				diff));
		bg->draw();

		if (vm["fps"].as<bool>())
			font.draw_text(
				FCPPT_TEXT("fps: ")+frames_counter.frames_str(),
				sge::font::pos::null(),
				fcppt::math::dim::structure_cast<sge::font::dim>(
					sys.renderer()->screen_size()),
				sge::font::align_h::left,
				sge::font::align_v::top);
	}

	fcppt::io::cerr << "Am Ende von main\n";
}
catch(fcppt::exception const &e)
{
	fcppt::io::cerr << e.string() << FCPPT_TEXT('\n');
	return EXIT_FAILURE;
}
catch(std::exception const &e)
{
	std::cerr << e.what() << FCPPT_TEXT('\n');
	return EXIT_FAILURE;
}
catch (...)
{
	fcppt::io::cerr << FCPPT_TEXT("Caught someting unknown");
}
Example #7
0
// We're reading in way too many entities here to mess around with creating sub-objects and
// seeking around in them, so we're using the json streaming API.
submap *mapbuffer::unserialize_submaps( const tripoint &p )
{
    // Map the tripoint to the submap quad that stores it.
    const tripoint om_addr = overmapbuffer::sm_to_omt_copy( p );
    const tripoint segment_addr = overmapbuffer::omt_to_seg_copy( om_addr );
    std::stringstream quad_path;
    quad_path << world_generator->active_world->world_path << "/maps/" <<
              segment_addr.x << "." << segment_addr.y << "." << segment_addr.z << "/" <<
              om_addr.x << "." << om_addr.y << "." << om_addr.z << ".map";

    std::ifstream fin( quad_path.str().c_str() );
    if( !fin.is_open() ) {
        // If it doesn't exist, trigger generating it.
        return NULL;
    }

    JsonIn jsin( fin );
    jsin.start_array();
    while( !jsin.end_array() ) {
        std::unique_ptr<submap> sm(new submap());
        tripoint submap_coordinates;
        jsin.start_object();
        bool rubpow_update = false;
        while( !jsin.end_object() ) {
            std::string submap_member_name = jsin.get_member_name();
            if( submap_member_name == "version" ) {
                if (jsin.get_int() < 22) {
                    rubpow_update = true;
                }
            } else if( submap_member_name == "coordinates" ) {
                jsin.start_array();
                int locx = jsin.get_int();
                int locy = jsin.get_int();
                int locz = jsin.get_int();
                jsin.end_array();
                submap_coordinates = tripoint( locx, locy, locz );
            } else if( submap_member_name == "turn_last_touched" ) {
                sm->turn_last_touched = jsin.get_int();
            } else if( submap_member_name == "temperature" ) {
                sm->temperature = jsin.get_int();
            } else if( submap_member_name == "terrain" ) {
                // TODO: try block around this to error out if we come up short?
                jsin.start_array();
                // Small duplication here so that the update check is only performed once
                if (rubpow_update) {
                    std::string ter_string;
                    item rock = item("rock", 0);
                    item chunk = item("steel_chunk", 0);
                    for( int j = 0; j < SEEY; j++ ) {
                        for( int i = 0; i < SEEX; i++ ) {
                            ter_string = jsin.get_string();
                            if (ter_string == "t_rubble") {
                                sm->ter[i][j] = termap[ "t_dirt" ].loadid;
                                sm->frn[i][j] = furnmap[ "f_rubble" ].loadid;
                                sm->itm[i][j].push_back( rock );
                                sm->itm[i][j].push_back( rock );
                            } else if (ter_string == "t_wreckage"){
                                sm->ter[i][j] = termap[ "t_dirt" ].loadid;
                                sm->frn[i][j] = furnmap[ "f_wreckage" ].loadid;
                                sm->itm[i][j].push_back( chunk );
                                sm->itm[i][j].push_back( chunk );
                            } else if (ter_string == "t_ash"){
                                sm->ter[i][j] = termap[ "t_dirt" ].loadid;
                                sm->frn[i][j] = furnmap[ "f_ash" ].loadid;
                            } else if (ter_string == "t_pwr_sb_support_l"){
                                sm->ter[i][j] = termap[ "t_support_l" ].loadid;
                            } else if (ter_string == "t_pwr_sb_switchgear_l"){
                                sm->ter[i][j] = termap[ "t_switchgear_l" ].loadid;
                            } else if (ter_string == "t_pwr_sb_switchgear_s"){
                                sm->ter[i][j] = termap[ "t_switchgear_s" ].loadid;
                            } else {
                                sm->ter[i][j] = terfind( ter_string );
                            }
                        }
                    }
                } else {
                    for( int j = 0; j < SEEY; j++ ) {
                        for( int i = 0; i < SEEX; i++ ) {
                            sm->ter[i][j] = terfind( jsin.get_string() );
                        }
                    }
                }
                jsin.end_array();
            } else if( submap_member_name == "radiation" ) {
                int rad_cell = 0;
                jsin.start_array();
                while( !jsin.end_array() ) {
                    int rad_strength = jsin.get_int();
                    int rad_num = jsin.get_int();
                    for( int i = 0; i < rad_num; ++i ) {
                        // A little array trick here, assign to it as a 1D array.
                        // If it's not in bounds we're kinda hosed anyway.
                        sm->set_radiation(0, rad_cell, rad_strength);
                        rad_cell++;
                    }
                }
            } else if( submap_member_name == "furniture" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    jsin.start_array();
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    sm->frn[i][j] = furnmap[ jsin.get_string() ].loadid;
                    jsin.end_array();
                }
            } else if( submap_member_name == "items" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    jsin.start_array();
                    while( !jsin.end_array() ) {
                        item tmp;
                        jsin.read( tmp );

                        if( tmp.is_emissive() ) {
                            sm->update_lum_add(tmp, i, j);
                        }

                        tmp.visit_items( [ &sm, i, j ]( item *it ) {
                            for( auto& e: it->magazine_convert() ) {
                                sm->itm[i][j].push_back( e );
                            }
                            return VisitResponse::NEXT;
                        } );

                        sm->itm[i][j].push_back( tmp );
                        if( tmp.needs_processing() ) {
                            sm->active_items.add( std::prev(sm->itm[i][j].end()), point( i, j ) );
                        }
                    }
                }
            } else if( submap_member_name == "traps" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    jsin.start_array();
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    // TODO: jsin should support returning an id like jsin.get_id<trap>()
                    sm->trp[i][j] = trap_str_id( jsin.get_string() );
                    jsin.end_array();
                }
            } else if( submap_member_name == "fields" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    // Coordinates loop
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    jsin.start_array();
                    while( !jsin.end_array() ) {
                        int type = jsin.get_int();
                        int density = jsin.get_int();
                        int age = jsin.get_int();
                        if (sm->fld[i][j].findField(field_id(type)) == NULL) {
                            sm->field_count++;
                        }
                        sm->fld[i][j].addField(field_id(type), density, age);
                    }
                }
            } else if( submap_member_name == "graffiti" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    jsin.start_array();
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    sm->set_graffiti( i, j, jsin.get_string() );
                    jsin.end_array();
                }
            } else if(submap_member_name == "cosmetics") {
                jsin.start_array();
                while (!jsin.end_array()) {
                    jsin.start_array();
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    jsin.read(sm->cosmetics[i][j]);
                    jsin.end_array();
                }
            } else if( submap_member_name == "spawns" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    jsin.start_array();
                    const mtype_id type = mtype_id( jsin.get_string() ); // TODO: json should know how to read an string_id
                    int count = jsin.get_int();
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    int faction_id = jsin.get_int();
                    int mission_id = jsin.get_int();
                    bool friendly = jsin.get_bool();
                    std::string name = jsin.get_string();
                    jsin.end_array();
                    spawn_point tmp( type, count, i, j, faction_id, mission_id, friendly, name );
                    sm->spawns.push_back( tmp );
                }
            } else if( submap_member_name == "vehicles" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    vehicle *tmp = new vehicle();
                    jsin.read( *tmp );
                    sm->vehicles.push_back( tmp );
                }
            } else if( submap_member_name == "computers" ) {
                std::string computer_data = jsin.get_string();
                sm->comp.load_data( computer_data );
            } else if( submap_member_name == "camp" ) {
                std::string camp_data = jsin.get_string();
                sm->camp.load_data( camp_data );
            } else {
                jsin.skip_value();
            }
        }
        if( !add_submap( submap_coordinates, sm ) ) {
            debugmsg( "submap %d,%d,%d was already loaded", submap_coordinates.x, submap_coordinates.y,
                      submap_coordinates.z );
        }
    }
    if( submaps.count( p ) == 0 ) {
        debugmsg("file %s did not contain the expected submap %d,%d,%d", quad_path.str().c_str(), p.x, p.y,
                 p.z);
        return NULL;
    }
    return submaps[ p ];
}
Example #8
0
int main(int argc, char *argv[]) {
	std::string sysmgr_host;
	std::string sysmgr_pass;
	uint16_t sysmgr_port;
	bool print_version;
	std::string command;
	std::vector<std::string> command_args;
	
	opt::options_description option_normal("Global options");
	option_normal.add_options()
		("help", "help (also supported by all subcommands)")
		("host,H", opt::value<std::string>(&sysmgr_host)->default_value("localhost"), "system manager hostname")
		("pass,P", opt::value<std::string>(&sysmgr_pass)->default_value(""), "system manager password")
		("port", opt::value<uint16_t>(&sysmgr_port)->default_value(4681), "system manager port");

	opt::options_description option_hidden("Hidden options");
	option_hidden.add_options()
		("help,h", "help")
		("version", opt::bool_switch(&print_version)->default_value(false), "version")
		("command", opt::value<std::string>(&command), "")
		("command-args", opt::value< std::vector<std::string> >(&command_args));

	opt::options_description option_all;
	option_all.add(option_normal).add(option_hidden);

	opt::variables_map option_vars;

	opt::positional_options_description option_pos;
	option_pos.add("command", 1);
	option_pos.add("command-args", -1);

	if (!getenv("HOME")) {
		printf("Missing HOME environment variable\n");
		return EXIT_INTERNAL_ERROR;
	}
	std::vector<std::string> config_paths = { stdsprintf("%s/.ipmimt.conf", getenv("HOME")), "/etc/ipmimt.conf" };

	if (parse_config(std::vector<std::string>(argv+1, argv+argc), option_all, option_pos, option_vars, config_paths) < 0)
		return EXIT_PARAM_ERROR;

	if (print_version) {
		printf("\nCompiled from %s@%s\n", GIT_BRANCH, GIT_COMMIT);
		if (strlen(GIT_DIRTY) > 1)
			printf("%s", GIT_DIRTY);
		printf("\n");
		return EXIT_OK;
	}

	if (argc == 1 || option_vars.count("help") || option_vars["command"].empty() || REGISTERED_COMMANDS->find(command) == REGISTERED_COMMANDS->end()) {
		printf("%s [options] command [arguments]\n", argv[0]);
		printf("\n");
		std::cout << option_normal << "\n";
		printf("Valid commands:\n");
		unsigned int command_maxlen = 1;
		for (std::map<std::string, Command*>::iterator it = REGISTERED_COMMANDS->begin(); it != REGISTERED_COMMANDS->end(); it++) {
			if (it->first.size() > command_maxlen)
				command_maxlen = it->first.size();
		}
		std::string format = stdsprintf("  %%%ds    %%s\n", command_maxlen);
		for (std::map<std::string, Command*>::iterator it = REGISTERED_COMMANDS->begin(); it != REGISTERED_COMMANDS->end(); it++) {
			printf(format.c_str(), it->second->name.c_str(), it->second->short_description.c_str());
		}
		return EXIT_OK;
	}

	sysmgr::sysmgr sm(sysmgr_host, sysmgr_pass, sysmgr_port);
	try {
		sm.connect();
	}
	catch (sysmgr::sysmgr_exception &e) {
		printf("Unable to connect to system manager: %s\n", e.message.c_str());
		return EXIT_REMOTE_ERROR;
	}

	// command is in the map, this was validated at the 'do you need help?' stage.
	return REGISTERED_COMMANDS->find(command)->second->execute(sm, command_args);
}
Example #9
0
// Compute the gradient of a^T K b
void Permutohedral::gradient ( float* df, const float * a, const float* b, int value_size ) const
{
    // Shift all values by 1 such that -1 -> 0 (used for blurring)
    float * values = new float[ (M_+2)*value_size ];
    float * new_values = new float[ (M_+2)*value_size ];

    // Set the results to 0
    std::fill( df, df+N_*d_, 0.f );

    // Initialize some constants
    std::vector<float> scale_factor( d_ );
    float inv_std_dev = sqrt(2.0 / 3.0)*(d_+1);
    for( int i=0; i<d_; i++ )
        scale_factor[i] = 1.0 / sqrt( double((i+2)*(i+1)) ) * inv_std_dev;

    // Alpha is a magic scaling constant multiplied by down_factor
    float alpha = 1.0f / (1+powf(2, -d_)) / (d_+1);

    for( int dir=0; dir<2; dir++ ) {
        for( int i=0; i<(M_+2)*value_size; i++ )
            values[i] = new_values[i] = 0;

        // Splatting
        for( int i=0;  i<N_; i++ ){
            for( int j=0; j<=d_; j++ ){
                int o = offset_[i*(d_+1)+j]+1;
                float w = barycentric_[i*(d_+1)+j];
                for( int k=0; k<value_size; k++ )
                    values[ o*value_size+k ] += w * (dir?b:a)[ i*value_size+k ];
            }
        }

        // BLUR
        for( int j=dir?d_:0; j<=d_ && j>=0; dir?j--:j++ ){
            for( int i=0; i<M_; i++ ){
                float * old_val = values + (i+1)*value_size;
                float * new_val = new_values + (i+1)*value_size;

                int n1 = blur_neighbors_[j*M_+i].n1+1;
                int n2 = blur_neighbors_[j*M_+i].n2+1;
                float * n1_val = values + n1*value_size;
                float * n2_val = values + n2*value_size;
                for( int k=0; k<value_size; k++ )
                    new_val[k] = old_val[k]+0.5*(n1_val[k] + n2_val[k]);
            }
            std::swap( values, new_values );
        }

        // Slicing gradient computation
        std::vector<float> r_a( (d_+1)*value_size ), sm( value_size );

        for( int i=0; i<N_; i++ ){
            // Rotate a
            std::fill( r_a.begin(), r_a.end(), 0.f );
            for( int j=0; j<=d_; j++ ){
                int r0 = d_ - rank_[i*(d_+1)+j];
                int r1 = r0+1>d_?0:r0+1;
                int o0 = offset_[i*(d_+1)+r0]+1;
                int o1 = offset_[i*(d_+1)+r1]+1;
                for( int k=0; k<value_size; k++ ) {
                    r_a[ j*value_size+k ] += alpha*values[ o0*value_size+k ];
                    r_a[ j*value_size+k ] -= alpha*values[ o1*value_size+k ];
                }
            }
            // Multiply by the elevation matrix
            std::copy( r_a.begin(), r_a.begin()+value_size, sm.begin() );
            for( int j=1; j<=d_; j++ ) {
                float grad = 0;
                for( int k=0; k<value_size; k++ ) {
                    // Elevate ...
                    float v = scale_factor[j-1]*(sm[k]-j*r_a[j*value_size+k]);
                    // ... and add
                    grad += (dir?a:b)[ i*value_size+k ]*v;

                    sm[k] += r_a[j*value_size+k];
                }
                // Store the gradient
                df[i*d_+j-1] += grad;
            }
        }
    }
    delete[] values;
    delete[] new_values;
}
Example #10
0
void ElemRearrange(size_t nComponents, const vector_fp& elementAbundances,
                   MultiPhase* mphase,
                   std::vector<size_t>& orderVectorSpecies,
                   std::vector<size_t>& orderVectorElements)
{
    size_t nelements = mphase->nElements();
    // Get the total number of species in the multiphase object
    size_t nspecies = mphase->nSpecies();

    if (BasisOptimize_print_lvl > 0) {
        writelog("   ");
        writeline('-', 77);
        writelog("   --- Subroutine ElemRearrange() called to ");
        writelog("check stoich. coefficient matrix\n");
        writelog("   ---    and to rearrange the element ordering once\n");
    }

    // Perhaps, initialize the element ordering
    if (orderVectorElements.size() < nelements) {
        orderVectorElements.resize(nelements);
        for (size_t j = 0; j < nelements; j++) {
            orderVectorElements[j] = j;
        }
    }

    // Perhaps, initialize the species ordering. However, this is dangerous, as
    // this ordering is assumed to yield the component species for the problem
    if (orderVectorSpecies.size() != nspecies) {
        orderVectorSpecies.resize(nspecies);
        for (size_t k = 0; k < nspecies; k++) {
            orderVectorSpecies[k] = k;
        }
    }

    // If the elementAbundances aren't input, just create a fake one based on
    // summing the column of the stoich matrix. This will force elements with
    // zero species to the end of the element ordering.
    vector_fp eAbund(nelements,0.0);
    if (elementAbundances.size() != nelements) {
        for (size_t j = 0; j < nelements; j++) {
            eAbund[j] = 0.0;
            for (size_t k = 0; k < nspecies; k++) {
                eAbund[j] += fabs(mphase->nAtoms(k, j));
            }
        }
    } else {
        copy(elementAbundances.begin(), elementAbundances.end(),
             eAbund.begin());
    }

    vector_fp sa(nelements,0.0);
    vector_fp ss(nelements,0.0);
    vector_fp sm(nelements*nelements,0.0);

    // Top of a loop of some sort based on the index JR. JR is the current
    // number independent elements found.
    size_t jr = 0;
    while (jr < nComponents) {
        // Top of another loop point based on finding a linearly independent
        // element
        size_t k = nelements;
        while (true) {
            // Search the element vector. We first locate elements that are
            // present in any amount. Then, we locate elements that are not
            // present in any amount. Return its identity in K.
            size_t kk;
            for (size_t ielem = jr; ielem < nelements; ielem++) {
                kk = orderVectorElements[ielem];
                if (eAbund[kk] != USEDBEFORE && eAbund[kk] > 0.0) {
                    k = ielem;
                    break;
                }
            }
            for (size_t ielem = jr; ielem < nelements; ielem++) {
                kk = orderVectorElements[ielem];
                if (eAbund[kk] != USEDBEFORE) {
                    k = ielem;
                    break;
                }
            }

            if (k == nelements) {
                // When we are here, there is an error usually.
                // We haven't found the number of elements necessary.
                if (BasisOptimize_print_lvl > 0) {
                    writelogf("Error exit: returning with nComponents = %d\n", jr);
                }
                throw CanteraError("ElemRearrange", "Required number of elements not found.");
            }

            // Assign a large negative number to the element that we have
            // just found, in order to take it out of further consideration.
            eAbund[kk] = USEDBEFORE;

            // CHECK LINEAR INDEPENDENCE OF CURRENT FORMULA MATRIX
            // LINE WITH PREVIOUS LINES OF THE FORMULA MATRIX

            // Modified Gram-Schmidt Method, p. 202 Dalquist
            // QR factorization of a matrix without row pivoting.
            size_t jl = jr;

            // Fill in the row for the current element, k, under consideration
            // The row will contain the Formula matrix value for that element
            // with respect to the vector of component species. (note j and k
            // indices are flipped compared to the previous routine)
            for (size_t j = 0; j < nComponents; ++j) {
                size_t jj = orderVectorSpecies[j];
                kk = orderVectorElements[k];
                sm[j + jr*nComponents] = mphase->nAtoms(jj,kk);
            }
            if (jl > 0) {
                // Compute the coefficients of JA column of the the upper
                // triangular R matrix, SS(J) = R_J_JR (this is slightly
                // different than Dalquist) R_JA_JA = 1
                for (size_t j = 0; j < jl; ++j) {
                    ss[j] = 0.0;
                    for (size_t i = 0; i < nComponents; ++i) {
                        ss[j] += sm[i + jr*nComponents] * sm[i + j*nComponents];
                    }
                    ss[j] /= sa[j];
                }

                // Now make the new column, (*,JR), orthogonal to the
                // previous columns
                for (size_t j = 0; j < jl; ++j) {
                    for (size_t i = 0; i < nComponents; ++i) {
                        sm[i + jr*nComponents] -= ss[j] * sm[i + j*nComponents];
                    }
                }
            }

            // Find the new length of the new column in Q.
            // It will be used in the denominator in future row calcs.
            sa[jr] = 0.0;
            for (size_t ml = 0; ml < nComponents; ++ml) {
                double tmp = sm[ml + jr*nComponents];
                sa[jr] += tmp * tmp;
            }
            // IF NORM OF NEW ROW  .LT. 1E-6 REJECT
            if (sa[jr] > 1.0e-6) {
                break;
            }
        }
        // REARRANGE THE DATA
        if (jr != k) {
            if (BasisOptimize_print_lvl > 0) {
                size_t kk = orderVectorElements[k];
                writelog("   ---   ");
                writelogf("%-2.2s", mphase->elementName(kk));
                writelog("replaces ");
                kk = orderVectorElements[jr];
                writelogf("%-2.2s", mphase->elementName(kk));
                writelogf(" as element %3d\n", jr);
            }
            std::swap(orderVectorElements[jr], orderVectorElements[k]);
        }

        // If we haven't found enough components, go back and find some more
        jr++;
    };
}
Example #11
0
 show_image_cmd::ptr show_image(uint32_t id, tex_image_t img, const pos2d_f& pos, const size_f& sz=size_f(0,0)) {
     show_image_cmd::ptr sm(new show_image_cmd(id, img, pos, sz));
     add_cmd(sm);
     return sm;
 }
Example #12
0
size_t BasisOptimize(int* usedZeroedSpecies, bool doFormRxn, MultiPhase* mphase,
                     std::vector<size_t>& orderVectorSpecies,
                     std::vector<size_t>& orderVectorElements,
                     vector_fp& formRxnMatrix)
{
    // Get the total number of elements defined in the multiphase object
    size_t ne = mphase->nElements();

    // Get the total number of species in the multiphase object
    size_t nspecies = mphase->nSpecies();

    // Perhaps, initialize the element ordering
    if (orderVectorElements.size() < ne) {
        orderVectorElements.resize(ne);
        iota(orderVectorElements.begin(), orderVectorElements.end(), 0);
    }

    // Perhaps, initialize the species ordering
    if (orderVectorSpecies.size() != nspecies) {
        orderVectorSpecies.resize(nspecies);
        iota(orderVectorSpecies.begin(), orderVectorSpecies.end(), 0);
    }

    if (BasisOptimize_print_lvl >= 1) {
        writelog("   ");
        writeline('-', 77);
        writelog("   --- Subroutine BASOPT called to ");
        writelog("calculate the number of components and ");
        writelog("evaluate the formation matrix\n");
        if (BasisOptimize_print_lvl > 0) {
            writelog("   ---\n");

            writelog("   ---      Formula Matrix used in BASOPT calculation\n");
            writelog("   ---      Species | Order | ");
            for (size_t j = 0; j < ne; j++) {
                size_t jj = orderVectorElements[j];
                writelog(" {:>4.4s}({:1d})", mphase->elementName(jj), j);
            }
            writelog("\n");
            for (size_t k = 0; k < nspecies; k++) {
                size_t kk = orderVectorSpecies[k];
                writelog("   --- {:>11.11s} |   {:4d} |",
                         mphase->speciesName(kk), k);
                for (size_t j = 0; j < ne; j++) {
                    size_t jj = orderVectorElements[j];
                    double num = mphase->nAtoms(kk,jj);
                    writelogf("%6.1g  ", num);
                }
                writelog("\n");
            }
            writelog("   --- \n");
        }
    }

    // Calculate the maximum value of the number of components possible. It's
    // equal to the minimum of the number of elements and the number of total
    // species.
    size_t nComponents = std::min(ne, nspecies);
    size_t nNonComponents = nspecies - nComponents;

    // Set this return variable to false
    *usedZeroedSpecies = false;

    // Create an array of mole numbers
    vector_fp molNum(nspecies,0.0);
    mphase->getMoles(molNum.data());

    // Other workspace
    DenseMatrix sm(ne, ne);
    vector_fp ss(ne, 0.0);
    vector_fp sa(ne, 0.0);
    if (formRxnMatrix.size() < nspecies*ne) {
        formRxnMatrix.resize(nspecies*ne, 0.0);
    }

    // For debugging purposes keep an unmodified copy of the array.
    vector_fp molNumBase = molNum;
    double molSave = 0.0;
    size_t jr = 0;

    // Top of a loop of some sort based on the index JR. JR is the current
    // number of component species found.
    while (jr < nComponents) {
        // Top of another loop point based on finding a linearly independent
        // species
        size_t k = npos;
        while (true) {
            // Search the remaining part of the mole number vector, molNum for
            // the largest remaining species. Return its identity. kk is the raw
            // number. k is the orderVectorSpecies index.
            size_t kk = max_element(molNum.begin(), molNum.end()) - molNum.begin();
            size_t j;
            for (j = 0; j < nspecies; j++) {
                if (orderVectorSpecies[j] == kk) {
                    k = j;
                    break;
                }
            }
            if (j == nspecies) {
                throw CanteraError("BasisOptimize", "orderVectorSpecies contains an error");
            }

            if (molNum[kk] == 0.0) {
                *usedZeroedSpecies = true;
            }
            // If the largest molNum is negative, then we are done.
            if (molNum[kk] == USEDBEFORE) {
                nComponents = jr;
                nNonComponents = nspecies - nComponents;
                break;
            }

            // Assign a small negative number to the component that we have
            // just found, in order to take it out of further consideration.
            molSave = molNum[kk];
            molNum[kk] = USEDBEFORE;

            // CHECK LINEAR INDEPENDENCE WITH PREVIOUS SPECIES

            // Modified Gram-Schmidt Method, p. 202 Dalquist
            // QR factorization of a matrix without row pivoting.
            size_t jl = jr;
            for (j = 0; j < ne; ++j) {
                size_t jj = orderVectorElements[j];
                sm(j, jr) = mphase->nAtoms(kk,jj);
            }
            if (jl > 0) {
                // Compute the coefficients of JA column of the the upper
                // triangular R matrix, SS(J) = R_J_JR (this is slightly
                // different than Dalquist) R_JA_JA = 1
                for (j = 0; j < jl; ++j) {
                    ss[j] = 0.0;
                    for (size_t i = 0; i < ne; ++i) {
                        ss[j] += sm(i, jr) * sm(i, j);
                    }
                    ss[j] /= sa[j];
                }

                // Now make the new column, (*,JR), orthogonal to the previous
                // columns
                for (j = 0; j < jl; ++j) {
                    for (size_t i = 0; i < ne; ++i) {
                        sm(i, jr) -= ss[j] * sm(i, j);
                    }
                }
            }

            // Find the new length of the new column in Q.
            // It will be used in the denominator in future row calcs.
            sa[jr] = 0.0;
            for (size_t ml = 0; ml < ne; ++ml) {
                sa[jr] += pow(sm(ml, jr), 2);
            }

            // IF NORM OF NEW ROW  .LT. 1E-3 REJECT
            if (sa[jr] > 1.0e-6) {
                break;
            }
        }

        // REARRANGE THE DATA
        if (jr != k) {
            if (BasisOptimize_print_lvl >= 1) {
                size_t kk = orderVectorSpecies[k];
                writelogf("   ---   %-12.12s", mphase->speciesName(kk));
                size_t jj = orderVectorSpecies[jr];
                writelogf("(%9.2g) replaces %-12.12s",
                          molSave, mphase->speciesName(jj));
                writelogf("(%9.2g) as component %3d\n", molNum[jj], jr);
            }
            std::swap(orderVectorSpecies[jr], orderVectorSpecies[k]);
        }

        // If we haven't found enough components, go back and find some more
        jr++;
    }

    if (! doFormRxn) {
        return nComponents;
    }

    // EVALUATE THE STOICHIOMETRY
    //
    // Formulate the matrix problem for the stoichiometric
    // coefficients. CX + B = 0
    //
    // C will be an nc x nc matrix made up of the formula vectors for the
    // components. Each component's formula vector is a column. The rows are the
    // elements.
    //
    // n RHS's will be solved for. Thus, B is an nc x n matrix.
    //
    // BIG PROBLEM 1/21/99:
    //
    // This algorithm makes the assumption that the first nc rows of the formula
    // matrix aren't rank deficient. However, this might not be the case. For
    // example, assume that the first element in FormulaMatrix[] is argon.
    // Assume that no species in the matrix problem actually includes argon.
    // Then, the first row in sm[], below will be identically zero. bleh.
    //
    // What needs to be done is to perform a rearrangement of the ELEMENTS ->
    // i.e. rearrange, FormulaMatrix, sp, and gai, such that the first nc
    // elements form in combination with the nc components create an invertible
    // sm[]. not a small project, but very doable.
    //
    // An alternative would be to turn the matrix problem below into an ne x nc
    // problem, and do QR elimination instead of Gauss-Jordan elimination.
    //
    // Note the rearrangement of elements need only be done once in the problem.
    // It's actually very similar to the top of this program with ne being the
    // species and nc being the elements!!

    sm.resize(nComponents, nComponents);
    for (size_t k = 0; k < nComponents; ++k) {
        size_t kk = orderVectorSpecies[k];
        for (size_t j = 0; j < nComponents; ++j) {
            size_t jj = orderVectorElements[j];
            sm(j, k) = mphase->nAtoms(kk, jj);
        }
    }

    for (size_t i = 0; i < nNonComponents; ++i) {
        size_t k = nComponents + i;
        size_t kk = orderVectorSpecies[k];
        for (size_t j = 0; j < nComponents; ++j) {
            size_t jj = orderVectorElements[j];
            formRxnMatrix[j + i * ne] = - mphase->nAtoms(kk, jj);
        }
    }

    // // Use LU factorization to calculate the reaction matrix
    solve(sm, formRxnMatrix.data(), nNonComponents, ne);

    if (BasisOptimize_print_lvl >= 1) {
        writelog("   ---\n");
        writelogf("   ---  Number of Components = %d\n", nComponents);
        writelog("   ---  Formula Matrix:\n");
        writelog("   ---                      Components:    ");
        for (size_t k = 0; k < nComponents; k++) {
            size_t kk = orderVectorSpecies[k];
            writelogf(" %3d (%3d) ", k, kk);
        }
        writelog("\n   ---                Components Moles:       ");
        for (size_t k = 0; k < nComponents; k++) {
            size_t kk = orderVectorSpecies[k];
            writelogf("%-11.3g", molNumBase[kk]);
        }
        writelog("\n   ---        NonComponent |   Moles  |       ");
        for (size_t i = 0; i < nComponents; i++) {
            size_t kk = orderVectorSpecies[i];
            writelogf("%-11.10s", mphase->speciesName(kk));
        }
        writelog("\n");

        for (size_t i = 0; i < nNonComponents; i++) {
            size_t k = i + nComponents;
            size_t kk = orderVectorSpecies[k];
            writelogf("   --- %3d (%3d) ", k, kk);
            writelogf("%-10.10s", mphase->speciesName(kk));
            writelogf("|%10.3g|", molNumBase[kk]);
            // Print the negative of formRxnMatrix[]; it's easier to interpret.
            for (size_t j = 0; j < nComponents; j++) {
                writelogf("     %6.2f", - formRxnMatrix[j + i * ne]);
            }
            writelog("\n");
        }
        writelog("   ");
        writeline('-', 77);
    }

    return nComponents;
} // basopt()
//----------------------------------------------------------------------------
Node* FoucaultPendulum::CreatePendulum ()
{
    VertexFormat* vformat = VertexFormat::Create(2,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_NORMAL, VertexFormat::AT_FLOAT3, 0);

    StandardMesh sm(vformat);

    // Pendulum rod.
    TriMesh* rod = sm.Cylinder(2, 8, 0.05f, 12.0f, true);
    rod->LocalTransform.SetTranslate(APoint(0.0f, 0.0f, 10.0f));

    // The pendulum bulb.  Start with a sphere (to get the connectivity) and
    // then adjust the vertices to form a pair of joined cones.
    TriMesh* bulb = sm.Sphere(16, 32, 2.0f);
    VertexBufferAccessor vba(bulb);
    int numVertices = vba.GetNumVertices();
    int i;
    for (i = 0; i < numVertices; ++i)
    {
        Vector3f& pos = vba.Position<Vector3f>(i);
        float r = Mathf::Sqrt(pos[0]*pos[0] + pos[1]*pos[1]);
        float z = pos[2] + 2.0f;
        if (z >= 2.0f)
        {
            z = 4.0f - r;
        }
        else
        {
            z = r;
        }
        pos[2] = z;
    }

    // Translate the pendulum joint to the origin for the purpose of
    // rotation.
    for (i = 0; i < numVertices; ++i)
    {
        vba.Position<Vector3f>(i)[2] -= 16.0f;
    }
    bulb->UpdateModelSpace(Visual::GU_NORMALS);

    vba.ApplyTo(rod);
    numVertices = vba.GetNumVertices();
    for (i = 0; i < numVertices; ++i)
    {
        vba.Position<Vector3f>(i)[2] -= 16.0f;
    }
    rod->UpdateModelSpace(Visual::GU_NORMALS);

    // Group the objects into a single subtree.
    mPendulum = new0 Node();
    mPendulum->AttachChild(rod);
    mPendulum->AttachChild(bulb);

    // Translate back to original model position.
    mPendulum->LocalTransform.SetTranslate(APoint(0.0f, 0.0f, 16.0f));

    // Add a material for coloring.
    Material* material = new0 Material();
    material->Emissive = Float4(0.0f, 0.0f, 0.0f, 1.0f);
    material->Ambient = Float4(0.1f, 0.1f, 0.1f, 1.0f);
    material->Diffuse = Float4(0.99607f, 0.83920f, 0.67059f, 1.0f);
    material->Specular = Float4(0.0f, 0.0f, 0.0f, 0.0f);

    // Use two lights to illuminate the pendulum.
    Light* light[2];
    light[0] = new0 Light(Light::LT_DIRECTIONAL);
    light[0]->Ambient = Float4(1.0f, 1.0f, 1.0f, 1.0f);
    light[0]->Diffuse = Float4(1.0f, 1.0f, 1.0f, 1.0f);
    light[0]->Specular = Float4(0.0f, 0.0f, 0.0f, 1.0f);
    light[0]->SetDirection(AVector(-1.0f, -1.0f, 0.0f));

    light[1] = new0 Light(Light::LT_DIRECTIONAL);
    light[1]->Ambient = Float4(1.0f, 1.0f, 1.0f, 1.0f);
    light[1]->Diffuse = Float4(1.0f, 1.0f, 1.0f, 1.0f);
    light[1]->Specular = Float4(0.0f, 0.0f, 0.0f, 1.0f);
    light[1]->SetDirection(AVector(+1.0f, -1.0f, 0.0f));

    // TODO:  The following code is used to piece together an effect with
    // two passes.  It is better to write an effect whose vertex shader
    // has constants corresponding to the two lights (for a single-pass
    // effect).
    LightDirPerVerEffect* effect = new0 LightDirPerVerEffect();
    VisualTechnique* technique = effect->GetTechnique(0);
    VisualPass* pass0 = technique->GetPass(0);
    VisualPass* pass1 = new0 VisualPass();
    pass1->SetVertexShader(pass0->GetVertexShader());
    pass1->SetPixelShader(pass0->GetPixelShader());
    AlphaState* astate = new0 AlphaState();
    astate->BlendEnabled = true;
    astate->SrcBlend = AlphaState::SBM_ONE;
    astate->DstBlend = AlphaState::DBM_ONE;
    pass1->SetAlphaState(astate);
    pass1->SetCullState(pass0->GetCullState());
    pass1->SetDepthState(pass0->GetDepthState());
    pass1->SetStencilState(pass0->GetStencilState());
    pass1->SetOffsetState(pass0->GetOffsetState());
    pass1->SetWireState(pass0->GetWireState());
    technique->InsertPass(pass1);

    VisualEffectInstance* instance = new0 VisualEffectInstance(effect, 0);
    for (int pass = 0; pass < 2; ++pass)
    {
        instance->SetVertexConstant(pass, 0,
            new0 PVWMatrixConstant());
        instance->SetVertexConstant(pass, 1,
            new0 CameraModelPositionConstant());
        instance->SetVertexConstant(pass, 2,
            new0 MaterialEmissiveConstant(material));
        instance->SetVertexConstant(pass, 3,
            new0 MaterialAmbientConstant(material));
        instance->SetVertexConstant(pass, 4,
            new0 MaterialDiffuseConstant(material));
        instance->SetVertexConstant(pass, 5,
            new0 MaterialSpecularConstant(material));
        instance->SetVertexConstant(pass, 6,
            new0 LightModelDVectorConstant(light[pass]));
        instance->SetVertexConstant(pass, 7,
            new0 LightAmbientConstant(light[pass]));
        instance->SetVertexConstant(pass, 8,
            new0 LightDiffuseConstant(light[pass]));
        instance->SetVertexConstant(pass, 9,
            new0 LightSpecularConstant(light[pass]));
        instance->SetVertexConstant(pass, 10,
            new0 LightAttenuationConstant(light[pass]));
    }

    rod->SetEffectInstance(instance);
    bulb->SetEffectInstance(instance);

    return mPendulum;
}
Example #14
0
NS_IMETHODIMP
nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
                            nsGUIEvent* aEvent,
                            nsEventStatus* aEventStatus)
{
  NS_ENSURE_ARG_POINTER(aEventStatus);
  if (nsEventStatus_eConsumeNoDefault == *aEventStatus) {
    return NS_OK;
  }

  nsWeakFrame weakFrame(this);
  bool doDefault = true;

  switch (aEvent->message) {
    case NS_MOUSE_BUTTON_DOWN: {
      if (aEvent->eventStructType == NS_MOUSE_EVENT &&
        static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton)
      {
        nsCOMPtr<nsIBaseWindow> window;
        nsIPresShell* presShell = aPresContext->GetPresShell();
        nsIContent* contentToResize =
          GetContentToResize(presShell, getter_AddRefs(window));
        if (contentToResize) {
          nsIFrame* frameToResize = contentToResize->GetPrimaryFrame();
          if (!frameToResize)
            break;

          // cache the content rectangle for the frame to resize
          // GetScreenRectInAppUnits returns the border box rectangle, so
          // adjust to get the desired content rectangle.
          nsRect rect = frameToResize->GetScreenRectInAppUnits();
          switch (frameToResize->GetStylePosition()->mBoxSizing) {
            case NS_STYLE_BOX_SIZING_CONTENT:
              rect.Deflate(frameToResize->GetUsedPadding());
            case NS_STYLE_BOX_SIZING_PADDING:
              rect.Deflate(frameToResize->GetUsedBorder());
            default:
              break;
          }

          mMouseDownRect = rect.ToNearestPixels(aPresContext->AppUnitsPerDevPixel());
          doDefault = false;
        }
        else {
          // If there is no window, then resizing isn't allowed.
          if (!window)
            break;

          doDefault = false;
            
          // ask the widget implementation to begin a resize drag if it can
          Direction direction = GetDirection();
          nsresult rv = aEvent->widget->BeginResizeDrag(aEvent,
                        direction.mHorizontal, direction.mVertical);
          // for native drags, don't set the fields below
          if (rv != NS_ERROR_NOT_IMPLEMENTED)
             break;
             
          // if there's no native resize support, we need to do window
          // resizing ourselves
          window->GetPositionAndSize(&mMouseDownRect.x, &mMouseDownRect.y,
                                     &mMouseDownRect.width, &mMouseDownRect.height);
        }

        // we're tracking
        mTrackingMouseMove = true;

        // remember current mouse coordinates
        mMouseDownPoint = aEvent->refPoint + aEvent->widget->WidgetToScreenOffset();

        nsIPresShell::SetCapturingContent(GetContent(), CAPTURE_IGNOREALLOWED);
      }
    }
    break;

  case NS_MOUSE_BUTTON_UP: {

    if (mTrackingMouseMove && aEvent->eventStructType == NS_MOUSE_EVENT &&
        static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton)
    {
      // we're done tracking.
      mTrackingMouseMove = false;

      nsIPresShell::SetCapturingContent(nsnull, 0);

      doDefault = false;
    }
  }
  break;

  case NS_MOUSE_MOVE: {
    if (mTrackingMouseMove)
    {
      nsCOMPtr<nsIBaseWindow> window;
      nsIPresShell* presShell = aPresContext->GetPresShell();
      nsCOMPtr<nsIContent> contentToResize =
        GetContentToResize(presShell, getter_AddRefs(window));

      // check if the returned content really is a menupopup
      nsMenuPopupFrame* menuPopupFrame = nsnull;
      if (contentToResize) {
        nsIFrame* frameToResize = contentToResize->GetPrimaryFrame();
        if (frameToResize && frameToResize->GetType() == nsGkAtoms::menuPopupFrame) {
          menuPopupFrame = static_cast<nsMenuPopupFrame *>(frameToResize);
        }
      }

      // both MouseMove and direction are negative when pointing to the
      // top and left, and positive when pointing to the bottom and right

      // retrieve the offset of the mousemove event relative to the mousedown.
      // The difference is how much the resize needs to be
      nsIntPoint screenPoint(aEvent->refPoint + aEvent->widget->WidgetToScreenOffset());
      nsIntPoint mouseMove(screenPoint - mMouseDownPoint);

      // Determine which direction to resize by checking the dir attribute.
      // For windows and menus, ensure that it can be resized in that direction.
      Direction direction = GetDirection();
      if (window || menuPopupFrame) {
        if (menuPopupFrame) {
          menuPopupFrame->CanAdjustEdges(
            (direction.mHorizontal == -1) ? NS_SIDE_LEFT : NS_SIDE_RIGHT,
            (direction.mVertical == -1) ? NS_SIDE_TOP : NS_SIDE_BOTTOM, mouseMove);
        }
      }
      else if (!contentToResize) {
        break; // don't do anything if there's nothing to resize
      }

      nsIntRect rect = mMouseDownRect;
      AdjustDimensions(&rect.x, &rect.width, mouseMove.x, direction.mHorizontal);
      AdjustDimensions(&rect.y, &rect.height, mouseMove.y, direction.mVertical);

      // Don't allow resizing a window or a popup past the edge of the screen,
      // so adjust the rectangle to fit within the available screen area.
      if (window) {
        nsCOMPtr<nsIScreen> screen;
        nsCOMPtr<nsIScreenManager> sm(do_GetService("@mozilla.org/gfx/screenmanager;1"));
        if (sm) {
          nsIntRect frameRect = GetScreenRect();
          sm->ScreenForRect(frameRect.x, frameRect.y, 1, 1, getter_AddRefs(screen));
          if (screen) {
            nsIntRect screenRect;
            screen->GetRect(&screenRect.x, &screenRect.y,
                            &screenRect.width, &screenRect.height);
            rect.IntersectRect(rect, screenRect);
          }
        }
      }
      else if (menuPopupFrame) {
        nsRect frameRect = menuPopupFrame->GetScreenRectInAppUnits();
        nsIFrame* rootFrame = aPresContext->PresShell()->FrameManager()->GetRootFrame();
        nsRect rootScreenRect = rootFrame->GetScreenRectInAppUnits();

        nsRect screenRect = menuPopupFrame->GetConstraintRect(frameRect, rootScreenRect);
        // round using ToInsidePixels as it's better to be a pixel too small
        // than be too large. If the popup is too large it could get flipped
        // to the opposite side of the anchor point while resizing.
        nsIntRect screenRectPixels = screenRect.ToInsidePixels(aPresContext->AppUnitsPerDevPixel());
        rect.IntersectRect(rect, screenRectPixels);
      }

      if (contentToResize) {
        // convert the rectangle into css pixels. When changing the size in a
        // direction, don't allow the new size to be less that the resizer's
        // size. This ensures that content isn't resized too small as to make
        // the resizer invisible.
        nsRect appUnitsRect = rect.ToAppUnits(aPresContext->AppUnitsPerDevPixel());
        if (appUnitsRect.width < mRect.width && mouseMove.x)
          appUnitsRect.width = mRect.width;
        if (appUnitsRect.height < mRect.height && mouseMove.y)
          appUnitsRect.height = mRect.height;
        nsIntRect cssRect = appUnitsRect.ToInsidePixels(nsPresContext::AppUnitsPerCSSPixel());

        nsIntRect oldRect;
        nsWeakFrame weakFrame(menuPopupFrame);
        if (menuPopupFrame) {
          nsCOMPtr<nsIWidget> widget = menuPopupFrame->GetWidget();
          if (widget)
            widget->GetScreenBounds(oldRect);

          // convert the new rectangle into outer window coordinates
          nsIntPoint clientOffset = widget->GetClientOffset();
          rect.x -= clientOffset.x; 
          rect.y -= clientOffset.y; 
        }

        SizeInfo sizeInfo, originalSizeInfo;
        sizeInfo.width.AppendInt(cssRect.width);
        sizeInfo.height.AppendInt(cssRect.height);
        ResizeContent(contentToResize, direction, sizeInfo, &originalSizeInfo);
        MaybePersistOriginalSize(contentToResize, originalSizeInfo);

        if (weakFrame.IsAlive() &&
            (oldRect.x != rect.x || oldRect.y != rect.y) &&
            (!menuPopupFrame->IsAnchored() ||
             menuPopupFrame->PopupLevel() != ePopupLevelParent)) {
          menuPopupFrame->MoveTo(rect.x, rect.y, true);
        }
      }
      else {
        window->SetPositionAndSize(rect.x, rect.y, rect.width, rect.height, true); // do the repaint.
      }

      doDefault = false;
    }
  }
  break;

  case NS_MOUSE_CLICK:
    if (NS_IS_MOUSE_LEFT_CLICK(aEvent))
    {
      MouseClicked(aPresContext, aEvent);
    }
    break;

  case NS_MOUSE_DOUBLECLICK:
    if (aEvent->eventStructType == NS_MOUSE_EVENT &&
        static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton)
    {
      nsCOMPtr<nsIBaseWindow> window;
      nsIPresShell* presShell = aPresContext->GetPresShell();
      nsIContent* contentToResize =
        GetContentToResize(presShell, getter_AddRefs(window));
      if (contentToResize) {
        nsIFrame* frameToResize = contentToResize->GetPrimaryFrame();
        if (frameToResize && frameToResize->GetType() == nsGkAtoms::menuPopupFrame)
          break; // Don't restore original sizing for menupopup frames until
                 // we handle screen constraints here. (Bug 357725)

        RestoreOriginalSize(contentToResize);
      }
    }
    break;
  }

  if (!doDefault)
    *aEventStatus = nsEventStatus_eConsumeNoDefault;

  if (doDefault && weakFrame.IsAlive())
    return nsTitleBarFrame::HandleEvent(aPresContext, aEvent, aEventStatus);

  return NS_OK;
}
//----------------------------------------------------------------------------
Node* RoughPlaneSolidBox::CreateBox ()
{
    mBox = new0 Node();

    float xExtent = (float)mModule.XLocExt;
    float yExtent = (float)mModule.YLocExt;
    float zExtent = (float)mModule.ZLocExt;

    VertexFormat* vformat = VertexFormat::Create(2,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_COLOR, VertexFormat::AT_FLOAT3, 0);

    StandardMesh sm(vformat);
    VertexColor3Effect* effect = new0 VertexColor3Effect();
    VertexBufferAccessor vba;
    Transform transform;
    TriMesh* face;
    int i;

    // +z face
    Float3 red(1.0f, 0.0f, 0.0f);
    transform.SetTranslate(APoint(0.0f, 0.0f, zExtent));
    sm.SetTransform(transform);
    face = sm.Rectangle(2, 2, xExtent, yExtent);
    vba.ApplyTo(face);
    for (i = 0; i < 4; ++i)
    {
        vba.Color<Float3>(0, 0) = red;
        vba.Color<Float3>(0, 1) = red;
        vba.Color<Float3>(0, 2) = red;
        vba.Color<Float3>(0, 3) = red;
    }
    face->SetEffectInstance(effect->CreateInstance());
    mBox->AttachChild(face);

    // -z face
    Float3 darkRed(0.5f, 0.0f, 0.0f);
    transform.SetTranslate(APoint(0.0f, 0.0f, -zExtent));
    transform.SetRotate(HMatrix(AVector::UNIT_Y, AVector::UNIT_X,
        -AVector::UNIT_Z, APoint::ORIGIN, true));
    sm.SetTransform(transform);
    face = sm.Rectangle(2, 2, yExtent, xExtent);
    vba.ApplyTo(face);
    for (i = 0; i < 4; ++i)
    {
        vba.Color<Float3>(0, 0) = darkRed;
        vba.Color<Float3>(0, 1) = darkRed;
        vba.Color<Float3>(0, 2) = darkRed;
        vba.Color<Float3>(0, 3) = darkRed;
    }
    face->SetEffectInstance(effect->CreateInstance());
    mBox->AttachChild(face);

    // +y face
    Float3 green(0.0f, 1.0f, 0.0f);
    transform.SetTranslate(APoint(0.0f, yExtent, 0.0f));
    transform.SetRotate(HMatrix(AVector::UNIT_Z, AVector::UNIT_X,
        AVector::UNIT_Y, APoint::ORIGIN, true));
    sm.SetTransform(transform);
    face = sm.Rectangle(2, 2, zExtent, xExtent);
    vba.ApplyTo(face);
    for (i = 0; i < 4; ++i)
    {
        vba.Color<Float3>(0, 0) = green;
        vba.Color<Float3>(0, 1) = green;
        vba.Color<Float3>(0, 2) = green;
        vba.Color<Float3>(0, 3) = green;
    }
    face->SetEffectInstance(effect->CreateInstance());
    mBox->AttachChild(face);

    // -y face
    Float3 darkGreen(0.0f, 1.0f, 0.0f);
    transform.SetTranslate(APoint(0.0f, -yExtent, 0.0f));
    transform.SetRotate(HMatrix(AVector::UNIT_X, AVector::UNIT_Z,
        -AVector::UNIT_Y, APoint::ORIGIN, true));
    sm.SetTransform(transform);
    face = sm.Rectangle(2, 2, xExtent, zExtent);
    vba.ApplyTo(face);
    for (i = 0; i < 4; ++i)
    {
        vba.Color<Float3>(0, 0) = darkGreen;
        vba.Color<Float3>(0, 1) = darkGreen;
        vba.Color<Float3>(0, 2) = darkGreen;
        vba.Color<Float3>(0, 3) = darkGreen;
    }
    face->SetEffectInstance(effect->CreateInstance());
    mBox->AttachChild(face);

    // +x face
    Float3 blue(0.0f, 0.0f, 1.0f);
    transform.SetTranslate(APoint(xExtent, 0.0f, 0.0f));
    transform.SetRotate(HMatrix(AVector::UNIT_Y, AVector::UNIT_Z,
        AVector::UNIT_X, APoint::ORIGIN, true));
    sm.SetTransform(transform);
    face = sm.Rectangle(2, 2, yExtent, zExtent);
    vba.ApplyTo(face);
    for (i = 0; i < 4; ++i)
    {
        vba.Color<Float3>(0, 0) = blue;
        vba.Color<Float3>(0, 1) = blue;
        vba.Color<Float3>(0, 2) = blue;
        vba.Color<Float3>(0, 3) = blue;
    }
    face->SetEffectInstance(effect->CreateInstance());
    mBox->AttachChild(face);

    // -x face
    Float3 darkBlue(0.0f, 0.0f, 1.0f);
    transform.SetTranslate(APoint(-xExtent, 0.0f, 0.0f));
    transform.SetRotate(HMatrix(AVector::UNIT_Z, AVector::UNIT_Y,
        -AVector::UNIT_X, APoint::ORIGIN, true));
    sm.SetTransform(transform);
    face = sm.Rectangle(2, 2, zExtent, yExtent);
    vba.ApplyTo(face);
    for (i = 0; i < 4; ++i)
    {
        vba.Color<Float3>(0, 0) = darkBlue;
        vba.Color<Float3>(0, 1) = darkBlue;
        vba.Color<Float3>(0, 2) = darkBlue;
        vba.Color<Float3>(0, 3) = darkBlue;
    }
    face->SetEffectInstance(effect->CreateInstance());
    mBox->AttachChild(face);

    MoveBox();
    return mBox;
}
Example #16
0
void TestAuthenticatedSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters)
{
	std::string type = GetRequiredDatum(v, "AlgorithmType");
	std::string name = GetRequiredDatum(v, "Name");
	std::string test = GetRequiredDatum(v, "Test");
	std::string key = GetDecodedDatum(v, "Key");

	std::string plaintext = GetOptionalDecodedDatum(v, "Plaintext");
	std::string ciphertext = GetOptionalDecodedDatum(v, "Ciphertext");
	std::string header = GetOptionalDecodedDatum(v, "Header");
	std::string footer = GetOptionalDecodedDatum(v, "Footer");
	std::string mac = GetOptionalDecodedDatum(v, "MAC");

	TestDataNameValuePairs testDataPairs(v);
	CombinedNameValuePairs pairs(overrideParameters, testDataPairs);

	if (test == "Encrypt" || test == "EncryptXorDigest" || test == "NotVerify")
	{
		member_ptr<AuthenticatedSymmetricCipher> asc1, asc2;
		asc1.reset(ObjectFactoryRegistry<AuthenticatedSymmetricCipher, ENCRYPTION>::Registry().CreateObject(name.c_str()));
		asc2.reset(ObjectFactoryRegistry<AuthenticatedSymmetricCipher, DECRYPTION>::Registry().CreateObject(name.c_str()));
		asc1->SetKey((const byte *)key.data(), key.size(), pairs);
		asc2->SetKey((const byte *)key.data(), key.size(), pairs);

		std::string encrypted, decrypted;
		AuthenticatedEncryptionFilter ef(*asc1, new StringSink(encrypted));
		bool macAtBegin = !mac.empty() && !GlobalRNG().GenerateBit();	// test both ways randomly
		AuthenticatedDecryptionFilter df(*asc2, new StringSink(decrypted), macAtBegin ? AuthenticatedDecryptionFilter::MAC_AT_BEGIN : 0);

		if (asc1->NeedsPrespecifiedDataLengths())
		{
			asc1->SpecifyDataLengths(header.size(), plaintext.size(), footer.size());
			asc2->SpecifyDataLengths(header.size(), plaintext.size(), footer.size());
		}

		StringStore sh(header), sp(plaintext), sc(ciphertext), sf(footer), sm(mac);

		if (macAtBegin)
			RandomizedTransfer(sm, df, true);
		sh.CopyTo(df, LWORD_MAX, AAD_CHANNEL);
		RandomizedTransfer(sc, df, true);
		sf.CopyTo(df, LWORD_MAX, AAD_CHANNEL);
		if (!macAtBegin)
			RandomizedTransfer(sm, df, true);
		df.MessageEnd();

		RandomizedTransfer(sh, ef, true, AAD_CHANNEL);
		RandomizedTransfer(sp, ef, true);
		RandomizedTransfer(sf, ef, true, AAD_CHANNEL);
		ef.MessageEnd();

		if (test == "Encrypt" && encrypted != ciphertext+mac)
		{
			std::cout << "incorrectly encrypted: ";
			StringSource xx(encrypted, false, new HexEncoder(new FileSink(std::cout)));
			xx.Pump(2048); xx.Flush(false);
			std::cout << "\n";
			SignalTestFailure();
		}
		if (test == "Encrypt" && decrypted != plaintext)
		{
			std::cout << "incorrectly decrypted: ";
			StringSource xx(decrypted, false, new HexEncoder(new FileSink(std::cout)));
			xx.Pump(256); xx.Flush(false);
			std::cout << "\n";
			SignalTestFailure();
		}

		if (ciphertext.size()+mac.size()-plaintext.size() != asc1->DigestSize())
		{
			std::cout << "bad MAC size\n";
			SignalTestFailure();
		}
		if (df.GetLastResult() != (test == "Encrypt"))
		{
			std::cout << "MAC incorrectly verified\n";
			SignalTestFailure();
		}
	}
	else
	{
		std::cout << "unexpected test name\n";
		SignalTestError();
	}
}
Example #17
0
  int VCS_SOLVE::vcs_rank(const double * awtmp, size_t numSpecies,  const double matrix[], size_t numElemConstraints,
			  std::vector<size_t> &compRes, std::vector<size_t>& elemComp, int * const usedZeroedSpecies) const 
  {

    int    lindep;
    size_t j, k, jl, i, l, ml;
    int numComponents = 0;

    compRes.clear();
    elemComp.clear();
    vector<double> sm(numElemConstraints*numSpecies);
    vector<double> sa(numSpecies);
    vector<double> ss(numSpecies);

    double test = -0.2512345E298;
#ifdef DEBUG_MODE
    if (m_debug_print_lvl >= 2) {
      plogf("   "); for(i=0; i<77; i++) plogf("-"); plogf("\n");
      plogf("   --- Subroutine vcs_rank called to ");
      plogf("calculate the rank and independent rows /colums of the following matrix\n");     
      if (m_debug_print_lvl >= 5) {
	plogf("   ---     Species |  ");
	for (j = 0; j < numElemConstraints; j++) {
	  plogf(" "); 
	  plogf("   %3d  ", j);
	}
	plogf("\n");
	plogf("   ---     -----------");
	for (j = 0; j < numElemConstraints; j++) {
	  plogf("---------");
	}
	plogf("\n");
	for (k = 0; k < numSpecies; k++) {
	  plogf("   --- ");
	  plogf("  %3d  ", k);
	  plogf("     |");
	  for (j = 0; j < numElemConstraints; j++) {
	    plogf(" %8.2g", matrix[j*numSpecies + k]);
	  }
	  plogf("\n");
	}
	plogf("   ---");
	plogendl();
      }
    }
#endif
   
    /*
     *  Calculate the maximum value of the number of components possible
     *     It's equal to the minimum of the number of elements and the
     *     number of total species.
     */
    int ncTrial = std::min(numElemConstraints, numSpecies);
    numComponents = ncTrial;
    *usedZeroedSpecies = false;

    /* 
     *     Use a temporary work array for the mole numbers, aw[] 
     */
    std::vector<double> aw(numSpecies);
    for (j = 0; j < numSpecies; j++) {
      aw[j] = awtmp[j];
    }

    int jr = -1;
    /*
     *   Top of a loop of some sort based on the index JR. JR is the 
     *   current number of component species found. 
     */
    do {
      ++jr;
      /* - Top of another loop point based on finding a linearly */
      /* - independent species */
      do {
	/*
	 *    Search the remaining part of the mole number vector, AW, 
	 *    for the largest remaining species. Return its identity in K. 
	 *    The first search criteria is always the largest positive
	 *    magnitude of the mole number.
	 */
	k = basisOptMax1(VCS_DATA_PTR(aw), numSpecies);

	if ((aw[k] != test) && fabs(aw[k]) == 0.0) {
	  *usedZeroedSpecies = true;
	}

    
	if (aw[k] == test) {
	  numComponents = jr;

	  goto L_CLEANUP;
	}
	/*
	 *  Assign a small negative number to the component that we have
	 *  just found, in order to take it out of further consideration.
	 */
	aw[k] = test;
	/* *********************************************************** */
	/* **** CHECK LINEAR INDEPENDENCE WITH PREVIOUS SPECIES ****** */
	/* *********************************************************** */
	/*    
	 *          Modified Gram-Schmidt Method, p. 202 Dalquist 
	 *          QR factorization of a matrix without row pivoting. 
	 */
	jl = jr;
	for (j = 0; j < numElemConstraints; ++j) {
	  sm[j + jr*numElemConstraints] = matrix[j*numSpecies + k];
	}
	if (jl > 0) {
	  /*
	   *         Compute the coefficients of JA column of the 
	   *         the upper triangular R matrix, SS(J) = R_J_JR 
	   *         (this is slightly different than Dalquist) 
	   *         R_JA_JA = 1 
	   */
	  for (j = 0; j < jl; ++j) {
	    ss[j] = 0.0;
	    for (i = 0; i < numElemConstraints; ++i) {
	      ss[j] += sm[i + jr* numElemConstraints] * sm[i + j* numElemConstraints];
	    }
	    ss[j] /= sa[j];
	  }
	  /* 
	   *     Now make the new column, (*,JR), orthogonal to the 
	   *     previous columns
	   */
	  for (j = 0; j < jl; ++j) {
	    for (l = 0; l < numElemConstraints; ++l) {
	      sm[l + jr*numElemConstraints] -= ss[j] * sm[l + j*numElemConstraints];
	    }
	  }
	}
	/*
	 *        Find the new length of the new column in Q. 
	 *        It will be used in the denominator in future row calcs. 
	 */
	sa[jr] = 0.0;
	for (ml = 0; ml < numElemConstraints; ++ml) {
	  sa[jr] += SQUARE(sm[ml + jr * numElemConstraints]);
	}
	/* **************************************************** */
	/* **** IF NORM OF NEW ROW  .LT. 1E-3 REJECT ********** */
	/* **************************************************** */
	if (sa[jr] < 1.0e-6)  lindep = true;
	else                  lindep = false;
      } while(lindep);
      /* ****************************************** */
      /* **** REARRANGE THE DATA ****************** */
      /* ****************************************** */
      compRes.push_back(k);
      elemComp.push_back(jr);
 
    } while (jr < (ncTrial-1));

  L_CLEANUP: ;
 
    if (numComponents  == ncTrial && numElemConstraints == numSpecies) {
      return numComponents;
    }
  

    int  numComponentsR = numComponents;

    ss.resize(numElemConstraints);
    sa.resize(numElemConstraints);
 
 
    elemComp.clear();
  
    aw.resize(numElemConstraints);
    for (j = 0; j < numSpecies; j++) {
      aw[j] = 1.0;
    }

    jr = -1;

    do {
      ++jr;

      do {

	k = basisOptMax1(VCS_DATA_PTR(aw), numElemConstraints);
    
	if (aw[k] == test) {
	  numComponents = jr;
	  goto LE_CLEANUP;
	}
	aw[k] = test;


	jl = jr;
	for (j = 0; j < numSpecies; ++j) {
	  sm[j + jr*numSpecies] = matrix[k*numSpecies + j];
	}
	if (jl > 0) {

	  for (j = 0; j < jl; ++j) {
	    ss[j] = 0.0;
	    for (i = 0; i < numSpecies; ++i) {
	      ss[j] += sm[i + jr* numSpecies] * sm[i + j* numSpecies];
	    }
	    ss[j] /= sa[j];
	  }

	  for (j = 0; j < jl; ++j) {
	    for (l = 0; l < numSpecies; ++l) {
	      sm[l + jr*numSpecies] -= ss[j] * sm[l + j*numSpecies];
	    }
	  }
	}

	sa[jr] = 0.0;
	for (ml = 0; ml < numSpecies; ++ml) {
	  sa[jr] += SQUARE(sm[ml + jr * numSpecies]);
	}

	if (sa[jr] < 1.0e-6)  lindep = true;
	else                  lindep = false;
      } while(lindep);
  
      elemComp.push_back(k);

    } while (jr < (ncTrial-1));
    numComponents = jr;
  LE_CLEANUP: ;

#ifdef DEBUG_MODE
    if (m_debug_print_lvl >= 2) {
      plogf("   --- vcs_rank found rank %d\n", numComponents);
      if (m_debug_print_lvl >= 5) {
	if (compRes.size() == elemComp.size()) {
	  printf("   ---       compRes    elemComp\n");
	  for (int i = 0; i < (int) compRes.size(); i++) {
	    printf("   ---          %d          %d \n", (int) compRes[i], (int) elemComp[i]);
	  }
	} else {
	  for (int i = 0; i < (int) compRes.size(); i++) {
	    printf("   ---   compRes[%d] =   %d \n", (int) i, (int) compRes[i]);
	  }
	  for (int i = 0; i < (int) elemComp.size(); i++) {
	    printf("   ---   elemComp[%d] =   %d \n", (int) i, (int) elemComp[i]);
	  }
	} 
      }
    }
#endif

    if (numComponentsR != numComponents) {
      printf("vcs_rank ERROR: number of components are different: %d %d\n", numComponentsR,  numComponents);
      throw Cantera::CanteraError("vcs_rank ERROR:",
			 " logical inconsistency");
      exit(-1);
    }
    return numComponents;
  }
Example #18
0
int main(int argc, char *argv[])
{
  b_po::variables_map vmgeneral;
  parsecommandlineExtract(argc, argv, vmgeneral);
  ralab::findmf::apps::Params aparam;
  analysisParameters(aparam,vmgeneral);
  int res = 0;
  boost::filesystem::path p1,p2;

  {
    // LOG(INFO)  << "i::::" << i << std::endl;
    p1 = ralab::findmf::createOutputs(aparam.infile,"");
    p2 = ralab::findmf::createOutputs(aparam.infile,"filtered");

    if( !boost::filesystem::exists(aparam.infile) )
    {
      return -1;
    }

    ralab::findmf::datastruct::MSFileInfoPtr sip;
    try{
      ralab::findmf::SwathPropertiesReader swathPropReader(aparam.infile);
      sip = swathPropReader.getSwathInfo();
    } catch(std::exception & e){
      std::cerr << "infile : " << aparam.infile << std::endl;
      std::cerr  << "can't open file: " << e.what() << std::endl;
      return 0;
    }

    double ppm = aparam.ppm;
    pwiz::msdata::MSDataPtr msdataptr = pwiz::msdata::MSDataPtr(new pwiz::msdata::MSDataFile(aparam.infile));
    ralab::findmf::LCMSImageReader sm(msdataptr, sip, ppm, aparam.rt2sum_ );
    ralab::findmf::datastruct::LCMSImage mp;
    sm.getMap( 0 , aparam.minmass, aparam.maxmass, mp);
    // LOG(INFO) << " " << mp.getMZsize() << " " << mp.getRTsize();

    ralab::findmf::datastruct::LCMSImage mp2( mp );
    {
      ralab::findmf::LCMSImageFilterGauss imgf;
      // imgf.filterMap( mp2.getImageMap().getMap() , aparam.mzpixelwidth , aparam.rtpixelwidth, aparam.mzscale, aparam.rtscale);

      imgf.filter( mp2.getImageMap().getMap() , aparam.mzpixelwidth , aparam.rtpixelwidth, aparam.mzscale, aparam.rtscale);
      mp2.getImageMap().updateImageRange();
      std::cout << mp2.getImageMap().getImageMin() << std::endl;
      //imgf.filterMap();
    }

    // feature finding
    ralab::findmf::FeatureFinderLocalMax ff;
    ff.findFeature( mp2.getImageMap().getMap() , aparam.minintensity );

    ralab::findmf::datastruct::FeaturesMap map;
    map.setMapDescription(mp2.getMapDescription());
    ralab::findmf::ComputeFeatureStatistics cfs;
    cfs.extractFeatures(map,mp2.getImageMap().getMap(),ff.getLabels());

    //this writes the accessor....
   cfs.writeFeatures(aparam.outdir , p1.stem().string() );

    ralab::FeaturesMapPrinter fp;
    fp.writeFeatures(aparam.outdir , p1.stem().string(), map);

    ralab::MultiArrayVisSegments<int> mavL( ff.getLabels() );
    //write filtered data into mzML file

    //TODO check why this isn't working
    sm.write( p2.string() , mp2 );

    if(1){
      QApplication app(argc, argv);
      ralab::TwoPaneledImageWidget tpi;
      ralab::MultiArrayVisLog<float> adapt2( mp2.getImageMap().getMap() );

      ralab::MultiArrayVisAsinh<float> adapt1( mp2.getImageMap().getMap() );
      ralab::MultiArrayVisLog<float> adapt0( mp.getImageMap().getMap() );

      tpi.setTopMap(&mavL);
      //tpi.setBottomMap(&adapt0);
      tpi.setBottomMap(&adapt0);

      tpi.show();
      res = app.exec();
    }
  }
  return res;
}
Example #19
0
// We're reading in way too many entities here to mess around with creating sub-objects and
// seeking around in them, so we're using the json streaming API.
submap *mapbuffer::unserialize_submaps( const tripoint &p )
{
    // Map the tripoint to the submap quad that stores it.
    const tripoint om_addr = overmapbuffer::sm_to_omt_copy( p );
    const tripoint segment_addr = overmapbuffer::omt_to_seg_copy( om_addr );
    std::stringstream quad_path;
    quad_path << world_generator->active_world->world_path << "/maps/" <<
        segment_addr.x << "." << segment_addr.y << "." << segment_addr.z << "/" <<
        om_addr.x << "." << om_addr.y << "." << om_addr.z << ".map";

    std::ifstream fin( quad_path.str().c_str() );
    if( !fin.is_open() ) {
        // If it doesn't exist, trigger generating it.
        return NULL;
    }

    JsonIn jsin( fin );
    jsin.start_array();
    while( !jsin.end_array() ) {
        std::unique_ptr<submap> sm(new submap());
        tripoint submap_coordinates;
        jsin.start_object();
        while( !jsin.end_object() ) {
            std::string submap_member_name = jsin.get_member_name();
            if( submap_member_name == "version" ) {
                // We aren't using the version number for anything at the moment.
                jsin.skip_value();
            } else if( submap_member_name == "coordinates" ) {
                jsin.start_array();
                int locx = jsin.get_int();
                int locy = jsin.get_int();
                int locz = jsin.get_int();
                jsin.end_array();
                submap_coordinates = tripoint( locx, locy, locz );
            } else if( submap_member_name == "turn_last_touched" ) {
                sm->turn_last_touched = jsin.get_int();
            } else if( submap_member_name == "temperature" ) {
                sm->temperature = jsin.get_int();
            } else if( submap_member_name == "terrain" ) {
                // TODO: try block around this to error out if we come up short?
                jsin.start_array();
                for( int j = 0; j < SEEY; j++ ) {
                    for( int i = 0; i < SEEX; i++ ) {
                        sm->ter[i][j] = termap[ jsin.get_string() ].loadid;
                    }
                }
                jsin.end_array();
            } else if( submap_member_name == "radiation" ) {
                int rad_cell = 0;
                jsin.start_array();
                while( !jsin.end_array() ) {
                    int rad_strength = jsin.get_int();
                    int rad_num = jsin.get_int();
                    for( int i = 0; i < rad_num; ++i ) {
                        // A little array trick here, assign to it as a 1D array.
                        // If it's not in bounds we're kinda hosed anyway.
                        sm->set_radiation(0, rad_cell, rad_strength);
                        rad_cell++;
                    }
                }
            } else if( submap_member_name == "furniture" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    jsin.start_array();
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    sm->frn[i][j] = furnmap[ jsin.get_string() ].loadid;
                    jsin.end_array();
                }
            } else if( submap_member_name == "items" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    jsin.start_array();
                    while( !jsin.end_array() ) {
                        item tmp;
                        jsin.read( tmp );
                        sm->itm[i][j].push_back( tmp );
                    }
                }
            } else if( submap_member_name == "traps" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    jsin.start_array();
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    sm->trp[i][j] = trapmap[ jsin.get_string() ];
                    jsin.end_array();
                }
            } else if( submap_member_name == "fields" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    // Coordinates loop
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    jsin.start_array();
                    while( !jsin.end_array() ) {
                        int type = jsin.get_int();
                        int density = jsin.get_int();
                        int age = jsin.get_int();
                        if (sm->fld[i][j].findField(field_id(type)) == NULL) {
                            sm->field_count++;
                        }
                        sm->fld[i][j].addField(field_id(type), density, age);
                    }
                }
            } else if( submap_member_name == "griffiti" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    jsin.start_array();
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    sm->set_graffiti(i, j, graffiti( jsin.get_string() ));
                    jsin.end_array();
                }
            } else if(submap_member_name == "cosmetics") {
                jsin.start_array();
                while (!jsin.end_array()) {
                    jsin.start_array();
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    jsin.read(sm->cosmetics[i][j]);
                    jsin.end_array();
                }
            } else if( submap_member_name == "spawns" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    jsin.start_array();
                    std::string type = jsin.get_string();
                    int count = jsin.get_int();
                    int i = jsin.get_int();
                    int j = jsin.get_int();
                    int faction_id = jsin.get_int();
                    int mission_id = jsin.get_int();
                    bool friendly = jsin.get_bool();
                    std::string name = jsin.get_string();
                    jsin.end_array();
                    spawn_point tmp( type, count, i, j, faction_id, mission_id, friendly, name );
                    sm->spawns.push_back( tmp );
                }
            } else if( submap_member_name == "vehicles" ) {
                jsin.start_array();
                while( !jsin.end_array() ) {
                    vehicle *tmp = new vehicle();
                    jsin.read( *tmp );
                    sm->vehicles.push_back( tmp );
                }
            } else if( submap_member_name == "computers" ) {
                std::string computer_data = jsin.get_string();
                sm->comp.load_data( computer_data );
            } else if( submap_member_name == "camp" ) {
                std::string camp_data = jsin.get_string();
                sm->camp.load_data( camp_data );
            } else {
                jsin.skip_value();
            }
        }
        if( !add_submap( submap_coordinates, sm ) ) {
            debugmsg( "submap %d,%d,%d was alread loaded", submap_coordinates.x, submap_coordinates.y, submap_coordinates.z );
        }
    }
    if( submaps.count( p ) == 0 ) {
        debugmsg("file %s did not contain the expected submap %d,%d,%d", quad_path.str().c_str(), p.x, p.y, p.z);
        return NULL;
    }
    return submaps[ p ];
}
NS_IMETHODIMP
nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
                            nsGUIEvent* aEvent,
                            nsEventStatus* aEventStatus)
{
  NS_ENSURE_ARG_POINTER(aEventStatus);
  if (nsEventStatus_eConsumeNoDefault == *aEventStatus) {
    return NS_OK;
  }

  nsWeakFrame weakFrame(this);
  PRBool doDefault = PR_TRUE;

  switch (aEvent->message) {
    case NS_MOUSE_BUTTON_DOWN: {
      if (aEvent->eventStructType == NS_MOUSE_EVENT &&
        static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton)
      {
        nsCOMPtr<nsIBaseWindow> window;
        nsIPresShell* presShell = aPresContext->GetPresShell();
        nsIContent* contentToResize =
          GetContentToResize(presShell, getter_AddRefs(window));
        if (contentToResize) {
          nsIFrame* frameToResize = contentToResize->GetPrimaryFrame();
          if (!frameToResize)
            break;

          mMouseDownRect = frameToResize->GetScreenRect();
        }
        else {
          // ask the widget implementation to begin a resize drag if it can
          Direction direction = GetDirection();
          nsresult rv = aEvent->widget->BeginResizeDrag(aEvent,
                        direction.mHorizontal, direction.mVertical);
          if (rv == NS_ERROR_NOT_IMPLEMENTED && window) {
            // if there's no native resize support, we need to do window
            // resizing ourselves
            window->GetPositionAndSize(&mMouseDownRect.x, &mMouseDownRect.y,
                                       &mMouseDownRect.width, &mMouseDownRect.height);
          }
          else {
            // for native drags, don't set the fields below
            doDefault = PR_FALSE;
            break;
          }
        }

        // we're tracking
        mTrackingMouseMove = PR_TRUE;

        // remember current mouse coordinates
        mMouseDownPoint = aEvent->refPoint + aEvent->widget->WidgetToScreenOffset();

        nsIPresShell::SetCapturingContent(GetContent(), CAPTURE_IGNOREALLOWED);

        doDefault = PR_FALSE;
      }
    }
    break;

  case NS_MOUSE_BUTTON_UP: {

    if (mTrackingMouseMove && aEvent->eventStructType == NS_MOUSE_EVENT &&
        static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton)
    {
      // we're done tracking.
      mTrackingMouseMove = PR_FALSE;

      nsIPresShell::SetCapturingContent(nsnull, 0);

      doDefault = PR_FALSE;
    }
  }
  break;

  case NS_MOUSE_MOVE: {
    if (mTrackingMouseMove)
    {
      nsCOMPtr<nsIBaseWindow> window;
      nsIPresShell* presShell = aPresContext->GetPresShell();
      nsCOMPtr<nsIContent> contentToResize =
        GetContentToResize(presShell, getter_AddRefs(window));

      // check if the returned content really is a menupopup
      nsMenuPopupFrame* menuPopupFrame = nsnull;
      if (contentToResize) {
        nsIFrame* frameToResize = contentToResize->GetPrimaryFrame();
        if (frameToResize && frameToResize->GetType() == nsGkAtoms::menuPopupFrame) {
          menuPopupFrame = static_cast<nsMenuPopupFrame *>(frameToResize);
        }
      }

      // both MouseMove and direction are negative when pointing to the
      // top and left, and positive when pointing to the bottom and right

      // retrieve the offset of the mousemove event relative to the mousedown.
      // The difference is how much the resize needs to be
      nsIntPoint screenPoint(aEvent->refPoint + aEvent->widget->WidgetToScreenOffset());
      nsIntPoint mouseMove(screenPoint - mMouseDownPoint);

      // what direction should we go in? For content resizing, always use
      // 'bottomend'. For other windows, check the dir attribute.
      Direction direction;
      if (window || menuPopupFrame) {
        direction = GetDirection();
        if (menuPopupFrame) {
          menuPopupFrame->CanAdjustEdges(
            (direction.mHorizontal == -1) ? NS_SIDE_LEFT : NS_SIDE_RIGHT,
            (direction.mVertical == -1) ? NS_SIDE_TOP : NS_SIDE_BOTTOM, mouseMove);
        }
      }
      else if (contentToResize) {
        direction.mHorizontal =
          GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL ? -1 : 1;
        direction.mVertical = 1;
      }
      else {
        break; // don't do anything if there's nothing to resize
      }

      nsIntRect rect = mMouseDownRect;
      AdjustDimensions(&rect.x, &rect.width, mouseMove.x, direction.mHorizontal);
      AdjustDimensions(&rect.y, &rect.height, mouseMove.y, direction.mVertical);

      // Don't allow resizing a window or a popup past the edge of the screen,
      // so adjust the rectangle to fit within the available screen area.
      if (window) {
        nsCOMPtr<nsIScreen> screen;
        nsCOMPtr<nsIScreenManager> sm(do_GetService("@mozilla.org/gfx/screenmanager;1"));
        if (sm) {
          nsIntRect frameRect = GetScreenRect();
          sm->ScreenForRect(frameRect.x, frameRect.y, 1, 1, getter_AddRefs(screen));
          if (screen) {
            nsIntRect screenRect;
            screen->GetRect(&screenRect.x, &screenRect.y,
                            &screenRect.width, &screenRect.height);
            rect.IntersectRect(rect, screenRect);
          }
        }
      }
      else if (menuPopupFrame) {
        nsPoint framePoint = menuPopupFrame->GetScreenRectInAppUnits().TopLeft();
        nsIFrame* rootFrame = aPresContext->PresShell()->FrameManager()->GetRootFrame();
        nsRect rootScreenRect = rootFrame->GetScreenRectInAppUnits();

        nsRect screenRect = menuPopupFrame->GetConstraintRect(framePoint, rootScreenRect);
        // round using ToInsidePixels as it's better to be a pixel too small
        // than be too large. If the popup is too large it could get flipped
        // to the opposite side of the anchor point while resizing.
        nsIntRect screenRectPixels = screenRect.ToInsidePixels(aPresContext->AppUnitsPerDevPixel());
        rect.IntersectRect(rect, screenRectPixels);
      }

      if (contentToResize) {
        nsIntRect cssRect =
          rect.ToAppUnits(aPresContext->AppUnitsPerDevPixel())
              .ToInsidePixels(nsPresContext::AppUnitsPerCSSPixel());

        nsAutoString widthstr, heightstr;
        widthstr.AppendInt(cssRect.width);
        heightstr.AppendInt(cssRect.height);

        // for XUL elements, just set the width and height attributes. For
        // other elements, set style.width and style.height
        if (contentToResize->IsXUL()) {
          nsIntRect oldRect;
          nsWeakFrame weakFrame(menuPopupFrame);
          if (menuPopupFrame) {
            nsCOMPtr<nsIWidget> widget;
            menuPopupFrame->GetWidget(getter_AddRefs(widget));
            if (widget)
              widget->GetScreenBounds(oldRect);
          }

          contentToResize->SetAttr(kNameSpaceID_None, nsGkAtoms::width, widthstr, PR_TRUE);
          contentToResize->SetAttr(kNameSpaceID_None, nsGkAtoms::height, heightstr, PR_TRUE);

          if (weakFrame.IsAlive() &&
              (oldRect.x != rect.x || oldRect.y != rect.y)) {
            // XXX This might go very wrong, since menu popups may add
            // offsets (e.g. from margins) to this position, so the popup's
            // widget won't end up at the desired position.
            menuPopupFrame->MoveTo(rect.x, rect.y, PR_TRUE);
          }
        }
        else {
          nsCOMPtr<nsIDOMElementCSSInlineStyle> inlineStyleContent =
            do_QueryInterface(contentToResize);
          if (inlineStyleContent) {
            widthstr += NS_LITERAL_STRING("px");
            heightstr += NS_LITERAL_STRING("px");

            nsCOMPtr<nsIDOMCSSStyleDeclaration> decl;
            inlineStyleContent->GetStyle(getter_AddRefs(decl));
            decl->SetProperty(NS_LITERAL_STRING("width"), widthstr, EmptyString());
            decl->SetProperty(NS_LITERAL_STRING("height"), heightstr, EmptyString());
          }
        }
      }
      else {
        window->SetPositionAndSize(rect.x, rect.y, rect.width, rect.height, PR_TRUE); // do the repaint.
      }

      doDefault = PR_FALSE;
    }
  }
  break;

  case NS_MOUSE_CLICK:
    if (NS_IS_MOUSE_LEFT_CLICK(aEvent))
    {
      MouseClicked(aPresContext, aEvent);
    }
    break;
  }

  if (!doDefault)
    *aEventStatus = nsEventStatus_eConsumeNoDefault;

  if (doDefault && weakFrame.IsAlive())
    return nsTitleBarFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
  else
    return NS_OK;
}
Example #21
0
void WBSDStartPage::gotMessage(Message aMsg){
    if(IsBakMode) return;
    float vermcb;
    Message::qtype atype=aMsg.getType();
    switch (atype){
        case (Message::METADATA_ANSWER):
            {
                StringMessage sm(aMsg);
                QList <QString> al=sm.getList();
                QList <QString> a2=al.at(1).split(":");
                vermcb = a2.at(1).toDouble();
                 qDebug()<<"vermcb"<<vermcb;
                 //panduan vermcb >=0.86
                 if(vermcb-0.85999999 >=0.001)
                 {
                     //ok
                     //enableButtons(true);
                 }else
                 {
                     /*
                     int reply=  QMessageBox::question(this,"The machine firmware is not the latest version !","Please press Cancel and first Update the latest version with the service key,\nsee http://www.cafitessesupport.com! \nWhen update not possible,press OK to start lower compact WBSD version.","OK","Cancle");
                     qDebug()<<"reply="<<reply;
                     if(reply == 1)
                     {
                         qApp->quit();

                     }
                     else if(reply == 0)
                     {
                         QProcess *ps = new QProcess();
                         ps->start(".\\WBSD085\\WBSD_Excellence_Compact.exe");
                         qApp->quit();
                     }
                    */


//**********************************************

                    int reply=  QMessageBox::question(this,"The machine firmware is not the latest version !","When update is possible, please follow the next steps:\n       1. Press \"Backup\" to save the current customer settings \n       2. Update to the latest SW version with the service USB key (see http://www.cafitessesupport.com) \n      3. After the update is completed, restore the customer settings with the Compact PC_Tool.\n\n\nWhen update is not possible, press OK to start a compatible WBSD version. \nOtherwise press Cancel. ","OK","Backup","Cancel");
                    qDebug()<<"reply="<<reply;
                     if(reply == 2)
                     {
                         qApp->quit();

                     }
                     else if(reply == 0)
                     {
                         system(".\\myatu.bat");

                     }else if(reply == 1)
                     {
                         //backup the machine info
                          IsBakMode = true;
                         enableButtons(false);
                         ui->btnlan->setEnabled(true);
                     }
//******************************/
                 }
            }
        break;
    }
}
Example #22
0
File: main.c Project: pH200/vttest
int
tst_insdel(MENU_ARGS)
{
  /* Test of:
     SM/RM(4) (= IRM (Insertion/replacement mode))
     ICH (Insert Character)
     DCH (Delete character)
     IL  (Insert line)
     DL  (Delete line)
   */

  int i, row, col, sw, dblchr, scr132;

  for (scr132 = 0; scr132 <= 1; scr132++) {
    if (scr132) {
      deccolm(TRUE);
      sw = max_cols;
    } else {
      deccolm(FALSE);
      sw = min_cols;
    }
    ed(2);
    cup(1, 1);
    for (row = 1; row <= max_lines; row++) {
      cup(row, 1);
      for (col = 1; col <= sw; col++)
        printf("%c", 'A' - 1 + row);
    }
    cup(4, 1);
    printf("Screen accordion test (Insert & Delete Line). ");
    holdit();

    ri();
    el(2);
    decstbm(2, max_lines - 1);
    decom(TRUE);
    cup(1, 1);
    for (row = 1; row <= max_lines; row++) {
      il(row);
      dl(row);
    }
    decom(FALSE);
    decstbm(0, 0);
    cup(2, 1);
    printf("Top line: A's, bottom line: %c's, this line, nothing more. ",
           'A' - 1 + max_lines);
    holdit();
    cup(2, 1);
    ed(0);
    cup(1, 2);
    printf("B");
    cub(1);
    sm("4");
    for (col = 2; col <= sw - 1; col++)
      printf("*");
    rm("4");
    cup(4, 1);
    printf("Test of 'Insert Mode'. The top line should be 'A*** ... ***B'. ");
    holdit();
    ri();
    el(2);
    cup(1, 2);
    dch(sw - 2);
    cup(4, 1);
    printf("Test of 'Delete Character'. The top line should be 'AB'. ");
    holdit();

    for (dblchr = 1; dblchr <= 2; dblchr++) {
      ed(2);
      for (row = 1; row <= max_lines; row++) {
        cup(row, 1);
        if (dblchr == 2)
          decdwl();
        for (col = 1; col <= sw / dblchr; col++)
          printf("%c", 'A' - 1 + row);
        cup(row, sw / dblchr - row);
        dch(row);
      }
      cup(4, 1);
      println("The right column should be staggered ");
      printf("by one.  ");
      holdit();
    }
    ed(2);
    cup(1, 1);
    println("If your terminal has the ANSI 'Insert Character' function");
    println("(the VT102 does not), then you should see a line like this");
    println("  A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
    println("below:");
    println("");
    for (i = 'Z'; i >= 'A'; i--) {
      printf("%c%c", i, BS);
      ich(2);
    }
    cup(10, 1);
    holdit();

    if (sw == max_cols)
      deccolm(FALSE);
  }
  return MENU_NOHOLD;
}
Example #23
0
int VCS_SOLVE::vcs_inest_TP()
{
    int retn = 0;
    Cantera::clockWC tickTock;

    if (m_doEstimateEquil > 0) {
        /*
         *  Calculate the elemental abundances
         */
        vcs_elab();
        if (vcs_elabcheck(0)) {
            if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) {
                plogf("%s Initial guess passed element abundances on input\n", pprefix);
                plogf("%s m_doEstimateEquil = 1 so will use the input mole "
                      "numbers as estimates", pprefix);
                plogendl();
            }
            return retn;
        } else if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) {
            plogf("%s Initial guess failed element abundances on input\n", pprefix);
            plogf("%s m_doEstimateEquil = 1 so will discard input "
                  "mole numbers and find our own estimate", pprefix);
            plogendl();
        }
    }

    /*
     *  Malloc temporary space for usage in this routine and in
     *  subroutines
     *        sm[ne*ne]
     *        ss[ne]
     *        sa[ne]
     *        aw[m]
     */
    std::vector<double> sm(m_numElemConstraints*m_numElemConstraints, 0.0);
    std::vector<double> ss(m_numElemConstraints, 0.0);
    std::vector<double> sa(m_numElemConstraints, 0.0);
    std::vector<double> aw(m_numSpeciesTot+ m_numElemConstraints, 0.0);
    /*
     *  Go get the estimate of the solution
     */
    if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) {
        plogf("%sGo find an initial estimate for the equilibrium problem",
              pprefix);
        plogendl();
    }
    double test = -1.0E20;
    vcs_inest(VCS_DATA_PTR(aw), VCS_DATA_PTR(sa), VCS_DATA_PTR(sm),
              VCS_DATA_PTR(ss), test);
    /*
     *  Calculate the elemental abundances
     */
    vcs_elab();

    /*
     *      If we still fail to achieve the correct elemental abundances,
     *      try to fix the problem again by calling the main elemental abundances
     *      fixer routine, used in the main program. This
     *      attempts to tweak the mole numbers of the component species to
     *      satisfy the element abundance constraints.
     *
     *       Note: We won't do this unless we have to since it involves inverting
     *             a matrix.
     */
    bool rangeCheck = vcs_elabcheck(1);
    if (!vcs_elabcheck(0)) {
        if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) {
            plogf("%sInitial guess failed element abundances\n", pprefix);
            plogf("%sCall vcs_elcorr to attempt fix", pprefix);
            plogendl();
        }
        vcs_elcorr(VCS_DATA_PTR(sm), VCS_DATA_PTR(aw));
        rangeCheck  = vcs_elabcheck(1);
        if (!vcs_elabcheck(0)) {
            plogf("%sInitial guess still fails element abundance equations\n",
                  pprefix);
            plogf("%s - Inability to ever satisfy element abundance "
                  "constraints is probable", pprefix);
            plogendl();
            retn = -1;
        } else {
            if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) {
                if (rangeCheck) {
                    plogf("%sInitial guess now satisfies element abundances", pprefix);
                    plogendl();
                } else {
                    plogf("%sElement Abundances RANGE ERROR\n", pprefix);
                    plogf("%s - Initial guess satisfies NC=%d element abundances, "
                          "BUT not NE=%d element abundances", pprefix,
                          m_numComponents, m_numElemConstraints);
                    plogendl();
                }
            }
        }
    } else {
        if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) {
            if (rangeCheck) {
                plogf("%sInitial guess satisfies element abundances", pprefix);
                plogendl();
            } else {
                plogf("%sElement Abundances RANGE ERROR\n", pprefix);
                plogf("%s - Initial guess satisfies NC=%d element abundances, "
                      "BUT not NE=%d element abundances", pprefix,
                      m_numComponents, m_numElemConstraints);
                plogendl();
            }
        }
    }

    if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) {
        plogf("%sTotal Dimensionless Gibbs Free Energy = %15.7E", pprefix,
              vcs_Total_Gibbs(VCS_DATA_PTR(m_molNumSpecies_old), VCS_DATA_PTR(m_feSpecies_new),
                              VCS_DATA_PTR(m_tPhaseMoles_old)));
        plogendl();
    }

    /*
     * Record time
     */
    m_VCount->T_Time_inest += tickTock.secondsWC();
    (m_VCount->T_Calls_Inest)++;
    return retn;
}
Example #24
0
	static void flush_local_buffer()
	{
		ScopedMutex sm(_buffer_mutex);
		array::push(*profiler_globals::_buffer, _thread_buffer, _thread_buffer_size);
		_thread_buffer_size = 0;
	}
Example #25
0
// void test() {
//  
//     aligned_buffer<short> a(16);
//     aligned_buffer<short> b(16);
//     aligned_buffer<short> c(16);
//     
//     std::fill( a.begin(), a.end(), 1 );
//     std::fill( b.begin(), b.end(), 2 );
//     a.m_ptr[0] = 2;
//     
//     typedef vector_unit<short,16> vu;
//     
//     vu::vec_t av = vu::load(a.m_ptr);
//     vu::vec_t bv = vu::load(b.m_ptr);
//     
//     vu::store( vu::cmp_lt(av,bv), c.m_ptr );
//     
//     for( int i = 0; i < c.size(); i++ ) {
//      
//         std::cout << i << ": " << c.m_ptr[i] << "\n";
//     }
//     
// }
int main( int argc, char *argv[] ) {
//     test();
//     return 0;
    
    
    seqs sq;
    seqs sd;
    
   // typedef mapped_file file_input;
    typedef std::ifstream file_input;
    
    if( argc != 6 ) {
     
        throw std::runtime_error( "missing parameters. expect: <open> <ext> <query.fa> <db.fa> <matrix>" );
        
    }
    
    const int gap_open = atoi( argv[1] );
    const int gap_extend = atoi( argv[2] );
    
    //std::cout << "gap: " <<

    std::ifstream ism( argv[5] );
    scoring_matrix sm( ism );
    
    file_input qfi( argv[3] );
    inc_fasta<file_input, scoring_matrix> qfasta( qfi, sm );
    
    file_input dfi( argv[4] );
    inc_fasta<file_input, scoring_matrix> dfasta( dfi, sm );
        
        
    
    
    
    
//     for( int i = 0 ; i < sd.names.size(); i++ ) {
//         int sc = align<int>( sd.data[i], sq.data[0], sm );
//         std::cout << sc << "\t" << sd.names[i] << "\n";
//     }
    
    
#if 0
    const int W = 8;
    typedef short score_t;
    typedef short sscore_t;
#else
    const int W = 16;
    typedef unsigned char score_t;
    typedef char sscore_t;
#endif
    persistent_state<score_t> ps;
//     size_t db_size = (sd.names.size() / W ) * W;
    
#ifndef LOCAL_ALIGN
#define PAD_FRONT  
#endif
    
    typedef uint8_t seq_char_t;
    
    std::string dname[W];
    std::vector<seq_char_t> ddata[W];
//     size_t dpad[W];
    aligned_buffer<seq_char_t> ddata_int;
    
//     std::vector<score_t> dmask[W];
    
    std::string qname;
    std::vector<seq_char_t> qdata;
    
    bool have_input = true;
    size_t n_qseq = 0;
    size_t n_qchar = 0;
    
    size_t n_dseq = 0;
    size_t n_dchar = 0;
    
    bool first_block = true;
    while( have_input ) {
        
        size_t maxlen = 0;
        
        int lj = -1;
        
        // determine db sequences for the current block
        
        for( int j = 0; j < W; j++ ) {
            dname[j].resize(0);
            ddata[j].resize(0);
            have_input = dfasta.next_seq( dname[j], ddata[j] );
            
            
            // if there aren't enough db sequences left to fill the block, pad with last db sequence
            if( !have_input ) {
                
                // break immediately if there are no db sequences left (means #db-seqs % W == 0, or otherwise have_input would have been == false from last iteration)
                if( j == 0 ) {
                    break;
                } else {
                    dname[j] = dname[lj];
                    ddata[j] = ddata[lj];
                }
            } else {
                n_dseq++;
                n_dchar += ddata[j].size();
                lj = j; // store largest valid 'j'
                
//                 for( int i = 0; i < ddata[j].length(); i++ ) {
//                         
//                     ddata[j][i] = sm.state_backmap(ddata[j][i]);
//                 }
            }
            
//             dmask[j].clear();
//             dmask[j].resize(ddata[j].length(), 0xffff );
            
            
            maxlen = std::max( maxlen, ddata[j].size() );
        }
        
        // jf == -1 at this point means that the block is empty (#db-seqs % W == 0)
        if( lj == -1 ) {
            break;
        }
        
        
        // WARNING: front-padding is currently defunct
#ifdef PAD_FRONT
        for( int j = 0; j < W; j++ ) {
            dpad[j] = maxlen - ddata[j].size();
        }
#endif

        // lj == -1 means that there are no remaining sequences
        
        
        
//         std::cout << "sdis: " << sdi.size() << "\n";
        aligned_buffer<sscore_t> qprofile( maxlen * W * sm.num_states());
        aligned_buffer<sscore_t>::iterator qpi = qprofile.begin();
#if 0
        for( int j = 0; j < sm.num_states(); j++ ) {
            const int jstate = sm.get_state(j);
//             const scoring_matrix::score_t *slice = sm.get_slice(jstate);
            const scoring_matrix::score_t *cslice = sm.get_cslice(j);
            for( int k = 0; k < maxlen; k++ ) {
                for( int l = 0; l < W; l++ ) {
                    
                    
                    std::vector<seq_char_t> &sdi = ddata[l];
                    
                    
#ifdef PAD_FRONT
                    const size_t frontpad = dpad[l];//maxlen - sdi.size();

                    //if( k < sdi.size() ) {
                    if( k >= frontpad )  {
                        //*qpi = sm.get_score( sdi[k], jstate);
                        *qpi = cslice[sdi[k - frontpad]];
#else
                    if( k < sdi.size() ) {
//                         *qpi = slice[sdi[k]];
                        
                        *qpi = cslice[sdi[k]];
#endif
                    } else {
                        *qpi = 0;   
                    }
//                     std::cout << "prof: " << (qpi - qprofile.begin() ) << " " << *qpi << " " << int(j) << " " << char(sm.get_state(j)) << " " << sdi[k] << "\n";
                    qpi++;
                }
            }
        }
#else
        // setup the qprofile (= lookup table for match penalties along the db-sequences in the current block)
        // this is the faster (at least on core i5) two-step version, using interleaved db-sequences
        
        // setup buffer for interleaved db sequences
        if( ddata_int.size() < maxlen * W ) {
            ddata_int.resize(maxlen * W);
        }
 
        // copy individual db sequences into interleaved buffer (padding the shorter sequnences 
        aligned_buffer<seq_char_t>::iterator dint_iter = ddata_int.begin();
        const int zero_state = sm.get_zero_state();
        for( size_t i = 0; i < maxlen; i++ ) {
            for( int j = 0; j < W; j++ ) {
                std::vector<seq_char_t> &sdi = ddata[j];
                if( i < sdi.size() ) {
                    *dint_iter = sdi[i];

                } else {
                    *dint_iter = zero_state;   
                }
                ++dint_iter;
            }
        }
        for( size_t j = 0; j < sm.num_states(); j++ ) {
            dint_iter = ddata_int.begin();
            const char *cslice = sm.get_cslice(j);
            for( size_t k = 0; k < maxlen; k++ ) {
                for( int l = 0; l < W; l++ ) {
//                     if( *dint_iter == zero_state ) {
//                         std::cout << int(cslice[*dint_iter]) << "\n";
//                        
//                     }
                    
                    *qpi = cslice[*dint_iter];
                    ++dint_iter;
                    ++qpi;
                }
            }
        }
#endif
//         std::cout << "sdis2: " << sdi.size() << std::endl;
//         aligned_buffer<short> dv(sdi.size() * W);
//         short *dv_iter = dv.begin();
//         
//         for( int j = 0; j < sdi.size(); j++ ) {
//                 
//             for( int k = 0; k < W; k++ ) {
//                 *dv_iter = sdi[j];
//                 dv_iter++;
//             }
//             
//         }
        
        
//         aligned_buffer<score_t> len(W);
//         for( int j = 0; j < W; j++ ) {
//             len.m_ptr[j] = sd.data[i + j].size();
//         }
        
        std::vector<int> out(W);
        
        qfasta.reset();
        
        while( qfasta.next_seq( qname, qdata )) {
            if( first_block ) {
                n_qseq++;
                n_qchar+=qdata.size();
            }
            
            align_vec<score_t,sscore_t,W>( ps, maxlen, qdata, sm, qprofile, gap_open, gap_extend, out );
        
            for( int j = 0; j <= lj; j++ ) {
//                 std::cout << out[j] << "\t" << dname[j] << " " << qname << " " << ddata[j].size() << "\n";
                std::cout << out[j] << "\t" << dname[j] << "\n";
            }
            qname.resize(0);
            qdata.resize(0);
            
        }
        first_block = false;
    }
    
    std::cerr << n_qseq << "[" << n_qchar << "] x " << n_dseq << "[" << n_dchar << "]\n";
}
Example #26
0
void MDFNSS_SaveSM(Stream *st, bool data_only, const MDFN_Surface *surface, const MDFN_Rect *DisplayRect, const int32 *LineWidths)
{
	StateMem sm(st);

	if(data_only)
	{
	 MDFN_StateAction(&sm, 0, true);
	 sm.ThrowDeferred();
	}
	else
	{
	 static const char *header_magic = "MDFNSVST";
	 int64 start_pos;
         uint8 header[32];
	 int neowidth = 0, neoheight = 0;

	 memset(header, 0, sizeof(header));

	 if(surface && DisplayRect && LineWidths)
	 {
	  bool is_multires = FALSE;

	  // We'll want to use the nominal width if the source rectangle is > 25% off on either axis, or the source image has
	  // multiple horizontal resolutions.
	  neowidth = MDFNGameInfo->nominal_width;
	  neoheight = MDFNGameInfo->nominal_height;

	  if(LineWidths[0] != ~0)
 	  {
	   int32 first_w = LineWidths[DisplayRect->y];

	   for(int y = 0; y < DisplayRect->h; y++)
	   {
	    if(LineWidths[DisplayRect->y + y] != first_w)
	    {
	     //puts("Multires!");
	     is_multires = TRUE;
	    }
	   }
	  }

	  if(!is_multires)
	  {
	   if(((double)DisplayRect->w / MDFNGameInfo->nominal_width) > 0.75  && ((double)DisplayRect->w / MDFNGameInfo->nominal_width) < 1.25)
	    neowidth = DisplayRect->w;

           if(((double)DisplayRect->h / MDFNGameInfo->nominal_height) > 0.75  && ((double)DisplayRect->h / MDFNGameInfo->nominal_height) < 1.25)
	    neoheight = DisplayRect->h;
	  }
	 }

	 memcpy(header, header_magic, 8);

	 MDFN_en64lsb(header + 8, time(NULL));

	 MDFN_en32lsb(header + 16, MEDNAFEN_VERSION_NUMERIC);
	 MDFN_en32lsb(header + 24, neowidth);
	 MDFN_en32lsb(header + 28, neoheight);

	 start_pos = st->tell();
	 st->write(header, 32);

	 if(surface && DisplayRect && LineWidths)
	 {
	  //
	  // TODO: Make work with 8bpp and 16bpp.
	  //
	  MDFN_Surface dest_surface(NULL, neowidth, neoheight, neowidth, surface->format);
	  MDFN_Rect dest_rect;

	  dest_rect.x = 0;
	  dest_rect.y = 0;
	  dest_rect.w = neowidth;
	  dest_rect.h = neoheight;

	  MDFN_ResizeSurface(surface, DisplayRect, LineWidths, &dest_surface, &dest_rect);

	  {
	   uint32* previewbuffer = dest_surface.pixels;
	   uint8* previewbuffer8 = (uint8*)previewbuffer;

	   for(int32 a = 0; a < neowidth * neoheight; a++)
	   {
	    int nr, ng, nb;

	    surface->DecodeColor(previewbuffer[a], nr, ng, nb);

	    previewbuffer8[0] = nr;
	    previewbuffer8[1] = ng;
	    previewbuffer8[2] = nb;

	    previewbuffer8 += 3;
	   }
	  }

          st->write((uint8*)dest_surface.pixels, 3 * neowidth * neoheight);
	 }

	 MDFN_StateAction(&sm, 0, data_only);
	 sm.ThrowDeferred();

	 {
	  int64 end_pos = st->tell();
	  uint32 pv = (end_pos - start_pos) & 0x7FFFFFFF;

	  #ifdef MSB_FIRST
	  pv |= 0x80000000;
	  #endif

	  st->seek(start_pos + 16 + 4, SEEK_SET);
	  st->put_LE<uint32>(pv);
	  st->seek(end_pos, SEEK_SET);		// Seek to just beyond end of save state before returning.
	 }
	}
}
//----------------------------------------------------------------------------
void CollisionsBoundTree::CreateScene ()
{
    // The root of the scene will have two cylinders as children.
    mScene = new0 Node();
    mWireState = new0 WireState();
    mRenderer->SetOverrideWireState(mWireState);
    mCullState = new0 CullState();
    mCullState->Enabled = false;
    mRenderer->SetOverrideCullState(mCullState);

    // Create a texture image to be used by both cylinders.
    Texture2D* texture = new0 Texture2D(Texture::TF_A8R8G8B8, 2, 2, 1);
    unsigned int* data = (unsigned int*)texture->GetData(0);
    data[0] = Color::MakeR8G8B8(0,     0, 255);  // blue
    data[1] = Color::MakeR8G8B8(0,   255, 255);  // cyan
    data[2] = Color::MakeR8G8B8(255,   0,   0);  // red
    data[3] = Color::MakeR8G8B8(255, 255,   0);  // yellow

    Texture2DEffect* effect = new0 Texture2DEffect(Shader::SF_LINEAR);

    // Create two cylinders, one short and thick, one tall and thin.
    VertexFormat* vformat = VertexFormat::Create(2,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0);

    StandardMesh sm(vformat);
    VertexBufferAccessor vba;
    int i;

    mCylinder0 = sm.Cylinder(8, 16, 1.0f, 2.0f, false);
    vba.ApplyTo(mCylinder0);
    for (i = 0; i < vba.GetNumVertices(); ++i)
    {
        vba.TCoord<Float2>(0, i) = mBlueUV;
    }
    mCylinder0->SetEffectInstance(effect->CreateInstance(texture));
    mScene->AttachChild(mCylinder0);

    mCylinder1 = sm.Cylinder(16,8,0.25,4.0,false);
    vba.ApplyTo(mCylinder1);
    for (i = 0; i < vba.GetNumVertices(); ++i)
    {
        vba.TCoord<Float2>(0, i) = mRedUV;
    }
    mCylinder1->SetEffectInstance(effect->CreateInstance(texture));
    mScene->AttachChild(mCylinder1);

    mScene->Update();

    // Set up the collision system.  Record0 handles the collision response.
    // Record1 is not given a callback so that 'double processing' of the
    // events does not occur.
    CTree* tree0 = new0 CTree(mCylinder0, 1, false);
    CRecord* record0 = new0 CRecord(tree0, 0, Response, this);
    CTree* tree1 = new0 CTree(mCylinder1, 1, false);
    CRecord* record1 = new0 CRecord(tree1, 0, 0, 0);
    mGroup = new0 CGroup();
    mGroup->Add(record0);
    mGroup->Add(record1);

    ResetColors();
    mGroup->TestIntersection();
}
Example #28
0
bool MDFNI_LoadState(const char *fname, const char *suffix) noexcept
{
 bool ret = true;

 try
 {
  if(!MDFNGameInfo->StateAction)
  {
   throw MDFN_Error(0, _("Module \"%s\" doesn't support save states."), MDFNGameInfo->shortname);
  }

  /* For network play and movies, be load the state locally, and then save the state to a temporary buffer,
     and send or record that.  This ensures that if an older state is loaded that is missing some
     information expected in newer save states, desynchronization won't occur(at least not
     from this ;)).
  */

  {
   GZFileStream st(fname ? std::string(fname) : MDFN_MakeFName(MDFNMKF_STATE,CurrentState,suffix), GZFileStream::MODE::READ);
   uint8 header[32];
   uint32 st_len;

   st.read(header, 32);

   st_len = MDFN_de32lsb(header + 16 + 4) & 0x7FFFFFFF;

   if(st_len < 32)
    throw MDFN_Error(0, _("Save state header length field is bad."));

   MemoryStream sm(st_len, -1);

   memcpy(sm.map(), header, 32);
   st.read(sm.map() + 32, st_len - 32);

   MDFNSS_LoadSM(&sm, false);
  }

  if(MDFNnetplay)
  {
   NetplaySendState();
  }

  if(MDFNMOV_IsRecording())
   MDFNMOV_RecordState();

  MDFND_SetStateStatus(NULL);

  if(!fname && !suffix)
  {
   SaveStateStatus[CurrentState] = true;
   MDFN_DispMessage(_("State %d loaded."), CurrentState);
  }
 }
 catch(std::exception &e)
 {
  if(!fname && !suffix)
   MDFN_DispMessage(_("State %d load error: %s"), CurrentState, e.what());
  else
   MDFN_PrintError("%s", e.what());

  if(MDFNnetplay)
   MDFND_NetplayText(e.what(), false);

  ret = false;
 }

 return(ret);
}
status_t SurfaceComposerClient::linkToComposerDeath(
        const sp<IBinder::DeathRecipient>& recipient,
        void* cookie, uint32_t flags) {
    sp<ISurfaceComposer> sm(getComposerService());
    return sm->asBinder()->linkToDeath(recipient, cookie, flags);
}
Example #30
0
/** solve one of the eight Appollonius Equations
| Cx - Ci|^2=(Rx+Ri)^2
with Cx the center of the common tangent circle, Rx the radius. Ci and Ri are the Center and radius of the i-th existing circle
**/
std::vector<RS_Circle> RS_Circle::solveAppolloniusSingle(const std::vector<RS_Circle>& circles)
{
//          std::cout<<__FILE__<<" : "<<__func__<<" : line "<<__LINE__<<std::endl;
//          for(int i=0;i<circles.size();i++){
//std::cout<<"i="<<i<<"\t center="<<circles[i].getCenter()<<"\tr="<<circles[i].getRadius()<<std::endl;
//          }
	std::vector<RS_Circle> ret;

	std::vector<RS_Vector> centers;
	std::vector<double> radii;

	for(auto c: circles){
		if(c.getCenter().valid==false) return ret;
		centers.push_back(c.getCenter());
		radii.push_back(c.getRadius());
	}
//              for(int i=0;i<circles.size();i++){
//    std::cout<<"i="<<i<<"\t center="<<circles[i].getCenter()<<"\tr="<<radii.at(i)<<std::endl;
//              }
/** form the linear equation to solve center in radius **/
	std::vector<std::vector<double> > mat(2,std::vector<double>(3,0.));
    mat[0][0]=centers[2].x - centers[0].x;
    mat[0][1]=centers[2].y - centers[0].y;
    mat[1][0]=centers[2].x - centers[1].x;
    mat[1][1]=centers[2].y - centers[1].y;
    if(fabs(mat[0][0]*mat[1][1] - mat[0][1]*mat[1][0])<RS_TOLERANCE2){
//        DEBUG_HEADER
//        std::cout<<"The provided circles are in a line, not common tangent circle"<<std::endl;
        size_t i0=0;
        if( centers[0].distanceTo(centers[1]) <= RS_TOLERANCE ||  centers[0].distanceTo(centers[2]) <= RS_TOLERANCE) i0 = 1;
        LC_Quadratic lc0(& (circles[i0]), & (circles[(i0+1)%3]));
        LC_Quadratic lc1(& (circles[i0]), & (circles[(i0+2)%3]));
		auto c0 = LC_Quadratic::getIntersection(lc0, lc1);
//        qDebug()<<"c0.size()="<<c0.size();
        for(size_t i=0; i<c0.size(); i++){
            const double dc =  c0[i].distanceTo(centers[i0]);
			ret.push_back(RS_Circle(nullptr, {c0[i], fabs(dc - radii[i0])}));
            if( dc > radii[i0]) {
				ret.push_back(RS_Circle(nullptr, {c0[i], dc + radii[i0]}));
            }
        }
        return ret;
    }
    // r^0 term
    mat[0][2]=0.5*(centers[2].squared()-centers[0].squared()+radii[0]*radii[0]-radii[2]*radii[2]);
    mat[1][2]=0.5*(centers[2].squared()-centers[1].squared()+radii[1]*radii[1]-radii[2]*radii[2]);
//    std::cout<<__FILE__<<" : "<<__func__<<" : line "<<__LINE__<<std::endl;
//    for(unsigned short i=0;i<=1;i++){
//        std::cout<<"eqs P:"<<i<<" : "<<mat[i][0]<<"*x + "<<mat[i][1]<<"*y = "<<mat[i][2]<<std::endl;
//    }
//    std::vector<std::vector<double> > sm(2,std::vector<double>(2,0.));
	std::vector<double> sm(2,0.);
    if(RS_Math::linearSolver(mat,sm)==false){
        return ret;
    }

    RS_Vector vp(sm[0],sm[1]);
//      std::cout<<__FILE__<<" : "<<__func__<<" : line "<<__LINE__<<std::endl;
//      std::cout<<"vp="<<vp<<std::endl;

    // r term
    mat[0][2]= radii[0]-radii[2];
    mat[1][2]= radii[1]-radii[2];
//    for(unsigned short i=0;i<=1;i++){
//        std::cout<<"eqs Q:"<<i<<" : "<<mat[i][0]<<"*x + "<<mat[i][1]<<"*y = "<<mat[i][2]<<std::endl;
//    }
    if(RS_Math::linearSolver(mat,sm)==false){
        return ret;
    }
    RS_Vector vq(sm[0],sm[1]);
//      std::cout<<"vq="<<vq<<std::endl;
    //form quadratic equation for r
    RS_Vector dcp=vp-centers[0];
    double a=vq.squared()-1.;
    if(fabs(a)<RS_TOLERANCE*1e-4) {
        return ret;
    }
    std::vector<double> ce(0,0.);
    ce.push_back(2.*(dcp.dotP(vq)-radii[0])/a);
    ce.push_back((dcp.squared()-radii[0]*radii[0])/a);
    std::vector<double>&& vr=RS_Math::quadraticSolver(ce);
    for(size_t i=0; i < vr.size();i++){
        if(vr.at(i)<RS_TOLERANCE) continue;
		ret.emplace_back(RS_Circle(nullptr, {vp+vq*vr.at(i),fabs(vr.at(i))}));
    }
//    std::cout<<__FILE__<<" : "<<__func__<<" : line "<<__LINE__<<std::endl;
//    std::cout<<"Found "<<ret.size()<<" solutions"<<std::endl;

    return ret;
}