void OctNode::coeffs_daub4(OrientedPoint &pt, int maxDepth, int depth, vect3f &mine, vect3f &ext, int minDepth)
{
	// don't construct the coefficient of an artificial node
	if (g.do_pts_node)
	{
		if (pts_node() == 0)
			return;
	}
	else
	{
		if (pt_num(0,0,0) + pt_num(0,0,1) + pt_num(0,1,0) + pt_num(0,1,1) +
			pt_num(1,0,0) + pt_num(1,0,1) + pt_num(1,1,0) + pt_num(1,1,1) == 0)
			return;
	}

	// split the node and push down point
	vect3f ext2 = ext*.5;
	vect3f center = mine + ext2;

	// split them (the fastest way of calculating ix,iy,iz is different here than elsewhere?)
	int ix = 0, iy = 0, iz = 0;

	if (pt.pos[0] > center[0])
		ix = 1;
	if (pt.pos[1] > center[1])
		iy = 1;
	if (pt.pos[2] > center[2])
		iz = 1;

	// push down
	if (children(ix,iy,iz).data)
	{
		// not a leaf
		vect3f corner2(mine[0] + ext2[0]*ix, mine[1] + ext2[1]*iy, mine[2] + ext2[2]*iz);
		children(ix,iy,iz).coeffs_daub4(pt, maxDepth, depth+1, corner2, ext2, minDepth);
	}
	
	if (pt.ds == 0)
	{
		if (g.do_pts_node)
			pt.ds = 0.25 / ((float)pts_node() * (float)(1 << (depth << 1)));
		else
			pt.ds = 0.25 / ((float)pt_num(ix,iy,iz) * (float)(1 << (depth << 1)));
	}

	if (depth > minDepth && depth <= maxDepth)
	{
		// "integrate over the surface"
		// find coordinates of point [0,1] in cell
		vect3f lp; // local position
		for (int i = 0; i < 3; i++)
			lp[i] = (pt.pos[i] - mine[i]) / ext[i];

		// add to coefficients
		float factor = (1 << (depth << 1))*pt.ds;
		bool do_zero = (depth == 2);

		// Scott: evaluating functions incrementally yields 4X improvement in speed
		float phiData [ 3 ] [ 3 ], int_phiData [ 3 ] [ 3 ], psiData [ 3 ] [ 3 ], int_psiData [ 3 ] [ 3 ];
		float phi [ 3 ], psi [ 3 ], int_psi [ 3 ], int_phi [ 3 ];

		// Scott: save a bunch of if statements... gives about 5% increase in performance
		// Scott: precomputing values of functions gives another 15% increase in performance
		if ( do_zero )
		{
			for ( int i = 0; i < 3; i++ )
			{
				for ( int x = -1; x <= 1; x++ )
				{
					phiData [ i ] [ x + 1 ] = Daub4::phi ( lp [ i ] - x );
					psiData [ i ] [ x + 1 ] = Daub4::psi ( lp [ i ] - x );
					int_psiData [ i ] [ x + 1 ] = Daub4::int_psi ( lp [ i ] - x ) * pt.norm [ i ] * factor;
					int_phiData [ i ] [ x + 1 ] = Daub4::int_phi ( lp [ i ] - x ) * pt.norm [ i ] * factor * (1.0/3.0);
				}
			}
		}
		else
		{
			for ( int i = 0; i < 3; i++ )
			{
				for ( int x = -1; x <= 1; x++ )
				{
					phiData [ i ] [ x + 1 ] = Daub4::phi ( lp [ i ] - x );
					psiData [ i ] [ x + 1 ] = Daub4::psi ( lp [ i ] - x );
					int_psiData [ i ] [ x + 1 ] = Daub4::int_psi ( lp [ i ] - x ) * pt.norm [ i ] * factor;
					int_phiData [ i ] [ x + 1 ] = 0;
				}
			}
		}
		//float total_int_phi [ 3 ] = {0,0,0};
		OctNode n [ 3 ];
		for (int x = -1; x <= 1; x++)
		{
			phi [ 0 ] = phiData [ 0 ] [ x + 1 ];
			psi [ 0 ] = psiData [ 0 ] [ x + 1 ];
			int_phi [ 0 ] = int_phiData [ 0 ] [ x + 1 ];
			int_psi [ 0 ] = int_psiData [ 0 ] [ x + 1 ];
			//total_int_phi [ 0 ] = int_phiData [ 0 ] [ x + 1 ];
			if (x)
				n [ 0 ] = neighbors(0, (x+1)>>1);
			else
				n[0] = *this;

			for (int y = -1; y <= 1; y++)
			{
				phi [ 1 ] = phiData [ 1 ] [ y + 1 ];
				psi [ 1 ] = psiData [ 1 ] [ y + 1 ];
				int_phi [ 1 ] = int_phiData [ 1 ] [ y + 1 ];
				int_psi [ 1 ] = int_psiData [ 1 ] [ y + 1 ];
				//total_int_phi [ 1 ] = total_int_phi [ 0 ] + int_phiData [ 1 ] [ y + 1 ];
				if (y)
					n [ 1 ] = n [ 0 ].neighbors(1, (y+1)>>1);
				else
					n [ 1 ] = n [ 0 ];

				for (int z = -1; z <= 1; z++)
				{
					phi [ 2 ] = phiData [ 2 ] [ z + 1 ];
					psi [ 2 ] = psiData [ 2 ] [ z + 1 ];
					int_phi [ 2 ] = int_phiData [ 2 ] [ z + 1 ];
					int_psi [ 2 ] = int_psiData [ 2 ] [ z + 1 ];
					//total_int_phi [ 2 ] = total_int_phi [ 1 ] + int_phiData [ 2 ] [ z + 1 ];
					if (z)
						n [ 2 ] = n [ 1 ].neighbors(2, (z+1)>>1);
					else
						n [ 2 ] = n [ 1 ];

					//n[2]->coeffs(0,0,0) += total_int_phi [ 2 ]; //(int_phi[0] + int_phi[1] + int_phi[2]) * factor3;
					n[2].coeffs(0,0,0) += (int_phi[0]*phi[1]*phi[2] + int_phi[1]*phi[0]*phi[2] + int_phi[2]*phi[0]*phi[1]) * (1.0/3.0);

					n[2].coeffs(0,0,1) += ( phi[0]*phi[1]*int_psi[2] );
					n[2].coeffs(0,1,0) += ( phi[0]*int_psi[1]*phi[2] );
					n[2].coeffs(1,0,0) += ( int_psi[0]*phi[1]*phi[2] );

					n[2].coeffs(0,1,1) += ( int_psi[1]*psi[2] + psi[1]*int_psi[2] )*phi[0] * .5;
					n[2].coeffs(1,1,0) += ( psi[0]*int_psi[1] + int_psi[0]*psi[1] )*phi[2] * .5;
					n[2].coeffs(1,0,1) += ( psi[0]*int_psi[2] + int_psi[0]*psi[2] )*phi[1] * .5;

					n[2].coeffs(1,1,1) += ( psi[0]*(psi[1]*int_psi[2] + int_psi[1]*psi[2]) + int_psi[0]*psi[1]*psi[2] ) * (1.0/3.0);
				}
Beispiel #2
0
void UmlClass::compute_dependency(QList<CppRefType *> & dependencies,
                                  const WrapperStr &, bool all_in_h)
{
    QVector<UmlItem*> ch = children();
    const WrapperStr stereotype = cpp_stereotype();
    bool a_typedef = (stereotype == "typedef");
    bool an_enum = (stereotype == "enum");
    const QList<UmlFormalParameter> formals = this->formals();
    const QList<UmlActualParameter> actuals = this->actuals();

    if (!formals.isEmpty())
        // template class, force depend in h
        all_in_h = TRUE;

    for (int index = 0; index != ch.size(); index += 1) {
        if (ch[index]->kind() != aNcRelation) {
            UmlClassItem * it = (UmlClassItem *) ch[index];

            if (! it->cppDecl().isEmpty())
                it->compute_dependency(dependencies, stereotype, all_in_h);
        }
    }

    if (an_enum && (!formals.isEmpty() || !actuals.isEmpty())) {
        write_trace_header();
        UmlCom::trace("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b><i>template enum</i></b></font><br>");
        incr_warning();
    }
    else if (a_typedef && !formals.isEmpty()) {
        write_trace_header();
        UmlCom::trace("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b><i>template typedef</i></b></font><br>");
        incr_warning();
    }
    else {
        QList<UmlFormalParameter>::ConstIterator itf;

        for (itf = formals.begin(); itf != formals.end(); ++itf)
            CppRefType::remove((*itf).name(), dependencies);

        QList<UmlActualParameter>::ConstIterator ita;

        for (ita = actuals.begin(); ita != actuals.end(); ++ita)
            UmlClassMember::compute_dependency(dependencies, "${type}",
                                               (*ita).value(), all_in_h);

        if (a_typedef) {
            WrapperStr decl = cppDecl();
            int index;

            remove_comments(decl);

            if ((index = decl.find("${name}")) != -1)
                decl.remove((unsigned) index, 7);

            replace_alias(decl);

            UmlClassMember::compute_dependency(dependencies, decl,
                                               baseType(), all_in_h);
        }
    }

    if ((associatedArtifact() == 0) ||
        (associatedArtifact()->associatedClasses().count() == 1))
        CppRefType::remove(this, dependencies);
    else
        CppRefType::force_ref(this, dependencies);
}
Beispiel #3
0
void Panel::do_layout(void) {
	E_RETURN_IF_FAIL(children() > 0);

	Fl_Widget     *o;
	unsigned long  opts;
	unsigned int   lsz;
	int            X, W, free_w;

	WidgetList left, right, center, unmanaged, resizable_h;

	for(int i = 0; i < children(); i++) {
		o = child(i);

		/* first resize it to some reasonable height and center it vertically */
		fix_widget_h(o, this);

		/* manage hider specifically */
		if(hider && o == hider) {
			right.push_back(o);
			continue;
		}

		/* could be slow, but I'm relaying how number of loaded applets will not be that large */
		if(!mgr.get_applet_options(o, opts)) {
			/* here are put widgets not loaded as applets */
			unmanaged.push_back(o);
			continue;
		}

		if(opts & EDE_PANEL_APPLET_OPTION_RESIZABLE_H)
			resizable_h.push_back(o);

		if(opts & EDE_PANEL_APPLET_OPTION_ALIGN_LEFT) {
			/* first item will be most leftest */
			left.push_back(o);
			continue;
		}

		if(opts & EDE_PANEL_APPLET_OPTION_ALIGN_RIGHT) {
			/* first item will be most rightest */
			right.push_back(o);
			continue;
		}

		/* rest of them */
		center.push_back(o);
	}

	/* make sure we at the end have all widgets, so we can overwrite group array */
	lsz = left.size() + center.size() + right.size() + unmanaged.size();
	E_ASSERT(lsz == (unsigned int)children() && "Size of layout lists size not equal to group size");

	X = INITIAL_SPACING;

	/* 
	 * Call add() on each element, processing lists in order. add() will remove element
	 * in group array and put it at the end of array. At the end, we should have array ordered by
	 * layout flags.
	 */
	add_from_list(left, this, X, true);
	add_from_list(center, this, X, true);
	add_from_list(unmanaged, this, X, true);

	free_w = X;

	/* elements right will be put from starting from the right panel border */
	X = w() - INITIAL_SPACING;
	add_from_list(right, this, X, false);

	/* 
	 * Code for horizontal streching. 
	 *
	 * FIXME: This code pretty sucks and need better rewrite in the future.
	 * To work properly, applets that will be streched must be successive or everything will be
	 * messed up. Also, applets that are placed right2left does not work with it; they will be resized to right.
	 */
	if(resizable_h.empty())
		return;

	/* calculate free space for horizontal alignement, per item in resizable_h list */
	free_w = (X - free_w) / resizable_h.size();
	if(!free_w) free_w = 0;

	/* 
	 * since add_from_list() will already reserve some space by current child width and default spacing,
	 * those values will be used again or holes will be made
	 */
	WidgetListIt it = resizable_h.begin(), ite = resizable_h.end();
	o = resizable_h.front();
	X = o->x();

	while(it != ite) {
		o = *it;

		W = o->w() + free_w;
		o->resize(X, o->y(), W, o->h());
		X += W + DEFAULT_SPACING;

		it = resizable_h.erase(it);
	}
}
Beispiel #4
0
void Value::dumpChildren(CommaPrinter& comma, PrintStream& out) const
{
    for (Value* child : children())
        out.print(comma, pointerDump(child));
}
Beispiel #5
0
uint64_t countLeafsByTraversal(libmaus::suffixtree::CompressedSuffixTree const & CST)
{
	libmaus::eta::LinearETA eta(CST.n);

	typedef libmaus::suffixtree::CompressedSuffixTree::Node Node;
	libmaus::parallel::SynchronousCounter<uint64_t> leafs = 0;
	std::stack< std::pair<Node,uint64_t> > S; S.push(std::pair<Node,uint64_t>(CST.root(),0));
	uint64_t const Sigma = CST.getSigma();
	libmaus::autoarray::AutoArray<Node> children(Sigma,false);
	
	std::deque < Node > Q;
	uint64_t const frac = 128;
	uint64_t const maxtdepth = 64;
	
	while ( S.size() )
	{
		std::pair<Node,uint64_t> const P = S.top(); S.pop();
		Node const & parent = P.first;
		uint64_t const tdepth = P.second;
		
		if ( CST.count(parent) < 2 || CST.count(parent) <= CST.n/frac || tdepth >= maxtdepth )
		{
			assert ( parent.ep-parent.sp );
			Q.push_back(parent);
		}
		else
		{
			uint64_t const numc = CST.enumerateChildren(parent,children.begin());
			
			for ( uint64_t i = 0; i < numc; ++i )
				S.push(std::pair<Node,uint64_t>(children[numc-i-1],tdepth+1));
		}
	}
	
	libmaus::parallel::OMPLock lock;
	
	#if defined(_OPENMP)
	#pragma omp parallel
	#endif
	while ( Q.size() )
	{
		libmaus::autoarray::AutoArray<Node> lchildren(Sigma,false);
		Node node(0,0);
		
		lock.lock();
		if ( Q.size() )
		{
			node = Q.front();
			Q.pop_front();
		}
		lock.unlock();
		
		std::stack<Node> SL;
		if ( node.ep-node.sp )
			SL.push(node);

		while ( SL.size() )
		{
			Node const parent = SL.top(); SL.pop();
			
			if ( parent.ep-parent.sp > 1 )
			{
				uint64_t const numc = CST.enumerateChildren(parent,lchildren.begin());
			
				for ( uint64_t i = 0; i < numc; ++i )
					SL.push(lchildren[numc-i-1]);
			}
			else
			{
				if ( (leafs++ % (32*1024)) == 0 )
				{
					lock.lock();
					std::cerr << static_cast<double>(leafs)/CST.n << "\t" << eta.eta(leafs) << std::endl;	
					lock.unlock();
				}
			}
		}
	}

	std::cerr << "Q.size()=" << Q.size() << " leafs=" << leafs << " n=" << CST.n << std::endl;

	return leafs;
}
Beispiel #6
0
QList<Folder *> Folder::folders() const {
  QList<Folder *> folderList;
  foreach (QObject *folder, children())
    folderList.append(static_cast<Folder *>(folder));
  return folderList;
}
Beispiel #7
0
//! [0]
DragWidget::DragWidget(QWidget *parent)
    : QWidget(parent)
{
    QFile dictionaryFile(":/dictionary/words.txt");
    dictionaryFile.open(QFile::ReadOnly);
    QTextStream inputStream(&dictionaryFile);
//! [0]

//! [1]
    int x = 5;
    int y = 5;

    while (!inputStream.atEnd()) {
        QString word;
        inputStream >> word;
        if (!word.isEmpty()) {
            DragLabel *wordLabel = new DragLabel(word, this);
            wordLabel->move(x, y);
            wordLabel->show();
            wordLabel->setAttribute(Qt::WA_DeleteOnClose);
            x += wordLabel->width() + 2;
#if defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
            if (x >= 345) {
#else
            if (x >= 245) {
#endif
                x = 5;
                y += wordLabel->height() + 2;
            }
        }
    }
//! [1]

//! [2]
    #ifndef Q_WS_S60
    //Fridge magnets is used for demoing Qt on S60 and themed backgrounds look better than white
    QPalette newPalette = palette();
    newPalette.setColor(QPalette::Window, Qt::white);
    setPalette(newPalette);
    #endif

    setMinimumSize(400, qMax(200, y));
    setWindowTitle(tr("Fridge Magnets"));
//! [2] //! [3]
    setAcceptDrops(true);
}
//! [3]

//! [4]
void DragWidget::dragEnterEvent(QDragEnterEvent *event)
{
//! [4] //! [5]
    if (event->mimeData()->hasFormat("application/x-fridgemagnet")) {
        if (children().contains(event->source())) {
            event->setDropAction(Qt::MoveAction);
            event->accept();
        } else {
            event->acceptProposedAction();
//! [5] //! [6]
        }
//! [6] //! [7]
    } else if (event->mimeData()->hasText()) {
        event->acceptProposedAction();
    } else {
        event->ignore();
    }
}
//! [7]

//! [8]
void DragWidget::dragMoveEvent(QDragMoveEvent *event)
{
    if (event->mimeData()->hasFormat("application/x-fridgemagnet")) {
        if (children().contains(event->source())) {
            event->setDropAction(Qt::MoveAction);
            event->accept();
        } else {
            event->acceptProposedAction();
        }
    } else if (event->mimeData()->hasText()) {
        event->acceptProposedAction();
    } else {
        event->ignore();
    }
}
//! [8]

//! [9]
void DragWidget::dropEvent(QDropEvent *event)
{
    if (event->mimeData()->hasFormat("application/x-fridgemagnet")) {
        const QMimeData *mime = event->mimeData();
//! [9] //! [10]
        QByteArray itemData = mime->data("application/x-fridgemagnet");
        QDataStream dataStream(&itemData, QIODevice::ReadOnly);

        QString text;
        QPoint offset;
        dataStream >> text >> offset;
//! [10]
//! [11]
        DragLabel *newLabel = new DragLabel(text, this);
        newLabel->move(event->pos() - offset);
        newLabel->show();
        newLabel->setAttribute(Qt::WA_DeleteOnClose);

        if (event->source() == this) {
            event->setDropAction(Qt::MoveAction);
            event->accept();
        } else {
            event->acceptProposedAction();
        }
//! [11] //! [12]
    } else if (event->mimeData()->hasText()) {
        QStringList pieces = event->mimeData()->text().split(QRegExp("\\s+"),
                             QString::SkipEmptyParts);
        QPoint position = event->pos();

        foreach (QString piece, pieces) {
            DragLabel *newLabel = new DragLabel(piece, this);
            newLabel->move(position);
            newLabel->show();
            newLabel->setAttribute(Qt::WA_DeleteOnClose);

            position += QPoint(newLabel->width(), 0);
        }
Beispiel #8
0
void UmlComponent::write(FileOut & out)
{
    const char * k = (parent()->kind() == anUseCase)
                     ? "ownedUseCase"
                     : ((_uml_20) ? "ownedMember" : "packagedElement");

    out.indent();
    out << "<" << k << " xmi:type=\"uml:Component\"";
    out.id(this);
    out << " name=\"";
    out.quote((const char *)name()); //[jasa] ambiguous call
    out << "\">\n";
    out.indent(+1);
    write_description_properties(out);

    const QVector<UmlItem*> ch = children();
    unsigned n = ch.size();
    unsigned index;

    for (index = 0; index != n; index += 1)
        ch[index]->write(out);

    // provided

    const QVector< UmlClass* > & prov = providedClasses();

    n = prov.size();

    for (index = 0; index != n; index += 1) {
        UmlClass * cl = prov[index];

        out.indent();
        out << "<interfaceRealization xmi:type=\"uml:InterfaceRealization\"";
        out.id_prefix(this, "PROV_", index);
        out.ref(cl, "supplier");
        out.ref(this, "client");
        out.ref(cl, "contract");
        out << "/>\n";
    }

    // realizing

    const QVector< UmlClass* > & rea = realizingClasses();

    n = rea.size();

    for (index = 0; index != n; index += 1) {
        UmlClass * cl = rea[index];

        out.indent();
        out << "<realization xmi:type=\"uml:ComponentRealization\"";
        out.id_prefix(this, "REA_", index);
        out.ref(cl, "supplier");
        out.ref(this, "client");
        out.ref(cl, "realizingClassifier");
        out << "/>\n";
    }

    out.indent(-1);
    out.indent();
    out << "</" << k << ">\n";

    // required

    const QVector< UmlClass* > & req = requiredClasses();

    n = req.size();

    for (index = 0; index != n; index += 1) {
        UmlClass * cl = req[index];

        out.indent();
        out << "<" << k << " xmi:type=\"uml:Usage\"";
        out.id_prefix(this, "REQ_", index);
        out.ref(cl, "supplier");
        out.ref(this, "client");
        out << "/>\n";
    }

    unload();

}
Beispiel #9
0
/*!
  Returns a rich text formatted QString representing the contents the contact.
*/
QString OContact::toRichText() const
{
    QString text;
    QString value, comp, state;
    QString str;
    bool marker = false;

    Config cfg("qpe");
    cfg.setGroup("Appearance");
    int addressformat = cfg.readNumEntry( "AddressFormat", Zip_City_State );

    // name, jobtitle and company
    if ( !(value = fullName()).isEmpty() )
	text += "<b><h3><img src=\"addressbook/AddressBook\"> " + Qtopia::escapeString(value) + "</h3></b>";

    if ( !(value = jobTitle()).isEmpty() )
	text += Qtopia::escapeString(value) + " ";

    comp = company();
    if ( !(value = department()).isEmpty() ) {
	text += Qtopia::escapeString(value);
	if ( comp )
		text += ", " + Qtopia::escapeString(comp);
    }else if ( comp )
	    text += "<br>" + Qtopia::escapeString(comp);
    text += "<br><hr>";

    // defailt email
    QString defEmail = defaultEmail();
    if ( !defEmail.isEmpty() ){
	text += "<b><img src=\"addressbook/email\"> " + QObject::tr("Default Email: ") + "</b>"
		+ Qtopia::escapeString(defEmail);
	marker = true;
    }

    // business address
    if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
	 !businessZip().isEmpty() || !businessCountry().isEmpty() ) {
	text += QObject::tr( "<br><b>Work Address:</b>" );
	marker = true;
    }

    if ( !(value = businessStreet()).isEmpty() ){
	    text += "<br>" + Qtopia::escapeString(value);
	    marker = true;
    }

    switch( addressformat ){
    case Zip_City_State:{ //  Zip_Code City, State
	    state =  businessState();
	    if ( !(value = businessZip()).isEmpty() ){
		    text += "<br>" + Qtopia::escapeString(value) + " ";
		    marker = true;

	    }
	    if ( !(value = businessCity()).isEmpty() ) {
		    marker = true;
		    if ( businessZip().isEmpty() && !businessStreet().isEmpty() )
			    text += "<br>";
		    text += Qtopia::escapeString(value);
		    if ( state )
			    text += ", " + Qtopia::escapeString(state);
	    } else if ( !state.isEmpty() ){
		    text += "<br>" + Qtopia::escapeString(state);
		    marker = true;
	    }
	    break;
    }
    case City_State_Zip:{ // City, State Zip_Code
	    state =  businessState();
	    if ( !(value = businessCity()).isEmpty() ) {
		    marker = true;
		    text += "<br>" + Qtopia::escapeString(value);
		    if ( state )
			    text += ", " + Qtopia::escapeString(state);
	    } else if ( !state.isEmpty() ){
		    text += "<br>" + Qtopia::escapeString(state);
		    marker = true;
	    }
	    if ( !(value = businessZip()).isEmpty() ){
		    text += " " + Qtopia::escapeString(value);
		    marker = true;
	    }
	    break;
    }
    }

    if ( !(value = businessCountry()).isEmpty() ){
	text += "<br>" + Qtopia::escapeString(value);
	marker = true;
    }

    // rest of Business data
    str = office();
    if ( !str.isEmpty() ){
	text += "<br><b>" + QObject::tr("Office: ") + "</b>"
		+ Qtopia::escapeString(str);
	marker = true;
    }
    str = businessWebpage();
    if ( !str.isEmpty() ){
	text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr("Business Web Page: ") + "</b>"
		+ Qtopia::escapeString(str);
	marker = true;
    }
    str = businessPhone();
    if ( !str.isEmpty() ){
	text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr("Business Phone: ") + "</b>"
		+ Qtopia::escapeString(str);
	marker = true;
    }
    str = businessFax();
    if ( !str.isEmpty() ){
	text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr("Business Fax: ") + "</b>"
		+ Qtopia::escapeString(str);
	marker = true;
    }
    str = businessMobile();
    if ( !str.isEmpty() ){
	text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr("Business Mobile: ") + "</b>"
		+ Qtopia::escapeString(str);
	marker = true;
    }
    str = businessPager();
    if ( !str.isEmpty() ){
	text += "<br><b>" + QObject::tr("Business Pager: ") + "</b>"
		+ Qtopia::escapeString(str);
	marker = true;
    }

    // text += "<br>";

    // home address
    if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
	 !homeZip().isEmpty() || !homeCountry().isEmpty() ) {
	text += QObject::tr( "<br><b>Home Address:</b>" );
	marker = true;
    }

    if ( !(value = homeStreet()).isEmpty() ){
	text += "<br>" + Qtopia::escapeString(value);
	marker = true;
    }

    switch( addressformat ){
    case Zip_City_State:{ //  Zip_Code City, State
	    state =  homeState();
	    if ( !(value = homeZip()).isEmpty() ){
		    text += "<br>" + Qtopia::escapeString(value) + " ";
		    marker = true;
	    }
	    if ( !(value = homeCity()).isEmpty() ) {
		    marker = true;
		    if ( homeZip().isEmpty() && !homeStreet().isEmpty() )
			    text += "<br>";
		    text += Qtopia::escapeString(value);
		    if ( !state.isEmpty() )
			    text += ", " + Qtopia::escapeString(state);
	    } else if (!state.isEmpty()) {
		    text += "<br>" + Qtopia::escapeString(state);
		    marker = true;
	    }
	    break;
    }
    case City_State_Zip:{ // City, State Zip_Code
	    state =  homeState();
	    if ( !(value = homeCity()).isEmpty() ) {
		    marker = true;
		    text += "<br>" + Qtopia::escapeString(value);
		    if ( state )
			    text += ", " + Qtopia::escapeString(state);
	    } else if ( !state.isEmpty() ){
		    text += "<br>" + Qtopia::escapeString(state);
		    marker = true;
	    }
	    if ( !(value = homeZip()).isEmpty() ){
		    text += " " + Qtopia::escapeString(value);
		    marker = true;
	    }
	    break;
    }
    }

    if ( !(value = homeCountry()).isEmpty() ){
	text += "<br>" + Qtopia::escapeString(value);
	marker = true;
    }

    // rest of Home data
    str = homeWebpage();
    if ( !str.isEmpty() ){
	text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr("Home Web Page: ") + "</b>"
		+ Qtopia::escapeString(str);
	marker = true;
    }
    str = homePhone();
    if ( !str.isEmpty() ){
	text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr("Home Phone: ") + "</b>"
		+ Qtopia::escapeString(str);
	marker = true;
    }
    str = homeFax();
    if ( !str.isEmpty() ){
	text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr("Home Fax: ") + "</b>"
		+ Qtopia::escapeString(str);
	marker = true;
    }
    str = homeMobile();
    if ( !str.isEmpty() ){
	text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr("Home Mobile: ") + "</b>"
		+ Qtopia::escapeString(str);
	marker = true;
    }

    if ( marker )
	    text += "<br><hr>";

    // the rest...
    str = emails();
    if ( !str.isEmpty() && ( str != defEmail ) )
	text += "<br><b>" + QObject::tr("All Emails: ") + "</b>"
		+ Qtopia::escapeString(str);
    str = profession();
    if ( !str.isEmpty() )
	text += "<br><b>" + QObject::tr("Profession: ") + "</b>"
		+ Qtopia::escapeString(str);
    str = assistant();
    if ( !str.isEmpty() )
	text += "<br><b>" + QObject::tr("Assistant: ") + "</b>"
		+ Qtopia::escapeString(str);
    str = manager();
    if ( !str.isEmpty() )
	text += "<br><b>" + QObject::tr("Manager: ") + "</b>"
		+ Qtopia::escapeString(str);
    str = gender();
    if ( !str.isEmpty() && str.toInt() != 0 ) {
	    text += "<br>";
	    if ( str.toInt() == 1 )
		    str = QObject::tr( "Male" );
	    else if ( str.toInt() == 2 )
		    str = QObject::tr( "Female" );
	    text += "<b>" + QObject::tr("Gender: ") + "</b>" + str;
    }
    str = spouse();
    if ( !str.isEmpty() )
	text += "<br><b>" + QObject::tr("Spouse: ") + "</b>"
		+ Qtopia::escapeString(str);
    if ( birthday().isValid() ){
	    str = TimeString::numberDateString( birthday() );
	    text += "<br><b>" + QObject::tr("Birthday: ") + "</b>"
		    + Qtopia::escapeString(str);
    }
    if ( anniversary().isValid() ){
	    str = TimeString::numberDateString( anniversary() );
	    text += "<br><b>" + QObject::tr("Anniversary: ") + "</b>"
		    + Qtopia::escapeString(str);
    }
    str = children();
    if ( !str.isEmpty() )
	text += "<br><b>" + QObject::tr("Children: ") + "</b>"
		+ Qtopia::escapeString(str);

    str = nickname();
    if ( !str.isEmpty() )
	text += "<br><b>" + QObject::tr("Nickname: ") + "</b>"
		+ Qtopia::escapeString(str);

    // categories
    if ( categoryNames("Contacts").count() ){
	    text += "<br><b>" + QObject::tr( "Category:") + "</b> ";
	    text += categoryNames("Contacts").join(", ");
    }

    // notes last
    if ( !(value = notes()).isEmpty() ) {
	    text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> ";
	    QRegExp reg("\n");

	    //QString tmp = Qtopia::escapeString(value);
	    QString tmp = QStyleSheet::convertFromPlainText(value);
	    //tmp.replace( reg, "<br>" );
	    text += "<br>" + tmp + "<br>";
    }
    return text;
}
Beispiel #10
0
void GUIController::touch_gui (const TouchEvent *event, const std::shared_ptr<CameraObject> &camera, WorldNode* &handled)
{        
    if (handled)
        return;

    // Scan for first event
    for (DTuint i = 0; i < TouchEvent::MAX_NUM_TOUCHES; ++i) {
        if ( event->touches[i].state != TouchEvent::STATE_NONE ) {
            _touch.set_initial_position(event->touches[i].first_pos);
            _touch.set_previous_position(event->touches[i].previous_pos);
            _touch.set_position(event->touches[i].pos);
            _touch.set_velocity(event->touches[i].velocity);
            _touch.set_state(event->touches[i].state);

            break;
        }
    }
    
    // If this is a new event, then we find the target widget
    if (_touch.state() == TouchEvent::STATE_PRESSED) {
        
        // Find first hit object
        std::list<PlaceableObject*> c = children();
        
        c.sort(CompareTouch());
        
        for (auto i = c.rbegin(); i != c.rend(); ++i) {
            GUIObject *gui = checked_cast<GUIObject*>(*i);
            if (!gui)
                continue;
        
            GUIObject *hit_object = NULL;
            gui->hit_test(&_touch, hit_object, Color4f(1.0F,1.0F,1.0F,1.0F));
            
            if (hit_object) {
                _touch.set_focused(hit_object);
                break;
            }

        }
        
        // Start touches
        if (_touch.focused())
            _touch.focused()->touches_began(&_touch);

        handled = _touch.focused();
            
    } else if (_touch.state() == TouchEvent::STATE_DOWN) {
    
        if (_touch.focused())
            _touch.focused()->touches_moved(&_touch);

        handled = _touch.focused();

    } else if (_touch.state() == TouchEvent::STATE_RELEASED) {
    
        if (_touch.focused())
            _touch.focused()->touches_ended(&_touch);
 
        handled = _touch.focused();

        // Reset touch
        _touch.set_state(TouchEvent::STATE_NONE);
        _touch.set_focused(NULL);
    } else if (_touch.state() == TouchEvent::STATE_HOVER) {
    
        // Do nothing

    } else {
        handled = _touch.focused();
    }
    
}
Flu_Combo_Box::Popup :: ~Popup()
{
  while( children() )
    remove( child(0) );
}
Beispiel #12
0
// 'Fl_FileBrowser::load()' - Load a directory into the browser.
int                                         // O - Number of files loaded
    Fl_File_Browser::load(const Fl_String &dir) // I - Directory to load
{   
    Fl_String old_dir(directory());
    m_dir_ds.directory(dir);

    clear();
    clear_columns();
    sort_col(1);
    m_up_item = 0;

    if(dir.empty()) {
        header()->add_column("", 20);

        // No directory specified:
        //  - For UNIX list all mount points.
        //  - For Win32 list all valid drive letters.

        //icon      = Fl_FileIcon::find("any", Fl_FileIcon::DEVICE);
        //if (icon == (Fl_FileIcon *)0)
        //  icon = Fl_FileIcon::find("any", Fl_FileIcon::DIR);

        begin();
        char filename[FL_PATH_MAX];
#ifdef _WIN32
        header()->add_column(_("File"), 100);
        header()->add_column(_("Type"), 100);
        header()->add_column(_("Capacity"), 100);
        header()->add_column(_("Free Space"), 100);

        // Drive available bits
        DWORD drives = GetLogicalDrives();
        for(int i = 'A'; i <= 'Z'; i ++, drives >>= 1) {
            if (drives & 1) {
                Fl_ListView_Item *item = new Fl_ListView_Item();
                item->image(&hd_pix);
                snprintf(filename, sizeof(filename)-1, "%c:\\", i);
                item->label(1, filename);

                Fl_File_Attr *attr = fl_file_attr(filename);
                if(attr->flags & Fl_File_Attr::DEVICE)
                {
                    uint type = GetDriveTypeA(filename);
                    const char *typestr=_(types[0]);

                    if (type==DRIVE_CDROM)      { typestr=_(types[4]); item->image(&cd_pix); }
                    else if (type==DRIVE_REMOVABLE) { typestr=_(types[5]); item->image(&floppy_pix); }
                    else if (type==DRIVE_FIXED)     typestr=_(types[6]);
                    else if (type==DRIVE_REMOTE)        typestr=_(types[7]);
                    else if (type==DRIVE_RAMDISK)   typestr=_(types[8]);

                    item->label(2, typestr);

                    uint s = 0;
                    Fl_String suffix;
                    if((s = get_dev_size(attr->capacity, suffix))>0) {
                        item->label(3, Fl_String(s)+" "+suffix);
                    }
                    if((s = get_dev_size(attr->free, suffix))>0) {
                        item->label(4, Fl_String(s)+" "+suffix);
                    }

                    /*
                     //TOO SLOW!!!
                     char drivename[255];
                     if(GetVolumeInformation(
                     filename, drivename, sizeof(drivename)-1,
                     NULL, NULL, NULL, NULL, 0))
                     {
                     if(drivename[0])
                     snprintf(fname, sizeof(fname)-1, "%s (%s)", filename, drivename);
                     }
                     */
                }

            }
        }
#else
        header()->add_column(_("File"), 100);
        header()->add_column(_("Device"), 100);
        header()->add_column(_("Type"), 100);

        FILE    *mtab = 0;      // /etc/mtab or /etc/mnttab file
        char    line[1024];     // Input line
        char    dev[256];       // Device name
        char    fstype[256];    // Filesystem type

        // Open the file that contains a list of mounted filesystems...
#  if defined(__hpux) || defined(__sun)
        // Fairly standard
        mtab = fl_fopen("/etc/mnttab", "r");
#  elif defined(__sgi) || defined(linux)
        // More standard
        mtab = fl_fopen("/etc/mtab", "r");
#  endif
        // Otherwise fallback to full list
        if(mtab == NULL) mtab = fl_fopen("/etc/fstab", "r");
        if(mtab == NULL) mtab = fl_fopen("/etc/vfstab", "r");

        if (mtab != NULL)
        {
            while (fgets(line, sizeof(line), mtab) != NULL)
            {
                if (line[0] == '#' || line[0] == '\n')
                    continue;
                if (sscanf(line, "%255s%4095s%255s", dev, filename, fstype) != 3)
                    continue;
                if(!strcasecmp(dev, "none"))
                    continue;

                Fl_ListView_Item *item = new Fl_ListView_Item();
                item->image(&hd_pix);
                item->label(1, filename);
                item->label(2, dev);
                item->label(3, fstype);
            }
            fclose(mtab);
        }
#endif // _WIN32
        end();
        resizable_col(0, false);
        return children();

    } else {
Beispiel #13
0
void Fl_Pack::layout()
{
    for (int iter = 0; iter < 2; iter++)
    {
        if (!layout_damage()) break;

        // we only need to do something special if the group is resized:
        if (!(layout_damage() & (FL_LAYOUT_WH|FL_LAYOUT_DAMAGE)) || !children())
        {
            Fl_Group::layout();
            if (!(layout_damage() & FL_LAYOUT_DAMAGE)) break;
        }

        // clear the layout flags, so any resizes of children will set them again:
        Fl_Widget::layout();

        // This is the rectangle to lay out the remaining widgets in:
        int x = 0;
        int y = 0;
        int r = this->w();
        int b = this->h();
        box()->inset(x,y,r,b);

        bool saw_horizontal = false;
        bool saw_vertical = false;

        // layout all the top & left widgets (the ones before the resizable):
        int i; for (i = 0; i < children(); i++)
        {
            Fl_Widget* widget = child(i);
            if (widget->contains(resizable())) break;
            if (!widget->visible()) continue;
            if (is_vertical(widget))
            {
                widget->resize(x, y, widget->w(), b-y);
                widget->layout();
                x = widget->x()+widget->w()+spacing_;
                saw_vertical = true;
            }                    // put along top edge:
            else
            {
                widget->resize(x, y, r-x, widget->h());
                widget->layout();
                y = widget->y()+widget->h()+spacing_;
                saw_horizontal = true;
            }
        }

        int resizable_index = i;

        // layout all the bottom & right widgets by going backwards:
        for (i = children()-1; i > resizable_index; i--)
        {
            Fl_Widget* widget = child(i);
            if (!widget->visible()) continue;
            if (is_vertical(widget))
            {
                int W = widget->w();
                widget->resize(r-W, y, W, b-y);
                widget->layout();
                r = widget->x()-spacing_;
                saw_vertical = true;
            }                    // put along top edge:
            else
            {
                int H = widget->h();
                widget->resize(x, b-H, r-x, H);
                widget->layout();
                b = widget->y()-spacing_;
                saw_horizontal = true;
            }
        }

        // Lay out the resizable widget to fill the remaining space:
        if (resizable_index < children())
        {
            Fl_Widget* widget = child(resizable_index);
            widget->resize(x, y, r-x, b-y);
            widget->layout();
        }

        // A non-resizable widget will become the size of it's items:
        int W = w();
        if (r < x || !resizable() && !saw_horizontal) W -= (r-x);
        int H = h();
        if (b < y || !resizable() && !saw_vertical) H -= (b-y);
        size(W,H);
    }
    redraw();
}
int GraphicsLinearLayoutObject::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 3)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 3;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QDeclarativeListProperty<QGraphicsLayoutItem>*>(_v) = children(); break;
        case 1: *reinterpret_cast< Qt::Orientation*>(_v) = orientation(); break;
        case 2: *reinterpret_cast< qreal*>(_v) = spacing(); break;
        case 3: *reinterpret_cast< qreal*>(_v) = contentsMargin(); break;
        }
        _id -= 4;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 1: setOrientation(*reinterpret_cast< Qt::Orientation*>(_v)); break;
        case 2: setSpacing(*reinterpret_cast< qreal*>(_v)); break;
        case 3: setContentsMargin(*reinterpret_cast< qreal*>(_v)); break;
        }
        _id -= 4;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 4;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Beispiel #15
0
 Node* Layer::doClone(const BBox3& worldBounds) const {
     Layer* layer = new Layer(m_name, worldBounds);
     cloneAttributes(layer);
     layer->addChildren(clone(worldBounds, children()));
     return layer;
 }
Beispiel #16
0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs,
                 const mxArray *prhs[]) {


  /* Check for proper number of arguments. */
  if (nrhs != 3) {
    mexErrMsgTxt("Three inputs required.");
  } 
 
  //the first argument is the array of vectors used to build the tree
  /*
    int nelements=mxGetNumberOfFields(prhs[0]);
  if(nelements!=1) {
    mexErrMsgTxt("Input should have one element.");
  }
  */
  
  //the second argument is the struct returned by covertree
  int nfields = mxGetNumberOfFields(prhs[1]);
  if(nfields!=8) {
    mexErrMsgTxt("Second input should have 8 fields.");
  }

  //the third argument is the struct whose first member is the array of
  //vectors being studied; 
  //whose second member is the distance; 
  //whose third member is the depth
  nfields = mxGetNumberOfFields(prhs[2]);
  if(nfields!=3) {
    mexErrMsgTxt("Third input should have three fields.");
  }
  
  const mxArray* tmp=0;

  //Check for proper number of return arguments; [D] or [D E] or [D E F]
  //Return argument one is a cell array D
  //D{i}=indices of A.vectors within distance of A.vectors(:,i) at right level
  //E{i} is corresponding distances
  //F is diagnostics

  bool dist_flag=false;
  bool diag_flag=false;
  if(nlhs==3) {
    dist_flag=true;
    diag_flag=true;
  } else if (nlhs=3) {
    dist_flag=true;
  } else {
    if(nlhs!=1) {
      mexErrMsgTxt("One, two or three return arguments required\n");
    }
  }

  //Extract appropriate members from first input; 
  //this is what what was passed to covertree

  tmp=prhs[0];
  mwSize ndims_in=mxGetNumberOfDimensions(tmp);
  const mwSize* dims_in=mxGetDimensions(tmp);
  
  int N=dims_in[ndims_in-1];
  int n=1;
  for(int i=0;i<ndims_in-1;i++) {
    n*=dims_in[i];
  }
  
  mexPrintf("n=%d N=%d\n",n,N);


  double* X=(double*)mxGetData(tmp);

  Vectors vectors(n,N,X);

  // Extract appropriate members from second input; 
  //this is what was returned from covertree

  tmp=mxGetField(prhs[1],0,cover_in[0]);
  double* ptheta=(double*)mxGetData(tmp);
  double theta=*ptheta;

  tmp=mxGetField(prhs[1],0,cover_in[1]);
  int* params=(int*)mxGetData(tmp); 

  tmp=mxGetField(prhs[1],0,cover_in[2]);
  int* lp=(int*)mxGetData(tmp); 

  tmp=mxGetField(prhs[1],0,cover_in[3]); 
  int* pchildren=(int*)mxGetData(tmp); 
  DisjointLists children(N,pchildren,false);


  int* pdescend_list=(int*)mxMalloc(2*N*sizeof(int));
  int* pdist_flags=(int*)mxMalloc(N*sizeof(int));
  int* pindices_to_dist_flags=(int*)mxMalloc(N*sizeof(int));
  double* pdistances=(double*)mxMalloc(N*sizeof(double));
  int* pcurrent_child_flags=(int*)mxMalloc(N*sizeof(int));
  int* pindices_to_current_child_flags=(int*)mxMalloc(N*sizeof(int));
  int* pcurrent_children=(int*)mxMalloc(N*sizeof(int));

//Get third input

  //tmp=prhs[2];
  tmp=mxGetField(prhs[2],0,within_in[0]);
  ndims_in=mxGetNumberOfDimensions(tmp);
  dims_in=mxGetDimensions(tmp);
  

  int N2=dims_in[ndims_in-1];
  int n2=1;
  for(int i=0;i<ndims_in-1;i++) {
    n2*=dims_in[i];
  }

  mexPrintf("N2=%d\n",N2);
  
  if(n2!=n) {
    mexPrintf("n2=%d must equal n=%d\n",n2,n);
  }

  double* Y=(double*)mxGetData(tmp);

  tmp=mxGetField(prhs[2],0,within_in[1]);
  double* pdwithin=(double*)mxGetData(tmp); 
  double dwithin=*pdwithin;

  tmp=mxGetField(prhs[2],0,within_in[2]);
  int* pdepth=(int*)mxGetData(tmp); 
  int depth=*pdepth;

  mexPrintf("point=%g dwithin=%g depth=%d\n",*Y,dwithin,depth);
  
  Cover cover(theta,
	      params,
	      &vectors,
	      lp,children,
	      pdescend_list,
	      pdist_flags,pindices_to_dist_flags,
	      pdistances,
	      pcurrent_child_flags,pindices_to_current_child_flags,
	      pcurrent_children);


  ndims=2;
  dims[0]=1;
  dims[1]=N2;

  mxArray* pointer0=mxCreateCellArray(ndims,dims);
  mxArray* pointer1=0;
  Cover::DescendList* pdescendlist=0;
  if(dist_flag) {
   pointer1= mxCreateCellArray(ndims,dims);
   pdescendlist=(Cover::DescendList*)&cover.getDescendList();
  }

  for(int i=0;i<N2;i++) {
    //mexPrintf("loop i=%d\n",i);
    Vector v(n,Y+i*n);
    cover.findWithin(&v,dwithin,depth);
    int count=cover.getDescendList().getCount();
    dims[1]=count;
    mxArray* fout=mxCreateNumericArray(ndims,dims,mxINT32_CLASS,mxREAL);
    int* arr=(int*)mxGetData(fout);
    cover.fillArrFromDescendList(arr);      
    /*
    bool test=cover.checkFindWithin(&v,dwithin,depth);    
    if(test) {
      mexPrintf("checkFindWithin passed\n");
    } else {
      mexPrintf("checkFindWithin failed\n");
    }
    */
    mxSetCell(pointer0,i,fout);
    if(dist_flag) {
      fout=mxCreateNumericArray(ndims,dims,mxDOUBLE_CLASS,mxREAL);
      double* dist=(double*)mxGetData(fout);
      for(int i=0;i<count;i++) {
	dist[i]=pdescendlist->getDist(&v,arr[i]);
      }
    }	
    mxSetCell(pointer1,i,fout);
    cover.clearDescendList();
  }

  plhs[0]=pointer0;
  if(dist_flag) {
    plhs[1]=pointer1;
  }
 
  if(diag_flag) {
    double* p=0;
    plhs[2]= mxCreateStructMatrix(1, 1, 4, fnames_out_2);
    ndims=2;
    dims[0]=1;
    dims[1]=1;

    mxArray* fout=0;
    fout = mxCreateNumericArray(ndims,dims,mxDOUBLE_CLASS,mxREAL);
    p=(double*)mxGetData(fout);
    mxSetField(plhs[2],0,fnames_out_2[0],fout);
    p[0]=cover.getDistNCallsToGet();

    fout = mxCreateNumericArray(ndims,dims,mxDOUBLE_CLASS,mxREAL);
    p=(double*)mxGetData(fout);
    mxSetField(plhs[2],0,fnames_out_2[1],fout);
    p[0]=cover.getDistNCallsToSet();

    fout = mxCreateNumericArray(ndims,dims,mxDOUBLE_CLASS,mxREAL);
    p=(double*)mxGetData(fout);
    mxSetField(plhs[2],0,fnames_out_2[2],fout);
    p[0]=cover.getChildrenNCallsToGet();

    fout = mxCreateNumericArray(ndims,dims,mxDOUBLE_CLASS,mxREAL);
    p=(double*)mxGetData(fout);
    mxSetField(plhs[2],0,fnames_out_2[3],fout);
    p[0]=cover.getChildrenNCallsToSet();
  }

  mxFree(pdescend_list);
  mxFree(pdist_flags);
  mxFree(pindices_to_dist_flags);
  mxFree(pdistances);
  mxFree(pcurrent_child_flags);
  mxFree(pindices_to_current_child_flags);
  mxFree(pcurrent_children);  


}
void Formula::finalize()
    {
    for(List_Iterator<Formula*> c(children()); c; c++)
	(*c)->finalize();
    }
Beispiel #18
0
NewGrpModal::~NewGrpModal()
{
    while(this->children().length()>0)
        delete(children().last());
}
Beispiel #19
0
void QWidget::scroll( int dx, int dy, const QRect& r )
{
    if ( testWState( WState_BlockUpdates ) && !children() )
	return;
    bool valid_rect = r.isValid();
    QRect sr = valid_rect?r:rect();
    int x1, y1, x2, y2, w=sr.width(), h=sr.height();
    if ( dx > 0 ) {
	x1 = sr.x();
	x2 = x1+dx;
	w -= dx;
    } else {
	x2 = sr.x();
	x1 = x2-dx;
	w += dx;
    }
    if ( dy > 0 ) {
	y1 = sr.y();
	y2 = y1+dy;
	h -= dy;
    } else {
	y2 = sr.y();
	y1 = y2-dy;
	h += dy;
    }

    if ( dx == 0 && dy == 0 )
	return;

    QSize s( qt_screen->width(), qt_screen->height() );
    QRegion alloc = valid_rect ? paintableRegion() : allocatedRegion();

    QRegion dAlloc = alloc;
    QPoint td1 = qt_screen->mapToDevice( QPoint(0,0), s );
    QPoint td2 = qt_screen->mapToDevice( QPoint(dx,dy), s );
    dAlloc.translate( td2.x()-td1.x(), td2.y()-td1.y() );

    QRegion scrollRegion( alloc & dAlloc );

    if ( w > 0 && h > 0 ) {
	QGfx * mygfx=graphicsContext( FALSE );
	mygfx->setClipDeviceRegion( scrollRegion );
	mygfx->scroll(x2,y2,w,h,x1,y1);
	delete mygfx;
    }

    paintable_region_dirty = TRUE;

    QPoint gpos = mapToGlobal( QPoint() );

    if ( !valid_rect && children() ) {	// scroll children
	setChildrenAllocatedDirty();
	QPoint pd( dx, dy );
	QObjectListIt it(*children());
	register QObject *object;
	while ( it ) {				// move all children
	    object = it.current();
	    if ( object->isWidgetType() ) {
		QWidget *w = (QWidget *)object;
		QPoint oldp = w->pos();
		QRect  r( w->pos() + pd, w->size() );
		w->crect = r;
		w->updateRequestedRegion( gpos + w->pos() );
		QMoveEvent e( r.topLeft(), oldp );
		QApplication::sendEvent( w, &e );
	    }
	    ++it;
	}
    }

    QSize ds( qt_screen->deviceWidth(), qt_screen->deviceHeight() );
    scrollRegion = qt_screen->mapFromDevice( scrollRegion, ds );
    scrollRegion.translate( -gpos.x(), -gpos.y() );

    QRegion update( sr );
    update -= scrollRegion;
    if ( dx ) {
	int x = x2 == sr.x() ? sr.x()+w : sr.x();
	update |= QRect( x, sr.y(), QABS(dx), sr.height() );
    }
    if ( dy ) {
	int y = y2 == sr.y() ? sr.y()+h : sr.y();
	update |= QRect( sr.x(), y, sr.width(), QABS(dy) );
    }
    repaint( update, !testWFlags(WRepaintNoErase) );
    if ( !valid_rect && children() )
	paint_children( this, update, FALSE );
}
Beispiel #20
0
	//!	Assign cluster number
	uvec labeltree(const mat& X, uvec conn)
	{
		uword n = X.n_rows;
		uword nleaves = n + 1;
		uvec T = ones<uvec>(n + 1);

		// Each cut potentially yeild as additional cluster
		uvec todo = ones<uvec>(n);

		// Define cluster numbers for each side of each non-leaf node
		umat clustlist = reshape(arma_ext::colon<uvec>(1, 2 * n), n, 2);

		// Propagate cluster numbers down the tree
		while (any(todo)) {
			// Work on rows that are now split but not yet processed
			// rows = find(todo & ~conn);
			uvec rows = find(todo % logical_not(conn));
			if (rows.empty()) break;

			for (uword j = 0 ; j < 2 ; j++) {	// 0: left, 1: right
				uvec children = conv_to<uvec>::from(X.col(j)).elem(rows);

				// Assign cluster number to child leaf node
				uvec leaf = (children <= nleaves);
				if (any(leaf)) {
					uvec leafi = find(leaf);
#ifdef ARMA_EXT_USE_CPP11
					std::for_each(leafi.begin(), leafi.end(), [&](uword index) {
#else
					for (size_type i = 0 ; i < leafi.size() ; i++) {
						uword index = leafi[i];
#endif
						T[children[index] - 1] = clustlist.at(rows[index], j);
#ifdef ARMA_EXT_USE_CPP11
					});
#else
					}
#endif
				}

				// Also assign it to both children of any joined child non-leaf nodes
				uvec joint = logical_not(leaf);	// ~leaf
				uvec jointi = find(joint);
				joint(jointi) = conn(children(jointi) - nleaves - 1);

				if (any(joint)) {
#ifdef ARMA_EXT_USE_CPP11
					std::for_each(jointi.begin(), jointi.end(), [&](uword index) {
#else
					for (size_type i = 0 ; i < jointi.size() ; i++) {
						uword index = jointi[i];
#endif
						uword clustnum = clustlist(rows(index), j);
						uword childnum = children(index) - nleaves - 1;
						clustlist.row(childnum).fill(clustnum);
						conn(childnum) = 0;
#ifdef ARMA_EXT_USE_CPP11
					});
#else
					}
#endif
				}
			}
Beispiel #21
0
array<patch>
children (patch p, int i, int j) {
  ASSERT (0 <= i && i <= nr_children (p), "index out of range");
  ASSERT (i <= j && j <= nr_children (p), "index out of range");
  return range (children (p), i, j);
}
Beispiel #22
0
void InnerDropdown::Container::setVisibleTopBottom(int visibleTop, int visibleBottom) {
	if (auto child = static_cast<TWidget*>(children().front())) {
		child->setVisibleTopBottom(visibleTop - _st.scrollPadding.top(), visibleBottom - _st.scrollPadding.top());
	}
}
/* Helper for gdbpy_apply_val_pretty_printer that formats children of the
   printer, if any exist.  If is_py_none is true, then nothing has
   been printed by to_string, and format output accordingly. */
static void
print_children (PyObject *printer, const char *hint,
		struct ui_file *stream, int recurse,
		const struct value_print_options *options,
		const struct language_defn *language,
		int is_py_none)
{
  int is_map, is_array, done_flag, pretty;
  unsigned int i;

  if (! PyObject_HasAttr (printer, gdbpy_children_cst))
    return;

  /* If we are printing a map or an array, we want some special
     formatting.  */
  is_map = hint && ! strcmp (hint, "map");
  is_array = hint && ! strcmp (hint, "array");

  gdbpy_ref<> children (PyObject_CallMethodObjArgs (printer, gdbpy_children_cst,
						    NULL));
  if (children == NULL)
    {
      print_stack_unless_memory_error (stream);
      return;
    }

  gdbpy_ref<> iter (PyObject_GetIter (children.get ()));
  if (iter == NULL)
    {
      print_stack_unless_memory_error (stream);
      return;
    }

  /* Use the prettyformat_arrays option if we are printing an array,
     and the pretty option otherwise.  */
  if (is_array)
    pretty = options->prettyformat_arrays;
  else
    {
      if (options->prettyformat == Val_prettyformat)
	pretty = 1;
      else
	pretty = options->prettyformat_structs;
    }

  /* Manufacture a dummy Python frame to work around Python 2.4 bug,
     where it insists on having a non-NULL tstate->frame when
     a generator is called.  */
#ifndef IS_PY3K
  dummy_python_frame frame;
  if (frame.failed ())
    {
      gdbpy_print_stack ();
      return;
    }
#endif

  done_flag = 0;
  for (i = 0; i < options->print_max; ++i)
    {
      PyObject *py_v;
      const char *name;

      gdbpy_ref<> item (PyIter_Next (iter.get ()));
      if (item == NULL)
	{
	  if (PyErr_Occurred ())
	    print_stack_unless_memory_error (stream);
	  /* Set a flag so we can know whether we printed all the
	     available elements.  */
	  else	
	    done_flag = 1;
	  break;
	}

      if (! PyTuple_Check (item.get ()) || PyTuple_Size (item.get ()) != 2)
	{
	  PyErr_SetString (PyExc_TypeError,
			   _("Result of children iterator not a tuple"
			     " of two elements."));
	  gdbpy_print_stack ();
	  continue;
	}
      if (! PyArg_ParseTuple (item.get (), "sO", &name, &py_v))
	{
	  /* The user won't necessarily get a stack trace here, so provide
	     more context.  */
	  if (gdbpy_print_python_errors_p ())
	    fprintf_unfiltered (gdb_stderr,
				_("Bad result from children iterator.\n"));
	  gdbpy_print_stack ();
	  continue;
	}

      /* Print initial "{".  For other elements, there are three
	 cases:
	 1. Maps.  Print a "," after each value element.
	 2. Arrays.  Always print a ",".
	 3. Other.  Always print a ",".  */
      if (i == 0)
	{
         if (is_py_none)
           fputs_filtered ("{", stream);
         else
           fputs_filtered (" = {", stream);
       }

      else if (! is_map || i % 2 == 0)
	fputs_filtered (pretty ? "," : ", ", stream);

      /* In summary mode, we just want to print "= {...}" if there is
	 a value.  */
      if (options->summary)
	{
	  /* This increment tricks the post-loop logic to print what
	     we want.  */
	  ++i;
	  /* Likewise.  */
	  pretty = 0;
	  break;
	}

      if (! is_map || i % 2 == 0)
	{
	  if (pretty)
	    {
	      fputs_filtered ("\n", stream);
	      print_spaces_filtered (2 + 2 * recurse, stream);
	    }
	  else
	    wrap_here (n_spaces (2 + 2 *recurse));
	}

      if (is_map && i % 2 == 0)
	fputs_filtered ("[", stream);
      else if (is_array)
	{
	  /* We print the index, not whatever the child method
	     returned as the name.  */
	  if (options->print_array_indexes)
	    fprintf_filtered (stream, "[%d] = ", i);
	}
      else if (! is_map)
	{
	  fputs_filtered (name, stream);
	  fputs_filtered (" = ", stream);
	}

      if (gdbpy_is_lazy_string (py_v))
	{
	  CORE_ADDR addr;
	  struct type *type;
	  long length;
	  gdb::unique_xmalloc_ptr<char> encoding;
	  struct value_print_options local_opts = *options;

	  gdbpy_extract_lazy_string (py_v, &addr, &type, &length, &encoding);

	  local_opts.addressprint = 0;
	  val_print_string (type, encoding.get (), addr, (int) length, stream,
			    &local_opts);
	}
      else if (gdbpy_is_string (py_v))
	{
	  gdb::unique_xmalloc_ptr<char> output;

	  output = python_string_to_host_string (py_v);
	  if (!output)
	    gdbpy_print_stack ();
	  else
	    fputs_filtered (output.get (), stream);
	}
      else
	{
	  struct value *value = convert_value_from_python (py_v);

	  if (value == NULL)
	    {
	      gdbpy_print_stack ();
	      error (_("Error while executing Python code."));
	    }
	  else
	    common_val_print (value, stream, recurse + 1, options, language);
	}

      if (is_map && i % 2 == 0)
	fputs_filtered ("] = ", stream);
    }

  if (i)
    {
      if (!done_flag)
	{
	  if (pretty)
	    {
	      fputs_filtered ("\n", stream);
	      print_spaces_filtered (2 + 2 * recurse, stream);
	    }
	  fputs_filtered ("...", stream);
	}
      if (pretty)
	{
	  fputs_filtered ("\n", stream);
	  print_spaces_filtered (2 * recurse, stream);
	}
      fputs_filtered ("}", stream);
    }
}
Beispiel #24
0
void UmlClass::gen_cpp_decl(QByteArray s, bool descr)
{
    const char * p = (descr)
                     ? (const char *) s
                     : (const char *) bypass_comment(s);

    while (*p) {
        if (!strncmp(p, "${comment}", 10))
            p += 10;
        else if (!strncmp(p, "${description}", 14))
            p += 14;
        else if (!strncmp(p, "${type}", 7)) {
            p += 7;
            bool find = FALSE;

            if (baseType().type != 0) {
                UmlClass * mother = baseType().type;
                const QVector<UmlItem*> ch = children();

                for (int i = 0; i != ch.size(); i += 1) {
                    if (ch[i]->kind() == aRelation) {
                        UmlRelation * rel = (UmlRelation *) ch[i];
                        aRelationKind k = rel->relationKind();

                        if (((k == aGeneralisation) ||
                             (k == aRealization)) &&
                            (rel->roleType() == mother)) {
                            rel->roleType()->write();
                            generate(actuals(), mother, TRUE);
                            find = TRUE;
                            break;
                        }
                    }
                }
            }

            if (! find)
                UmlItem::write(baseType(), cppLanguage);
        }
        else if (!strncmp(p, "${template}", 11)) {
            p += 11;
            generate(formals());
        }
        else if (!strncmp(p, "${name}", 7)) {
            p += 7;
            writeq(name());
        }
        else if (!strncmp(p, "${inherit}", 10)) {
            p += 10;

            const QVector<UmlItem*> ch = children();
            const char * sep = " : ";

            for (int i = 0; i != ch.size(); i += 1) {
                if (ch[i]->kind() == aRelation) {
                    UmlRelation * rel = (UmlRelation *) ch[i];
                    aRelationKind k = rel->relationKind();

                    if (((k == aGeneralisation) ||
                         (k == aRealization)) &&
                        !rel->cppDecl().isEmpty()) {
                        fw.write(sep);
                        // UmlItem::write else G++ call UmlClass::write(QCString) !
                        UmlItem::write((rel->cppVisibility() == DefaultVisibility)
                                       ? rel->visibility() : rel->cppVisibility(),
                                       cppLanguage);
                        fw.write((rel->cppVirtualInheritance()) ? " virtual " : " ");
                        rel->roleType()->write();
                        generate(actuals(), rel->roleType(), TRUE);
                        sep = ", ";
                    }
                }
            }
        }
        else if (*p == '{') {
            if (descr)
                fw.write(*p++);
            else
                break;
        }
        else if (*p == '\r')
            p += 1;
        else if (*p == '\n') {
            if (descr) {
                fw.write("<br />");
                p += 1;
            }
            else {
                fw.write(' ');

                do
                    p += 1;

                while ((*p != 0) && (*p <= ' '));
            }
        }
        else if (*p == '@')
            manage_alias(p);
        else
            writeq(*p++);
    }

}
Beispiel #25
0
void UmlClass::generate_decl(QTextStream & f_h, WrapperStr indent)
{
    context.append(this);

    bool removed = FALSE;
    QVector<UmlItem*> ch = children();
    const unsigned sup = ch.size();
    QLOG_INFO() << "children.size() is: " << sup;
    const WrapperStr & stereotype = cpp_stereotype();
    bool a_typedef = (stereotype == "typedef");

    bool an_enum = (stereotype == "enum");
    QLOG_INFO() << "the class is an enum: " << an_enum;
    const QList<UmlFormalParameter> formals = this->formals();
    const QList<UmlActualParameter> actuals = this->actuals();
    unsigned index;
    const char * p = cppDecl();
    const char * pp = 0;
    const char * sep;
    bool nestedp = parent()->kind() == aClass;

    if (nestedp)
        indent += "    ";

    while ((*p == ' ') || (*p == '\t'))
        indent += toLocale(p);

    if (*p != '#')
        f_h << indent;

    for (;;) {
        if (*p == 0) {
            if (pp == 0)
                break;

            // comment management done
            p = pp;
            pp = 0;

            if (*p == 0)
                break;

            if (*p != '#')
                f_h << indent;
        }

        if (*p == '\n') {
            f_h << toLocale(p);
            bool isNotNull = *p;
            bool isNotGrid = *p != '#';
            bool isMembers = strncmp(p, "${members}", 10);
            bool isItems = strncmp(p, "${items}", 8);

            if (isNotNull && isNotGrid && (isMembers || isItems))
                f_h << indent;
        }
        else if (*p == '@')
            manage_alias(p, f_h);
        else if (*p != '$')
            f_h << toLocale(p);
        else if (!strncmp(p, "${comment}", 10))
            manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment());
        else if (!strncmp(p, "${description}", 14))
            manage_description(p, pp);
        else if (! strncmp(p, "${name}", 7)) {
            p += 7;
            f_h << name();
        }
        else if (a_typedef) {
            if (!strncmp(p, "${type}", 7)) {
                p += 7;
                UmlClass::write(f_h, baseType(), FALSE);

                UmlClass * cl = baseType().type;

                if ((cl != 0) && !actuals.isEmpty()) {
                    QList<UmlActualParameter>::ConstIterator ita;
                    BooL need_space = FALSE;

                    for (ita = actuals.begin(); ita != actuals.end(); ++ita)
                        if ((*ita).superClass() == cl)
                            if (!(*ita).generate(f_h, need_space))
                                // no specified value
                                break;

                    if (need_space)
                        f_h << " >";
                    else
                        f_h << '>';
                }
            }
            else
                // strange
                f_h << toLocale(p);
        }
        else if (an_enum) {
            if (!strncmp(p, "${items}", 8)) {
                p += 8;

                // items declaration

                aVisibility current_visibility = DefaultVisibility;
                unsigned max = sup - 1;
                BooL first = TRUE;
                QLOG_INFO() << "Found enum";

                for (index = 0; index < sup; index += 1) {
                    UmlItem * it = ch[index];
                    QLOG_INFO() << "The item is of kind: " <<  it->kind();

                    switch (it->kind()) {
                    case aClass:
                    case aNcRelation:
                        break;

                    default:
                        if (!((UmlClassItem *) it)->cppDecl().isEmpty()) {
                            ((UmlClassItem *) it)->generate_decl(current_visibility,
                                                                 f_h, stereotype, indent,
                                                                 first, index == max);
                        }
                    }
                }

                if (*p == '}')
                    f_h << indent;
            }
            else
                // strange
                f_h << toLocale(p);
        }
        else if (! strncmp(p, "${template}", 11)) {
            p += 11;

            // template

            if (!formals.isEmpty()) {
                sep = "template<";
                const char * sep2 = "<";
                BooL need_space = FALSE;

                QList<UmlFormalParameter>::ConstIterator itf;

                for (itf = formals.begin(); itf != formals.end(); ++itf)
                    (*itf).generate(f_h, sep, sep2, need_space);

                f_h << ((need_space) ? " >\n" : ">\n");

                if (nestedp)
                    f_h << indent;
            }
            else if (name().find('<') != -1) {
                f_h << "template<>\n";

                if (nestedp)
                    f_h << indent;
            }
        }
        else if (! strncmp(p, "${inherit}", 10)) {
            p += 10;

            // inherit

            sep = " : ";

            for (index = 0; index != sup; index += 1) {
                UmlItem * x = ch[index];

                if ((x->kind() == aRelation) &&
                    !((UmlRelation *) ch[index])->cppDecl().isEmpty())
                    ((UmlRelation *) x)->generate_inherit(sep, f_h, actuals, stereotype);
            }
        }
        else if (! strncmp(p, "${members}", 10)) {
            p += 10;

            // members declaration

            aVisibility current_visibility;

            current_visibility = ((stereotype == "struct") || (stereotype == "union"))
                                 ? PublicVisibility : DefaultVisibility;
            unsigned last = sup - 1;
            BooL first = TRUE;

            for (index = 0; index != sup; index += 1) {
                UmlItem * it = ch[index];

                if ((it->kind() != aNcRelation) &&
                    !((UmlClassItem *) it)->cppDecl().isEmpty()) {
                    QLOG_INFO() << "generating member declarations";
                    ((UmlClassItem *) it)->generate_decl(current_visibility,
                                                         f_h, stereotype, indent,
                                                         first, index == last);
                }
            }

            if (*p == '}')
                f_h << indent;
        }
        else if (!strncmp(p, "${inlines}", 10)) {
            p += 10;

            context.removeLast();
            removed = TRUE;

            if (! nestedp) {
                // inline operations definition
                // template class members
                WrapperStr templates;
                WrapperStr cl_names;
                WrapperStr templates_tmplop;
                WrapperStr cl_names_tmplop;

                spec(templates, cl_names, templates_tmplop, cl_names_tmplop);

                for (index = 0; index != sup; index += 1)
                    if (ch[index]->kind() != aNcRelation)
                        ((UmlClassItem *) ch[index])
                        ->generate_def(f_h, indent, TRUE, templates, cl_names,
                                       templates_tmplop, cl_names_tmplop);
            }

            if (*p == '\n')
                p += 1;
        }
        else
            // strange
            f_h << toLocale(p);
    }

    if (! removed)
        context.removeLast();
}
Beispiel #26
0
void UmlClass::gen_php_decl(QByteArray s, bool descr)
{
    QByteArray st = PhpSettings::classStereotype(stereotype());

    if (st == "ignored")
        return;

    const char * p = bypass_comment(s);
    UmlRelation * extend = 0;

    while (*p != 0) {
        if (!strncmp(p, "${comment}", 10))
            p += 10;
        else if (!strncmp(p, "${description}", 14))
            p += 14;
        else if (!strncmp(p, "${visibility}", 13)) {
            p += 13;
            UmlItem::write(visibility(), phpLanguage);
            fw.write(' ');
        }
        else if (!strncmp(p, "${final}", 8)) {
            p += 8;

            if (isPhpFinal())
                fw.write("final ");
        }
        else if (!strncmp(p, "${abstract}", 11)) {
            p += 11;

            if (isAbstract())
                fw.write("abstract ");
        }
        else if (!strncmp(p, "${name}", 7)) {
            p += 7;
            writeq(name());
            generics();
        }
        else if (!strncmp(p, "${extends}", 10)) {
            p += 10;

            const QVector<UmlItem*> ch = children();

            for (int i = 0; i != ch.size(); i += 1) {
                if (ch[i]->kind() == aRelation) {
                    UmlRelation * rel = (UmlRelation *) ch[i];
                    aRelationKind k = rel->relationKind();

                    if (((k == aGeneralisation) ||
                         (k == aRealization)) &&
                        (!rel->phpDecl().isEmpty()) &&
                        ((st == "interface") ||
                         (PhpSettings::classStereotype(rel->roleType()->stereotype()) != "interface"))) {
                        extend = rel;
                        fw.write(" extends ");
                        rel->roleType()->write();
                        break;
                    }
                }
            }
        }
        else if (!strncmp(p, "${implements}", 13)) {
            p += 13;

            const QVector<UmlItem*> ch = children();
            const char * sep = " implements ";

            for (int i = 0; i != ch.size(); i += 1) {
                if (ch[i]->kind() == aRelation) {
                    UmlRelation * rel = (UmlRelation *) ch[i];
                    aRelationKind k = rel->relationKind();

                    if ((rel != extend) &&
                        ((k == aGeneralisation) ||
                         (k == aRealization)) &&
                        (!rel->phpDecl().isEmpty())) {
                        fw.write(sep);
                        sep = ", ";
                        rel->roleType()->write();
                    }
                }
            }
        }
        else if (*p == '\r')
            p += 1;
        else if (*p == '\n') {
            if (descr) {
                fw.write("<br />");
                p += 1;
            }
            else {
                fw.write(' ');

                do
                    p += 1;

                while ((*p != 0) && (*p <= ' '));
            }
        }
        else if ((*p == '{') || (*p == ';')) {
            if (descr)
                fw.write(*p++);
            else
                break;
        }
        else if (*p == '@')
            manage_alias(p);
        else
            writeq(*p++);
    }
}
Beispiel #27
0
 void clearChildren()
 {
     qDeleteAll(children());
     new QHBoxLayout(this);
 }
Beispiel #28
0
void UmlClass::gen_html(QByteArray pfix, unsigned int rank, unsigned int level)
{
    UmlCom::message(name());

    QByteArray s;

    s = description();

    if (isActive())
        fw.write("<p>Active class</p>\n");

    if (!s.isEmpty()) {
        fw.write("<p>");

        if (! javaDecl().isEmpty())
            gen_java_decl(s, TRUE);
        else if (! phpDecl().isEmpty())
            gen_php_decl(s, TRUE);
        else if (! pythonDecl().isEmpty())
            gen_python_decl(s, TRUE);
        else
            gen_cpp_decl(s, TRUE);

        fw.write("<br /></p>\n");
    }

    if (!cppDecl().isEmpty() ||
        !javaDecl().isEmpty() ||
        !phpDecl().isEmpty() ||
        !pythonDecl().isEmpty()) {
        fw.write("<p>Declaration :</p><ul>\n");

        s = cppDecl();

        if (!s.isEmpty()) {
            fw.write("<li>C++ : ");
            gen_cpp_decl(s, FALSE);
            fw.write("</li>");
        }

        s = javaDecl();

        if (!s.isEmpty()) {
            fw.write("<li>Java : ");
            gen_java_decl(s, FALSE);
            fw.write("</li>");
        }

        s = phpDecl();

        if (!s.isEmpty()) {
            fw.write("<li>Php : ");
            gen_php_decl(s, FALSE);
            fw.write("</li>");
        }

        s = pythonDecl();

        if (!s.isEmpty()) {
            fw.write("<li>Python : ");
            gen_python_decl(s, FALSE);
            fw.write("</li>");
        }

        fw.write("</ul>");
    }

    if (subClasses.size() != 0) {
        sort(subClasses);
        fw.write("<p>Directly inherited by : ");

        for (unsigned i = 0; i != subClasses.size(); i += 1) {
            subClasses.elementAt(i)->write();
            fw.write(' ');
        }

        fw.write("</p>\n");
    }

    write_dependencies();

    annotation_constraint();

    bool p = FALSE;
    UmlItem * x;

    if ((x = associatedArtifact()) != 0) {
        p = TRUE;
        fw.write("<p>Artifact : ");
        x->write();
    }

    const QVector<UmlComponent*> comps = associatedComponents();

    if (comps.size() != 0) {
        if (p)
            fw.write(", Component(s) :");
        else {
            p = TRUE;
            fw.write("<p>Component(s) :");
        }

        for (int i = 0; i != comps.size(); i += 1) {
            fw.write(' ');
            comps[i]->write();
        }
    }

    if ((x = associatedDiagram()) != 0) {
        if (p)
            fw.write(", Diagram : ");
        else {
            p = TRUE;
            fw.write("<p>Diagram : ");
        }

        x->write();
    }

    if (p)
        fw.write("</p>\n");

    if (parent()->kind() == aClass) {
        fw.write("<p>nested in ");
        parent()->write();
        fw.write("</p>\n");
    }

    write_properties();

    //

    const QVector<UmlItem*> ch = children();

    if (ch.size() != 0) {
        if (stereotype() == "enum_pattern") {
            p = FALSE;

            for (int i = 0; i != ch.size(); i += 1) {
                if (ch[i]->kind() == anAttribute) {
                    if (!p) {
                        p = TRUE;
                        fw.write("<div class=\"sub\">\n<p>Items :</p><ul>\n");
                    }

                    fw.write("<li>");
                    writeq(ch[i]->name());
                    fw.write("</li>\n");
                }
            }

            if (p)
                fw.write("</ul>\n</div>\n");
        }
        else {
            fw.write("<div class=\"sub\">\n");

            if (stereotype() == "enum") {
                int i;

                p = FALSE;

                for (i = 0; i != ch.size(); i += 1) {
                    if ((ch[i]->kind() == anAttribute) &&
                        (ch[i]->stereotype() != "attribute")) {
                        if (!p) {
                            p = TRUE;
                            fw.write("<p>Items :</p><ul>\n");
                        }

                        fw.write("<li>");
                        writeq(ch[i]->name());
                        fw.write("</li>\n");
                    }
                }

                if (p)
                    fw.write("</ul>\n");

                s = "";

                for (i = 0; i != ch.size(); i += 1)
                    if ((ch[i]->kind() != anAttribute) ||
                        (ch[i]->stereotype() == "attribute"))
                        ch[i]->html(s, 0, 0);
            }
            else if (flat)
                write_children(pfix, rank, level);
            else {
                // non flat
                s = "";

                for (int i = 0; i != ch.size(); i += 1)
                    ch[i]->html(s, 0, 0);
            }

            fw.write("</div>\n");
        }
    }
    sort(*inherited_opers);
    bool already = FALSE;

    for (unsigned i = 0; i != inherited_opers->size(); i += 1) {
        if (already)
            fw.write(", ");
        else {
            already = TRUE;
            fw.write("<p>All public operations : ");
        }

        inherited_opers->elementAt(i)->write();
        fw.write(' ');
    }

    if (already)
        fw.write("</p>\n");
}
void GraphicsLayerTextureMapper::commitLayerChanges()
{
    if (m_changeMask == NoChanges)
        return;

    if (m_changeMask & ChildrenChange) {
        Vector<TextureMapperLayer*> textureMapperLayerChildren;
        toTextureMapperLayerVector(children(), textureMapperLayerChildren);
        m_layer->setChildren(textureMapperLayerChildren);
    }

    if (m_changeMask & MaskLayerChange)
        m_layer->setMaskLayer(toTextureMapperLayer(maskLayer()));

    if (m_changeMask & ReplicaLayerChange)
        m_layer->setReplicaLayer(toTextureMapperLayer(replicaLayer()));

    if (m_changeMask & PositionChange)
        m_layer->setPosition(position());

    if (m_changeMask & AnchorPointChange)
        m_layer->setAnchorPoint(anchorPoint());

    if (m_changeMask & SizeChange)
        m_layer->setSize(size());

    if (m_changeMask & TransformChange)
        m_layer->setTransform(transform());

    if (m_changeMask & ChildrenTransformChange)
        m_layer->setChildrenTransform(childrenTransform());

    if (m_changeMask & Preserves3DChange)
        m_layer->setPreserves3D(preserves3D());

    if (m_changeMask & ContentsRectChange)
        m_layer->setContentsRect(contentsRect());

    if (m_changeMask & MasksToBoundsChange)
        m_layer->setMasksToBounds(masksToBounds());

    if (m_changeMask & DrawsContentChange)
        m_layer->setDrawsContent(drawsContent());

    if (m_changeMask & ContentsVisibleChange)
        m_layer->setContentsVisible(contentsAreVisible());

    if (m_changeMask & ContentsOpaqueChange)
        m_layer->setContentsOpaque(contentsOpaque());

    if (m_changeMask & BackfaceVisibilityChange)
        m_layer->setBackfaceVisibility(backfaceVisibility());

    if (m_changeMask & OpacityChange)
        m_layer->setOpacity(opacity());

    if (m_changeMask & BackgroundColorChange)
        m_layer->setSolidColor(solidColor());

#if ENABLE(CSS_FILTERS)
    if (m_changeMask & FilterChange)
        m_layer->setFilters(filters());
#endif

    if (m_changeMask & BackingStoreChange)
        m_layer->setBackingStore(m_backingStore);

    if (m_changeMask & DebugVisualsChange)
        m_layer->setDebugVisuals(isShowingDebugBorder(), debugBorderColor(), debugBorderWidth(), isShowingRepaintCounter());

    if (m_changeMask & RepaintCountChange)
        m_layer->setRepaintCount(repaintCount());

    if (m_changeMask & ContentChange)
        m_layer->setContentsLayer(platformLayer());

    if (m_changeMask & AnimationChange)
        m_layer->setAnimations(m_animations);

    if (m_changeMask & AnimationStarted)
        client()->notifyAnimationStarted(this, m_animationStartTime);

    if (m_changeMask & FixedToViewporChange)
        m_layer->setFixedToViewport(fixedToViewport());

    if (m_changeMask & IsScrollableChange)
        m_layer->setIsScrollable(isScrollable());

    if (m_changeMask & CommittedScrollOffsetChange)
        m_layer->didCommitScrollOffset(m_committedScrollOffset);

    m_changeMask = NoChanges;
}
Beispiel #30
0
RequestBroker::ProcessResponse ImageRequest::Process(RequestBroker & rb)
{
	VideoBuffer * image = NULL;

	//Have a look at the thumbnail cache
	for(std::deque<std::pair<std::string, VideoBuffer*> >::iterator iter = rb.imageCache.begin(), end = rb.imageCache.end(); iter != end; ++iter)
	{
		if((*iter).first == URL)
		{
			image = (*iter).second;
#ifdef DEBUG
			std::cout << typeid(*this).name() << " " << URL << " found in cache" << std::endl;
#endif
		}
	}

	if(!image)
	{
		if(HTTPContext)
		{
			if(http_async_req_status(HTTPContext))
			{
				pixel * imageData;
				char * data;
				int status, data_size, imgw, imgh;
				data = http_async_req_stop(HTTPContext, &status, &data_size);

				if (status == 200 && data)
				{
					imageData = Graphics::ptif_unpack(data, data_size, &imgw, &imgh);
					free(data);

					if(imageData)
					{
						//Success!
						image = new VideoBuffer(imageData, imgw, imgh);
						free(imageData);
					}
					else
					{
						//Error thumbnail
						image = new VideoBuffer(32, 32);
						image->SetCharacter(14, 14, 'x', 255, 255, 255, 255);
					}

					if(rb.imageCache.size() >= THUMB_CACHE_SIZE)
					{
						//Remove unnecessary from thumbnail cache
						delete rb.imageCache.front().second;
						rb.imageCache.pop_front();
					}
					rb.imageCache.push_back(std::pair<std::string, VideoBuffer*>(URL, image));
				}
				else
				{
	#ifdef DEBUG
					std::cout << typeid(*this).name() << " Request for " << URL << " failed with status " << status << std::endl;
	#endif	
					free(data);

					return RequestBroker::Failed;
				}
			}
		}
		else 
		{
			//Check for ongoing requests
			for(std::vector<Request*>::iterator iter = rb.activeRequests.begin(), end = rb.activeRequests.end(); iter != end; ++iter)
			{
				if((*iter)->Type != Request::Image)
					continue;
				ImageRequest * otherReq = (ImageRequest*)(*iter);
				if(otherReq->URL == URL && otherReq != this)
				{
	#ifdef DEBUG
					std::cout << typeid(*this).name() << " Request for " << URL << " found, appending." << std::endl;
	#endif
					//Add the current listener to the item already being requested
					(*iter)->Children.push_back(this);
					return RequestBroker::Duplicate;
				}
			}

			//If it's not already being requested, request it
	#ifdef DEBUG
			std::cout << typeid(*this).name() << " Creating new request for " << URL << std::endl;
	#endif
			HTTPContext = http_async_req_start(NULL, (char *)URL.c_str(), NULL, 0, 0);
			RequestTime = time(NULL);
		}
	}
	
	if(image)
	{

		//Create a copy, to separate from the cache
		std::vector<Request *> children(Children.begin(), Children.end());
		Children.clear();

		VideoBuffer * myVB = new VideoBuffer(*image);
		myVB->Resize(Width, Height, true);
		ResultObject = (void*)myVB;
		rb.requestComplete(this);
		for(std::vector<Request*>::iterator childIter = children.begin(), childEnd = children.end(); childIter != childEnd; ++childIter)
		{
			if((*childIter)->Type == Request::Image)
			{
				ImageRequest * childReq = (ImageRequest*)*childIter;
				VideoBuffer * tempImage = new VideoBuffer(*image);
				tempImage->Resize(childReq->Width, childReq->Height, true);
				childReq->ResultObject = (void*)tempImage;
				rb.requestComplete(*childIter);
			}
		}
		return RequestBroker::Finished;
	}

	return RequestBroker::OK;
}