Пример #1
0
QDomElement
OutputFileParams::toXml(QDomDocument& doc, QString const& name) const
{
    if (isValid()) {
        QDomElement el(doc.createElement(name));
        el.setAttribute("size", QString::number(m_size));
        el.setAttribute("mtime", QString::number(m_mtime));
        return el;
    } else {
        return QDomElement();
    }
}
Пример #2
0
Matrix::Matrix(const Matrix & mt):r(mt.r),c(mt.c)
{
    elm = new double*[r];
    for (int i = 0; i < r; i++) {
        elm[i] = new double[c];
    }
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            el(i,j) = mt.el(i,j);
        }
    }
}
Пример #3
0
QDomElement
Params::toXml(QDomDocument& doc, QString const& name) const
{
	XmlMarshaller marshaller(doc);
	
	QDomElement el(doc.createElement(name));
	el.setAttribute("mode", m_mode == MODE_AUTO ? "auto" : "manual");
	el.appendChild(marshaller.rectF(m_contentRect, "content-rect"));
	el.appendChild(marshaller.sizeF(m_contentSizeMM, "content-size-mm"));
	el.appendChild(m_deps.toXml(doc, "dependencies"));
	return el;
}
Пример #4
0
bool
xml_inresp_t::is_fault (int *code, str *msg) const
{
  ptr<const xml_element_t> e;
  ptr<const xml_method_response_t> r;
  ptr<const xml_fault_t> f;

  // comment out debug statement
  // warn << "obj: "<< el ()->xml_typename () << "\n"; 

  if (el () && 
      (r = el ()->to_xml_method_response ()) && 
      (e = r->body ()) &&
      (f = e->to_xml_fault ())) {
    xml_obj_const_t o (f);
    *code = o("faultCode");
    *msg = o("faultString");
    return true;
  }
  return false;
}
Пример #5
0
 int MenuBar::calculateWidth(SizeConstraint inSizeConstraint) const
 {
     int result = 0;
     std::vector<Element *> items;
     el()->getElementsByTagName(XMLMenuItem::TagName(), items);
     for (size_t idx = 0; idx != items.size(); ++idx)
     {
         MenuItem * item = items[idx]->component()->downcast<MenuItem>();
         result += item->calculateWidth(inSizeConstraint) + Defaults::menuBarSpacing();
     }
     return result;
 }
Пример #6
0
void agg_renderer<T0,T1>::process(dot_symbolizer const& sym,
                                  mapnik::feature_impl & feature,
                                  proj_transform const& prj_trans)
{
    double width = 0.0;
    double height = 0.0;
    bool has_width = has_key(sym,keys::width);
    bool has_height = has_key(sym,keys::height);
    if (has_width && has_height)
    {
        width = get<double>(sym, keys::width, feature, common_.vars_, 0.0);
        height = get<double>(sym, keys::height, feature, common_.vars_, 0.0);
    }
    else if (has_width)
    {
        width = height = get<double>(sym, keys::width, feature, common_.vars_, 0.0);
    }
    else if (has_height)
    {
        width = height = get<double>(sym, keys::height, feature, common_.vars_, 0.0);
    }
    double rx = width/2.0;
    double ry = height/2.0;
    double opacity = get<double>(sym, keys::opacity, feature, common_.vars_, 1.0);
    color const& fill = get<mapnik::color>(sym, keys::fill, feature, common_.vars_, mapnik::color(128,128,128));
    ras_ptr->reset();
    agg::rendering_buffer buf(current_buffer_->raw_data(),current_buffer_->width(),current_buffer_->height(),current_buffer_->width() * 4);
    using blender_type = agg::comp_op_adaptor_rgba_pre<agg::rgba8, agg::order_rgba>;
    using pixfmt_comp_type = agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer>;
    using renderer_base = agg::renderer_base<pixfmt_comp_type>;
    using renderer_type = agg::renderer_scanline_aa_solid<renderer_base>;
    pixfmt_comp_type pixf(buf);
    pixf.comp_op(static_cast<agg::comp_op_e>(get<composite_mode_e>(sym, keys::comp_op, feature, common_.vars_, src_over)));
    renderer_base renb(pixf);
    renderer_type ren(renb);
    agg::scanline_u8 sl;
    ren.color(agg::rgba8_pre(fill.red(), fill.green(), fill.blue(), int(fill.alpha() * opacity)));
    agg::ellipse el(0,0,rx,ry);
    unsigned num_steps = el.num_steps();
    for (geometry_type const& geom : feature.paths()) {
        double x,y,z = 0;
        unsigned cmd = 1;
        geom.rewind(0);
        while ((cmd = geom.vertex(&x, &y)) != mapnik::SEG_END) {
            if (cmd == SEG_CLOSE) continue;
            prj_trans.backward(x,y,z);
            common_.t_.forward(&x,&y);
            el.init(x,y,rx,ry,num_steps);
            ras_ptr->add_path(el);
            agg::render_scanlines(*ras_ptr, sl, ren);
        }
    }
}
Пример #7
0
int main()
{
	int control = 1; 
	int w = 1; 
	int *d, *path; 
	int n, m; 
	cout << "Please input the number of the city:" << endl; 
	cin >> n; 
	cout << "Please input the number of the flight:" << endl; 
	cin >> m; 
	
	d = new int[n]; 
	path = new int[n];

	extLGraph<int> el(n); 
	int u, v; 
	for(int i = 0; i < m; i++)
	{
		cout << "Please input the start point and end point of the " << i+1 << " flight:" << endl; 
		cin >> u >> v; 
		cout << el.insert(u, v, w) << endl; 
	}
	
	while(control)
	{
		for (int i = 0; i < n; i++) d[i] = INF;
		memset(path, 0, sizeof(path));
		cout << "Please input the start and destination of you travel:"; 
		cin >> u >> v; 
		el.dijkstra(u, d, path); 
		
		if(d[v] != 0 && d[v] < INF)
		{	
			cout << "The length of the route that takes the least transition is:" << d[v] << endl; 
			cout << "And the route is:"; 
			int *p = new int [d[v]]; 
			int t = path[v]; 
			for(int i = 0; i < d[v]; i++){
				p[i] = t; 
				t = path[t]; 
			}
			for(int i = d[v]-1; i >= 0; i--){
				cout << " " << p[i]; 
			}
			cout << " " << v; 
		}
		else
			cout << "Between the two places is no route! or The start and end is same!"; 
		cout << endl << endl << "Enter 1 to continue or 0 to exit."; 
		cin >> control; 
	}
	return 0; 
} 
Пример #8
0
int
bug_b(MENU_ARGS)
{
  char c;

  decaln();

  cup(1, 1);
  el(0);
  printf("Line 11 should be double-wide, line 12 should be cleared.");

  cup(2, 1);
  el(0);
  printf("Then, the letters A-P should be written at the beginning");

  cup(3, 1);
  el(0);
  printf("of lines 12-%d, and the empty line and A-E are scrolled away.", max_lines);

  cup(4, 1);
  el(0);
  printf("If the bug is present, some lines are confused, look at K-P.");

  cup(11, 1);
  decdwl();
  decstbm(12, max_lines);

  cup(12, 1);
  el(0);
  printf("Here we go... ");
  holdit();

  cup(12, 1);
  ri();         /* Bug comes here */
  for (c = 'A'; c <= 'P'; c++)
    printf("%c\n", c);  /* Bug shows here */
  holdit();
  decstbm(0, 0);  /* No scr. region */
  return MENU_NOHOLD;
}
Пример #9
0
//To print the complex matrix in a formatted way:
//It first converts the complex number in to strings (the display of complex number is the same as the one above)
//and store them in a 2D string array. Then find the longest number in every column, padding the rest to the same
//length by spaces. This can make the matrix look better.
void CplxMatrix::printMatrix() const{
    std::string **output;
    output = new std::string*[r];
    for (int i = 0; i < r; i++) {
        output[i] = new std::string[c];
    }
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            std::string realstr = patch::to_string(el(i,j).re);
            realstr.erase (realstr.find_last_not_of('0') + 1, std::string::npos );
            std::string imstr = patch::to_string(el(i, j).im);
            imstr.erase (imstr.find_last_not_of('0') + 1, std::string::npos );
            if (el(i, j).im!=0&&el(i, j).re!=0) {
                output[i][j] = realstr+((el(i, j).im<0)?"":"+")+imstr+"i"+" ";
            }else if(el(i, j).im==0&&el(i, j).re!=0){
                output[i][j] = realstr + " ";
            }else if(el(i, j).im!=0&&el(i, j).re==0){
                output[i][j] = imstr + "i ";
            }else{
                output[i][j] = "0.";
            }
        }
    }
    int maxlength = 0;
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            if (output[i][j].length() > maxlength) {
                maxlength = (int)output[i][j].length();
            }
        }
    }
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            std::cout<< std::left << std::setw(maxlength) << std::setfill(' ')
            << output[i][j];
        }
        std::cout<<std::endl;
    }
    for (int i = 0; i < r; i++) {
        delete[] output[i];
    }
    delete[] output;
    output = 0;
}
Пример #10
0
void CplxMatrix::assign(const CplxMatrix & op){
    if (!(r == op.r && c == op.c)) {
        for (int i = 0; i < r; i++) {
            delete[] elm[i];
        }
        delete[] elm;
        r = op.r;
        c = op.c;
        elm = new cplxnum*[r];
        for (int i = 0; i < r; i++) {
            elm[i] = new cplxnum[c];
        }
    }
        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                el(i,j).re = op.el(i,j).re;
                el(i,j).im = op.el(i,j).im;
            }
        }
    
    
}
void StelSphericalIndexMultiRes::insert(StelRegionObjectP regObj)
{
	NodeElem el(regObj);
	int i;
	for (i=1;i<MAX_INDEX_LEVEL&&cosRadius[i]<el.cap.d;++i) {;}
	RootNode* node = treeForRadius[i-1];
	if (node==NULL)
	{
		node=new RootNode(cosRadius[i-1], maxObjectsPerNode, i-1);
		treeForRadius[i-1]=node;
	}
	node->insert(el, 0);
}
Пример #12
0
Element AssetTemplate::create( const QString & name, const Element & parent, const Project & project )
{
	RecordList rl;
	Element e = Element::createFromTemplate( *this, rl );
	ElementList el( rl );
	el.setProjects( project );
	el.commit();
	e.setProject( project );
	e.setParent( parent );
	e.setName( name );
	e.commit();
	return e;
}
Пример #13
0
// Construct a tree parity machine with given dimensions
TreeParityMachine::TreeParityMachine(std::size_t k, std::size_t n, std::size_t l): _l(l) {
    std::random_device rd;	// Create random device
	std::mt19937 el(rd());	// Use 32 bit mersenne twister
	std::uniform_int_distribution<int> udist(-_l,_l);
	
    for(int i=0; i<k; i++){
        std::vector<int> temp;
        for(int j=0; j<n; j++){
            temp.push_back(udist(el));
        }
        _w.push_back(temp);
    }
}
Пример #14
0
QDomElement
OutputImageParams::PartialXform::toXml(QDomDocument& doc, QString const& name) const
{
	XmlMarshaller marshaller(doc);
	
	QDomElement el(doc.createElement(name));
	el.appendChild(marshaller.string(Utils::doubleToString(m_11), "m11"));
	el.appendChild(marshaller.string(Utils::doubleToString(m_12), "m12"));
	el.appendChild(marshaller.string(Utils::doubleToString(m_21), "m21"));
	el.appendChild(marshaller.string(Utils::doubleToString(m_22), "m22"));
	
	return el;
}
Пример #15
0
/*
 * Clear around the box for simple_bce_test().
 */
static void
simple_bce_erases(BOX *box)
{
  int i;

  cup(box->top - 1, min_cols / 2);
  ed(1);        /* clear from home to cursor */
  cuf(1);
  el(0);        /* clear from cursor to end of line */

  cup(box->bottom + 1, min_cols / 2);
  ed(0);        /* clear from cursor to end */
  cub(1);
  el(1);        /* clear to beginning of line */

  for (i = box->top; i <= box->bottom; i++) {
    cup(i, box->left - 1);
    el(1);
    cup(i, box->right + 1);
    el(0);
  }
}
Пример #16
0
void Logger::msg(QString s, int level) {
	setTextColor(Qt::lightGray);
	append(QTime::currentTime().toString("hh:mm:ss")+": ");
	moveCursor(QTextCursor::End);
	switch (level) {
		case 0: setTextColor(Qt::black); break;
		case 1: setTextColor(Qt::gray); break;
		case 99: setTextColor(Qt::red); break;
	}
	insertPlainText(s);
	repaint();
	QEventLoop el(this);
	el.processEvents(QEventLoop::ExcludeUserInputEvents);
}
Пример #17
0
void ExtractModel::act(AV& av, collection_nvp<E,S> nvp )
{
	E* entry;
	construct(av, &entry, static_cast<unsigned int>(0));
		av.diveTable(nvp.name);

			putNamedColumn(av.getScope().table(), HIBERLITE_PARENTID_COLUMN, HIBERLITE_ID_STORAGE_CLASS);
			putNamedColumn(av.getScope().table(), HIBERLITE_ENTRY_INDEX_COLUMN, HIBERLITE_ID_STORAGE_CLASS);

			sql_nvp<E> el("item",*entry);
			av & el;
		av.pop();
	destroy(*this, entry, static_cast<unsigned int>(0));
}
Пример #18
0
        virtual BOOL on_event(HELEMENT he, HELEMENT target, BEHAVIOR_EVENTS type, UINT_PTR reason )
        {
            if (EDIT_VALUE_CHANGED == type)
            {
                dom::element el(he);
                json::string stext = el.text();
                el.set_attribute("filename", stext.c_str());
                el.set_attribute("title", stext.c_str());

                dom::element eparent = el.parent();
                eparent.set_attribute("filename", stext.c_str());
            }
            return false;
        }
Пример #19
0
QDomElement
Dependencies::toXml(QDomDocument& doc, QString const& name) const
{
	XmlMarshaller marshaller(doc);
	
	QDomElement el(doc.createElement(name));
	el.appendChild(
		marshaller.polygonF(
			m_rotatedPageOutline, "rotated-page-outline"
		)
	);
	
	return el;
}
Пример #20
0
CmdLine::CmdLine(int argc,char**argv) : should_exit_(false) {
      po::options_description general("General options");

      general.add_options()
          ("directories,d", po::value< std::vector<std::string> >(&dirs_),"directories to display on video")
          ("captions,c", po::value< std::vector<std::string> >(&captions_),"captions to display on videos (in the same order as directories)")
          ("output-directory,o", po::value<std::string>(&output_dir_),"output directory where the concatenated images are stored")
          ("verbose,v", "verbose mode")
          ("debug,D", "debug mode")

          ("help", "produce help message")
          ;

      prog_args.add(general);
      po::store(po::parse_command_line(argc, argv, prog_args), vm_);
      po::notify(vm_);

      if (vm_.count("help")) {
          std::cout << prog_args << std::endl;
          should_exit_ = true;
      }
      DEBUG_WRITE("Debug mode active.");

      unsigned int nbvid=0;
      std::string cur_caption("");
      for(std::vector< std::string >::iterator i=dirs_.begin(), cap_iter=captions_.begin();
          i!=dirs_.end();
          i++,nbvid++){
        if(cap_iter==captions_.end())
          cur_caption = "";
        else{
          cur_caption = *cap_iter;
          cap_iter++;
        }
        boost::shared_ptr<VideoWithCaption> el(new VideoWithCaption());
        el->caption=cur_caption;
        el->path = i->c_str();
        el->reader.setFileName( i->c_str() );
        el->reader.setFirstFrameIndex(0);
        el->reader.open(el->I);
        videos_.push_back(el);
        if(get_verbose()){
          std::cout << "Adding video with path " << el->path << " and caption " << el->caption << std::endl;
        }
      }
      DEBUG_WRITE("Done adding videos.");

      if(get_verbose())
        std::cout << nbvid << " videos added." << std::endl;
}
Пример #21
0
vector vector::operator=(matrix a)
{ int i,n = a.nrows();

  if (a.ncols() != 1)
  { std::cout << "\nMatrix attempted to assign to vector";
    } else
  if (this != &a)
    { delete [] elem;
      h = n; w= 1;
      elem = new double[h];
      for (i = 0; i < h; i++) el(i) = a.el(i,0);
      }
  return(*this);
  }
Пример #22
0
//Element-wise times
CplxMatrix CplxMatrix::times(const CplxMatrix & op) const{
    if (!(r == op.r && c == op.c)) {
        std::cout<<"incompatible shapes"<<std::endl;
        CplxMatrix result;
        return result;
    }
    CplxMatrix result(r, c);
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            result.el(i,j) = el(i, j) * op.el(i, j);
        }
    }
    return result;
}
Пример #23
0
vector3D vector3D::outer(vector3D& a)
{ vector3D v;

  v.el(0) = el(1)*a.el(2) - el(2)*a.el(1);
  v.el(1) = el(2)*a.el(0) - el(0)*a.el(2);
  v.el(2) = el(0)*a.el(1) - el(1)*a.el(0);

  return(v);
  }
Пример #24
0
Instancing::Instancing(const int n, const OPTION opt,
		       const glm::vec3 dscale, const glm::vec3 dtrans, const glm::quat droate)
{
	(void)dtrans;
	if (opt == Instancing::OPTION::square_instances) {
		this->rsts.translations.resize(n * n);
		this->rsts.scales.resize(n * n);
		this->rsts.rotations.resize(n * n);

		int rows  = n;
		int cols  = n;
		int count = 0;
		for (int i = 0; i < rows; i++) {
			for( int j = 0;  j < cols; j++) {
				this->rsts.translations[count] = glm::vec3((float)i, 0.0f, (float)j);
				this->rsts.rotations[count] = droate;
				this->rsts.scales[count] = dscale;
				count += 1;
			}
		}

	}
	else if (opt == Instancing::OPTION::random_instances) {
		this->rsts.translations.resize(n);
		this->rsts.scales.resize(n);
		this->rsts.rotations.resize(n);
		std::random_device rd;
		std::minstd_rand el(rd());

		for (int i = 0; i < n; i++) {
			this->rsts.translations[i] = glm::vec3(el(), el(), el());
			this->rsts.rotations[i] = droate;
			this->rsts.scales[i] = dscale;
		}
	}

}
Пример #25
0
//returns a companion matrix of a matrix. Not a helper function of any others, nor did it appear in my demo
CplxMatrix CplxMatrix::companionMatrix()const{
    if (r!=1||c<3) {
        std::cout<<"incorrect size"<<std::endl;
        CplxMatrix r;
        return r;
    }
    CplxMatrix result(c-1,c-1);
    for (int i = 0; i < c-1; i++) {
        result.el(i, c-2) = 0-el(0, c-1-i);
    }
    for (int i = 1; i < c - 1; i++) {
        result.el(i, i-1).re = 1;
    }
    return result;
}
/*
 * Diagram "B1", SQED, broken SUSY,
 * Gauge sector.
 */
main()
{
  page                   pg;
  FeynDiagram            fd(pg);

#define RAD    2.5

  fd.line_thickness.set(0.15);
  fd.vertex_thickness.set(0.15);
  /* define the left and the right external points */
  xy                     el(-6, 0), er(6, 0);
  /* the SB vertex */
  xy                     sb_coord(0, -RAD);

  vertex_box             sb(fd, sb_coord); sb.fill.setfalse();
  vertex_cross           sb_cross(fd, sb_coord);
                         sb.radius.scale(SB_RADIUS_SCALE);
                         sb_cross.radius.scale(SB_RADIUS_SCALE);
  /* the LV vertex */
  xy                     lv_coord(RAD, 0);
                         lv_coord.rotate(-45);
  vertex_circlecross     lv(fd, lv_coord);


  xy                     arcpt1(0, RAD);
  xy                     arcpt2(RAD, 0); arcpt2.rotate(-20);
  xy                     arcpt3(RAD, 0); arcpt3.rotate(-60);
  xy                     arcpt4(RAD, 0); arcpt4.rotate(-135);
  /* the ordinary SQED vertex */
  vertex                 v1(fd, -RAD, 0);
  vertex                 v2(fd,  RAD, 0);
  /* photon line propagators */
  line_wiggle            ph1(fd, el, v1), ph2(fd, v2, er);

  line_plain             f1(fd, v1, v2); 
  line_plain             f2(fd, v2, lv); f2.arrowon.setfalse(); 
  line_plain             f3(fd, lv, sb); f3.arrowon.setfalse();
  line_plain             f4(fd, sb, v1);

  /* stretch it to be an arc */
  f1.arcthru(arcpt1);
  f2.arcthru(arcpt2);
  f3.arcthru(arcpt3);
  f4.arcthru(arcpt4);

  pg.output();
  return 0;
}
Пример #27
0
CplxMatrix CplxMatrix::mul(const CplxMatrix & op) const{
    if (c != op.r) {
        std::cout<<"incompatible shapes"<<std::endl;
    }
    CplxMatrix result(r, op.c);
    for (int i = 0; i < result.r; i++) {
        for (int j = 0; j < result.c; j++) {
            cplxnum sum;
            for (int k = 0; k < c; k++) {
                sum = sum + el(i,k)*op.el(k,j);
            }
            result.el(i,j) = sum;
        }
    }
    return result;
}
Пример #28
0
//This function removes the row and col in a matrix, thich is called first i,j minor according to wikipedia
CplxMatrix CplxMatrix::minorMat(int row, int col) const{
    if (row > r || row < 0 || col > c || col < 0) {
        std::cout<<"invalid element specification"<<std::endl;
        CplxMatrix result;
        return result;
    }
    CplxMatrix minor(r-1, c-1);
    for (int i = 0, ori_i = 0; i < r-1; i++, ori_i++) {
        for (int j = 0, ori_j = 0; j < c-1; j++, ori_j++) {
            if (ori_i == row) ori_i++;
            if (ori_j == col) ori_j++;
            minor.el(i,j) = el(ori_i,ori_j);
        }
    }
    return minor;
}
Пример #29
0
Matrix Matrix::mul(const Matrix & op) const{
    if (c != op.r) {
        std::cout<<"ncompatible shapes"<<std::endl;
    }
    Matrix result(r, op.c);
    for (int i = 0; i < result.r; i++) {
        for (int j = 0; j < result.c; j++) {
            double sum = 0.0;
            for (int k = 0; k < c; k++) {
                sum += el(i,k)*op.el(k,j);
            }
            result.el(i,j) = sum;
        }
    }
    return result;
}
Пример #30
0
template<typename T> static void ToJSVal_vector(JSContext* cx, JS::MutableHandleValue ret, const std::vector<T>& val)
{
	JSAutoRequest rq(cx);
	JS::RootedObject obj(cx, JS_NewArrayObject(cx, 0));
	if (!obj)
	{
		ret.setUndefined();
		return;
	}
	for (u32 i = 0; i < val.size(); ++i)
	{
		JS::RootedValue el(cx);
		ScriptInterface::ToJSVal<T>(cx, &el, val[i]);
		JS_SetElement(cx, obj, i, el);
	}
	ret.setObject(*obj);
}