source: trunk/source/visualization/HepRep/src/DefaultHepRepAttribute.cc @ 1098

Last change on this file since 1098 was 834, checked in by garnier, 16 years ago

import all except CVS

File size: 3.1 KB
Line 
1// Copyright FreeHEP, 2005.
2
3#include "cheprep/config.h"
4
5#include <iostream>
6#include <algorithm>
7
8#include "cheprep/DefaultHepRepAttribute.h"
9#include "cheprep/DefaultHepRepAttValue.h"
10
11using namespace std;
12using namespace HEPREP;
13
14/**
15 * @author Mark Donszelmann
16 * @version $Id: DefaultHepRepAttribute.cc,v 1.8 2005/06/02 21:28:45 duns Exp $
17 */
18namespace cheprep {
19
20
21DefaultHepRepAttribute::DefaultHepRepAttribute() {
22}
23
24DefaultHepRepAttribute::~DefaultHepRepAttribute() {
25    for (map<string, HepRepAttValue*>::iterator i = attValues.begin(); i != attValues.end(); i++) {
26        delete (*i).second;
27    }
28}
29
30set<HepRepAttValue*> DefaultHepRepAttribute::getAttValuesFromNode() {
31    set<HepRepAttValue*> attSet;
32    for (map<string, HepRepAttValue*>::iterator i = attValues.begin(); i != attValues.end(); i++) {
33        if ((*i).first != "layer") attSet.insert((*i).second);
34    }
35    return attSet;
36}
37
38void DefaultHepRepAttribute::addAttValue(HepRepAttValue* hepRepAttValue) {
39    string lowerCaseName = hepRepAttValue->getLowerCaseName();
40    if (attValues[lowerCaseName] != NULL) delete attValues[lowerCaseName];
41    attValues[lowerCaseName] = hepRepAttValue;
42}
43
44void DefaultHepRepAttribute::addAttValue(string key, char *value, int showLabel) {
45    addAttValue(key, (std::string)value, showLabel);
46}
47
48void DefaultHepRepAttribute::addAttValue(string key, string value, int showLabel) {
49    addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
50}
51
52void DefaultHepRepAttribute::addAttValue(string key, int64 value, int showLabel) {
53    addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
54}
55
56void DefaultHepRepAttribute::addAttValue(string key, int value, int showLabel) {
57    addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
58}
59
60void DefaultHepRepAttribute::addAttValue(string key, double value, int showLabel) {
61    addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
62}
63
64void DefaultHepRepAttribute::addAttValue(string key, bool value, int showLabel) {
65    addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
66}
67
68void DefaultHepRepAttribute::addAttValue(string key, vector<double> value, int showLabel) {
69    addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
70}
71
72void DefaultHepRepAttribute::addAttValue(string key, double red, double green, double blue, double alpha, int showLabel) {
73    vector<double> color;
74    color.push_back(red);
75    color.push_back(green);
76    color.push_back(blue);
77    color.push_back(alpha);
78    addAttValue(new DefaultHepRepAttValue(key, color, showLabel));
79}
80
81HepRepAttValue* DefaultHepRepAttribute::getAttValueFromNode(string name) {
82    string s = name;
83    transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
84    return (attValues.count(s) > 0) ? attValues[s] : NULL;   
85}
86
87HepRepAttValue* DefaultHepRepAttribute::removeAttValue(string name) {
88    string s = name;
89    transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
90    HepRepAttValue* attValue = attValues[s];
91    attValues.erase(s);
92    return attValue;
93}
94
95
96} // cheprep
Note: See TracBrowser for help on using the repository browser.