Fresco/Berlin/modules/Primitives PrimitiveImpl.cc,1.6,1.7 PrimitiveImpl.hh,1.5,1.6
Tobias Hunger <[email protected]> Mon, 27 Oct 2003 17:09:11 +0000
| Newsgroups | gmane.comp.video.fresco.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvs/fresco/Fresco/Berlin/modules/Primitives In directory purcel:/tmp/cvs-serv5328/Berlin/modules/Primitives Modified Files: PrimitiveImpl.cc PrimitiveImpl.hh Log Message: Make sure all classes defined by Kits are in the Kit's namespace. Do some coding style fixups while touching the files anyway. Index: PrimitiveImpl.cc =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Primitives/PrimitiveImpl.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- PrimitiveImpl.cc 9 Nov 2002 02:22:10 -0000 1.6 +++ PrimitiveImpl.cc 27 Oct 2003 17:08:38 -0000 1.7 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 2001 Stefan Seefeld <[email protected]> + * Copyright (C) 2001 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -38,107 +38,113 @@ using namespace Prague; using namespace Fresco; -TransformPrimitive::TransformPrimitive() - : //_mode(Figure::outline), +Berlin::PrimitiveKit::TransformPrimitive::TransformPrimitive() : + //_mode(Figure::outline), _tx(new TransformImpl), _ext(new RegionImpl) -{ -} +{ } -TransformPrimitive::~TransformPrimitive() {} -Transform_ptr TransformPrimitive::transformation() { return _tx->_this();} -void TransformPrimitive::request(Fresco::Graphic::Requisition &r) +Berlin::PrimitiveKit::TransformPrimitive::~TransformPrimitive() { } +Transform_ptr Berlin::PrimitiveKit::TransformPrimitive::transformation() +{ return _tx->_this(); } +void Berlin::PrimitiveKit::TransformPrimitive::request(Fresco::Graphic::Requisition &r) { - Trace trace("TransformPrimitive::request"); - Allocation::Info info; - Lease_var<RegionImpl> region(Provider<RegionImpl>::provide()); - extension(info, Region_var(region->_this())); - if (region->valid) + Trace trace("TransformPrimitive::request"); + Allocation::Info info; + Lease_var<RegionImpl> region(Provider<RegionImpl>::provide()); + extension(info, Region_var(region->_this())); + if (region->valid) { - Coord x_lead = -region->lower.x, x_trail = region->upper.x; - Coord y_lead = -region->lower.y, y_trail = region->upper.y; - Coord z_lead = -region->lower.z, z_trail = region->upper.z; - GraphicImpl::require_lead_trail(r.x, x_lead, x_lead, x_lead, x_trail, x_trail, x_trail); - GraphicImpl::require_lead_trail(r.y, y_lead, y_lead, y_lead, y_trail, y_trail, y_trail); - GraphicImpl::require_lead_trail(r.z, z_lead, z_lead, z_lead, z_trail, z_trail, z_trail); + Coord x_lead = -region->lower.x, x_trail = region->upper.x; + Coord y_lead = -region->lower.y, y_trail = region->upper.y; + Coord z_lead = -region->lower.z, z_trail = region->upper.z; + GraphicImpl::require_lead_trail(r.x, x_lead, x_lead, x_lead, + x_trail, x_trail, x_trail); + GraphicImpl::require_lead_trail(r.y, y_lead, y_lead, y_lead, + y_trail, y_trail, y_trail); + GraphicImpl::require_lead_trail(r.z, z_lead, z_lead, z_lead, + z_trail, z_trail, z_trail); } - else + else { - r.x.defined = false; - r.y.defined = false; - r.z.defined = false; + r.x.defined = false; + r.y.defined = false; + r.z.defined = false; } } -void TransformPrimitive::extension(const Allocation::Info &info, Region_ptr region) +void Berlin::PrimitiveKit::TransformPrimitive::extension(const Allocation::Info &info, + Region_ptr region) { - Trace trace("TransformPrimitive::extension"); - if (_ext->valid) + Trace trace("TransformPrimitive::extension"); + if (_ext->valid) { - Lease_var<RegionImpl> tmp(Provider<RegionImpl>::provide()); - tmp->copy(Region_var(_ext->_this())); - tmp->xalign = tmp->yalign = tmp->zalign = 0.; - Lease_var<TransformImpl> transformation(Provider<TransformImpl>::provide()); - if (!CORBA::is_nil(info.transformation)) transformation->copy(info.transformation); - transformation->premultiply(Transform_var(_tx->_this())); - tmp->apply_transform(Transform_var(transformation->_this())); - region->merge_union(Region_var(tmp->_this())); + Lease_var<RegionImpl> tmp(Provider<RegionImpl>::provide()); + tmp->copy(Region_var(_ext->_this())); + tmp->xalign = tmp->yalign = tmp->zalign = 0.; + Lease_var<TransformImpl> transformation(Provider<TransformImpl>::provide()); + if (!CORBA::is_nil(info.transformation)) + transformation->copy(info.transformation); + transformation->premultiply(Transform_var(_tx->_this())); + tmp->apply_transform(Transform_var(transformation->_this())); + region->merge_union(Region_var(tmp->_this())); } } -void TransformPrimitive::pick(PickTraversal_ptr traversal) +void Berlin::PrimitiveKit::TransformPrimitive::pick(PickTraversal_ptr traversal) { - if (_ext->valid && traversal->intersects_region(Region_var(_ext->_this()))) - traversal->hit(); + if (_ext->valid && traversal->intersects_region(Region_var(_ext->_this()))) + traversal->hit(); } -void TransformPrimitive::need_redraw() +void Berlin::PrimitiveKit::TransformPrimitive::need_redraw() { - Trace trace("TransformPrimitive::need_redraw"); - Allocation::Info info; - Lease_var<RegionImpl> region(Provider<RegionImpl>::provide()); - extension(info, Region_var(region->_this())); - need_redraw_region(Region_var(region->_this())); + Trace trace("TransformPrimitive::need_redraw"); + Allocation::Info info; + Lease_var<RegionImpl> region(Provider<RegionImpl>::provide()); + extension(info, Region_var(region->_this())); + need_redraw_region(Region_var(region->_this())); } -void TransformPrimitive::resize() {} -void TransformPrimitive::copy(const TransformPrimitive &tp) +void Berlin::PrimitiveKit::TransformPrimitive::resize() { } +void Berlin::PrimitiveKit::TransformPrimitive::copy(const TransformPrimitive &tp) { - // _mode = tp._mode; - // _fg = tp._fg; - // _bg = tp._bg; - _tx->copy(Transform_var(tp._tx->_this())); - if (tp._ext->valid) _ext->copy(Region_var(tp._ext->_this())); + // _mode = tp._mode; + // _fg = tp._fg; + // _bg = tp._bg; + _tx->copy(Transform_var(tp._tx->_this())); + if (tp._ext->valid) _ext->copy(Region_var(tp._ext->_this())); } -PrimitiveImpl::PrimitiveImpl() : _mesh(new Fresco::Mesh()) {} -PrimitiveImpl::~PrimitiveImpl() {} +Berlin::PrimitiveKit::PrimitiveImpl::PrimitiveImpl() : _mesh(new Fresco::Mesh()) { } +Berlin::PrimitiveKit::PrimitiveImpl::~PrimitiveImpl() { } -void PrimitiveImpl::draw(DrawTraversal_ptr traversal) +void Berlin::PrimitiveKit::PrimitiveImpl::draw(DrawTraversal_ptr traversal) { - Trace trace("PrimitiveImpl::draw"); - if (_mesh->nodes.length() > 0) + Trace trace("PrimitiveImpl::draw"); + if (_mesh->nodes.length() > 0) { - // bounding box culling, use extension(...) to add brush effect into extension. - Allocation::Info info; - Lease_var<RegionImpl> region(Provider<RegionImpl>::provide()); - extension(info, Region_var(region->_this())); - if (traversal->intersects_region(Region_var(region->_this()))) - { - DrawingKit_var drawing = traversal->drawing(); - DrawingKit3D_var d3d = DrawingKit3D::_narrow(drawing); - if (CORBA::is_nil(d3d)) { - if (_error == false) - std::cerr << "No DrawingKit3D interface found." << std::endl - << "Consider passing \"-d GLDrawingKit\" to Berlin." - << std::endl; - _error = true; - return; - } - d3d->save(); - d3d->draw_mesh(_mesh); - d3d->restore(); - } + // bounding box culling, use extension(...) to add brush effect into extension. + Allocation::Info info; + Lease_var<RegionImpl> region(Provider<RegionImpl>::provide()); + extension(info, Region_var(region->_this())); + if (traversal->intersects_region(Region_var(region->_this()))) + { + DrawingKit_var drawing = traversal->drawing(); + DrawingKit3D_var d3d = DrawingKit3D::_narrow(drawing); + if (CORBA::is_nil(d3d)) + { + if (_error == false) + std::cerr << "No DrawingKit3D interface found." << std::endl + << "Consider passing \"-d GLDrawingKit\" to Berlin." + << std::endl; + _error = true; + return; + } + d3d->save(); + d3d->draw_mesh(_mesh); + d3d->restore(); + } } } @@ -146,16 +152,15 @@ * Picking just does a bounding box test for now. */ -void PrimitiveImpl::pick(PickTraversal_ptr traversal) +void Berlin::PrimitiveKit::PrimitiveImpl::pick(PickTraversal_ptr traversal) { - TransformPrimitive::pick(traversal); - return; - if (_ext->valid) + TransformPrimitive::pick(traversal); + return; + if (_ext->valid) { - if (traversal->intersects_region(Region_var(_ext->_this()))) - { - } - traversal->hit(); + if (traversal->intersects_region(Region_var(_ext->_this()))) + { } + traversal->hit(); } } @@ -163,34 +168,34 @@ * Reset the primitive's list of vertices */ -void PrimitiveImpl::resize() +void Berlin::PrimitiveKit::PrimitiveImpl::resize() { - _ext->valid = false; - if (_mesh->nodes.length() > 0) + _ext->valid = false; + if (_mesh->nodes.length() > 0) { - _ext->valid = true; - _ext->lower = _mesh->nodes[0]; - _ext->upper = _mesh->nodes[0]; - CORBA::ULong n = _mesh->nodes.length(); - for (CORBA::ULong i = 1; i < n; ++i) - { - _ext->lower.x = Math::min(_ext->lower.x, _mesh->nodes[i].x); - _ext->upper.x = Math::max(_ext->upper.x, _mesh->nodes[i].x); - _ext->lower.y = Math::min(_ext->lower.y, _mesh->nodes[i].y); - _ext->upper.y = Math::max(_ext->upper.y, _mesh->nodes[i].y); - _ext->lower.z = Math::min(_ext->lower.z, _mesh->nodes[i].z); - _ext->upper.z = Math::max(_ext->upper.z, _mesh->nodes[i].z); - } - } + _ext->valid = true; + _ext->lower = _mesh->nodes[0]; + _ext->upper = _mesh->nodes[0]; + CORBA::ULong n = _mesh->nodes.length(); + for (CORBA::ULong i = 1; i < n; ++i) + { + _ext->lower.x = Math::min(_ext->lower.x, _mesh->nodes[i].x); + _ext->upper.x = Math::max(_ext->upper.x, _mesh->nodes[i].x); + _ext->lower.y = Math::min(_ext->lower.y, _mesh->nodes[i].y); + _ext->upper.y = Math::max(_ext->upper.y, _mesh->nodes[i].y); + _ext->lower.z = Math::min(_ext->lower.z, _mesh->nodes[i].z); + _ext->upper.z = Math::max(_ext->upper.z, _mesh->nodes[i].z); + } + } } -void PrimitiveImpl::reset() +void Berlin::PrimitiveKit::PrimitiveImpl::reset() { - _ext->valid = false; + _ext->valid = false; } -void PrimitiveImpl::copy(const PrimitiveImpl &p) +void Berlin::PrimitiveKit::PrimitiveImpl::copy(const PrimitiveImpl &p) { - TransformPrimitive::copy(p); - _mesh = new Fresco::Mesh(p._mesh); + TransformPrimitive::copy(p); + _mesh = new Fresco::Mesh(p._mesh); } Index: PrimitiveImpl.hh =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Primitives/PrimitiveImpl.hh,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- PrimitiveImpl.hh 9 Nov 2002 02:22:10 -0000 1.5 +++ PrimitiveImpl.hh 27 Oct 2003 17:08:38 -0000 1.6 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 2001 Stefan Seefeld <[email protected]> + * Copyright (C) 2001 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -31,52 +31,60 @@ class TransformImpl; class RegionImpl; -static bool _error = false; - -class TransformPrimitive : public virtual POA_Primitive::PrimitiveBase, - public GraphicImpl +namespace Berlin { - public: - TransformPrimitive(); - ~TransformPrimitive(); - virtual Fresco::Transform_ptr transformation(); - virtual void request(Fresco::Graphic::Requisition &); - virtual void extension(const Fresco::Allocation::Info &, Fresco::Region_ptr); - virtual void pick(Fresco::PickTraversal_ptr); - virtual void need_redraw(); - - // Figure::Mode type() { return _mode;} - // void type(Figure::Mode m) { _mode = m; need_redraw();} - // Fresco::Color foreground() { return _fg;} - // void foreground(const Fresco::Color &f) { _fg = f; need_redraw();} - // Fresco::Color background() { return _bg;} - // void background(const Fresco::Color &b) { _bg = b; need_redraw();} + namespace PrimitiveKit + { - virtual void resize(); + static bool _error = false; - void copy(const TransformPrimitive &); - protected: - // Figure::Mode _mode; - // Fresco::Color _fg, _bg; - Impl_var<TransformImpl> _tx; - Impl_var<RegionImpl> _ext; -}; + class TransformPrimitive : public virtual POA_Primitive::PrimitiveBase, + public GraphicImpl + { + public: + TransformPrimitive(); + ~TransformPrimitive(); + virtual Fresco::Transform_ptr transformation(); + virtual void request(Fresco::Graphic::Requisition &); + virtual void extension(const Fresco::Allocation::Info &, Fresco::Region_ptr); + virtual void pick(Fresco::PickTraversal_ptr); + virtual void need_redraw(); -class PrimitiveImpl : public TransformPrimitive -{ -public: - PrimitiveImpl(); - virtual ~PrimitiveImpl(); + // Figure::Mode type() { return _mode;} + // void type(Figure::Mode m) { _mode = m; need_redraw();} + // Fresco::Color foreground() { return _fg;} + // void foreground(const Fresco::Color &f) { _fg = f; need_redraw();} + // Fresco::Color background() { return _bg;} + // void background(const Fresco::Color &b) { _bg = b; need_redraw();} - void reset(); - virtual void resize(); + virtual void resize(); - virtual void draw(Fresco::DrawTraversal_ptr); - virtual void pick(Fresco::PickTraversal_ptr); + void copy(const TransformPrimitive &); + protected: + // Figure::Mode _mode; + // Fresco::Color _fg, _bg; + Impl_var<TransformImpl> _tx; + Impl_var<RegionImpl> _ext; + }; - void copy(const PrimitiveImpl &); -protected: - Fresco::Mesh_var _mesh; -}; + class PrimitiveImpl : public TransformPrimitive + { + public: + PrimitiveImpl(); + virtual ~PrimitiveImpl(); + + void reset(); + virtual void resize(); + + virtual void draw(Fresco::DrawTraversal_ptr); + virtual void pick(Fresco::PickTraversal_ptr); + + void copy(const PrimitiveImpl &); + protected: + Fresco::Mesh_var _mesh; + }; + + } // namespace +} // namespace #endif