Пример #1
0
void HelpBrowser::showHelpForKeyword(const QString &id)
{
	if (mEngine->engine())
	{
		QMap<QString, QUrl> links = mEngine->engine()->linksForIdentifier(id);
		if (links.count())
		{
			setSource(links.first());
		}
	}
}
Пример #2
0
Resultat Agent1::chooseResult() const
{
    QMap<QPair<const Experience, const Resultat>, Interaction> temp = m_motivation.systeme();

    Resultat ret;
    int motiv = 0;
    if(!temp.isEmpty())
    {
        motiv = temp.first().motivation();
        ret = temp.first().resultat();
    }

    foreach(const Interaction& it, temp)
    {
        if(it.motivation() > motiv)
        {
            ret = it.resultat();
            motiv = it.motivation();
        }
    }

    return ret;
}
Пример #3
0
// 显示在线音乐搜索结果
void NetWorkWidget::showSearchResult(QMap<QString, QStringList> musicList)
{
    musicUrls = musicList.first();
    QString musicName = musicList.firstKey();

    while(tableWidget->rowCount())
    {
        tableWidget->removeRow(tableWidget->rowCount()-1);
    }

    for (int i=0; i<musicUrls.count(); ++i)
    {
        tableWidget->insertRow(tableWidget->rowCount());
        tableWidget->setItem(tableWidget->rowCount()-1, 0, new QTableWidgetItem(musicName));
        tableWidget->setItem(tableWidget->rowCount()-1, 1, new QTableWidgetItem("试听"));
        tableWidget->setItem(tableWidget->rowCount()-1, 2, new QTableWidgetItem("下载"));
    }
}
Пример #4
0
// --------------------------------------------------------
// --------------------------------------------------------
// --------------------------------------------------------

TEST_CASE("org.custusx.help: HelpEngine loads a page", "[unit][plugins][org.custusx.help]")
{
	cx::DataLocations::setTestMode();

	cx::HelpEnginePtr engine(new cx::HelpEngine);
	REQUIRE(engine->engine());

	QString id = "user_doc_overview";
	QMap<QString, QUrl> links = engine->engine()->linksForIdentifier(id);
	REQUIRE(links.size()==1);

	CHECK(QString(links.first().toString()).contains(id));
}


TEST_CASE("org.custusx.help: HelpWidget displays initial help text", "[unit][plugins][org.custusx.help]")
{
	cxtest::TestHelpFixture fixture;
	fixture.setupHelpBrowserInsideMainWindow();

	CHECK(fixture.browser->source().toString().contains("user_doc_overview"));
	// this can be a tricky test for overriding applications: they must have this string in the main page in order to
	// succeed.
	CHECK(fixture.browser->toPlainText().contains("CustusX"));
	CHECK(fixture.browser->toPlainText().contains("User Documentation"));

//	fixture.printBrowserContents();
Пример #5
0
void ConfigTreeObject_Math::slotMathAlarm_Level4OutTypeChanged()
{
    QVariant value = ConfigTreeObject::getConfigObject(MATH_DELEGATE_ALARM_LVL4_OUTTYPE)->getData();

    QFile file(XML_MATH_ALARM_LVL4_OUTTYPE);
    if(!file.open(QFile::ReadOnly | QFile::Text)){
        qWarning()<< "Can't open the file:MathAlarm_Lvl4Output!";
    }else{
        XmlConfigParser::parseValueChangeXml(file, value);
        file.close();
    }

    quint32 valueNo = value.toUInt();
    if(0 == valueNo) {

    } else if (1 == valueNo) {
        QMap<QString, quint32> curChanDO = CfgChannel::instance()->getExistChannelDO();
        if(!curChanDO.isEmpty()) {
            ConfigTreeObject::getConfigObject(MATH_DELEGATE_ALARM_LVL4_OUTNO)->changeData(curChanDO.first(), false);
        }
    } else if (2 == valueNo) {
        ConfigTreeObject::getConfigObject(MATH_DELEGATE_ALARM_LVL4_OUTNO)->changeData(1, false);
    }
}
Пример #6
0
void Level::rubeB2DLevel(b2dJson& mBox2dJson)
{
    if(mJsonFilePath.isEmpty()){
        qDebug() << " mJsonFilePath is empty ";
    }

    if(!Util::fileExists(mJsonFilePath)){
        qDebug() << " Level: "  << mJsonFilePath << " does not exists. ";
        return;
    }
    std::string worldJson = Util::readFileAsStdString(mJsonFilePath);

    std::string errorstring;
    b2World* w = mBox2dJson.readFromString(worldJson,errorstring,mWorld.get());

    if(w){
        //custom properties to be read
        int useWorldGravity = mBox2dJson.getCustomInt(w,"use_world_gravity",0);
        float grav_x ;
        float grav_y ;
        if(useWorldGravity){
            grav_x = mBox2dJson.getCustomFloat(w,"world_gravity_x",0);
            grav_y = mBox2dJson.getCustomFloat(w,"world_gravity_y",0);
             w->SetGravity(b2Vec2(grav_x,grav_y));
        }

        qDebug() << " Reading jsonfile Complete!  \n\t ";


        //check if there is a camera body
        //used for camera bounds. (Square body)
        b2Body* cam_body = mBox2dJson.getBodyByName("camera");
        if(cam_body){
            b2Fixture* cam_fixture = cam_body->GetFixtureList();
            if(cam_fixture){
                QRectF bbox = Box2dUtil::toQRectF(cam_fixture->GetAABB(0));
                this->setCameraBoundary(bbox);
                cam_body->SetActive(false);
#ifdef D_PARSE
                qDebug() << "Bounding box "<< bbox;
#endif
            }
#ifdef D_PARSE
            qDebug() << "camera found!";
#endif
        }

        //TODO: this is sooooo lazy,
        for(QVariant v:mLevelActorMapping){
            QMap<QString,QVariant> tmp = v.toMap();
            qDebug() << " Mapped LevelActorrr  " << tmp;

            mLevelActorMap.insert(tmp.firstKey(),tmp.first().toString());
        }


        Engine* engine = Engine::getInstance();
        QQmlEngine* qmlEngine = engine->getQmlEngine();

        // Check if bodies are referenced in the Actor Mapping Category
        Body* b = nullptr;
        std::string actorTypeString;
        b2Body* body = mWorld->GetBodyList();
        while(body){
            actorTypeString = mBox2dJson.getCustomString(body,"actorType");
            if(actorTypeString.empty() || actorTypeString == "none"){
                b = Body::BodyFromb2Body(body);
                if(b) b->setParent(this);
            }else{
                actorFromMapping(body,actorTypeString,qmlEngine);
            }
            body = body->GetNext();
        }

        // Use Nodes for parsing the specific type of node
        //QList<LevelNode*> nodes = findChildren<LevelNode*>();
        for(LevelNode* node: findChildren<LevelNode*>())  {
            switch(node->type())  {
                case LevelNode::BODY_REFERENCE:{
                    actorReferenceBody(node);
                }break;
                case LevelNode::ACTOR_COMPONENT_W_BODY:{
                    actorComponentWithBody(node,qmlEngine);
                }break;
                default:{
                    qDebug() << " unknown LevelNode type = " << node->type();
                }
            }
        }

       //check for images associated with the body.
       int imageCount = 0;
       body = nullptr;
       b = nullptr;
       QString image_path;
       Actor* actor = nullptr;
       ImageRenderer* img_renderer = nullptr;
       std::vector<b2dJsonImage*> world_images;
       imageCount = mBox2dJson.getAllImages(world_images);

       for(b2dJsonImage* img: world_images)
       {
           if((body = img->body))
           {
               b = static_cast<Body*>(img->body->GetUserData());
               if(b)
               {
                   image_path = Util::getPathToLevel(QString::fromStdString(img->file));
                   actor = new Actor(b);
                   actor->setPosition(b->getPosition());
                   actor->setParent(this);
                   actor->setParentItem(this);
                   img_renderer = new ImageRenderer(actor);
                   img_renderer->setSource(image_path);
                   img_renderer->setSizeScale(img->scale);
                   img_renderer->setVisible(true);
                   img_renderer->setCacheRenderParams(body->GetType() == Body::StaticBody);

                   QRectF c;
                   c.setTopLeft(Box2dUtil::toQPointF(img->corners[0]));
                   c.setTopRight(Box2dUtil::toQPointF(img->corners[1]));
                   c.setBottomRight(Box2dUtil::toQPointF(img->corners[2]));
                   c.setBottomLeft(Box2dUtil::toQPointF(img->corners[3]));
                   img_renderer->setCustomLocalBox(c);

#ifdef D_PARSE
                   qDebug() << image_path << " box2d " << Box2dUtil::toQPointF(img->corners[0]);
                   qDebug() << image_path << " box2d " << Box2dUtil::toQPointF(img->corners[1]);
                   qDebug() << image_path << " box2d " << Box2dUtil::toQPointF(img->corners[2]);
                   qDebug() << image_path << " box2d " << Box2dUtil::toQPointF(img->corners[3]);
                   qDebug() << image_path << " render localbox " << c;
                   //TODO: fixe the scale ratio, to match box2d.
                   b2AABB aabb = img->getAABB();
                   qDebug() <<"Image aabb = " << Box2dUtil::toQRectF(aabb);
                  // img_renderer->setPosition(QPointF(img->center.x,img->center.y ));
                   qDebug() << "Image pos = " <<img_renderer->position();
#endif
               }
           }
       }
    }else{
        qDebug() << "World null, Error Reading jsonfile: \n\t " << errorstring.c_str();
    }
    w = nullptr;
}