void CMenu::_initGameInfoMenu(CMenu::SThemeData &theme) { STexture emptyTex; _addUserLabels(theme, m_gameinfoLblUser, 0, 1, "GAMEINFO"); _addUserLabels(theme, m_gameinfoLblUser, 2, 1, "GAMEINFO"); m_gameinfoBg = _texture(theme.texSet, "GAMEINFO/BG", "texture", theme.bg); m_gameinfoLblID = _addLabel(theme, "GAMEINFO/GAMEID", 125, 10, 420, 75, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE); m_gameinfoLblGenre = _addText(theme, "GAMEINFO/GENRE", 40, 140, 560, 56, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP); m_gameinfoLblDev = _addText(theme, "GAMEINFO/DEVELOPER", 40, 170, 560, 56, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP); m_gameinfoLblPublisher = _addText(theme, "GAMEINFO/PUBLISHER", 40, 200, 560, 56, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP); m_gameinfoLblRlsdate = _addText(theme, "GAMEINFO/RLSDATE", 40, 230, 560, 56, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP); m_gameinfoLblRegion = _addText(theme, "GAMEINFO/REGION", 40, 260, 560, 56, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP); m_gameinfoLblRating = _addLabel(theme, "GAMEINFO/RATING", 550, 380, 48, 60, 0, m_rating); m_gameinfoLblSynopsis = _addText(theme, "GAMEINFO/SYNOPSIS", 40, 120, 560, 320, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP); m_gameinfoLblWifiplayers = _addLabel(theme, "GAMEINFO/WIFIPLAYERS", 550, 110, 68, 60, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP, m_wifi); _addUserLabels(theme, m_gameinfoLblUser, 1, 1, "GAMEINFO"); _addUserLabels(theme, m_gameinfoLblUser, 3, 2, "GAMEINFO"); m_gameinfoLblTitle = _addLabel(theme, "GAMEINFO/TITLE", 20, 37, 600, 75, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE); for (u8 i = 0; i < ARRAY_SIZE(m_gameinfoLblControlsReq); ++i) { string dom(sfmt("GAMEINFO/CONTROLSREQ%i", i + 1)); m_gameinfoLblControlsReq[i] = _addLabel(theme, dom.c_str(), 40 + (i*60), 310, 60, 40, 0, emptyTex); _setHideAnim(m_gameinfoLblControlsReq[i], dom.c_str(), 0, -100, 0.f, 0.f); } for (u8 i = 0; i < ARRAY_SIZE(m_gameinfoLblControls); ++i) { string dom(sfmt("GAMEINFO/CONTROLS%i", i + 1)); m_gameinfoLblControls[i] = _addLabel(theme, dom.c_str(), 40 + (i*60), 380, 60, 40, 0, emptyTex); _setHideAnim(m_gameinfoLblControls[i], dom.c_str(), 0, -100, 0.f, 0.f); } // _setHideAnim(m_gameinfoLblID, "GAMEINFO/GAMEID",0, -100, 0.f, 0.f); _setHideAnim(m_gameinfoLblTitle, "GAMEINFO/TITLE", 0, -100, 0.f, 0.f); _setHideAnim(m_gameinfoLblRating, "GAMEINFO/RATING", 100, 0, 0.f, 0.f); _setHideAnim(m_gameinfoLblSynopsis, "GAMEINFO/SYNOPSIS", 0, 100, 0.f, 0.f); _setHideAnim(m_gameinfoLblRegion, "GAMEINFO/REGION", 0, -100, 0.f, 0.f); _setHideAnim(m_gameinfoLblDev, "GAMEINFO/DEVELOPER", 0, -100, 0.f, 0.f); _setHideAnim(m_gameinfoLblPublisher, "GAMEINFO/PUBLISHER", 0, -100, 0.f, 0.f); _setHideAnim(m_gameinfoLblRlsdate, "GAMEINFO/RLSDATE", 0, -100, 0.f, 0.f); _setHideAnim(m_gameinfoLblGenre, "GAMEINFO/GENRE", 0, -100, 0.f, 0.f); _setHideAnim(m_gameinfoLblWifiplayers, "GAMEINFO/WIFIPLAYERS", 0, -100, 0.f, 0.f); // _hideGameInfo(true); }
void VideoQualityJob::onOpenTiggered() { // Parse the XML. QFile file(xmlPath()); file.open(QIODevice::ReadOnly); QDomDocument dom(xmlPath()); dom.setContent(&file); file.close(); // Locate the VQM transition. QDomNodeList transitions = dom.elementsByTagName("transition"); for (int i = 0; i < transitions.length(); i++ ) { QDomElement property = transitions.at(i).firstChildElement("property"); while (!property.isNull()) { // Change the render property to 1. if (property.attribute("name") == "render") { property.firstChild().setNodeValue("1"); // Save the new XML. file.open(QIODevice::WriteOnly); QTextStream textStream(&file); dom.save(textStream, 2); file.close(); MAIN.open(xmlPath().toUtf8().constData()); break; } property = property.nextSiblingElement("property"); } } }
sparse_table_t create_sparse_table(unsigned v0_id, unsigned v1_id, unsigned v2_id) { // create a table with dimensions ordered like the original table (e.g., from // belief prop) to make computing the linear index easier std::vector<std::pair<size_t, double> > data; { variable_t v0(0, 4); variable_t v1(1, 3); variable_t v2(2, 2); std::vector<variable_t> args; args.push_back(v0); args.push_back(v1); args.push_back(v2); domain_t dom(args); create_data_vector(data, dom); } variable_t v0(v0_id, 4); variable_t v1(v1_id, 3); variable_t v2(v2_id, 2); std::vector<variable_t> args; args.push_back(v0); args.push_back(v1); args.push_back(v2); sparse_table_t st(args, data); return st; }
void Navigator::syncFunctionNav() { m_syncTimer->stop(); if (FunctionDom fun = currentFunction()) { if ( m_part->widget()->doFollowEditor() ) { ItemDom dom(fun); m_part->jumpedToItem( dom ); } if( !fun->isFunctionDefinition() ) { if (m_functionNavDecls[fullFunctionDeclarationName(fun)]) { m_part->m_functionsnav->view()->blockSignals(true); m_part->m_functionsnav->view()->setCurrentActiveItem(m_functionNavDecls[fullFunctionDeclarationName(fun)]); m_part->m_functionsnav->view()->blockSignals(false); } } else { if (m_functionNavDefs[fullFunctionDeclarationName(fun)]) { m_part->m_functionsnav->view()->blockSignals(true); m_part->m_functionsnav->view()->setCurrentActiveItem(m_functionNavDefs[fullFunctionDeclarationName(fun)]); m_part->m_functionsnav->view()->blockSignals(false); } } } else m_part->m_functionsnav->view()->setCurrentText(NAV_NODEFINITION); }
main () { FILE *fin = fopen ("friday.in", "r"); FILE *fout = fopen ("friday.out", "w"); // sat sun mon tue ... fri unsigned days[7] = {0,0,0,0,0,0,0}; unsigned n; fscanf(fin, "%u", &n); assert(n <= 400); int dow = ( 12 % 7 + 2 ) % 7; unsigned i = 0, j = 0; for(i = 0; i < n; i++) { // n years for(j = 0; j < 12; j++) { // each month for n years days[dow] ++; dow = (dow + dom(1900 + i, j)) % 7; } } for(i = 0; i < 7; i++) { if( i>0 ) fprintf (fout, " "); fprintf (fout, "%u", days[i]); } fprintf(fout, "\n"); exit (0); }
/////////////////////////////////////////////////////////////////////// //! \author BONNIER David //! //! \brief Fonction appeler par tout les contructeurs héritant de la classe (Regle, Equerre, Compas, Crayon). //! //! Fonction qui initialise toutes les données membres d'Instrument avec le XML. //! Nom des fichiers XML données dans les constructeurs spécifiques des classes filles. //! Les 3 paramètres avant de l'appeler sont : m_nomFichierXML, m_nomDocument, m_nomElement. //! //! \date 01/02/2014 /////////////////////////////////////////////////////////////////////// void Instrument::Initialisation() { QFile xml_doc(*m_nomFichierXML);// On choisit le fichier contenant les informations XML. if(!xml_doc.open(QIODevice::ReadOnly))// Si l'on n'arrive pas à ouvrir le fichier XML. { QMessageBox::warning(this,"Erreur a l'ouverture du document XML","Le document XML n'a pas pu etre ouvert. Verifiez que le nom est le bon et que le document est bien place"); return; } QDomDocument dom(*m_nomDocument); // Création de l'objet DOM if (!dom.setContent(&xml_doc)) // Si l'on n'arrive pas à associer le fichier XML à l'objet DOM. { xml_doc.close(); QMessageBox::warning(this,"Erreur a l'ouverture du document XML","Le document XML n'a pas pu etre attribue a l'objet QDomDocument."); return; } QDomElement dom_element = dom.documentElement(); QDomNode noeud = dom_element.firstChild(); while(!noeud.isNull()) //Parours du fichier { QDomElement element = noeud.toElement(); // On utilise cette propriété afin de transformer le nœud en éléments. //Cela nous permet aussi de récupérer l'élément ou nœud courant. if(!element.isNull()) //S'il y a un élément dans le noeud { //Boolean if (element.tagName() == "transparence") m_transparence = element.text().toInt(); if (element.tagName() == "moveSelected") m_moveSelected = element.text().toInt(); if (element.tagName() == "rotateSelected") m_rotateSelected = element.text().toInt(); //Variable if (element.tagName() == "positionX") m_position.setX(element.text().toInt()); if (element.tagName() == "positionY") m_position.setY(element.text().toInt()); if (element.tagName() == "angle") m_angle = element.text().toDouble(); if (element.tagName() == "offsetX") m_offset.setX(element.text().toInt()); if (element.tagName() == "offsetY") m_offset.setY(element.text().toInt()); if (element.tagName() == "posClicX") m_posClic.setX(element.text().toInt()); if (element.tagName() == "posClicY") m_posClic.setY(element.text().toInt()); //Constantes if (element.tagName() == "longueur") m_longueur = element.text().toInt(); if (element.tagName() == "largeur") m_largeur = element.text().toInt(); } noeud = noeud.nextSibling(); //Ce code permet d'aller à l'élément suivant. } xml_doc.close(); m_ecartSelected = false; m_traceSelected = false; }
ibex::IntervalVector box::get_domains() const { ibex::IntervalVector dom(m_vars->size()); for (unsigned i = 0; i < m_vars->size(); i++) { Enode const * const e = (*m_vars)[i]; double const lb = e->getDomainLowerBound(); double const ub = e->getDomainUpperBound(); dom[i] = ibex::Interval(lb, ub); } return dom; }
/** * Initializes the node and edge potentials with the given functors. * This is performed by invoking the functors on the arguments given * by each vertex and edge and assigning the result to the model. */ void initialize(std::function<NodeF(const node_domain_type&)> nodefn, std::function<EdgeF(const edge_domain_type&)> edgefn) { typename NodeF::result_type one(1); for (vertex_type v : this->vertices()) { (*this)[v] = nodefn ? nodefn({v}) : NodeF({v}, one); } for (edge_type e : this->edges()) { edge_domain_type dom({e.source(), e.target()}); (*this)[e] = edgefn ? edgefn(dom) : EdgeF(dom, one); } }
void Navigator::slotSyncWithEditor() { kdDebug(9003) << k_funcinfo << endl; if (FunctionDom fun = currentFunction()) { m_part->mainWindow()->raiseView( m_part->widget() ); ItemDom dom(fun); m_part->jumpedToItem( dom ); } }
template<typename scalar_type> finite_hyperbox<scalar_type> finite_bounding_box( const support_function_provider& s) { scalar_type xp, xn; math::vdom_vector<scalar_type> v; bool is_empty = false; bool is_bounded = true; typename finite_hyperbox<scalar_type>::point_type c_point(s.get_dim()); typename finite_hyperbox<scalar_type>::point_type g_point(s.get_dim()); /* Positive and negative direction */ variable_id_set vars = s.get_variable_ids(); positional_vdomain dom(vars); for (unsigned int j = 0; j < dom.size(); ++j) { math::vdom_vector<scalar_type> ln(dom); math::vdom_vector<scalar_type> lp(dom); ln[j] = -scalar_type(1); lp[j] = scalar_type(1); s.compute_support(ln, xn, v, is_empty, is_bounded); if (!is_bounded) { std::stringstream ss; ss << "unbounded in direction " << ln << std::endl; ss << "in set: " << s << std::endl; throw std::runtime_error( "finite_bounding_box not allowed with unbounded set:\n" + ss.str()); }; s.compute_support(lp, xp, v, is_empty, is_bounded); if (!is_bounded) { std::stringstream ss; ss << "unbounded in direction " << lp; ss << "in set: " << s << std::endl; throw std::runtime_error( "finite_bounding_box not allowed with unbounded set:\n" + ss.str()); }; //std::cout << l << ":" << x << " at " << v << ", empty:" << is_empty << ", bounded:" << is_bounded << std::endl; if (is_empty) { // return an empty box return finite_hyperbox<scalar_type>::empty_box(dom); } else { if (is_bounded) { c_point[j] = (xp - xn) / scalar_type(2); g_point[j] = xp - c_point[j]; } else { throw std::runtime_error( "finite_bounding_box not allowed with unbounded set"); }; } } return finite_hyperbox<scalar_type> (c_point, g_point, dom); }
main() { printf("Hello!\n"); int a; int b; printf("Vvedite visoty:\n"); scanf("%d", &a); //printf("a+1=%d\n", a+1); printf("Vvedite shiriny:\n"); scanf("%d", &b); dom(a,b); }
/** * Returns true if the domain of the factor matches the vertex / vertices. */ bool valid() const { for (vertex_type v : this->vertices()) { if (!equivalent(arguments(v), node_domain_type({v}))) { return false; } } for (edge_type e : this->edges()) { edge_domain_type dom({e.source(), e.target()}); if (!equivalent(arguments(e), dom)) { return false; } } return true; }
void QXmlTreeView::pasteNode() { QXmlTreeModel* treeModel = static_cast<QXmlTreeModel*>(model()); if( !treeModel ) return; QXmlTreeNode* xmlNode = treeModel->rootNode(); if (currentIndex().isValid()) xmlNode = static_cast<QXmlTreeNode*>(currentIndex().internalPointer()); const QMimeData* mime = QApplication::clipboard()->mimeData();; if (mime->hasFormat("text/plain")) { QDomDocument dom("Paste"); if (dom.setContent(mime->data("text/plain"))) treeModel->undoStack()->push(createAddUndoCommand(dom.documentElement(), xmlNode->xmlNode(), treeModel, tr("Paste nodes"))); } }
void testDataReorder(unsigned v0_id, unsigned v1_id, unsigned v2_id) { assert(v0_id != v1_id && v1_id != v2_id && v0_id != v2_id); // setup the data as if its from belief prop std::vector<std::pair<size_t, double> > data; variable_t v0(0, 4); variable_t v1(1, 3); variable_t v2(2, 2); std::vector<variable_t> args; args.push_back(v0); args.push_back(v1); args.push_back(v2); domain_t dom(args); create_data_vector(data, dom); // create a table with variables that are not resorted sparse_table_t st_gm(args, data); //std::cout << "st_gm " << st_gm << std::endl; variable_t r0(v0_id, 4); variable_t r1(v1_id, 3); variable_t r2(v2_id, 2); std::vector<variable_t> reordered_args; reordered_args.push_back(r0); reordered_args.push_back(r1); reordered_args.push_back(r2); sparse_table_t st(reordered_args, data); //std::cout << "st " << st << std::endl; assignment_t asg_gm(st_gm.domain()); domain_t::const_iterator asg_it = dom.begin(); domain_t::const_iterator end = dom.begin(); for( ; asg_it != end; ++asg_it) { asg_gm.set_asg(v0, asg_it->asg(r0)); asg_gm.set_asg(v1, asg_it->asg(r1)); asg_gm.set_asg(v2, asg_it->asg(r2)); //std::cout << "st_gm{" << asg_gm << "}=" << st_gm.logP(asg_gm) << "; " // << "st{" << asg_it << "}=" << st.logP(asg_it) << std::endl; ASSERT_TRUE(st_gm.logP(asg_gm) == st.logP(*asg_it)); } }
void MainWindow::openNews(QString path) { QString title; QString content; // On va ouvrir le fichier XML et en extraire ce dont on a besoin QDomDocument dom("news_xml"); QFile newsFile(path); if(newsFile.exists()) { if(!newsFile.open(QIODevice::ReadOnly)) { QMessageBox::critical(this, "Impossible d'ouvrir le fichier", "Erreur lors de l'ouverture de " + path); qApp->exit(); } if(!dom.setContent(&newsFile, false)) { newsFile.close(); QMessageBox::critical(this, "Impossible de parser le XML", "Impossible d'analyser le fichier " + path); qApp->exit(); } QDomElement racine = dom.documentElement(); racine = racine.firstChildElement(); while(!racine.isNull()) { if(racine.tagName() == "header") { QDomElement elm = racine.firstChildElement(); while(!elm.isNull()) { if(elm.tagName() == "title") { title = elm.text(); } elm = elm.nextSiblingElement(); } } racine = racine.nextSiblingElement(); if(racine.tagName() == "content") { content = trim(racine.text()); } racine = racine.nextSiblingElement(); } news->setContent(content); news->setTitle(title); nTitle->setText(title); editor->setText(content); sParse(); setWindowTitle("zNews - " + newsFile.fileName()); newsFile.close(); currentFile = &newsFile; } }
// **************************************************************************** // Method: avtDatasetOnDemandFilter::GetLoadedDomains // // Purpose: // Return a list of domains that are loaded. // // Programmer: Dave Pugmire // Creation: March 19, 2008 // // Modifications: // // Dave Pugmire, Tue Mar 10 12:41:11 EDT 2009 // Added support for time/domain. // // **************************************************************************** void avtDatasetOnDemandFilter::GetLoadedDomains(std::vector<std::vector<int> > &domains) { debug1<<"avtDatasetOnDemandFilter::GetLoadedDomains()\n"; if ( ! OperatingOnDemand() ) EXCEPTION0(ImproperUseException); domains.resize(0); std::list<DomainCacheEntry>::const_iterator it; for ( it = domainQueue.begin(); it != domainQueue.end(); it++ ) { vector<int> dom(2); dom[0] = it->domainID; dom[1] = it->timeStep; domains.push_back(dom); } }
void UpdateDialog::analyse_meta_informations(QNetworkReply* r){ if(r->error()!= QNetworkReply::NoError){ ui->error_label->setText(r->errorString()); current_repo_index++; if(current_repo_index<repositories_list.size()) Download_meta_informations(); return; } QDomDocument dom("updater"); dom.setContent(r); QDomElement dom_element = dom.firstChildElement("files"); if(dom_element.isNull()) return; int size = dom_element.childNodes().length(); QDomNode noeud= dom_element.firstChild(); while(!noeud.isNull()){ QDomNodeList i = noeud.childNodes(); File* item = new File(); for(int j =0; j< i.count();j++){ QDomElement ele = i.item(j).toElement(); if(ele.tagName()=="filename"){ item->setFilePath(ele.text()); } if(ele.tagName()=="md5"){ item->setMd5Hash(ele.text()); } if(ele.tagName()=="sha1"){ item->setSha1Hash(ele.text()); } if(ele.tagName()=="date"){ item->setLastModifiedDate(QDateTime::fromString(ele.text(),QString("dd/MM/yyyy"))); } } addFiletoTree(item); file_list << item; ui->meta_dl_bar->setValue(ui->meta_dl_bar->value()+ui->meta_dl_bar->maximum()/size); noeud = noeud.nextSibling(); } ui->update_files_tree->sortItems(0, Qt::AscendingOrder); ui->error_label->setText(tr("finished")); ui->nextButton->setEnabled(true); }
//////////////////////////////////////////////////////////////////////////////// // 領域情報のチェック cpm_ErrorCode cpm_GlobalDomainInfo::CheckData( int nRank ) { cpm_ErrorCode ret; // 親クラス if( (ret = cpm_DomainInfo::CheckData()) != CPM_SUCCESS ) { return ret; } // 領域分割数 if( m_divNum[0] <= 0 || m_divNum[1] <= 0 || m_divNum[2] <= 0 ) { return CPM_ERROR_INVALID_DIVNUM; } // 活性サブドメイン情報 int ndom = m_subDomainInfo.size(); if( ndom == 0 ) { //活性サブドメイン情報が空のとき、全領域を活性サブドメインとする if( nRank != m_divNum[0]*m_divNum[1]*m_divNum[2] ) { return CPM_ERROR_MISMATCH_NP_SUBDOMAIN; } for( int k=0;k<m_divNum[2];k++ ){ for( int j=0;j<m_divNum[1];j++ ){ for( int i=0;i<m_divNum[0];i++ ){ int pos[3] = {i,j,k}; cpm_ActiveSubdomainInfo dom( pos ); AddSubdomain( dom ); }}} } else { if( nRank != ndom ) { return CPM_ERROR_MISMATCH_NP_SUBDOMAIN; } } return CPM_SUCCESS; }
int main (int argc, char *argv[]) { int opt; write_checksum = 0; while ((opt = getopt(argc, argv, "rcmd:")) !=-1) { switch (opt) { case 'r': read_sfp(); break; case 'c': write_checksum = 1; read_sfp(); vendor_fy(); break; case 'm': dom(); break; case 'd': dump(optarg); break; default: /* '?' */ fprintf(stderr, "Usage: %s\n" " -r read the sfp or sfp+\n" " -c calculate and write Vendor bytes\n" " -m Print DOM values if SFP supports DOM\n" " -d filename - dump the eprom to a file\n" ,argv[0]); exit(EXIT_FAILURE); } } if (argc <=1) { fprintf(stderr, "Usage: %s\n" " -r read the sfp or sfp+\n" " -c calculate and write Vendor bytes\n" " -m Print DOM values if SFP supports DOM\n" " -d filename - save the eprom to a file\n" ,argv[0]); exit(EXIT_FAILURE); } }
void Project::load(std::string new_filename) { File file(new_filename); DomDocument dom(file, true); file.close(); DomElement dom_project = dom.get_document_element(); if (dom_project.get_tag_name() != "project") throw Exception("Not a game project file"); filename = new_filename; name = PathHelp::get_basename(filename); items.clear(); std::vector<DomNode> items_nodes = dom_project.select_nodes("items"); for (size_t i = 0; i < items_nodes.size(); i++) { load_item_children(&items, dom_project.select_node("items").to_element()); } }
CString GetDomain(CString& src) { CString result; char* address = StringToChar(src); bool is_ip = true; int i=0; while(address[i]!='\0') { if((address[i]!='.')||((address[i]<'0')&&(address[i]>'9'))) { is_ip = false; break; } i++; } if(is_ip) result = src; else { int dots = 0; int i=strlen(address)-1; while(i>=0) { if(address[i]=='.') dots++; if(dots==2) break; i--; } char* addr = MidStr(address,i+1,strlen(address)); CString dom(addr); result = dom; } return result; }
void MainWindow::newPoints(int n) { scene.periodic_triangulation.clear(); scene.points.clear(); CGAL::Random rnd(std::time(NULL)); CGAL::Random_points_in_cube_3<Point_3, Creator> in_cube(1,rnd); for (int i=0 ; i<n ; i++) if (scene.two_dimensional) { Point_3 rdpt = *in_cube++; scene.points.push_back(Point_3(rdpt.x(),rdpt.y(),0.)); } else scene.points.push_back(*in_cube++); Iso_cuboid_3 dom(-1,-1,-1,1,1,1); scene.periodic_triangulation.set_domain(dom); scene.periodic_triangulation.insert(scene.points.begin(), scene.points.end()); FT cx(0),cy(0),cz(0); for (int i=0 ; i<8 ; i++) { cx += dom[i].x(); cy += dom[i].y(); cy += dom[i].y(); } qglviewer::Vec center(cx/8.,cy/8.,cz/8.); viewer->setSceneCenter(center); viewer->setSceneRadius(std::sqrt( ((dom.xmax()-dom.xmin())*(dom.xmax()-dom.xmin())) + ((dom.xmax()-dom.xmin())*(dom.xmax()-dom.xmin())) + ((dom.xmax()-dom.xmin())*(dom.xmax()-dom.xmin())))); speedSlider->setRange(0,100); speedSlider->setSliderPosition(100); emit (sceneChanged()); }
sparse_table_t create_rand_sparse_table(unsigned v0_id, unsigned v1_id, unsigned v2_id) { variable_t v0(v0_id, 4); variable_t v1(v1_id, 3); variable_t v2(v2_id, 2); std::vector<variable_t> args; args.push_back(v0); args.push_back(v1); args.push_back(v2); domain_t dom(args); sparse_table_t st(dom); domain_t::const_iterator asg_it = dom.begin(); domain_t::const_iterator end = dom.end(); for( ; asg_it != end; ++asg_it) { if(rand() % 100 <= 20) { st.set_logP( *asg_it, -1 * (rand() % 100) ); } } return st; }
extern "C" CDECL int rust_start(uintptr_t main_fn, rust_crate const *crate, int argc, char **argv) { int ret; { rust_srv srv; rust_dom dom(&srv, crate, "main"); command_line_args args(dom, argc, argv); dom.log(rust_log::DOM, "startup: %d args", args.argc); for (int i = 0; i < args.argc; ++i) dom.log(rust_log::DOM, "startup: arg[%d] = '%s'", i, args.argv[i]); if (dom._log.is_tracing(rust_log::DWARF)) { rust_crate_reader rdr(&dom, crate); } uintptr_t main_args[4] = { 0, 0, 0, (uintptr_t)args.args }; dom.root_task->start(crate->get_exit_task_glue(), main_fn, (uintptr_t)&main_args, sizeof(main_args)); ret = dom.start_main_loop(); } #if !defined(__WIN32__) // Don't take down the process if the main thread exits without an // error. if (!ret) pthread_exit(NULL); #endif return ret; }
static void draw_week(Calendar *c, XRectangle *rect, Boundary boundary) { Week *w = (Week *)c->view->week_info; register int current_day; register int n; register int x, y; int char_height; int start_date; char **day_names; char label[80]; char buf[MAXNAMELEN]; char *footer_message = NULL; int start_ind, end_ind; int today_dom, day_om; new_XContext *xc; Props *p = (Props*)c->properties; XRectangle chartrect; OrderingType ot = get_int_prop(p, CP_DATEORDERING); Tick start_tick, end_tick; time_t start, stop; CSA_return_code stat; CSA_entry_handle *list; CSA_attribute *range_attrs; CSA_enum *ops; CSA_uint32 a_total; int i, lower_bound = 0, upper_bound = 0; XFontSetExtents regfontextents, boldfontextents; int notused, width1, width2, width3; CalFontExtents(w->font, ®fontextents); char_height = regfontextents.max_logical_extent.height; start_date = w->start_date; xc = c->xcontext; start = (time_t) lowerbound(start_date); stop = (time_t) next_ndays(start, 7) - 1; if (c->paint_cache == NULL) { setup_range(&range_attrs, &ops, &i, start, stop, CSA_TYPE_EVENT, 0, B_FALSE, c->general->version); csa_list_entries(c->cal_handle, i, range_attrs, ops, &a_total, &list, NULL); free_range(&range_attrs, &ops, i); allocate_paint_cache(list, a_total, &c->paint_cache); c->paint_cache_size = a_total; csa_free(list); } gr_clear_box(xc, 0, 0, w->canvas_w, w->canvas_h); CalTextExtents(w->font, days2[3], cm_strlen(days2[3]), ¬used, ¬used, &width1, ¬used); CalTextExtents(w->font, " 00", cm_strlen(" 00"), ¬used, ¬used, &width2, ¬used); CalTextExtents(w->font, "Wed 00", cm_strlen("Wed 00"), ¬used, ¬used, &width3, ¬used); if (width1 + width2 <= w->day_width - 2) day_names = days2; else if (width3 <= w->day_width - 2) day_names = days; else day_names = days3; x = w->x; y = w->y; format_week_header(start_date, ot, label); gr_text(xc, x, y - char_height / 2, w->font, label, rect); /* * Draw bold box around first 5 days */ gr_draw_box(xc, x, y, w->width, w->day_height, rect); gr_draw_box(xc, x - 1, y - 1, w->width + 2, w->day_height + 2, rect); gr_draw_line(xc, x, y + w->label_height, x + w->width, y + w->label_height, gr_solid, rect); /* * Draw bold box around last 2 days */ x += 3 * w->day_width; y += w->day_height; gr_draw_box(xc, x, y, 2 * w->day_width, w->day_height, rect); gr_draw_box(xc, x - 1, y, 2 * w->day_width + 2, w->day_height + 1,rect); gr_draw_line(xc, x, y + w->label_height, x + 2 * w->day_width, y + w->label_height, gr_solid, rect); y = w->y; x = w->x + w->day_width; for (n = 0; n < 4; n++) { if (n < 3) { gr_draw_line(xc, x, y, x, y + w->day_height, gr_solid, rect); } else { gr_draw_line(xc, x, y, x, y + 2 * w->day_height, gr_solid, rect); } x += w->day_width; } /* * Fill in week with appointments */ x = w->x; y = w->y; current_day = start_date; today_dom = dom(time(0)); /* Crock alert!!!! The obscure code below is doing something really nasty. The variable boundary indicates whether the week being displayed falls across a boundary with the beginning or the end of time. In the case of the beginning of time, the code then assumes that the first 2 days in the week need to be unbuttoned, and the rest buttoned and painted. Likewise, with the end of time case, the code assumes the last 3 days of the week need similar treatment. */ for (n = 0; n < 7; n++) { if (n == 5) { y += w->day_height; x = w->x + 3 * w->day_width; } if (boundary == okay) { day_om = dom(current_day); display_hot_btn(c, n, day_om); fill_day(c, w, x, y, current_day, c->paint_cache, c->paint_cache_size, rect); current_day += daysec; if (lower_bound > 0) { sprintf(buf, "%s", catgets(c->DT_catd, 1, 623, "Calendar does not display dates prior to January 1, 1970")); footer_message = buf; } else footer_message = NULL; } else if (boundary == lower) { /* skip days before Jan 1, 1970 */ clear_hot_btn(c, n); if (lower_bound++ == 2) boundary = okay; } else if (boundary == upper) { day_om = dom(current_day); if (++upper_bound <= 4) display_hot_btn(c, n, day_om); fill_day(c, w, x, y, current_day, c->paint_cache, c->paint_cache_size, rect); current_day += daysec; sprintf(buf, "%s", catgets(c->DT_catd, 1, 624, "Calendar does not display dates after December 31, 2037")); footer_message = buf; if (upper_bound > 4) clear_hot_btn(c, n); } x += w->day_width; } if (rect != NULL) { CalFontExtents(w->small_bold_font, &boldfontextents); chartrect.x = w->x; chartrect.y = w->chart_y - w->label_height; chartrect.width = w->chart_width + 3*boldfontextents.max_logical_extent.width; chartrect.height = w->chart_height + 2*w->label_height; } if (rect == NULL || myrect_intersectsrect(rect, &chartrect)) { for (i = 0; i < c->paint_cache_size; i++) { start_tick = (c->paint_cache)[i].start_time; end_tick = (c->paint_cache)[i].end_time; cm_update_segs(w, start_tick, (end_tick ? (end_tick - start_tick) : 0), &start_ind, &end_ind, True); } chart_draw_appts(w, 0, w->segs_in_array); draw_chart(c, w, NULL); } /* do not repaint the footer message in a damage display. For some reason this causes the damage routine to get called again, resulting in a recursive dsaster. */ if (footer_message && !rect) set_message(c->message_text, footer_message); }
void Scene::read(const char *filename) { QString path; if(!filename) path = QString("./data/scenes/open/"); else path = "./data/scenes/"+QString(filename)+"/"; //Parsing XML document. QDomDocument dom("config"); QFile xml_doc(path+"config.xml"); if(!xml_doc.open(QIODevice::ReadOnly)) { QMessageBox::warning(NULL, QString("Read ")+filename+QString(" config"), QString("Can't open the file config.xml of ")+filename); return; } if (!dom.setContent(xml_doc.readAll())) { xml_doc.close(); QMessageBox::warning(NULL, QString("Read ")+filename+QString(" config"), "Le document XML n'a pas pu être attribué à l'objet QDomDocument."); return; } xml_doc.close(); //Count layers QDomNode node = dom.documentElement().firstChild(); while(!node.isNull()) { QDomElement element = node.toElement(); if(element.tagName() == "layer") m_nbLayer++; if(element.tagName() == "copy") m_nbCopy++; node = node.nextSibling(); } //Init new layers & copyers m_layer = new Layer[m_nbLayer]; for(int i=0; i<m_nbLayer; i++) { m_layer[i].shader = NULL; m_layer[i].buffer = NULL; m_layer[i].backBuffer = NULL; m_layer[i].tmpBuffer = NULL; m_layer[i].mode = DEFAULT; for(int j=0; j<4; j++) { m_layer[i].channel[j] = NULL; } } m_copy = new Copy[m_nbCopy]; for(int i=0; i<m_nbCopy; i++) { m_copy[i].src = NULL; m_copy[i].dest = NULL; } //Read the xml file node = dom.documentElement().firstChild(); int textureID=0; while(!node.isNull()) { QDomElement element = node.toElement(); if(element.tagName() == "copy") { int id = element.attribute("id", "0").toInt(); int src = element.attribute("src", "0").toInt(); int dest = element.attribute("dest", "0").toInt(); m_copy[id].src = m_layer[src].buffer; m_copy[id].dest = m_layer[dest].backBuffer; } else if(element.tagName() == "layer") { //Get infos .. int id = element.attribute("id", "0").toInt(); QString format = element.attribute("format", "rgba"); QString blend = element.attribute("mode", "default"); m_layer[id].width = element.attribute("width", "-1").toInt(); m_layer[id].height = element.attribute("height", "-1").toInt(); QString type = element.attribute("type", "pixel"); if(type == "pixel") m_layer[id].type = PIXEL; else if(type == "particle") { m_layer[id].type = PARTICLE; m_nbParticles = element.attribute("count", "0").toInt(); generateParticles(); } m_layer[id].iterate = element.attribute("iterate", "0").toInt(); if(m_layer[id].width == -1) m_layer[id].width = Core::instance()->getResX(); if(m_layer[id].height == -1) m_layer[id].height = Core::instance()->getResY(); if(blend != "default") { m_layer[id].tmpBuffer = new FBO(); m_layer[id].tmpBuffer->setSize(m_layer[id].width, m_layer[id].height); } //Select format GLint bufferFormat = GL_RGBA; if(format == "rgb") bufferFormat = GL_RGB; else if(format == "rgba") bufferFormat = GL_RGBA; else if(format == "rgba32") bufferFormat = GL_RGBA32F_ARB; //work ? else if(format == "rgba32") bufferFormat = GL_RGBA32F_ARB; //work ? else if(format == "rgba32half") bufferFormat = GL_RGBA16F_ARB; //work ? else if(format == "luminance") bufferFormat = GL_LUMINANCE; else QMessageBox::warning(NULL, QString("Scene ")+filename, QString("This layer format doesn't exist : ")+format); //Select mode if(blend == "default") m_layer[id].mode = DEFAULT; else if(blend == "alpha") m_layer[id].mode = BLEND_ALPHA; else if(blend == "add") m_layer[id].mode = BLEND_ADD; else if(blend == "none") m_layer[id].mode = NONE; else QMessageBox::warning(NULL, QString("Scene ")+filename, QString("This layer mode doesn't exist : ")+blend); //Compute shader QString filePath = element.attribute("value", "none"); m_layer[id].name = filePath; int ok; if(filePath != "none") { QFile file(path+filePath); QString strings; if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file); while (!in.atEnd()) { strings += in.readLine()+"\n"; } } Core::instance()->writeInfo( QString("Compiling ") + m_layer[id].name + QString(".. ") ); m_layer[id].shader = new Shader(); if( m_layer[id].type == PIXEL) ok = m_layer[id].shader->compil(Core::instance()->getVertexShader(),strings.toStdString().c_str()); else if( m_layer[id].type == PARTICLE) ok = m_layer[id].shader->compil(Core::instance()->getVertexShaderParticle(),strings.toStdString().c_str()); if(ok == SHADER_SUCCESS) Core::instance()->writeInfo( QString("[Done]\n"), false ); file.close(); } //Generate buffers ! if(ok == SHADER_SUCCESS) { m_layer[id].buffer = new FBO(); m_layer[id].buffer->setSize(m_layer[id].width, m_layer[id].height); m_layer[id].buffer->setFormat(bufferFormat); if(element.attribute("backbuffer", "false") == "true" || m_layer[id].iterate > 0) { m_layer[id].backBuffer = new FBO(); m_layer[id].backBuffer->setSize(m_layer[id].width, m_layer[id].height); m_layer[id].backBuffer->setFormat(bufferFormat); } } else { return; } //Load channel textureID=0; QDomNode n = element.firstChild(); while(!n.isNull()) { QDomElement e = n.toElement(); if(e.tagName() == "channel") { if(textureID<4) { m_layer[id].channelName[textureID] = e.attribute("id", "tex"); if( e.attribute("type", "") == "image" ) { m_layer[id].channel[textureID] = new Texture(); m_layer[id].channel[textureID]->load("./data/textures/"+e.attribute("value", "none").toStdString()); } else if( e.attribute("type", "") == "layer" ) { m_layer[id].channel[textureID] = m_layer[e.attribute("value", "0").toInt()].buffer; m_layer[e.attribute("value", "0").toInt()].buffer->bind(); } textureID++; } else QMessageBox::warning(NULL, QString("Read ")+filename+QString(" config"), QString("Too many textures (max is 4)")); } n = n.nextSibling(); } } else if(element.tagName() == "param") { m_param[element.attribute("id", "0").toInt()] = element.attribute("value","none"); } node = node.nextSibling(); } }
void ISPCATBuilder::processCFG(WorkSpace *ws, CFG *cfg) { ISPProblem problem(_isp_size); DefaultListener<ISPProblem> listener(ws, problem,true); DefaultFixPoint<DefaultListener<ISPProblem> > fixpoint(listener); HalfAbsInt<DefaultFixPoint<DefaultListener<ISPProblem> > > halfabsint(fixpoint, *ws); halfabsint.solve(); for(CFG::BBIterator bb(cfg); bb; bb++) { if (bb->isEntry() || bb->isExit()) continue; FunctionBlock *fb = FUNCTION_BLOCK(bb); if (fb) { ISPProblem::Domain dom(*listener.results[cfg->number()][bb->number()]); bool may, must; dom.contains(fb, &may, &must); if (must) { ISP_CATEGORY(bb) = ISP_ALWAYS_HIT; } else { if (!may) { ISP_CATEGORY(bb) = ISP_ALWAYS_MISS; } else { BasicBlock *pers_header = NULL; BasicBlock *loop_header = ENCLOSING_LOOP_HEADER(bb); while (loop_header){ bool pers_entering, pers_back = true; for (BasicBlock::InIterator edge(loop_header) ; edge && pers_back; edge++){ BasicBlock * source = edge->source(); ISPProblem::Domain source_out(*listener.results_out[cfg->number()][source->number()]); bool pers_may, pers_must; source_out.contains(fb, &pers_may, &pers_must); if (!Dominance::isBackEdge(edge)){ // edge thats enters the loop pers_entering = pers_must; } else { // backedge if (!pers_must) pers_back = false; } } if (pers_back){ pers_header = loop_header; if (pers_entering) loop_header = ENCLOSING_LOOP_HEADER(loop_header); else loop_header = NULL; } else loop_header = NULL; } if (pers_header){ ISP_CATEGORY(bb) = ISP_PERSISTENT; ISP_HEADER(bb) = pers_header; } else ISP_CATEGORY(bb) = ISP_NOT_CLASSIFIED; } } } } }
void CL_GUIComponent::load_css_layout(const CL_String &xml_filename, const CL_String &css_filename) { CL_CSSDocument2 css_document; css_document.add_sheet(css_filename); CL_File file(xml_filename); CL_DomDocument dom(file, false); CL_DomNode cur = dom.get_document_element().get_first_child(); std::vector<CL_CSSLayoutElement> element_stack; { CL_DomSelectNode select_node(dom.get_document_element()); impl->css_element.apply_properties(css_document.select(&select_node)); impl->css_element.apply_properties(dom.get_document_element().get_attribute("style")); impl->css_element.set_col_span(dom.get_document_element().get_attribute_int("colspan", 1)); impl->css_element.set_row_span(dom.get_document_element().get_attribute_int("rowspan", 1)); } element_stack.push_back(impl->css_element); while (!cur.is_null()) { CL_CSSLayoutElement child_css_element; if (cur.is_element()) { CL_DomElement cur_element = cur.to_element(); CL_DomSelectNode select_node(cur_element); child_css_element = element_stack.back().create_element(cur_element.get_tag_name()); child_css_element.apply_properties(css_document.select(&select_node)); child_css_element.apply_properties(cur_element.get_attribute("style")); child_css_element.set_col_span(cur_element.get_attribute_int("colspan", 1)); child_css_element.set_row_span(cur_element.get_attribute_int("rowspan", 1)); } else if (cur.is_text()) { CL_DomText cur_text = cur.to_text(); element_stack.back().create_text(cur_text.get_node_value()); } CL_DomNode next = cur.get_first_child(); if (next.is_null()) { next = cur.get_next_sibling(); if (next.is_null()) { next = cur.get_parent_node(); while (!next.is_null() && next.get_next_sibling().is_null()) next = next.get_parent_node(); if (!next.is_null()) next = next.get_next_sibling(); } } else { element_stack.push_back(child_css_element); } cur = next; } CL_GraphicContext gc = get_gc(); impl->css_layout.layout(gc, get_size()); }
int main(int argc, char *argv[]) { // Initialize POOMA and output stream, using Tester class Pooma::initialize(argc, argv); Pooma::Tester tester(argc, argv); tester.out() << argv[0] << ": Tests of expressions with multipatch." << std::endl; tester.out() << "------------------------------------------------" << std::endl; int size = 30; int from = 0; int to = size-1; int fromInterior = 0; int toInterior = size-1; int loc1 = 4; int loc2 = 14; int loc3 = 22; Interval<1> dom(from,to); Interval<1> I(fromInterior,toInterior); Interval<1> domain(size); UniformGridPartition<1> partition(Loc<1>(10),GuardLayers<1>(1)); UniformGridLayout<1> layout(domain,partition,ReplicatedTag()); Array<1,double,MultiPatch<UniformTag,Brick> > a1(layout), a2(layout), a3(layout), a4(layout), initial(layout); initial = 0.0; Pooma::blockAndEvaluate(); initial(loc1) = 2.0; initial(loc2) = 3.0; initial(loc3) = 4.0; test1(tester, 1, a1, a2, a3, a4, initial, I); test2(tester, 2, a1, a2, a3, a4, initial, I); test3(tester, 3, a1, a2, a3, a4, initial, I); test4(tester, 4, a1, a2, a3, a4, initial, I); Array<1,Vector<2,double>,MultiPatch<UniformTag,Brick> > av1(layout),av2(layout),av3(layout),av4(layout), initialv(layout); initialv = Vector<2,double>(0.0,0.0); Pooma::blockAndEvaluate(); initialv(loc1) = Vector<2,double>(2.0,3.0); initialv(loc2) = Vector<2,double>(3.0,-1.0); initialv(loc3) = Vector<2,double>(4.0,-5.0); test5(tester, 5, av1, av2, av3, av4, initialv, I); test1(tester, 6, av1, av2, av3, av4, initialv, I); test4(tester, 7, av1, av2, av3, av4, initialv, I); UniformGridLayout<1> layoutr(domain, partition, DistributedTag()); Array<1, double, MultiPatch<UniformTag, Remote<Brick> > > ar1(layoutr), ar2(layoutr), ar3(layoutr), ar4(layoutr); test1(tester, 8, ar1, ar2, ar3, ar4, initial, I); test2(tester, 9, ar1, ar2, ar3, ar4, initial, I); test3(tester, 10, ar1, ar2, ar3, ar4, initial, I); test4(tester, 11, ar1, ar2, ar3, ar4, initial, I); tester.out() << "------------------------------------------------" << std::endl; int retval = tester.results("array_test18"); Pooma::finalize(); return retval; }
TEST_F(fisheyeTest, jacobians) { int n = 10; cv::Mat X(1, n, CV_64FC3); cv::Mat om(3, 1, CV_64F), theT(3, 1, CV_64F); cv::Mat f(2, 1, CV_64F), c(2, 1, CV_64F); cv::Mat k(4, 1, CV_64F); double alpha; cv::RNG r; r.fill(X, cv::RNG::NORMAL, 2, 1); X = cv::abs(X) * 10; r.fill(om, cv::RNG::NORMAL, 0, 1); om = cv::abs(om); r.fill(theT, cv::RNG::NORMAL, 0, 1); theT = cv::abs(theT); theT.at<double>(2) = 4; theT *= 10; r.fill(f, cv::RNG::NORMAL, 0, 1); f = cv::abs(f) * 1000; r.fill(c, cv::RNG::NORMAL, 0, 1); c = cv::abs(c) * 1000; r.fill(k, cv::RNG::NORMAL, 0, 1); k*= 0.5; alpha = 0.01*r.gaussian(1); cv::Mat x1, x2, xpred; cv::Matx33d theK(f.at<double>(0), alpha * f.at<double>(0), c.at<double>(0), 0, f.at<double>(1), c.at<double>(1), 0, 0, 1); cv::Mat jacobians; cv::fisheye::projectPoints(X, x1, om, theT, theK, k, alpha, jacobians); //test on T: cv::Mat dT(3, 1, CV_64FC1); r.fill(dT, cv::RNG::NORMAL, 0, 1); dT *= 1e-9*cv::norm(theT); cv::Mat T2 = theT + dT; cv::fisheye::projectPoints(X, x2, om, T2, theK, k, alpha, cv::noArray()); xpred = x1 + cv::Mat(jacobians.colRange(11,14) * dT).reshape(2, 1); CV_Assert (cv::norm(x2 - xpred) < 1e-10); //test on om: cv::Mat dom(3, 1, CV_64FC1); r.fill(dom, cv::RNG::NORMAL, 0, 1); dom *= 1e-9*cv::norm(om); cv::Mat om2 = om + dom; cv::fisheye::projectPoints(X, x2, om2, theT, theK, k, alpha, cv::noArray()); xpred = x1 + cv::Mat(jacobians.colRange(8,11) * dom).reshape(2, 1); CV_Assert (cv::norm(x2 - xpred) < 1e-10); //test on f: cv::Mat df(2, 1, CV_64FC1); r.fill(df, cv::RNG::NORMAL, 0, 1); df *= 1e-9*cv::norm(f); cv::Matx33d K2 = theK + cv::Matx33d(df.at<double>(0), df.at<double>(0) * alpha, 0, 0, df.at<double>(1), 0, 0, 0, 0); cv::fisheye::projectPoints(X, x2, om, theT, K2, k, alpha, cv::noArray()); xpred = x1 + cv::Mat(jacobians.colRange(0,2) * df).reshape(2, 1); CV_Assert (cv::norm(x2 - xpred) < 1e-10); //test on c: cv::Mat dc(2, 1, CV_64FC1); r.fill(dc, cv::RNG::NORMAL, 0, 1); dc *= 1e-9*cv::norm(c); K2 = theK + cv::Matx33d(0, 0, dc.at<double>(0), 0, 0, dc.at<double>(1), 0, 0, 0); cv::fisheye::projectPoints(X, x2, om, theT, K2, k, alpha, cv::noArray()); xpred = x1 + cv::Mat(jacobians.colRange(2,4) * dc).reshape(2, 1); CV_Assert (cv::norm(x2 - xpred) < 1e-10); //test on k: cv::Mat dk(4, 1, CV_64FC1); r.fill(dk, cv::RNG::NORMAL, 0, 1); dk *= 1e-9*cv::norm(k); cv::Mat k2 = k + dk; cv::fisheye::projectPoints(X, x2, om, theT, theK, k2, alpha, cv::noArray()); xpred = x1 + cv::Mat(jacobians.colRange(4,8) * dk).reshape(2, 1); CV_Assert (cv::norm(x2 - xpred) < 1e-10); //test on alpha: cv::Mat dalpha(1, 1, CV_64FC1); r.fill(dalpha, cv::RNG::NORMAL, 0, 1); dalpha *= 1e-9*cv::norm(f); double alpha2 = alpha + dalpha.at<double>(0); K2 = theK + cv::Matx33d(0, f.at<double>(0) * dalpha.at<double>(0), 0, 0, 0, 0, 0, 0, 0); cv::fisheye::projectPoints(X, x2, om, theT, theK, k, alpha2, cv::noArray()); xpred = x1 + cv::Mat(jacobians.col(14) * dalpha).reshape(2, 1); CV_Assert (cv::norm(x2 - xpred) < 1e-10); }