41 #ifdef CHECK_MEMORY_LEAKS
43 #endif // CHECK_MEMORY_LEAKS
60 return mySelected.count(
id) > 0;
66 mySelected.insert(
id);
88 const std::set<GUIGlID>&
155 throw ProcessError(
"Unkown object in GUISelectedStorage::toggleSelection (id=" +
toString(
id) +
").");
168 const std::set<GUIGlID>&
174 const std::set<GUIGlID>&
182 for (std::map<GUIGlObjectType, SingleTypeSelections>::iterator it =
mySelections.begin(); it !=
mySelections.end(); it++) {
194 std::set<GUIGlID> result;
195 std::ostringstream msg;
196 std::ifstream strm(filename.c_str());
200 msgOut =
"Could not open '" + filename +
"'.\n";
203 while (strm.good()) {
206 if (line.length() == 0) {
214 if (numIgnored + numMissing <= maxErrors) {
215 msg <<
"Ignoring item '" << line <<
"' because of invalid type " <<
toString(object->
getType()) <<
"\n";
218 result.insert(object->
getGlID());
222 if (numIgnored + numMissing <= maxErrors) {
223 msg <<
"Item '" + line +
"' not found\n";
229 if (numIgnored + numMissing > maxErrors) {
230 msg <<
"...\n" << numIgnored <<
" objects ignored, " << numMissing <<
" objects not found\n";
240 const std::set<GUIGlID> ids =
loadIDs(filename, errors, type);
241 for (std::set<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
278 for (std::set<GUIGlID>::const_iterator i = ids.begin(); i != ids.end(); ++i) {
virtual void selectionUpdated()=0
void close()
Closes the device and removes it from the dictionary.
~GUISelectedStorage()
Destructor.
void toggleSelection(GUIGlID id)
Toggles selection of an object.
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
void remove2Update()
Removes the dialog to be updated.
std::set< GUIGlID > myAllSelected
List of selected objects.
void clear()
Clears the list of selected objects.
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
GUIGlID getGlID() const
Returns the numerical id of the object.
void save(const std::string &filename)
Saves the list of selected objects to a file named as given.
std::map< GUIGlObjectType, SingleTypeSelections > mySelections
std::set< GUIGlID > loadIDs(const std::string &filename, std::string &msgOut, GUIGlObjectType type=GLO_MAX, int maxErrors=16)
Loads a selection list (optionally with restricted type) and returns the ids of all active objects...
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
const std::set< GUIGlID > & getSelected() const
Returns the list of ids of all selected objects.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
void select(GUIGlID id)
Adds the object with the given id to the list of selected objects.
std::string load(const std::string &filename, GUIGlObjectType type=GLO_MAX)
Loads a selection list (optionally with restricted type)
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
SingleTypeSelections()
Constructor.
~SingleTypeSelections()
Destructor.
void deselect(GUIGlID id)
Deselects the object with the given id from the list of selected objects.
void deselect(GUIGlID id)
Deselects the object with the given id.
void add2Update(UpdateTarget *updateTarget)
Adds a dialog to be updated.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
void clear()
Clears the list of selected objects.
Static storage of an output device and its base (abstract) implementation.
bool isSelected(GUIGlID id)
Returns the information whether the object with the given id is qithin the selection.
void unblockObject(GUIGlID id)
Marks an object as unblocked.
GUISelectedStorage()
Constructor.
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
const std::set< GUIGlID > & getSelected() const
Returns the list of selected ids.
const std::string & getFullName() const
Returns the full name appearing in the tool tip.
void save(GUIGlObjectType type, const std::string &filename)
Saves a selection list.
UpdateTarget * myUpdateTarget
The dialog to be updated.