X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdesigner%2Fselection.h;h=89f7100e3e6e854945219bf074ad7f4ff3388e4f;hb=dfeb2d2896fe18e55b1f6c4a8028b7cfb878dede;hp=24d935458448014411d5a65c32cb5b98bd054fe7;hpb=e9653dffd0026fb3c02c91a4c0feca688a86c721;p=r2c2.git diff --git a/source/designer/selection.h b/source/designer/selection.h index 24d9354..89f7100 100644 --- a/source/designer/selection.h +++ b/source/designer/selection.h @@ -1,16 +1,9 @@ -/* $Id$ - -This file is part of the MSP Märklin suite -Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #ifndef SELECTION_H_ #define SELECTION_H_ #include #include -#include "3d/track.h" +#include "libr2c2/object.h" class Selection { @@ -18,16 +11,48 @@ public: sigc::signal signal_changed; private: - std::set tracks; + std::set objects; public: - const std::set &get_tracks() const { return tracks; } - Marklin::Track *get_track() const; - unsigned size() const { return tracks.size(); } + const std::set &get_objects() const { return objects; } + R2C2::Object *get_object() const; + + template + std::set get_objects() const + { + std::set result; + for(std::set::const_iterator i=objects.begin(); i!=objects.end(); ++i) + if(T *to = dynamic_cast(*i)) + result.insert(to); + return result; + } + + template + T *get_object() const + { + for(std::set::const_iterator i=objects.begin(); i!=objects.end(); ++i) + if(T *to = dynamic_cast(*i)) + return to; + return 0; + } + + unsigned size() const { return objects.size(); } + bool empty() const { return objects.empty(); } + void clear(); - void add_track(Marklin::Track *); - void remove_track(Marklin::Track *); - void toggle_track(Marklin::Track *); + + template + void replace(Iter begin, Iter end) + { + objects.clear(); + objects.insert(begin, end); + signal_changed.emit(); + } + + void add_object(R2C2::Object *); + void remove_object(R2C2::Object *); + void toggle_object(R2C2::Object *); + void select_more(); void select_linked(); void select_blocks();