Esempio n. 1
0
	// remove all contained objects. 
	virtual void clear()
	{
		while(!objects.empty())
		{
#ifdef _DEBUG
			Target *obj=objects.begin()->second;
			delete obj;
#else
			delete objects.begin()->second;
#endif
		}
		assert(objects.empty());
	}
Esempio n. 2
0
void
ObjectDeleteCommandImpl::undo()
{
  for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
  {
    object_layer.add_object(*i);
  }
}
Esempio n. 3
0
void
ObjectDeleteCommandImpl::execute()
{
  for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
  {
    object_layer.delete_object(*i);
  }
}
void
ObjectMoveCommandImpl::undo()
{
  for(ObjectMoveCommandImpl::Objects::iterator i = objects.begin(); 
      i != objects.end();
      ++i)
  {
    i->obj.set_pos(i->old_pos);
  }
}
Esempio n. 5
0
void Frame::drawAll()
{
	clear(sf::Color::Black);
	Objects toDraw = objectsInBounds(sf::FloatRect(sf::Vector2f(0,0),_bounds));
	Objects::iterator it = toDraw.begin();
	for(;it != toDraw.end();it++)
	{
		(*it)->onDisplay();
		draw(*(*it)->getDrawable());
	}
	display();
}
	void drawCalibratedObjects(gluit::Graphics& g) const
	{
		Objects transformed = objects;
		for (Objects::Iterator object = transformed.begin(); object != transformed.end(); ++object) {
			(*object)->transform(*transformer);

			gluit::Point position = convert((*object)->getPosition());

			g.setColor(0xFF6666CC);
			g.drawEllipse(gluit::Rectangle(gluit::Size(40)).centerOn(position), true);
		}
	}
Esempio n. 7
0
void TUIOSender::send(const Objects& objects)
{
	Mutex::scoped_lock lock(mutex);

	if (!socket) {
		return;
	}

	try {
		char buffer[OUTBOUND_PACKET_STREAM_BUFFER_SIZE];
		osc::OutboundPacketStream p(buffer, OUTBOUND_PACKET_STREAM_BUFFER_SIZE);

		p << osc::BeginBundleImmediate;

		p << osc::BeginMessage(oscAddress.getValue().c_str()) << "source" << sourceId.get().c_str() << osc::EndMessage;

		p << osc::BeginMessage(oscAddress.getValue().c_str());
		p << "alive";
		for (Objects::ConstIterator object = objects.begin(); object != objects.end(); ++object) {
			if ((*object)->isAlive()) {
				p << int((*object)->getId());
			}
		}
		p << osc::EndMessage;

		for (Objects::ConstIterator object = objects.begin(); object != objects.end(); ++object) {
			if ((*object)->isAlive()) {
				p << osc::BeginMessage(oscAddress.getValue().c_str()) << "set" << (*object) << osc::EndMessage;
			}
		}

		p << osc::BeginMessage(oscAddress.getValue().c_str()) << "fseq" << int(frameSequenceNumber++) << osc::EndMessage;

		p << osc::EndBundle;

		socket->Send(p.Data(), p.Size());
	} catch (osc::OutOfBufferMemoryException& e) {
		LOG4CPLUS_ERROR(logger, "Sending objects failed, too many objects to send (" << objects.getSize() << ")");
	}
}
Esempio n. 8
0
void SEQFile::drawAnims() {
	Objects objects = getOrderedObjects();

	// Draw the animation frames and advance the animation
	for (Objects::iterator o = objects.begin(); o != objects.end(); ++o) {
		int16 left, top, right, bottom;

		if (o->object->draw(*_vm->_draw->_backSurface, left, top, right, bottom))
			_vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom);

		o->object->advance();
	}
}
Esempio n. 9
0
	PtrTracer(const ManagedHeap& heap)
	{
		// сформировать список объектов
		objects.reserve(heap.allocations.size());
		for(Allocations::const_iterator i = heap.allocations.begin(); i != heap.allocations.end(); ++i)
			objects.push_back(Object(i->first, i->second.size, i->second.info));
		std::sort(objects.begin(), objects.end(), sorter);

		// сформировать карту ссылок
		for(Ptrs::const_iterator i = heap.ptrs.begin(); i != heap.ptrs.end(); ++i)
		{
			// найти объект, в котором содержится указатель
			Objects::const_iterator j = std::upper_bound(objects.begin(), objects.end(), i->first, sorter);
			if(j > objects.begin())
			{
				--j;
				if((size_t)((char*)i->first - (char*)j->data) < j->size)
					// да, указатель содержится в этом объекте
					// получить объект, на который указывает указатель, и добавить ссылку
					links.insert(std::make_pair(j, std::lower_bound(objects.begin(), objects.end(), i->second, sorter)));
			}
		}
	}
Esempio n. 10
0
	void Print(std::ostream& stream)
	{
		std::vector<Objects::const_iterator> referencedObjects;
		referencedObjects.reserve(links.size());
		for(Links::const_iterator i = links.begin(); i != links.end(); ++i)
			referencedObjects.push_back(i->second);
		std::sort(referencedObjects.begin(), referencedObjects.end());
		referencedObjects.resize(std::unique(referencedObjects.begin(), referencedObjects.end()) - referencedObjects.begin());

		// пока просто вывести
		for(Objects::const_iterator object = objects.begin(); object != objects.end(); ++object)
		{
			if(std::binary_search(referencedObjects.begin(), referencedObjects.end(), object))
				continue;
			Print(stream, object);
		}
	}
	void handleSourceDataUpdate(const Source<Objects>& source)
	{
		Objects::Mutex::scoped_lock lock(objects.mutex);

		objects = source.get();

		if (calibrating) {
			for (Objects::Iterator object = objects.begin(); object != objects.end(); ++object) {
				if ((*object)->isNew()) {
					objectAdded(*object);
				} else if ((*object)->isDead()) {
					objectRemoved(*object);
				} else {
					objectUpdated(*object);
				}
			}
		}

		repaint();
	}
Esempio n. 12
0
void
Store::rename(const iterator top, const Raul::Path& new_path)
{
	const Raul::Path old_path = top->first;

	// Remove the object and all its descendants
	Objects removed;
	remove(top, removed);

	// Rename all the removed objects
	for (Objects::const_iterator i = removed.begin(); i != removed.end(); ++i) {
		const Raul::Path path = (i->first == old_path)
			? new_path
			: new_path.child(
				Raul::Path(i->first.substr(old_path.base().length() - 1)));

		i->second->set_path(path);
		assert(find(path) == end());  // Shouldn't be dropping objects!
		insert(make_pair(path, i->second));
	}
}
Esempio n. 13
0
void CriticalCurves::setParameters(double radius_1, double radius_2, Arrangements_2 insets_1, Arrangements_2 insets_2)
{
    Arrangement_2_iterator inset_1 = insets_1.begin();
    Arrangement_2_iterator inset_2 = insets_2.begin();

    while (inset_1 != insets_1.end() && inset_2 != insets_2.end())
    {
        Arrangement_2 arrangement;

        // Add the curves of the inset.
        for (Edge_iterator edge = inset_1->edges_begin(); edge != inset_1->edges_end(); ++edge)
        {
            insert(arrangement, edge->curve());
        }

        // Add the critical curves of type I.
        for (Edge_iterator edge = inset_2->edges_begin(); edge != inset_2->edges_end(); ++edge)
        {
            if (CGAL::COLLINEAR == edge->curve().orientation())
            {
                // Displaced a segment.
                Nt_traits nt_traits;
                Algebraic_ft factor = nt_traits.convert(Rational(radius_1) + Rational(radius_2));
                Conic_point_2 source = edge->curve().source();
                Conic_point_2 target = edge->curve().target();
                Algebraic_ft delta_x = target.x() - source.x();
                Algebraic_ft delta_y = target.y() - source.y();
                Algebraic_ft length = nt_traits.sqrt(delta_x * delta_x + delta_y * delta_y);
                Algebraic_ft translation_x = factor * delta_y / length;
                Algebraic_ft translation_y = - factor * delta_x / length;
                Conic_point_2 point_1(source.x() + translation_x, source.y() + translation_y);
                Conic_point_2 point_2(target.x() + translation_x, target.y() + translation_y);
                Algebraic_ft a = - delta_y;
                Algebraic_ft b = delta_x;
                Algebraic_ft c = factor * length - (source.y() * target.x() - source.x() * target.y());
                X_monotone_curve_2 x_monotone_curve(a, b, c, point_1, point_2);
                insert(arrangement, x_monotone_curve);
            }
            else
            {
                // Displaces an arc.
                Rational two(2);
                Rational four(4);

                Rational r = edge->curve().r();
                Rational s = edge->curve().s();
                Rational t = edge->curve().t();
                Rational u = edge->curve().u();
                Rational v = edge->curve().v();
                Rational w = edge->curve().w();

                Nt_traits nt_traits;
                Rational x_center = - u / (two * r);
                Rational y_center = - v / (two * r);
                Rat_point_2 rat_center(x_center, y_center);
                Conic_point_2 center(nt_traits.convert(x_center), nt_traits.convert(y_center));

                Rational radius = Rational(radius_1) + two * Rational(radius_2);

                Algebraic_ft coefficient = nt_traits.convert(radius / Rational(radius_2));

                Conic_point_2 source_1 = edge->curve().source();
                Algebraic_ft x_source_2 = center.x() + coefficient * (source_1.x() - center.x());
                Algebraic_ft y_source_2 = center.y() + coefficient * (source_1.y() - center.y());
                Conic_point_2 source_2(x_source_2, y_source_2);

                Conic_point_2 target_1 = edge->curve().target();
                Algebraic_ft x_target_2 = center.x() + coefficient * (target_1.x() - center.x());
                Algebraic_ft y_target_2 = center.y() + coefficient * (target_1.y() - center.y());
                Conic_point_2 target_2(x_target_2, y_target_2);

                Rat_circle_2 circle(rat_center, radius * radius);

                Conic_arc_2 conic_arc(circle, CGAL::COUNTERCLOCKWISE, source_2, target_2);

                insert(arrangement, conic_arc);
            }
        }

        // Add the critical curves of type II.
        for (Edge_iterator edge = inset_2->edges_begin(); edge != inset_2->edges_end(); ++edge)
        {
            double x = CGAL::to_double(edge->curve().source().x());
            double y = CGAL::to_double(edge->curve().source().y());
            double radius = radius_1 + radius_2;
            Rat_point_2 center(x, y);
            Rat_circle_2 circle(center, radius * radius);
            Conic_arc_2 conic_arc(circle);
            insert(arrangement, conic_arc);
        }

        // Remove the curves which are not include in the inset.
        Objects objects;
        Face_handle face;
        for (Edge_iterator edge = arrangement.edges_begin(); edge != arrangement.edges_end(); ++edge)
        {
            CGAL::zone(*inset_1, edge->curve(), std::back_inserter(objects));
            for (Object_iterator object = objects.begin(); object != objects.end(); ++object)
            {
                if (assign(face, *object))
                {
                    if (face->is_unbounded())
                    {
                        remove_edge(arrangement, edge);
                        break;
                    }
                }
            }
            objects.clear();
        }

        // Print essential information on the standard input.
        std::cout << "Arrangement:" << std::endl;
        std::cout << "  Number of vertices: " << arrangement.number_of_vertices() << std::endl;
        std::cout << "  Number of edges   : " << arrangement.number_of_edges() << std::endl;
        std::cout << "  Number of face    : " << arrangement.number_of_faces() << std::endl;

        this->critical_curves.push_back(arrangement);

        ++inset_1;
        ++inset_2;
    }

    // Commit changes.
    emit(criticalCurvesChanged());
    return;
}
Esempio n. 14
0
 const_iterator begin() const { return objects.begin(); }
Esempio n. 15
0
 iterator begin() { return objects.begin(); }