X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fdimension-cache.cc;h=33294db5e62cd37c9a3253554b083f94f6b023de;hb=47db9a3883d726ca53e2133a3b2298f78dd6a32e;hp=8746337cca4b96bac67fd08dfcb7cd38726fed47;hpb=afa5829cd270e1b0c616b7ba5c5e6cdc0e920e5f;p=lilypond.git diff --git a/lily/dimension-cache.cc b/lily/dimension-cache.cc index 8746337cca..33294db5e6 100644 --- a/lily/dimension-cache.cc +++ b/lily/dimension-cache.cc @@ -1,151 +1,68 @@ -/* - dimension-cache.cc -- implement Dimension_cache - - source file of the GNU LilyPond music typesetter - - (c) 1998 Han-Wen Nienhuys - */ +/* + This file is part of LilyPond, the GNU music typesetter. -#include "dimension-cache.hh" -#include "parray.hh" + Copyright (C) 1998--2015 Han-Wen Nienhuys -Dimension_cache::Dimension_cache (Dimension_cache const &d) -{ - init(); - empty_b_ = d.empty_b_; -} + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. -Dimension_cache::Dimension_cache () -{ - init(); -} + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -void -Dimension_cache::init() -{ - offset_ =0.0; - elt_l_ = 0; - dim_.set_empty (); - parent_l_ =0; - valid_b_ = false; - empty_b_ = false; -} + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . +*/ +#include "dimension-cache.hh" -void -Dimension_cache::invalidate () -{ - valid_b_ = false; - invalidate_dependencies (); -} +#include "warn.hh" +#include "grob.hh" -void -Dimension_cache::invalidate_dependencies () -{ - for (int i=0; i < dependencies_l_arr_.size (); i++) - { - Dimension_cache * g = dependencies_l_arr_[i]; - if (g->valid_b_) - { - g->invalidate (); - } - } -} - -void -Dimension_cache::set_offset (Real x) +Dimension_cache::Dimension_cache (Dimension_cache const &d) { - invalidate_dependencies (); - offset_ = x; + init (); + offset_ = d.offset_ ? new Real (*d.offset_) : 0; + parent_ = d.parent_; + extent_ = d.extent_ ? new Interval (*d.extent_) : 0; } -void -Dimension_cache::translate (Real x) +Dimension_cache & +Dimension_cache::operator = (Dimension_cache const &d) { - invalidate_dependencies (); - offset_ += x; + clear (); + offset_ = d.offset_ ? new Real (*d.offset_) : 0; + parent_ = d.parent_; + extent_ = d.extent_ ? new Interval (*d.extent_) : 0; + return *this; } - -Real -Dimension_cache::absolute_coordinate () const +Dimension_cache::Dimension_cache () { - Real r = offset_; - for (Dimension_cache * c = parent_l_; - c; c = c->parent_l_) - r += c->offset_; - return r; + init (); } -Real -Dimension_cache::relative_coordinate (Dimension_cache *d) const +void +Dimension_cache::init () { - Real r =0.0; - - for (Dimension_cache* c = parent_l_; - c != d; - c = c->parent_l_) - r += c->offset_; - return r; + offset_ = 0; + extent_ = 0; + parent_ = 0; } -Dimension_cache * -Dimension_cache::common_group (Dimension_cache const* s) const +Dimension_cache::~Dimension_cache () { - Link_array my_groups; - for (Dimension_cache const *c = this; - c ; c = c->parent_l_) - my_groups.push (c); - - - Dimension_cache const *common=0; - - for (Dimension_cache const * d = s; - !common && d; - d = d->parent_l_) - common = my_groups.find_l (d); - - return (Dimension_cache*)common; + clear (); } - - void -Dimension_cache::set_empty (bool b) +Dimension_cache::clear () { - if (empty_b_ != b) - { - empty_b_ = b; - if (!empty_b_) - invalidate (); - } -} - -void -Dimension_cache::set_dim (Interval v) -{ - dim_ = v; - valid_b_ = true; + delete extent_; + delete offset_; + extent_ = 0; + offset_ = 0; } - - -Interval -Dimension_cache::get_dim () const -{ - Interval r; - if (empty_b_) - { - r.set_empty (); - return r; - } - - assert (valid_b_); - - r=dim_; - if (!r.empty_b()) // float exception on DEC Alpha - r += offset_; - - return r; -} - -